From nobody Sat Apr 20 19:35:53 2024 X-Original-To: dev-commits-src-main@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 4VMMF54WHyz5JLSB; Sat, 20 Apr 2024 19:35:53 +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 4VMMF52cY1z4NvJ; Sat, 20 Apr 2024 19:35:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713641753; 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=hHlJ85zwP262V+Q08Gc+LnioRuh5m7PPqHTWUw7TLFE=; b=f0ahbLbTzGezDrscli/u1VeqOyh2rsLEOC+P4l2fLX0hrRVHrwSCMhunIiHQC5hwZotty2 dQXn6fj13TKXMH3v3IkTh1tp0vrLRAu5KsgcYhIjgkBAHAk2a/UpEQucFJf4xuuBzo5OUV yKv2vPR/PhmVCQ8r1DmtVioYIuB1IqepcuXiea3uXwm9t1s8SR3EknK4YI/EE81T9KOVZN pwhWSs5u0rug+EgjVx4BFM/gJIUeV6O1QFvAgws+cuQM0gs4gnSYhfabPZbvmAYpndVjaq CbVzUoxOT7Jyq9H5wtUKW5v3Z4Z8BGsH2rWZtqlyAVwHKWF4Ik8aOy32OwiSWw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713641753; a=rsa-sha256; cv=none; b=l5tlqfsMpuMwlaBs2DqtPZVy/lwVQ8cMUMOi/rDPkAKoFYSKnuUCNewEffYQmRaoI/SCKR JB3fKXKriYsMLKyrRxDjthmhJF4cwJCD54G247JL3ozfQy2H6jxflV5hcHA7RdTQcaQ9KU mKnKvviLS6e9BbDXgnYdgIIWF5D2+aCJrgPbU/ZqDNKF+B/XuH7eeuptMxDshsM7HsYKTK YpUqLzurUUdUASDNcOkmbMyXhKwAyNOsnm4pKeJkISs1y7runxpqJYOrlAtm4YVutN1Pho /pCj0v5ntEz2PKmjikarIwtTSjA7ZlwQcRR2Cu2lbCMYP6PUtLDSz6OvQoVLuA== 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=1713641753; 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=hHlJ85zwP262V+Q08Gc+LnioRuh5m7PPqHTWUw7TLFE=; b=D82zo9tsJ+MdoIENrIFlgA8upEHxObz3chndY1rrwrILumtas43Jqw5uI3BKjwtfwZN0GY ivmKoitInygn3q0XhAVsjMMukZ62RYkcNrOd2eCozFkyveyQ0/9EV/Zah6DxWMEprnmQyp U7vuHgdB39HHyT1XnTfAoIsCzBCvlEPiXGPsspWX2AeIq6etHaXnLpv3r0HVbJPBt6HPUu ELOANE7N2O/zT67/0vXZamzs90t92hj67EWydkiQgUA7f0OSILzjmtTmFucarJo0Bws2Yw N69yvmRvd+jlYj10bjPu7OQok1FQN8i5ICLVIaeFeDm0e00Th/RMHMbQ0/H0Pg== 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 4VMMF52CyVzqGv; Sat, 20 Apr 2024 19:35:53 +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 43KJZrAS038806; Sat, 20 Apr 2024 19:35:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43KJZrmj038803; Sat, 20 Apr 2024 19:35:53 GMT (envelope-from git) Date: Sat, 20 Apr 2024 19:35:53 GMT Message-Id: <202404201935.43KJZrmj038803@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: b37333899bd2 - main - adduser: A few more improvements. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: b37333899bd27a74bdef34b7f34eb41bc6bd51bd Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b37333899bd27a74bdef34b7f34eb41bc6bd51bd commit b37333899bd27a74bdef34b7f34eb41bc6bd51bd Author: Dag-Erling Smørgrav AuthorDate: 2024-04-20 19:35:25 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-04-20 19:35:32 +0000 adduser: A few more improvements. MFC after: 1 week Reviewed by: jrm Differential Revision: https://reviews.freebsd.org/D44871 --- usr.sbin/adduser/adduser.sh | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh index 692b54bebf78..d1c9e12098f7 100644 --- a/usr.sbin/adduser/adduser.sh +++ b/usr.sbin/adduser/adduser.sh @@ -59,12 +59,11 @@ get_nextuid () { _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 @@ -262,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 @@ -354,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 @@ -476,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 + if ! "$KLDSTATCMD" -q -m zfs || 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