aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/adduser/adduser.sh
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/adduser/adduser.sh')
-rw-r--r--usr.sbin/adduser/adduser.sh50
1 files changed, 29 insertions, 21 deletions
diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh
index e9027b6b7876..ecac7478befd 100644
--- a/usr.sbin/adduser/adduser.sh
+++ b/usr.sbin/adduser/adduser.sh
@@ -53,7 +53,7 @@ info() {
# by pw(8).
#
get_nextuid () {
- local _uid=$1 _nextuid
+ local _uid=$1 _nextuid=
if [ -z "$_uid" ]; then
_nextuid="$(${PWCMD} usernext | cut -f1 -d:)"
@@ -101,7 +101,7 @@ show_usage() {
# basename of the shell is output.
#
valid_shells() {
- local _prefix
+ local _prefix=
${GREPCMD} '^[^#]' ${ETCSHELLS} |
while read _path _junk ; do
@@ -119,7 +119,7 @@ valid_shells() {
# full path to the shell from the /etc/shells file.
#
fullpath_from_shell() {
- local _shell=$1 _fullpath
+ local _shell=$1 _fullpath=
if [ -z "$_shell" ]; then
return
@@ -154,7 +154,7 @@ fullpath_from_shell() {
# will emit an informational message saying so.
#
shell_exists() {
- local _sh="$1"
+ local _sh=$1
if [ -z "$(fullpath_from_shell "$_sh")" ] ; then
err "Invalid shell ($_sh) for user $username."
@@ -193,8 +193,9 @@ save_config() {
# message or lock the account, do so.
#
add_user() {
- local _uid _name _comment _gecos _home _group _grouplist _shell _class
- local _dotdir _expire _pwexpire _passwd _upasswd _passwdmethod
+ local _uid= _name= _comment= _gecos= _home= _group= _grouplist=
+ local _shell= _class= _dotdir= _expire= _pwexpire= _passwd= _upasswd=
+ local _passwdmethod= _pwcmd=
# Is this a configuration run? If so, don't modify user database.
#
@@ -299,7 +300,7 @@ add_user() {
fi
fi
- local _line _owner _perms _file _dir
+ local _line= _owner= _perms= _file= _dir=
if [ -n "$msgflag" ]; then
if [ -r "$msgfile" ]; then
# We're evaluating the contents of an external file.
@@ -331,7 +332,7 @@ add_user() {
# a file it will output an error message and return to the caller.
#
get_user() {
- local _input
+ local _input=
# No need to take down user names if this is a configuration saving run.
[ -n "$configflag" ] && return
@@ -366,7 +367,7 @@ get_user() {
# and batch (from file) mode.
#
get_gecos() {
- local _input
+ local _input=
# No need to take down additional user information for a configuration run.
[ -n "$configflag" ] && return
@@ -386,7 +387,7 @@ get_gecos() {
# If an invalid shell is entered it will simply use the default shell.
#
get_shell() {
- local _input _fullpath
+ local _input= _fullpath=
ushell="$defaultshell"
# Make sure the current value of the shell is a valid one
@@ -424,7 +425,7 @@ get_shell() {
# and batch input.
#
get_homedir() {
- _input=
+ local _input=
if [ -z "$fflag" ]; then
echo -n "Home directory [${homeprefix}/${username}]: "
read _input
@@ -450,7 +451,7 @@ get_homedir() {
# Reads the account's home directory permissions.
#
get_homeperm() {
- local _input _prompt
+ local _input= _prompt=
uhomeperm=$defaultHomePerm
if [ -n "$uhomeperm" ]; then
@@ -473,7 +474,7 @@ get_homeperm() {
# so, enable ZFS home dataset creation.
#
get_zfs_home() {
- local _prefix
+ local _prefix= _tmp=
# check if zfs kernel module is loaded before attempting to run zfs to
# prevent loading the kernel module on systems that don't use ZFS
@@ -486,6 +487,13 @@ get_zfs_home() {
Zcreate="no"
return
fi
+ # Make sure that _prefix is not a subdirectory within a dataset. If it
+ # is, the containing dataset will be the same for it and its parent.
+ _tmp=$(${ZFSCMD} list -Ho name "$(dirname "${homeprefix}")" 2>/dev/null)
+ if [ "${_tmp}" = "${_prefix}" ]; then
+ Zcreate="no"
+ return
+ fi
zhome="${_prefix}/${username}"
}
@@ -494,7 +502,7 @@ get_zfs_home() {
# allocates one if it is not specified.
#
get_uid() {
- local _input _prompt
+ local _input= _prompt=
uuid=${uidstart}
if [ -n "$uuid" ]; then
@@ -519,7 +527,7 @@ get_uid() {
# Reads login class of account. Can be used in interactive or batch mode.
#
get_class() {
- local _input _uclass
+ local _input= _class=
uclass="$defaultclass"
_class=${uclass:-"default"}
@@ -541,7 +549,7 @@ get_class() {
# will then provide a login group with the same name as the username.
#
get_logingroup() {
- local _input
+ local _input=
ulogingroup="$defaultLgroup"
if [ -z "$fflag" ]; then
@@ -560,7 +568,7 @@ get_logingroup() {
# and batch modes.
#
get_groups() {
- local _input _group
+ local _input= _group=
ugroups="$defaultgroups"
_group=${ulogingroup:-"${username}"}
@@ -626,7 +634,7 @@ get_password() {
# Ask user if they want to enable encryption on their ZFS home dataset.
#
get_zfs_encryption() {
- local _input _prompt
+ local _input= _prompt=
_prompt="Enable ZFS encryption? (yes/no) [${Zencrypt}]: "
while : ; do
echo -n "$_prompt"
@@ -702,7 +710,7 @@ set_zfs_perms() {
# adds it to the user database.
#
input_from_file() {
- local _field
+ local _field=
while read -r fileline ; do
case "$fileline" in
@@ -733,14 +741,13 @@ input_from_file() {
# the user database.
#
input_interactive() {
- local _disable _pass _passconfirm _input
+ local _disable= _pass= _passconfirm= _input=
local _random="no"
local _emptypass="no"
local _usepass="yes"
local _logingroup_ok="no"
local _groups_ok="no"
local _all_ok="yes"
- local _another_user="no"
case $passwdtype in
none)
_emptypass="yes"
@@ -1129,6 +1136,7 @@ if [ -n "$fflag" ]; then
else
input_interactive
while : ; do
+ _another_user="no"
if [ -z "$configflag" ]; then
echo -n "Add another user? (yes/no) [$_another_user]: "
else