From nobody Mon May 20 13:44:28 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 4Vjf1m40t0z5LJHS; Mon, 20 May 2024 13:44:28 +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 4Vjf1m2LxPz4QFL; Mon, 20 May 2024 13:44:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716212668; 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=O92m/83AwjQxcMCZRUeYXKll791XU4gHHtX3UphlaG8=; b=WTG+/+bqnguHHAEdpa9wMzWq8UI6LyvUX2NfMIDTuvaAplRoPK1AR4QAafBm/Qf4cNtKVj 3fWV+Gsi4c1it+H1XPTCl9jn0d0d5QCE0JJC2n/LILjgKpLaLT5YuvLmaz2D3K+cn2OyRE t/LVB82JMbVaRb1FWKUZ/StfHYXA8kvcguntbWNoUUVlg9LS7t5Ksjz42xXd3/mgtgQblI A+Mi+GBZq+0ztxyj2haqcoQqRJZTaAJzBJzoEtt0k8IG66cWC48G+67suTLZ23ngXSBq4a OcQaqLaQ7nGvdNBRhvlA8KJCJnMKPn73JuAIqqwRIMSkbEHPrB3uVfE/z4426w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716212668; a=rsa-sha256; cv=none; b=M6ZjsCPu94Ox0K7zpaS/CWujRFYLlm/auZq/rymb6u4eQ518r/51K76Av5ywnPuwSgQDAk ttf3vr3QsAgu6KKDt3W++cHSae7Rr+7lXpSNfc4Q8umc6dsaA3gNe2QlYUAjmVk1QZWrfX vfPIMJLMvpjmEjVG4z8PrTKq9f2HTSDxbldvNBSTU8h0kNFUCnHeuA02dQZUnqPkD7X4AJ 7dIi44wRSGRtDHsx73LF1qYToftD1ucvnixhTJXbAPu1hEhWt7wLa6HGiDPGY18cBtL2ph 7Rf2TVLTnih4wRa+tOs+KJ1l3aQrdMt5LWVowwrIp66cNrCrxdP5IstjGsgZAw== 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=1716212668; 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=O92m/83AwjQxcMCZRUeYXKll791XU4gHHtX3UphlaG8=; b=ZaBm5y+Wi5wclg7imHusuMrXrZKg/GEqDYitIiLIjkYaI8Ld/ZI0WmFZgKuHCAZWnsBLyq hQ1bB3gzWuQANYref0dlT24u+fwnwxz07E+HI3ot1XmXjzXBXsWxDNBcqIQ6Rg/7uVy020 HHxfM5d6jVuYMczX1xBrBuN6XZ/RoHqFFMrK/XgXYI8fIQEKWLCmL08GLkdvJekX2tffyu HLVQ8+V/PKGyZAWaPeGztFD1wRrkGQRlT5O7HIRuBMvRayR0vUCZu0UXRSOKyaWWBWQoCE peeqkM6+Oz5TWPyQwNhUhQVOOXDWUbzxduapptV94/f837h0ziKSjpy0qXqIDQ== 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 4Vjf1m1fM0zh6J; Mon, 20 May 2024 13:44:28 +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 44KDiSLj062462; Mon, 20 May 2024 13:44:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44KDiSrg062458; Mon, 20 May 2024 13:44:28 GMT (envelope-from git) Date: Mon, 20 May 2024 13:44:28 GMT Message-Id: <202405201344.44KDiSrg062458@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mike Karels Subject: git: 0b39b2e2ddb2 - main - adduser: create dataset only if home is directly within dataset 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: karels X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0b39b2e2ddb2df1d1325e042893ddcb1a1c12b8e Auto-Submitted: auto-generated The branch main has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=0b39b2e2ddb2df1d1325e042893ddcb1a1c12b8e commit 0b39b2e2ddb2df1d1325e042893ddcb1a1c12b8e Author: Mike Karels AuthorDate: 2024-05-20 13:43:34 +0000 Commit: Mike Karels CommitDate: 2024-05-20 13:43:34 +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 MFC after: 3 days --- 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}" }