From b7ca0fb0cefab36f28337f65b3ae12b94f637527 Mon Sep 17 00:00:00 2001 From: Lukas Ertl Date: Mon, 26 Mar 2007 22:22:10 +0000 Subject: Check if the new user already exists right after entering the username instead of watching the final call to pw(8) fail. --- adduser/adduser.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'adduser/adduser.sh') 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" -- cgit v1.2.3-56-ge451