From nobody Wed Aug 21 10:29:42 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 4WpjJ65P6Gz5TdQD; Wed, 21 Aug 2024 10:29:42 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WpjJ64shLz4lxq; Wed, 21 Aug 2024 10:29:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724236182; 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=TGgjWaNaqbACxSS6r5PtXfNOaupI6fLb35HgwDD6d8E=; b=M+wIsnxTITrw0+X4t/aazwPBmAcKmHClushZ/jK9pQdw+YoEbPOmpjIdpSOdcZVY8oSWAy 47A+QTtq5jUny1Ls7nUL/fuzp41Pyqjr/Lk6fIVO/XA/c74KceiQrpJX2VfR4EzBXKeWEm TDNNBLcCiXLUzMVY8YKCN7HoO7ncEgDc/Pm66el2gaizAPWboepqwb+Bb/f/9pDqLseIKW IjXAUS+RrczNSZhU2VZKHk/BhFzDS2yucGRTxuUvvogBfUi1qpGdvjt6uRVG7xKXglP9G+ Zap7ChVaW+O9uqvi+jLvzHorEIQEydMJwDyKcQ4Nuss7Xh3VPKG3cya+0t4MVw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724236182; a=rsa-sha256; cv=none; b=HwEGV4uu9tI4F4Pewil6GHv5G3zemWXxXUhYf698Wy8q9L69rr5KzaKUsi0NhUDSguw6aN mL+jpVJabODcqaDgo8g8NNlNEeJuFYX2LOe7BkfEODvSv8ybl6/aBuhqhUv2+Byj9kCWQl BD17JOJ3j5R6EKe7i0q/UKQ61uBnNrZ7COGm4bXG92qe4D/ecY+06qqJIYOstoNW2NPRqq qeBsqpidAGenhr+ta2fqjRbZqXHP1RNl7rWFieSDdPaFsOmNQhZ+510jyd8CUD2hchBJsI HXruirNp5S/gJK2IGkMLeSiAus/9oMH5YYI7of5t/cll7Ky2xqwisuNDIhijBg== 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=1724236182; 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=TGgjWaNaqbACxSS6r5PtXfNOaupI6fLb35HgwDD6d8E=; b=qg5/eepgIpzFEG4T3wZwyiVqjnkAUNjr02jcm3uttQJHTgJcZUJX0JK20SMAt7q9RZ4fNn 0NIWveZW+p5OdoY7rDnWosLNdDs0suK9gBjhViCq229b+X1tgn/k1PlPxwOzaDdxuhPqyB Eo311o885L0wP74NRVaq2MGvL7Zc+INMfiNocgwWHAllBew4jFL+q/M4sOiq642XKMw6I2 6bie+VQ1FXk/5AZaudGDAqQx8l3d7Ql1FvAm/CuMXR8kgXRspSOzNq81jh1f4XM1jLQj+p Ul2NgeH5yG+rQXvjkwWfephUMjpAZIkPG2XsreHydr4zkTjQlOW53oIad+6xeA== 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 4WpjJ64Nvszg6d; Wed, 21 Aug 2024 10:29:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47LATgF8061899; Wed, 21 Aug 2024 10:29:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47LATgw1061896; Wed, 21 Aug 2024 10:29:42 GMT (envelope-from git) Date: Wed, 21 Aug 2024 10:29:42 GMT Message-Id: <202408211029.47LATgw1061896@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: da384ffbd5ad - stable/13 - adduser: create dataset only if home is directly within dataset 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/13 X-Git-Reftype: branch X-Git-Commit: da384ffbd5adebd7079b4dadd2592e82232566e0 Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=da384ffbd5adebd7079b4dadd2592e82232566e0 commit da384ffbd5adebd7079b4dadd2592e82232566e0 Author: Mike Karels AuthorDate: 2024-05-20 13:43:34 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-08-21 10:29:26 +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 (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}" }