summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adduser/adduser.810
-rw-r--r--adduser/adduser.sh22
2 files changed, 22 insertions, 10 deletions
diff --git a/adduser/adduser.8 b/adduser/adduser.8
index 4daa77e..69b5141 100644
--- a/adduser/adduser.8
+++ b/adduser/adduser.8
@@ -39,6 +39,7 @@
.Op Fl L Ar login_class
.Op Fl d Ar partition
.Op Fl f Ar file
+.Op Fl g Ar login_group
.Op Fl k Ar dotdir
.Op Fl m Ar message_file
.Op Fl s Ar shell
@@ -189,10 +190,17 @@ If an error is encountered while processing an account, it will write a
message to standard error and move to the next account.
The format
of the input file is described below.
+.It Fl g Ar login_group
+Normaly,
+if no login group is specified,
+it is assumed to be the same as the username.
+This option makes
+.Ar login_group
+the default.
.It Fl G Ar groups
Additional groups.
-By default, the user name is used as the login group.
This option allows the user to specify additional groups to add users to.
+The user is a member of these groups in addition to their login group.
.It Fl h
Print a summary of options and exit.
.It Fl k Ar directory
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