From nobody Mon Apr 29 10:34:26 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VSfpB6BkWz5J2d5; Mon, 29 Apr 2024 10:34:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VSfpB5V1rz4mC4; Mon, 29 Apr 2024 10:34:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714386866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kWB2xAjPaAw0/+O4D+YzsXk+NpUKTKP3UxWFvY+edOQ=; b=WRuWD53RU3OS8kSzib6iCzTpzOlFqtrM6lUUQ1zPar8RN299cLtGnh5f4Lgy4t78cWh/RQ UCosPhsHNSS+bYhp1321Ty0IL5x8dv96pZ8kcup77ySWPTcpInzyCR4FkBQP1oe89hXyrl UT9Oxy0J6WOeHYC3lTFGQoZ5LN+pgY30U6L5xRthC++A0gwKgUzauqda1oCnZ2Uj+CPITh WBcUF8THOPP7J8lGj+BxgqexNuK3ucM993CV7D3dRcMD7e1M5f0wSZWAI8GpYd6qniq+k+ lwZ3szcRNRhdGtmqq9sUK8DArKYqgIKcmD+MZkwCuNBb1Xqpox5eHeRU+MU9jQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714386866; a=rsa-sha256; cv=none; b=TUcw+TAQD01d+v6rf193r5JJKHPk6LqHgS9TSKS6SibyyNgUZxQQPN6BvivgGC3XWVESyf 1f4GXYOi/zcdflxMre/jc/AQWaTVlo8luDf+SZg8QVvTpj1PVtulwSdqzUihcrgBv0lfOZ yUSAMqejvIqJsRoX+1+KaIw4INNDhzwxLMYeRErX17sjdCKYqilTRliYKkTUTPeTeMPCWC V4VJnaKCJV/iAKDYN24JJla7SR7HyjERvjEL7SZApzpdLNTTnOEeHmzM5RkWwUI4bKJgUP o4KGBb8wfVh8wctdP1sXhac5VseZ96sGXQ6nw4msQo3yyD73P8wg0lEDWtCBoQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714386866; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kWB2xAjPaAw0/+O4D+YzsXk+NpUKTKP3UxWFvY+edOQ=; b=voMNaLkCmn8+/67n0K9+aA6V+mbIRk5T9t+ay9MXlVLhT7+FimN5V8u+DDZTc877e5thii z/s/YP9MhD1MhgCR32rQBFDeWzxitfgao6bt/4ZoMor8OOxVjrr/xrYMDBVtoiPSS1OL+N 400lUOXhAXnho06xftsl36rjfKU9dx5r5wjD2kZExWHMah8l/n+2jj4brbUcdkNATNFCtP rRF6ZOMuWGdhZju3oT0/geP7sAVPemeaxDXcsGFcRrVrFDQ4s0wK1oRP2kAICnJOzfpEh3 O5PcZukmjuObNEVLKVyTUna9MEnXdJ9b0YKDh57YRX+9K2OWDr6DisCUZVQTgg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VSfpB55qyz158N; Mon, 29 Apr 2024 10:34:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43TAYQOb071558; Mon, 29 Apr 2024 10:34:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43TAYQeJ071555; Mon, 29 Apr 2024 10:34:26 GMT (envelope-from git) Date: Mon, 29 Apr 2024 10:34:26 GMT Message-Id: <202404291034.43TAYQeJ071555@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: b7a56907af0c - stable/13 - adduser: Overhaul. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b7a56907af0cae57375ca2fb7f3e3a77da916ca8 Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b7a56907af0cae57375ca2fb7f3e3a77da916ca8 commit b7a56907af0cae57375ca2fb7f3e3a77da916ca8 Author: Dag-Erling Smørgrav AuthorDate: 2024-04-19 15:11:16 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-04-29 10:30:39 +0000 adduser: Overhaul. Most importantly: * Make local variables local. * Use `$()` instead of backticks. * Avoid unsafe use of `-a` and `-o` operators in `test` expressions. * Remove a hack intended to ease the transition from Perl 22 years ago. MFC after: 1 week Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D44863 (cherry picked from commit 170d0882903eb75b92cd10e9a1bcbe57a647ae7d) adduser: A few more improvements. MFC after: 1 week Reviewed by: jrm Differential Revision: https://reviews.freebsd.org/D44871 (cherry picked from commit b37333899bd27a74bdef34b7f34eb41bc6bd51bd) adduser: Fix a syntax error Reported by: Jose Luis Duran Fixes: b37333899bd2 MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44871 (cherry picked from commit 5cafc38f11297cb302514f3cedb703a3ed199a22) adduser: Really fix a syntax error Fixes: 5cafc38f1129 Differential Revision: https://reviews.freebsd.org/D44871 (cherry picked from commit 9e8618276fada5c68cc64676fba2ae2abd0544f5) --- usr.sbin/adduser/adduser.sh | 243 ++++++++++++++++++-------------------------- 1 file changed, 101 insertions(+), 142 deletions(-) diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh index 0d5a628f8f33..e9027b6b7876 100644 --- a/usr.sbin/adduser/adduser.sh +++ b/usr.sbin/adduser/adduser.sh @@ -53,19 +53,17 @@ info() { # by pw(8). # get_nextuid () { - _uid=$1 - _nextuid= + local _uid=$1 _nextuid if [ -z "$_uid" ]; then - _nextuid="`${PWCMD} usernext | cut -f1 -d:`" + _nextuid="$(${PWCMD} usernext | cut -f1 -d:)" else while : ; do - ${PWCMD} usershow $_uid > /dev/null 2>&1 - if [ ! "$?" -eq 0 ]; then + if ! ${PWCMD} usershow $_uid > /dev/null 2>&1; then _nextuid=$_uid break fi - _uid=$(($_uid + 1)) + _uid=$((_uid + 1)) done fi echo $_nextuid @@ -103,17 +101,12 @@ show_usage() { # basename of the shell is output. # valid_shells() { - _prefix= - cat ${ETCSHELLS} | + local _prefix + + ${GREPCMD} '^[^#]' ${ETCSHELLS} | while read _path _junk ; do - case $_path in - \#*|'') - ;; - *) - echo -n "${_prefix}`basename $_path`" - _prefix=' ' - ;; - esac + echo -n "${_prefix}${_path##*/}" + _prefix=' ' done # /usr/sbin/nologin is a special case @@ -126,36 +119,31 @@ valid_shells() { # full path to the shell from the /etc/shells file. # fullpath_from_shell() { - _shell=$1 - [ -z "$_shell" ] && return 1 + local _shell=$1 _fullpath + + if [ -z "$_shell" ]; then + return + fi # /usr/sbin/nologin is a special case; it needs to be handled - # before the cat | while loop, since a 'return' from within + # before the grep | while loop, since a 'return' from within # a subshell will not terminate the function's execution, and # the path to the nologin shell might be printed out twice. # - if [ "$_shell" = "${NOLOGIN}" -o \ - "$_shell" = "${NOLOGIN_PATH}" ]; then + if [ "$_shell" = "${NOLOGIN}" ] || + [ "$_shell" = "${NOLOGIN_PATH}" ]; then echo ${NOLOGIN_PATH} - return 0; + return fi - cat ${ETCSHELLS} | + ${GREPCMD} '^[^#]' ${ETCSHELLS} | while read _path _junk ; do - case "$_path" in - \#*|'') - ;; - *) - if [ "$_path" = "$_shell" -o \ - "`basename $_path`" = "$_shell" ]; then - echo $_path - return 0 - fi - ;; - esac + if [ "$_path" = "$_shell" ] || + [ "${_path##*/}" = "$_shell" ]; then + echo "$_path" + break + fi done - - return 1 } # shell_exists shell @@ -166,19 +154,14 @@ fullpath_from_shell() { # will emit an informational message saying so. # shell_exists() { - _sh="$1" - _shellchk="${GREPCMD} '^$_sh$' ${ETCSHELLS} > /dev/null 2>&1" + local _sh="$1" - if ! eval $_shellchk; then - # The nologin shell is not listed in /etc/shells. - if [ "$_sh" != "${NOLOGIN_PATH}" ]; then - err "Invalid shell ($_sh) for user $username." - return 1 - fi + if [ -z "$(fullpath_from_shell "$_sh")" ] ; then + err "Invalid shell ($_sh) for user $username." + return 1 fi - ! [ -x "$_sh" ] && + [ -x "$_sh" ] || info "The shell ($_sh) does not exist or is not executable." - return 0 } @@ -190,7 +173,7 @@ shell_exists() { save_config() { echo "# Configuration file for adduser(8)." > ${ADDUSERCONF} echo "# NOTE: only *some* variables are saved." >> ${ADDUSERCONF} - echo "# Last Modified on `${DATECMD}`." >> ${ADDUSERCONF} + echo "# Last Modified on $(${DATECMD})." >> ${ADDUSERCONF} echo '' >> ${ADDUSERCONF} echo "defaultHomePerm=$uhomeperm" >> ${ADDUSERCONF} echo "defaultLgroup=$ulogingroup" >> ${ADDUSERCONF} @@ -210,6 +193,8 @@ 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 # Is this a configuration run? If so, don't modify user database. # @@ -218,22 +203,6 @@ add_user() { return fi - _uid= - _name= - _comment= - _gecos= - _home= - _group= - _grouplist= - _shell= - _class= - _dotdir= - _expire= - _pwexpire= - _passwd= - _upasswd= - _passwdmethod= - _name="-n '$username'" [ -n "$uuid" ] && _uid='-u "$uuid"' [ -n "$ulogingroup" ] && _group='-g "$ulogingroup"' @@ -244,7 +213,7 @@ add_user() { [ -n "$udotdir" ] && _dotdir='-k "$udotdir"' [ -n "$uexpire" ] && _expire='-e "$uexpire"' [ -n "$upwexpire" ] && _pwexpire='-p "$upwexpire"' - if [ -z "$Dflag" -a -n "$uhome" ]; then + if [ -z "$Dflag" ] && [ -n "$uhome" ]; then # The /nonexistent home directory is special. It # means the user has no home directory. if [ "$uhome" = "$NOHOME" ]; then @@ -257,7 +226,7 @@ add_user() { _home='-m -d "$uhome"' fi fi - elif [ -n "$Dflag" -a -n "$uhome" ]; then + elif [ -n "$Dflag" ] && [ -n "$uhome" ]; then _home='-d "$uhome"' fi case $passwdtype in @@ -292,8 +261,7 @@ add_user() { if [ -n "$BSDINSTALL_CHROOT" ]; then create_zfs_chrooted_dataset else - create_zfs_dataset - if [ "$?" -ne 0 ]; then + if ! create_zfs_dataset; then err "There was an error adding user ($username)." return 1 fi @@ -304,7 +272,7 @@ add_user() { _pwcmd="$_pwcmd $_shell $_class $_home $_dotdir $_passwdmethod $_passwd" _pwcmd="$_pwcmd $_expire $_pwexpire" - if ! _output=`eval $_pwcmd` ; then + if ! _output=$(eval $_pwcmd) ; then err "There was an error adding user ($username)." return 1 else @@ -331,30 +299,27 @@ add_user() { fi fi - _line= - _owner= - _perms= + local _line _owner _perms _file _dir if [ -n "$msgflag" ]; then - [ -r "$msgfile" ] && { + if [ -r "$msgfile" ]; then # We're evaluating the contents of an external file. # Let's not open ourselves up for attack. _perms will # be empty if it's writeable only by the owner. _owner # will *NOT* be empty if the file is owned by root. # - _dir="`dirname $msgfile`" - _file="`basename $msgfile`" - _perms=`/usr/bin/find $_dir -name $_file -perm +07022 -prune` - _owner=`/usr/bin/find $_dir -name $_file -user 0 -prune` - if [ -z "$_owner" -o -n "$_perms" ]; then + _dir="$(dirname "$msgfile")" + _file="$(basename "$msgfile")" + _perms=$(/usr/bin/find "$_dir" -name "$_file" -perm +07022 -prune) + _owner=$(/usr/bin/find "$_dir" -name "$_file" -user 0 -prune) + if [ -z "$_owner" ] || [ -n "$_perms" ]; then err "The message file ($msgfile) may be writeable only by root." return 1 fi - cat "$msgfile" | while read _line ; do eval echo "$_line" - done | ${MAILCMD} -s"Welcome" ${username} + done <"$msgfile" | ${MAILCMD} -s"Welcome" ${username} info "Sent welcome message to ($username)." - } + fi fi } @@ -366,7 +331,7 @@ add_user() { # a file it will output an error message and return to the caller. # get_user() { - _input= + local _input # No need to take down user names if this is a configuration saving run. [ -n "$configflag" ] && return @@ -376,7 +341,7 @@ get_user() { echo -n "Username: " read _input else - _input="`echo "$fileline" | cut -f1 -d:`" + _input="$(echo "$fileline" | cut -f1 -d:)" fi # There *must* be a username, and it must not exist. If @@ -387,8 +352,7 @@ get_user() { err "You must enter a username!" [ -z "$fflag" ] && continue fi - ${PWCMD} usershow $_input > /dev/null 2>&1 - if [ "$?" -eq 0 ]; then + if ${PWCMD} usershow "$_input" > /dev/null 2>&1; then err "User exists!" [ -z "$fflag" ] && continue fi @@ -402,7 +366,7 @@ get_user() { # and batch (from file) mode. # get_gecos() { - _input= + local _input # No need to take down additional user information for a configuration run. [ -n "$configflag" ] && return @@ -411,7 +375,7 @@ get_gecos() { echo -n "Full name: " read _input else - _input="`echo "$fileline" | cut -f7 -d:`" + _input="$(echo "$fileline" | cut -f7 -d:)" fi ugecos="$_input" } @@ -422,8 +386,7 @@ get_gecos() { # If an invalid shell is entered it will simply use the default shell. # get_shell() { - _input= - _fullpath= + local _input _fullpath ushell="$defaultshell" # Make sure the current value of the shell is a valid one @@ -435,16 +398,16 @@ get_shell() { fi if [ -z "$fflag" ]; then - echo -n "Shell ($shells) [`basename $ushell`]: " + echo -n "Shell ($shells) [${ushell##*/}]: " read _input else - _input="`echo "$fileline" | cut -f9 -d:`" + _input="$(echo "$fileline" | cut -f9 -d:)" fi if [ -n "$_input" ]; then if [ -n "$Sflag" ]; then ushell="$_input" else - _fullpath=`fullpath_from_shell $_input` + _fullpath=$(fullpath_from_shell "$_input") if [ -n "$_fullpath" ]; then ushell="$_fullpath" else @@ -466,7 +429,7 @@ get_homedir() { echo -n "Home directory [${homeprefix}/${username}]: " read _input else - _input="`echo "$fileline" | cut -f8 -d:`" + _input="$(echo "$fileline" | cut -f8 -d:)" fi if [ -n "$_input" ]; then @@ -475,7 +438,9 @@ get_homedir() { # directory prefix. Otherwise it is understood to # be $prefix/$user # - [ -z "$configflag" ] && homeprefix="`dirname $uhome`" || homeprefix="$uhome" + [ -z "$configflag" ] && + homeprefix="$(dirname "$uhome")" || + homeprefix="$uhome" else uhome="${homeprefix}/${username}" fi @@ -485,9 +450,8 @@ get_homedir() { # Reads the account's home directory permissions. # get_homeperm() { + local _input _prompt uhomeperm=$defaultHomePerm - _input= - _prompt= if [ -n "$uhomeperm" ]; then _prompt="Home directory permissions [${uhomeperm}]: " @@ -509,19 +473,20 @@ get_homeperm() { # so, enable ZFS home dataset creation. # get_zfs_home() { + local _prefix + # 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 if ! "$KLDSTATCMD" -q -m zfs; then Zcreate="no" return fi - zfs_homeprefix=`${ZFSCMD} list -Ho name "${homeprefix}" 2>/dev/null` - if [ "$?" -ne 0 ]; then - Zcreate="no" - elif [ -z "${zfs_homeprefix}" ]; then + if ! _prefix=$(${ZFSCMD} list -Ho name "${homeprefix}" 2>/dev/null) || + [ -z "${_prefix}" ]; then Zcreate="no" + return fi - zhome="${zfs_homeprefix}/${username}" + zhome="${_prefix}/${username}" } # get_uid @@ -529,12 +494,11 @@ get_zfs_home() { # allocates one if it is not specified. # get_uid() { + local _input _prompt uuid=${uidstart} - _input= - _prompt= if [ -n "$uuid" ]; then - uuid=`get_nextuid $uuid` + uuid=$(get_nextuid "$uuid") _prompt="Uid [$uuid]: " else _prompt="Uid (Leave empty for default): " @@ -543,11 +507,11 @@ get_uid() { echo -n "$_prompt" read _input else - _input="`echo "$fileline" | cut -f2 -d:`" + _input="$(echo "$fileline" | cut -f2 -d:)" fi [ -n "$_input" ] && uuid=$_input - uuid=`get_nextuid $uuid` + uuid=$(get_nextuid "$uuid") uidstart=$uuid } @@ -555,15 +519,15 @@ get_uid() { # Reads login class of account. Can be used in interactive or batch mode. # get_class() { + local _input _uclass uclass="$defaultclass" - _input= _class=${uclass:-"default"} if [ -z "$fflag" ]; then echo -n "Login class [$_class]: " read _input else - _input="`echo "$fileline" | cut -f4 -d:`" + _input="$(echo "$fileline" | cut -f4 -d:)" fi [ -n "$_input" ] && uclass="$_input" @@ -577,14 +541,14 @@ get_class() { # will then provide a login group with the same name as the username. # get_logingroup() { + local _input ulogingroup="$defaultLgroup" - _input= if [ -z "$fflag" ]; then echo -n "Login group [${ulogingroup:-$username}]: " read _input else - _input="`echo "$fileline" | cut -f3 -d:`" + _input="$(echo "$fileline" | cut -f3 -d:)" fi # Pw(8) will use the username as login group if it's left empty @@ -596,8 +560,8 @@ get_logingroup() { # and batch modes. # get_groups() { + local _input _group ugroups="$defaultgroups" - _input= _group=${ulogingroup:-"${username}"} if [ -z "$configflag" ]; then @@ -616,8 +580,8 @@ get_groups() { # routine is used only from batch processing mode. # get_expire_dates() { - upwexpire="`echo "$fileline" | cut -f5 -d:`" - uexpire="`echo "$fileline" | cut -f6 -d:`" + upwexpire="$(echo "$fileline" | cut -f5 -d:)" + uexpire="$(echo "$fileline" | cut -f6 -d:)" } # get_password @@ -632,10 +596,10 @@ get_password() { # We may temporarily change a password type. Make sure it's changed # back to whatever it was before we process the next account. # - [ -n "$savedpwtype" ] && { + if [ -n "$savedpwtype" ]; then passwdtype=$savedpwtype savedpwtype= - } + fi # There may be a ':' in the password upass=${fileline#*:*:*:*:*:*:*:*:*:} @@ -662,7 +626,7 @@ get_password() { # Ask user if they want to enable encryption on their ZFS home dataset. # get_zfs_encryption() { - _input= + local _input _prompt _prompt="Enable ZFS encryption? (yes/no) [${Zencrypt}]: " while : ; do echo -n "$_prompt" @@ -738,7 +702,7 @@ set_zfs_perms() { # adds it to the user database. # input_from_file() { - _field= + local _field while read -r fileline ; do case "$fileline" in @@ -769,16 +733,14 @@ input_from_file() { # the user database. # input_interactive() { - _disable= - _pass= - _passconfirm= - _random="no" - _emptypass="no" - _usepass="yes" - _logingroup_ok="no" - _groups_ok="no" - _all_ok="yes" - _another_user="no" + 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" @@ -801,7 +763,7 @@ input_interactive() { until [ "$_logingroup_ok" = yes ]; do get_logingroup _logingroup_ok=yes - if [ -n "$ulogingroup" -a "$username" != "$ulogingroup" ]; then + if [ -n "$ulogingroup" ] && [ "$username" != "$ulogingroup" ]; then if ! ${PWCMD} show group $ulogingroup > /dev/null 2>&1; then echo "Group $ulogingroup does not exist!" _logingroup_ok=no @@ -865,8 +827,7 @@ input_interactive() { stty echo # if user entered a blank password # explicitly ask again. - [ -z "$upass" -a -z "$_passconfirm" ] \ - && continue + [ -z "$upass$_passconfirm" ] && continue ;; [Yy][Ee][Ss]|[Yy][Ee]|[Yy]) passwdtype="none" @@ -934,8 +895,10 @@ input_interactive() { [ -n "$configflag" ] && printf "%-11s : %s\n" "Pass Type" "$passwdtype" [ -z "$configflag" ] && printf "%-11s : %s\n" "Full Name" "$ugecos" [ -z "$configflag" ] && printf "%-11s : %s\n" "Uid" "$uuid" - [ "$Zcreate" = "yes" -a -z "$configflag" ] && printf "%-11s : %s\n" "ZFS dataset" "${zhome}" - [ "$Zencrypt" = "yes" -a -z "$configflag" ] && printf "%-11s : %s\n" "Encrypted" "${Zencrypt}" + [ "$Zcreate" = "yes" ] && [ -z "$configflag" ] && + printf "%-11s : %s\n" "ZFS dataset" "${zhome}" + [ "$Zencrypt" = "yes" ] && [ -z "$configflag" ] && + printf "%-11s : %s\n" "Encrypted" "${Zencrypt}" printf "%-11s : %s\n" "Class" "$uclass" printf "%-11s : %s %s\n" "Groups" "${ulogingroup:-$username}" "$ugroups" printf "%-11s : %s\n" "Home" "$uhome" @@ -966,7 +929,7 @@ input_interactive() { #### END SUBROUTINE DEFINITION #### -THISCMD=`/usr/bin/basename $0` +THISCMD=${0##*/} DEFAULTSHELL=/bin/sh ADDUSERCONF="${ADDUSERCONF:-/etc/adduser.conf}" PWCMD="${PWCMD:-/usr/sbin/pw}" @@ -999,7 +962,7 @@ udotdir=/usr/share/skel ugroups= uexpire= upwexpire= -shells="`valid_shells`" +shells="$(valid_shells)" passwdtype="yes" msgfile=/etc/adduser.msg msgflag= @@ -1028,7 +991,7 @@ Zencrypt="no" # measure as much as it is a useful method of reminding the user to # 'su -' before he/she wastes time entering data that won't be saved. # -procowner=${procowner:-`/usr/bin/id -u`} +procowner=${procowner:-$(/usr/bin/id -u)} if [ "$procowner" != "0" ]; then err 'you must be the super-user (uid 0) to use this utility.' exit 1 @@ -1046,12 +1009,8 @@ for _i in $* ; do break; fi done -if [ -n "$readconfig" ]; then - # On a long-lived system, the first time this script is run it - # will barf upon reading the configuration file for its perl predecessor. - if ( . ${ADDUSERCONF} > /dev/null 2>&1 ); then - [ -r ${ADDUSERCONF} ] && . ${ADDUSERCONF} > /dev/null 2>&1 - fi +if [ -n "$readconfig" ] && [ -r "${ADDUSERCONF}" ]; then + . "${ADDUSERCONF}" fi # Process command-line options @@ -1136,7 +1095,7 @@ for _switch ; do shift ;; -s) - defaultshell="`fullpath_from_shell $2`" + defaultshell="$(fullpath_from_shell $2)" shift; shift ;; -S) @@ -1181,7 +1140,7 @@ else fi case $_input in [Yy][Ee][Ss]|[Yy][Ee]|[Yy]) - uidstart=`get_nextuid $uidstart` + uidstart=$(get_nextuid $uidstart) input_interactive continue ;;