From nobody Thu May 23 12:53:31 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 4VlSlb5Kt0z5LgM5; Thu, 23 May 2024 12:53:31 +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 4VlSlb4V43z4B3k; Thu, 23 May 2024 12:53:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716468811; 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=3mKlZrdIo9oTTyWyCiS0um0fqJmxVdL2BmYxTKqYKDU=; b=xMBeERCm/X6F1DLWrjYi3ZTBqEVlxH25IBMiNWAPxCKhjDNIZ7sqW6s53rD+o5lOHKAaHz RFr6Fsv0py9Oip7iNTmQIS3HRWLNCFAEIkYlGVEt3r3Rr3/0/OvgR1hhiSFGK23Uhaz+Zt jzCpl9v+dDgAJ00wH/L6cuUu+hDBYKhVppQ7kPd1ApMmrT6eG8MYehsk+VK762Nq/wA4On HOxq4F1h/X8TVlv4x5VgynW9Cvl4oWCbugmX5jxZ6tcmJiVirVaUHE+Fe8aCQ6v5tnfsOB QYyug5VUJIGUcwQ9YVRuzsi+YVjoVeJGCIiUMjwLUurjnwf5dYEIHmJvp+7OwQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716468811; a=rsa-sha256; cv=none; b=dzV+D+GcXkqRngk1hWoNpAFTaEBkADy8jZyp5ET47k8i5km8TmutkQs2bZLY1Emx0XulMZ Kg7z0R5CcGJyhCgbqFND8n2jAIwH+NaCh/THeDAYueTLhJYn452GffUk1QQ7/5yICozntk DjBAdfLw8IwFfgfahVljOUr+b/MUVp9mmiG00j5YZgQJkUmvpOdbspDvvmIOFV5TPX1OIA vUPg+2/Y70+3h2bt9mJxsWYqz7TtrHi0mI/+Kegvb4MTSIkLEhMnJGydIbdSWZx70LUo8u 4Uqtj58sZ54e9frVUmUjVPOQkdjONDIWS+KCbgnuO8Yi1HPztHhSqLLqjDsyrQ== 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=1716468811; 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=3mKlZrdIo9oTTyWyCiS0um0fqJmxVdL2BmYxTKqYKDU=; b=s/udqqLnMuC4PCxBNcs/Wu+VAZ3RKy9tEFfzHanNTHN9IkRkR7lQdUNUs0kNc7BNM7grfP I2oTgX/uve3vcpbukdPJZQCbySNw3tnZTw7EMRMHQ3bUflLJCot29CnYPhNPtOGiylylSx nPkf/Pka4pbpbYI8vG4B9Pdf29wX9WQfM2cCOOiygqvmb5sdRl28bfZ5R++lvANYs/xfT5 xht20k9juLHFy/kExc66DMhJACpsO/HCl6LjKhePmJlMJVq+892kcvKfu8vqSM/ZWYAYIa X0nRuZG+F89Z2BzzJvHgp301KEmET1QXuaBa3A/z/eSZGukFjQbYnzhE/4GbpA== 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 4VlSlb45BBzr1G; Thu, 23 May 2024 12:53:31 +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 44NCrVTa090050; Thu, 23 May 2024 12:53:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44NCrVq2090047; Thu, 23 May 2024 12:53:31 GMT (envelope-from git) Date: Thu, 23 May 2024 12:53:31 GMT Message-Id: <202405231253.44NCrVq2090047@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mike Karels Subject: git: 83731cdde6c6 - stable/14 - adduser: create dataset only if home is directly within dataset 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: karels X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 83731cdde6c672b16338de4c6a0c4939c02c0928 Auto-Submitted: auto-generated The branch stable/14 has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=83731cdde6c672b16338de4c6a0c4939c02c0928 commit 83731cdde6c672b16338de4c6a0c4939c02c0928 Author: Mike Karels AuthorDate: 2024-05-20 13:43:34 +0000 Commit: Mike Karels CommitDate: 2024-05-23 12:52:37 +0000 adduser: create dataset only if home is directly within dataset Currently, if the prefix of the new home directory is a subdirectory of a ZFS dataset, adduser will create a new dataset up one or more levels from the intended destination. "pw useradd" will then create a normal directory in the desired location, leaving an unused dataset. Check for this situation when determining whether to create a dataset, and let pw create the directory. Reviewed by: des Differential Revision: https://reviews.freebsd.org/D45229 (cherry picked from commit 0b39b2e2ddb2df1d1325e042893ddcb1a1c12b8e) --- usr.sbin/adduser/adduser.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/usr.sbin/adduser/adduser.sh b/usr.sbin/adduser/adduser.sh index 7c3fdb418179..ecac7478befd 100644 --- a/usr.sbin/adduser/adduser.sh +++ b/usr.sbin/adduser/adduser.sh @@ -474,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 @@ -487,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}" }