diff options
author | Lukas Ertl <le@FreeBSD.org> | 2007-03-26 22:22:10 +0000 |
---|---|---|
committer | Lukas Ertl <le@FreeBSD.org> | 2007-03-26 22:22:10 +0000 |
commit | b7ca0fb0cefab36f28337f65b3ae12b94f637527 (patch) | |
tree | 9a4b7b9c80aca1669d36d98e18cc5aa12909102e /adduser/adduser.sh | |
parent | ccf3c1c10dd7550437eceb01525d679cf617c6e4 (diff) | |
download | pw-darwin-b7ca0fb0cefab36f28337f65b3ae12b94f637527.tar.gz pw-darwin-b7ca0fb0cefab36f28337f65b3ae12b94f637527.tar.zst pw-darwin-b7ca0fb0cefab36f28337f65b3ae12b94f637527.zip |
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 'adduser/adduser.sh')
-rw-r--r-- | adduser/adduser.sh | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/adduser/adduser.sh b/adduser/adduser.sh index 735d178..7097caf 100644 --- a/adduser/adduser.sh +++ b/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" |