From 8c5b1d1aecd0e5a764a72ebc88a81f194f81046b Mon Sep 17 00:00:00 2001 From: Max Khon Date: Thu, 23 Jan 2003 20:07:40 +0000 Subject: - restore an ability to write log of added users (default to /var/log/adduser, disabled if empty or adduserlog="no") - do not ask for password in configure mode - print $passwdtype instead of password in configure mode - add DATECMD, GREPCMD (not overridable but with full path) --- adduser/adduser.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'adduser/adduser.sh') diff --git a/adduser/adduser.sh b/adduser/adduser.sh index 0a92133..6c14251 100644 --- a/adduser/adduser.sh +++ b/adduser/adduser.sh @@ -145,7 +145,7 @@ fullpath_from_shell() { save_config() { echo "# Configuration file for adduser(8)." > ${ADDUSERCONF} echo "# NOTE: only *some* variables are saved." >> ${ADDUSERCONF} - echo "# Last Modified on `date`." >> ${ADDUSERCONF} + echo "# Last Modified on `${DATECMD}`." >> ${ADDUSERCONF} echo '' >> ${ADDUSERCONF} echo "defaultclass=$uclass" >> ${ADDUSERCONF} echo "defaultgroups=$ugroups" >> ${ADDUSERCONF} @@ -155,6 +155,7 @@ save_config() { echo "udotdir=$udotdir" >> ${ADDUSERCONF} echo "msgfile=$msgfile" >> ${ADDUSERCONF} echo "disableflag=$disableflag" >> ${ADDUSERCONF} + echo "adduserlog=$adduserlog" >> ${ADDUSERCONF} } # add_user @@ -238,6 +239,9 @@ add_user() { fi fi + _log=${adduserlog:-no} + [ x"$_log" = x"no" ] || (echo "$(${DATECMD} +'%Y/%m/%d %T') $(${PWCMD} 2>/dev/null usershow -n $username)" >> $_log) + _line= _owner= _perms= @@ -328,7 +332,7 @@ get_shell() { ushell="$defaultshell" # Make sure the current value of the shell is a valid one - _shellchk="grep '^$ushell$' ${ETCSHELLS} > /dev/null 2>&1" + _shellchk="${GREPCMD} '^$ushell$' ${ETCSHELLS} > /dev/null 2>&1" eval $_shellchk || { err "Invalid shell ($ushell). Using default shell ${defaultshell}." ushell="$defaultshell" @@ -601,6 +605,7 @@ input_interactive() { ;; esac passwdtype="yes" + [ -n "$configrun" ] && break trap 'stty echo; exit' 0 1 2 3 15 stty -echo echo -n "Enter password: " @@ -677,7 +682,8 @@ input_interactive() { _pass='' ;; esac - printf "%-10s : %s\n" "Password" "$_pass" + [ -z "$configflag" ] && printf "%-10s : %s\n" "Password" "$_pass" + [ -n "$configflag" ] && printf "%-10s : %s\n" "Pass Type" "$passwdtype" [ -z "$configflag" ] && printf "%-10s : %s\n" "Full Name" "$ugecos" [ -z "$configflag" ] && printf "%-10s : %s\n" "Uid" "$uuid" printf "%-10s : %s\n" "Class" "$uclass" @@ -709,9 +715,12 @@ input_interactive() { THISCMD=`/usr/bin/basename $0` DEFAULTSHELL=/bin/sh ADDUSERCONF="${ADDUSERCONF:-/etc/adduser.conf}" +ADDUSERLOG="${ADDUSERLOG:-/var/log/adduser}" PWCMD="${PWCMD:-/usr/sbin/pw}" MAILCMD="${MAILCMD:-mail}" ETCSHELLS="${ETCSHELLS:-/etc/shells}" +GREPCMD="/usr/bin/grep" +DATECMD="/bin/date" # Set default values # @@ -737,6 +746,7 @@ configflag= fflag= infile= disableflag= +adduserlog="${ADDUSERLOG}" readconfig="yes" homeprefix="/home" randompass= -- cgit v1.2.3-56-ge451