diff options
author | le <le@FreeBSD.org> | 2007-03-26 22:22:10 +0000 |
---|---|---|
committer | le <le@FreeBSD.org> | 2007-03-26 22:22:10 +0000 |
commit | 2db2cb377d2f7b610b6aa3d70dda8991193fc1ac (patch) | |
tree | 623bf3650dc1af68e3b3d41e6ad6774c9b60c718 /usr.sbin/adduser/adduser.sh | |
parent | 2ddeaf92036c8988cca5697c02d5c476feeffbdb (diff) | |
download | FreeBSD-src-2db2cb377d2f7b610b6aa3d70dda8991193fc1ac.zip FreeBSD-src-2db2cb377d2f7b610b6aa3d70dda8991193fc1ac.tar.gz |
Check if the new user already exists right after entering the
username instead of watching the final call to pw(8) fail.
Diffstat (limited to 'usr.sbin/adduser/adduser.sh')
-rw-r--r-- | usr.sbin/adduser/adduser.sh | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh index 735d178..7097caf 100644 --- a/usr.sbin/adduser/adduser.sh +++ b/usr.sbin/adduser/adduser.sh @@ -346,13 +346,19 @@ get_user() { _input="`echo "$fileline" | cut -f1 -d:`" fi - # There *must* be a username. If this is an interactive - # session give the user an opportunity to retry. + # There *must* be a username, and it must not exist. If + # this is an interactive session give the user an + # opportunity to retry. # if [ -z "$_input" ]; then err "You must enter a username!" [ -z "$fflag" ] && continue fi + ${PWCMD} usershow $_input > /dev/null 2>&1 + if [ "$?" -eq 0 ]; then + err "User exists!" + [ -z "$fflag" ] && continue + fi break done username="$_input" |