summaryrefslogtreecommitdiffstats
path: root/adduser
diff options
context:
space:
mode:
authorLukas Ertl <le@FreeBSD.org>2007-03-26 22:22:10 +0000
committerLukas Ertl <le@FreeBSD.org>2007-03-26 22:22:10 +0000
commit50a7ffedcffc04d8fed26606e47ab9d53fc04125 (patch)
tree60dcf1c1813a684b6799ef3cdb1e87056e2402e5 /adduser
parentd63a3fda56b5934ad4d054f338d1c21f027b4af5 (diff)
downloadpw-darwin-50a7ffedcffc04d8fed26606e47ab9d53fc04125.tar.gz
pw-darwin-50a7ffedcffc04d8fed26606e47ab9d53fc04125.tar.zst
pw-darwin-50a7ffedcffc04d8fed26606e47ab9d53fc04125.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')
-rw-r--r--adduser/adduser.sh10
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"