From nobody Wed May 15 16:00:03 2024 X-Original-To: dev-commits-src-branches@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 4VfdGW6Z84z5L5W1; Wed, 15 May 2024 16:00:03 +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 4VfdGW4P10z4SQv; Wed, 15 May 2024 16:00:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715788803; 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=62Zhn8bZHdo1TU9K0Cjmn7wEI9eyFP5EmkW1sa1VnAs=; b=M28BpiuNPym0o7CFBqQ3IVDCZtnGW6/HUS/OVkhWihevOeyx8Q0GFRfRNIgGNLPr7D84tw MqFjTFNwha9fLMigtere6korOUJhLirt1/U0b8W/YGgRPlwCFFfXlYc8tN0hW6NRr1iVdI uU/fhZhgTWb+5n8KrbkGG1Z8kaR1WHFChpXSIkoHsrYDH6cT7u8bar1IkImduNmVIlUtSM BAYcz4q5jAtf6hEYnpp9WzF4NOIdbsRXn5FCFGvv4rLDGkrAH2ADYKoaQd7v1NztV2YD6u titDNX3PL2RAbHJGSkiSKoHWV/ehEcSqdJIJCXDkfqibgpAK6almLagDity7wg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715788803; a=rsa-sha256; cv=none; b=nYZW7OnhBqHDIlE1dWkM6k9yfWGXtzNpi4lBI0+qWMSIC+RBX5Vd7NlD7ABK/lQtZFApIU FkQhXfq866E2da8Wxv3zXevVLWX/iaUfPUf18CMRy4rHwWo8Z9NIPna5Wye2qE7wYHRAni gcTLjbDlY62+voikdhuyIE1vf3b+WklF7Cmw9gehqjDRPKlF5A4hPyIcugs6lQe6j6OKM7 Yd3aUOwyhWYuem39usKID1e6QLFLsMUwcZ0m2xIkUaRL4tZ9hzjpVJvWdgavShlMsVRmGU C8MF73SrVpcCUrwpnsbrRx1e0KDBdX6m7Wo82U+YgrwScd0OHd4OCicmWuOLCQ== 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=1715788803; 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=62Zhn8bZHdo1TU9K0Cjmn7wEI9eyFP5EmkW1sa1VnAs=; b=rSri6cZL/fJQIhBjo2GzHFanrD0GpH1tkt/DdisXzobU1o0VhUC/7rA0XHUK81nagEUb+m l2g4vxB46bAbblYAkMb8V6mYDpf/0YYGsEtsJaLx9gHTMQ3WxCm1tihAuvPXcNe4fwYL54 cQal1Nxt0zCJku7UNvWlA3lesPRVnz9sRqXnFq5dgTRuhP7iWRlcRN7pyX8AU2SMgspX60 HBcSUaVMx8o6d6vA1MvqGCC7JoyXd2m+bhz9nR1RxvXLndAsy/zeIG8XIYTv6bopPS//fS P3V5OPYOBvGuh4BGoiAUFTB7NQZ9NAGJOnxW/xXhi+83Xr9mtxgFTrcpfX2h0g== 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 4VfdGW419kzLZc; Wed, 15 May 2024 16:00:03 +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 44FG03hV056337; Wed, 15 May 2024 16:00:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44FG03AF056330; Wed, 15 May 2024 16:00:03 GMT (envelope-from git) Date: Wed, 15 May 2024 16:00:03 GMT Message-Id: <202405151600.44FG03AF056330@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: db5aefb1cae1 - stable/14 - adduser: Additional variable fixes. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: db5aefb1cae14e31263ddb146f5952ca64bf6865 Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=db5aefb1cae14e31263ddb146f5952ca64bf6865 commit db5aefb1cae14e31263ddb146f5952ca64bf6865 Author: Dag-Erling Smørgrav AuthorDate: 2024-05-15 12:13:49 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-05-15 15:59:30 +0000 adduser: Additional variable fixes. One function used `_input` without making it local, causing its value to leak into other functions. This broke the `-f` case. Fix that instance and initialize all local variables that weren't already initialized. Fixes: 170d0882903e MFC after: 3 days Reviewed by: karels Differential Revision: https://reviews.freebsd.org/D45204 (cherry picked from commit 46a619c6d4cfc662069950baca16ec2a3b18b8a5) --- usr.sbin/adduser/adduser.sh | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh index 61a4b3b5058f..7c3fdb418179 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 _pwcmd + 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= # 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 @@ -494,7 +495,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 +520,7 @@ get_uid() { # Reads login class of account. Can be used in interactive or batch mode. # get_class() { - local _input _class + local _input= _class= uclass="$defaultclass" _class=${uclass:-"default"} @@ -541,7 +542,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 +561,7 @@ get_logingroup() { # and batch modes. # get_groups() { - local _input _group + local _input= _group= ugroups="$defaultgroups" _group=${ulogingroup:-"${username}"} @@ -626,7 +627,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 +703,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,7 +734,7 @@ 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"