aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/adduser/adduser.sh
diff options
context:
space:
mode:
authorMax Khon <fjoe@FreeBSD.org>2003-01-23 20:07:40 +0000
committerMax Khon <fjoe@FreeBSD.org>2003-01-23 20:07:40 +0000
commite63bd70a30ce6a7c886eb78a80972c0a8337aae0 (patch)
tree4064e4869e98f9ff9e7a34ef260ca803859ee0de /usr.sbin/adduser/adduser.sh
parentce1794a8071ba72757ca156932fa89ebd346a380 (diff)
downloadsrc-e63bd70a30ce6a7c886eb78a80972c0a8337aae0.tar.gz
src-e63bd70a30ce6a7c886eb78a80972c0a8337aae0.zip
- 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)
Notes
Notes: svn path=/head/; revision=109751
Diffstat (limited to 'usr.sbin/adduser/adduser.sh')
-rw-r--r--usr.sbin/adduser/adduser.sh16
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh
index 0a921338a096..6c142513b1d2 100644
--- a/usr.sbin/adduser/adduser.sh
+++ b/usr.sbin/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='<random>'
;;
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=