diff options
author | adrian <adrian@FreeBSD.org> | 2003-02-08 08:04:53 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2003-02-08 08:04:53 +0000 |
commit | ad4137525e8db67ebb61e6184ed706d38e73d6cb (patch) | |
tree | f45bfdab6f7f1fffebb03c439b74e4ef0560ef11 /usr.sbin | |
parent | b723a9faa7fec610ea26689c83ed8ac9c1358d6e (diff) | |
download | FreeBSD-src-ad4137525e8db67ebb61e6184ed706d38e73d6cb.zip FreeBSD-src-ad4137525e8db67ebb61e6184ed706d38e73d6cb.tar.gz |
Change the behaviour of adduser to match the previous incarnation a little more.
If any of the given groups do not exist complain and let the user try again.
This saves the user from discovering at the end of the process that they've
forgotten to add a group or they've typoed.
Thanks to cmc/dougb for pointing out how bad my sh fu actually is.
Original code by: me
Scary sh rewrite by: dougb
Reviewed by: dougb
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/adduser/adduser.sh | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh index 96049bd..ee47bdd 100644 --- a/usr.sbin/adduser/adduser.sh +++ b/usr.sbin/adduser/adduser.sh @@ -570,8 +570,32 @@ input_interactive() { get_user get_gecos get_uid - get_logingroup - get_groups + + # The case where group = user is handled elsewhere, so + # validate any other groups the user is invited to. + until [ "$_logingroup_ok" = yes ]; do + get_logingroup + _logingroup_ok=yes + if [ -n "$ulogingroup" -a "$username" != "$ulogingroup" ]; then + if ! ${PWCMD} show group $ulogingroup > /dev/null 2>&1; then + echo "Group $ulogingroup does not exist!" + _logingroup_ok=no + fi + fi + done + until [ "$_groups_ok" = yes ]; do + get_groups + _groups_ok=yes + for i in $ugroups; do + if [ "$username" != "$i" ]; then + if ! ${PWCMD} show group $i > /dev/null 2>&1; then + echo "Group $i does not exist!" + _groups_ok=no + fi + fi + done + done + get_class get_shell get_homedir |