Add a -g option to specify a default login group.

Approved by:	markm (mentor)(implicit)
This commit is contained in:
mtm 2003-03-20 16:36:03 +00:00
parent 0077bc4bf0
commit 66726447ae
2 changed files with 22 additions and 10 deletions

View File

@ -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

View File

@ -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