summaryrefslogtreecommitdiffstats
path: root/adduser/adduser.sh
diff options
context:
space:
mode:
authorMike Makonnen <mtm@FreeBSD.org>2003-03-20 16:36:03 +0000
committerMike Makonnen <mtm@FreeBSD.org>2003-03-20 16:36:03 +0000
commitc03e082693d66d2ac6afdfcd84602edf77b466d5 (patch)
tree18310d589691d71bfb2f01d96a54ebac30f818a1 /adduser/adduser.sh
parente5f96223fdef6911fdc8c7324635681d33f14049 (diff)
downloadpw-darwin-c03e082693d66d2ac6afdfcd84602edf77b466d5.tar.gz
pw-darwin-c03e082693d66d2ac6afdfcd84602edf77b466d5.tar.zst
pw-darwin-c03e082693d66d2ac6afdfcd84602edf77b466d5.zip
Add a -g option to specify a default login group.
Approved by: markm (mentor)(implicit)
Diffstat (limited to 'adduser/adduser.sh')
-rw-r--r--adduser/adduser.sh22
1 files changed, 13 insertions, 9 deletions
diff --git a/adduser/adduser.sh b/adduser/adduser.sh
index 79e3752..bd9c42f 100644
--- a/adduser/adduser.sh
+++ b/adduser/adduser.sh
@@ -145,6 +145,7 @@ save_config() {
echo "# NOTE: only *some* variables are saved." >> ${ADDUSERCONF}
echo "# Last Modified on `${DATECMD}`." >> ${ADDUSERCONF}
echo '' >> ${ADDUSERCONF}
+ echo "defaultLgroup=$ulogingroup" >> ${ADDUSERCONF}
echo "defaultclass=$uclass" >> ${ADDUSERCONF}
echo "defaultgroups=$ugroups" >> ${ADDUSERCONF}
echo "passwdtype=$passwdtype" >> ${ADDUSERCONF}
@@ -430,25 +431,23 @@ get_class() {
# get_logingroup
# Reads user's login group. Can be used in both interactive and batch
# modes. The specified value can be a group name or its numeric id.
-# This routine leaves the field blank if nothing is provided. The pw(8)
-# command will then provide a login group with the same name as the username.
+# This routine leaves the field blank if nothing is provided and
+# a default login group has not been set. The pw(8) command
+# will then provide a login group with the same name as the username.
#
get_logingroup() {
- ulogingroup=
+ ulogingroup="$defaultLgroup"
_input=
- # No need to take down a login group for a configuration saving run.
- [ -n "$configflag" ] && return
-
if [ -z "$fflag" ]; then
- echo -n "Login group [$username]: "
+ echo -n "Login group [${ulogingroup:-$username}]: "
read _input
else
_input="`echo "$fileline" | cut -f3 -d:`"
fi
# Pw(8) will use the username as login group if it's left empty
- [ -n "$_input" ] && ulogingroup="$_input" || ulogingroup=
+ [ -n "$_input" ] && ulogingroup="$_input"
}
# get_groups
@@ -713,7 +712,7 @@ input_interactive() {
[ -z "$configflag" ] && printf "%-10s : %s\n" "Full Name" "$ugecos"
[ -z "$configflag" ] && printf "%-10s : %s\n" "Uid" "$uuid"
printf "%-10s : %s\n" "Class" "$uclass"
- [ -z "$configflag" ] && printf "%-10s : %s %s\n" "Groups" "${ulogingroup:-$username}" "$ugroups"
+ printf "%-10s : %s %s\n" "Groups" "${ulogingroup:-$username}" "$ugroups"
printf "%-10s : %s\n" "Home" "$uhome"
printf "%-10s : %s\n" "Shell" "$ushell"
printf "%-10s : %s\n" "Locked" "$_disable"
@@ -777,6 +776,7 @@ randompass=
fileline=
savedpwtype=
defaultclass=
+defaultLgroup=
defaultgoups=
defaultshell="${DEFAULTSHELL}"
@@ -835,6 +835,10 @@ for _switch ; do
fflag=yes
shift; shift
;;
+ -g)
+ defaultLgroup="$2"
+ shift; shift
+ ;;
-G)
defaultgroups="$2"
shift; shift