Date: Sat, 20 Apr 2024 19:35:53 GMT From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= <des@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: b37333899bd2 - main - adduser: A few more improvements. Message-ID: <202404201935.43KJZrmj038803@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b37333899bd27a74bdef34b7f34eb41bc6bd51bd commit b37333899bd27a74bdef34b7f34eb41bc6bd51bd Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2024-04-20 19:35:25 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404201935.43KJZrmj038803>