#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/list-users - list users # # Copyright (c) 2001-2004 Frank Meyer # # Creation: 04.11.2001 fm # Last Update: $Id$ # # 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 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 IFS=':' # read group information while read line do set -- $line eval group_$3=$1 done < $group_file # print header clrhome mecho -info "List users" mecho techo begin 2 22 7 10 7 10 5 20 techo row "" -info User -info Uid -info Group -info Gid -info Valid-PW -info FTP -info Name tty=`tty` row=4 # read user information while read line do set -- $line user="$1" uid="$3" gid="$4" eval group='$group_'$gid name="$5" shell="$7" # get password from /etc/shadow pword=`grep "^$user:" $shadow_file|cut -d: -f2` if [ "$pword" = '*' ] then password='no' # invalidated elif [ "$pword" = '!' ] then password='no' # invalidated else password='yes' # valid 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 $password $ftpusr $name row=`expr $row + 1` if [ "$act_pmode" = 'tty' ] then if [ $row -eq 21 ] then mecho mecho anykey <$tty # print header clrhome mecho -info "List users" <$tty mecho 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 mecho anykey