Check if the new user already exists right after entering the

username instead of watching the final call to pw(8) fail.
This commit is contained in:
Lukas Ertl 2007-03-26 22:22:10 +00:00
parent 6455de0029
commit a80d527f45
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=167917

View file

@ -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"