#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/list-users - list users # # Creation: 2001-11-04 fm # Last Update: $Id$ # # Copyright (c) 2001-2007 the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib # check if screensize handling is available if [ "$_EISLIB_SCREENSIZE_Y" != '' ] then if check_screensize then # # define maxrownum = _EISLIB_SCREENSIZE # - 3 Header Lines # - 1 Footer Lines # ask line let maxrownum=${_EISLIB_SCREENSIZE_Y}-4 true else mecho -info "Return to calling script" exit 1 fi else # default if screensize handling is not available maxrownum=18 fi #---------------------------------------------------------------------------- # check if password is valid # input : $1 - user name # return: 0 - valid password # 1 - invalid password #---------------------------------------------------------------------------- function is_valid_pw () { usr="$1" ret=1 if [ "$1" != "" ] then pword=`grep "^$user:" $shadow_file|cut -d: -f2` [ "$pword" != "*" ] && ! echo "$pword"|grep -q "^!" if [ $? -eq 0 ] then ret=0 fi fi return $ret } #============================================================================ # main #============================================================================ act_pmode=`get_printmode` # testroot=/soft/list-users testroot='' inet_config='/etc/config.d/inet' # inet package config file passwd_file="$testroot/etc/passwd" shadow_file="$testroot/etc/shadow" group_file="$testroot/etc/group" ftpusers_file="$testroot/etc/ftpusers" shells_file="$testroot/etc/shells" # check if package inet is installed if [ -f ${inet_config} ] then . ${inet_config} has_inet='TRUE' else ftp_default='n/a' # not applicable has_inet='FALSE' fi # read group information _ifs="$IFS" while read line do IFS=':' set -- $line eval group_$3=$1 IFS="$_ifs" done < $group_file # print header clrhome mecho -info "List users" mecho techo begin 2 15 7 10 7 10 5 24 techo row "" -info User -info Uid -info Group -info Gid -info Valid-PW -info FTP -info Name tty=`tty` row=4 # read user information _ifs="$IFS" while read line do IFS=':' set -- $line user="$1" uid="$3" gid="$4" eval group='$group_'$gid name="$5" shell="$7" IFS="$_ifs" if is_valid_pw "$user" then # valid password password='yes' passwordcolor="-std" else # invalid password password='no' passwordcolor="-warn" fi # check if FTP is allowed if [ "${has_inet}" = 'FALSE' ] then ftpusr="$ftp_default" else # check /etc/ftpuser only if PAM authentication is switched on if [ "${FTP_USE_PAM}" = 'yes' ] then ftpusers=`grep "^$user\$" $ftpusers_file 2>/dev/null` else ftpusers='' fi # check if root (uid=0) can do FTP if [ "${FTP_ALLOW_ROOT_ACCESS}" = 'no' ] then forbidden_uid=0 else forbidden_uid='' fi # check if only anonymous is allowed if [ "${FTP_ONLY_ANONYMOUS}" = 'yes' ] then only_anonymous='TRUE' else only_anonymous='FALSE' fi # check if shell is in /etc/shells shells=`grep "^$shell\$" $shells_file` # ftp is not allowd if # only_anonymous = 'TRUE' # or ftpusers != "" # or uid = forbidden_uid # or password = password lock string (*) or (!) # or shell not in /etc/shells if [ "$only_anonymous" = 'TRUE' -o "$ftpusers" != "" -o $uid = "${forbidden_uid}" -o "$password" = 'no' -o "$shells" = "" ] then ftpusr='no' else ftpusr='yes' fi fi # output data techo row "" $user $uid $group $gid $passwordcolor $password $ftpusr "$name" row=`expr $row + 1` if [ "$act_pmode" = 'tty' ] then if [ $row -eq $maxrownum ] then echo echo anykey <$tty # print header clrhome mecho -info "List users" <$tty echo techo row "" -info User -info Uid -info Group -info Gid -info Valid-PW -info FTP -info Name row=4 fi fi done < $passwd_file techo end echo anykey