Hi,
The adduser in -current doesn't check if a specified group exists until
the call to pw right at the end. eep.
My sh foo isn't terribly great, but this did it for me.
Comments/rewrites are welcome. I'll commit the group consensus.
Adrian
diff:
--- /usr/src/usr.sbin/adduser/adduser.sh Fri Jan 24 02:05:51 2003
+++ adduser.sh Fri Feb 7 08:04:15 2003
@@ -47,6 +47,16 @@
fi
}
+# Check whether the given group exists
+check_group() {
+ ${PWCMD} show group $1 1> /dev/null 2> /dev/null
+ if [ "$?" = "0" ]; then
+ echo "1"
+ return
+ fi
+ echo "0"
+}
+
# get_nextuid
# Output the value of $_uid if it is available for use. If it
# is not, output the value of the next higher uid that is available.
@@ -570,8 +580,31 @@
get_user
get_gecos
get_uid
- get_logingroup
- get_groups
+ ok="NO"
+
+ # The code creates a group = $user if one doesn't exist.
+ # We are just going to capture other non-existant groups!
+ while [ "$ok" = "NO" ] ; do
+ ok="YES"
+ get_logingroup
+ if [ "$ulogingroup" != "" -a "$username" != "$ulogingroup" -a
+"`check_group $ulogingroup`" = "0" ]; then
+ echo "Group $ulogingroup does not exist!"
+ ok="NO"
+ fi
+ done
+
+ ok="NO"
+ while [ "$ok" = "NO" ] ; do
+ ok="YES"
+ get_groups
+ for i in $ugroups; do
+ if [ "$username" != "$i" -a "`check_group $i`" = "0" ]; then
+ echo "Group $i does not exist!"
+ ok="NO"
+ fi
+ done
+ done
+
get_class
get_shell
get_homedir
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message