o Add an -S option to not attempt to ascertain the validity of a shell.
o Add a -D option to not attempt to create the home directory. o Treat the /nonexistent home directory specially. It means the user has no home directory and it should not be created. o Update Copyright year and my email.
This commit is contained in:
parent
fe6f003286
commit
b888616478
@ -1,6 +1,6 @@
|
||||
.\" Copyright (c) 1995-1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 2002 Michael Telahun Makonnen <makonnen@pacbell.net>
|
||||
.\" Copyright (c) 2002-2004 Michael Telahun Makonnen <mtm@FreeBSD.Org>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
@ -34,7 +34,7 @@
|
||||
.Nd command for adding new users
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl CENhq
|
||||
.Op Fl CDENShq
|
||||
.Op Fl G Ar groups
|
||||
.Op Fl L Ar login_class
|
||||
.Op Fl d Ar partition
|
||||
@ -164,6 +164,16 @@ option.
|
||||
Home partition.
|
||||
Default partition, under which all user directories
|
||||
will be located.
|
||||
The
|
||||
.Pa /nonexistant
|
||||
partition is considered special.
|
||||
The
|
||||
.Nm
|
||||
script will not create and populate a home directory by that name.
|
||||
Otherwise,
|
||||
by default it attempts to create a home directory.
|
||||
.It Fl D
|
||||
Do not attempt to create the home directory.
|
||||
.It Fl E
|
||||
Disable the account.
|
||||
This option will lock the account by prepending the string
|
||||
@ -243,6 +253,8 @@ It must exist in
|
||||
or be the special shell
|
||||
.Em nologin
|
||||
to be considered a valid shell.
|
||||
.It Fl S
|
||||
The existence or validity of the specified shell will not be checked.
|
||||
.It Fl u Ar uid
|
||||
Use UIDs from
|
||||
.Ar uid
|
||||
@ -353,6 +365,11 @@ Full name and other extra information about the user.
|
||||
Home directory.
|
||||
If this field is left empty, it will be automatically
|
||||
created by appending the username to the home partition.
|
||||
The
|
||||
.Pa /nonexistent
|
||||
home directory is considered special and
|
||||
is understood to mean that no home directory is to be
|
||||
created for the user.
|
||||
.It Ar shell
|
||||
Login shell.
|
||||
This field should contain the full path to a valid login shell.
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2002, 2003 Michael Telahun Makonnen. All rights reserved.
|
||||
# Copyright (c) 2002-2004 Michael Telahun Makonnen. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
@ -77,10 +77,12 @@ show_usage() {
|
||||
echo "usage: ${THISCMD} [options]"
|
||||
echo " options may include:"
|
||||
echo " -C save to the configuration file only"
|
||||
echo " -D do not attempt to create the home directory"
|
||||
echo " -E disable this account after creation"
|
||||
echo " -G additional groups to add accounts to"
|
||||
echo " -L login class of the user"
|
||||
echo " -N do not read configuration file"
|
||||
echo " -S a nonexistent shell is not an error"
|
||||
echo " -d home directory"
|
||||
echo " -f file from which input will be received"
|
||||
echo " -g default login group"
|
||||
@ -226,12 +228,22 @@ add_user() {
|
||||
[ -n "$ulogingroup" ] && _group='-g "$ulogingroup"'
|
||||
[ -n "$ugroups" ] && _grouplist='-G "$ugroups"'
|
||||
[ -n "$ushell" ] && _shell='-s "$ushell"'
|
||||
[ -n "$uhome" ] && _home='-m -d "$uhome"'
|
||||
[ -n "$uclass" ] && _class='-L "$uclass"'
|
||||
[ -n "$ugecos" ] && _comment='-c "$ugecos"'
|
||||
[ -n "$udotdir" ] && _dotdir='-k "$udotdir"'
|
||||
[ -n "$uexpire" ] && _expire='-e "$uexpire"'
|
||||
[ -n "$upwexpire" ] && _pwexpire='-p "$upwexpire"'
|
||||
if [ -z "$Dflag" -a -n "$uhome" ]; then
|
||||
# The /nonexistent home directory is special. It
|
||||
# means the user has no home directory.
|
||||
if [ "$uhome" = "$NOHOME" ]; then
|
||||
_home='-d "$uhome"'
|
||||
else
|
||||
_home='-m -d "$uhome"'
|
||||
fi
|
||||
elif [ -n "$Dflag" -a -n "$uhome" ]; then
|
||||
_home='-d "$uhome"'
|
||||
fi
|
||||
case $passwdtype in
|
||||
no)
|
||||
_passwdmethod="-w no"
|
||||
@ -369,9 +381,11 @@ get_shell() {
|
||||
ushell="$defaultshell"
|
||||
|
||||
# Make sure the current value of the shell is a valid one
|
||||
if ! shell_exists $ushell ; then
|
||||
info "Using default shell ${defaultshell}."
|
||||
ushell="$defaultshell"
|
||||
if [ -z "$Sflag" ]; then
|
||||
if ! shell_exists $ushell ; then
|
||||
info "Using default shell ${defaultshell}."
|
||||
ushell="$defaultshell"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$fflag" ]; then
|
||||
@ -381,13 +395,17 @@ get_shell() {
|
||||
_input="`echo "$fileline" | cut -f9 -d:`"
|
||||
fi
|
||||
if [ -n "$_input" ]; then
|
||||
_fullpath=`fullpath_from_shell $_input`
|
||||
if [ -n "$_fullpath" ]; then
|
||||
ushell="$_fullpath"
|
||||
if [ -n "$Sflag" ]; then
|
||||
ushell="$_input"
|
||||
else
|
||||
err "Invalid shell ($_input) for user $username."
|
||||
info "Using default shell ${defaultshell}."
|
||||
ushell="$defaultshell"
|
||||
_fullpath=`fullpath_from_shell $_input`
|
||||
if [ -n "$_fullpath" ]; then
|
||||
ushell="$_fullpath"
|
||||
else
|
||||
err "Invalid shell ($_input) for user $username."
|
||||
info "Using default shell ${defaultshell}."
|
||||
ushell="$defaultshell"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -779,6 +797,7 @@ ADDUSERCONF="${ADDUSERCONF:-/etc/adduser.conf}"
|
||||
PWCMD="${PWCMD:-/usr/sbin/pw}"
|
||||
MAILCMD="${MAILCMD:-mail}"
|
||||
ETCSHELLS="${ETCSHELLS:-/etc/shells}"
|
||||
NOHOME="/nonexistent"
|
||||
NOLOGIN="nologin"
|
||||
NOLOGIN_PATH="/sbin/nologin"
|
||||
GREPCMD="/usr/bin/grep"
|
||||
@ -808,6 +827,8 @@ configflag=
|
||||
fflag=
|
||||
infile=
|
||||
disableflag=
|
||||
Dflag=
|
||||
Sflag=
|
||||
readconfig="yes"
|
||||
homeprefix="/home"
|
||||
randompass=
|
||||
@ -860,6 +881,10 @@ for _switch ; do
|
||||
configflag=yes
|
||||
shift
|
||||
;;
|
||||
-D)
|
||||
Dflag=yes
|
||||
shift
|
||||
;;
|
||||
-E)
|
||||
disableflag=yes
|
||||
shift
|
||||
@ -925,6 +950,10 @@ for _switch ; do
|
||||
defaultshell="`fullpath_from_shell $2`"
|
||||
shift; shift
|
||||
;;
|
||||
-S)
|
||||
Sflag=yes
|
||||
shift
|
||||
;;
|
||||
-u)
|
||||
uidstart=$2
|
||||
shift; shift
|
||||
|
Loading…
x
Reference in New Issue
Block a user