From nobody Wed Aug 21 17:15:01 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 4WptHn3tCdz5VC6X; Wed, 21 Aug 2024 17:15:01 +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 4WptHn3MrXz4fwr; Wed, 21 Aug 2024 17:15:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724260501; 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=F5MrbDYB/O4FVIAHn/dnHXO5Hp4xrj5O/oiLCUdgYo0=; b=J13gVJaAyh8qs628S3C4OPKWPOrV8+E8viw5prm0CpY2Ns2tHnvP7OYPyWOHRZjkJ8e5dj IE+PVgS43r7x5Y2dZVMn3/YHHWxacViiWo3JSQ1audoUUxJM8DSvWhoPSDyIGmOKocVeGS fny+tAnHyaub67vPwkF2xZbiuJsIqBRUiKTocHdfP6RxPEGtqXx9c+7+633Te6ySQL2PKL OiQdwhWua6XJP31zrgEVvv4QEyubQNapt9DM0id7X7yL779vEr6nZunRkpQ85MzGWNMpkC 4bj65/a0Gahl7bD80W9fRhL9SKLM0/0vyH1Dw3VTPbXD6n9Wcaurfe1gXc3x4g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724260501; a=rsa-sha256; cv=none; b=TscVFPUT8pidGoO8tFZUjCyX4NwhtLogIUcu6pr8wpAXkCuq7M8H6lwImMiNNZaJVv4KjV cpMABKq8NDbMiuzZoImGOQUc3ni5TNFJ4bQm+iRGQ9eAHc1E6bggHzkMWBK9VaJzDkVAbJ 0Ftk5vJHfKKtFhlIvLKNnzsZwQMkXyZg1ojxwjIPxrBJZGujum85vyWl1ZoY0iOGv70Rg4 mOJFptZQWD8D5QNhvDiJBQJeukszrHvXOw8Lk+SqbOJxc2WzmMps0RjfIlM2ajofn4bQGo OaIUwgiWuXKih73/9AtKJl0GKZt1NtQ8ugf4PBk1r7C0YO4mq40TFh36fsKqWA== 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=1724260501; 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=F5MrbDYB/O4FVIAHn/dnHXO5Hp4xrj5O/oiLCUdgYo0=; b=oUTN76iCi2kWeRLIGmpl1rzGnH8gLJOIoPrWdvuE7umOXsJk6NdVS3ldbttQCxXhda9Jff azPhhQfxlGDNxYl9DWuv4aVSPmr0gLx7rHMOVZfaSnO9qwgvBjoUC0pXiIw313BWEBjMuF 7IK06fI2Ir7IgbKfKuprx6om6RaRYLQA1dfwQJlT0jvAPC9O8hKmnf5uHLFaenXMJGu52Q YHJ01JLPw/k4xAOI4SQoShUg4SYigMYC57zhHG8fFeOUtSDYPonHPsLcCnkDMIii8nPawl sOiN2cHOLXq4MDah6km1qbHoAUkkAkwMKv9ZzQDgj3mEMTg9SaMOqiZmL7QxLA== 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 4WptHn2z4dzsCF; Wed, 21 Aug 2024 17:15:01 +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 47LHF1e4057764; Wed, 21 Aug 2024 17:15:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47LHF1fO057761; Wed, 21 Aug 2024 17:15:01 GMT (envelope-from git) Date: Wed, 21 Aug 2024 17:15:01 GMT Message-Id: <202408211715.47LHF1fO057761@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: 0ebe6df086f3 - releng/13.4 - 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: des X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.4 X-Git-Reftype: branch X-Git-Commit: 0ebe6df086f3bac96945415965a8e0ea1431259a Auto-Submitted: auto-generated The branch releng/13.4 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=0ebe6df086f3bac96945415965a8e0ea1431259a commit 0ebe6df086f3bac96945415965a8e0ea1431259a Author: Mike Karels AuthorDate: 2024-05-20 13:43:34 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-08-21 17:13:22 +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 Approved by: re (cperciva) (cherry picked from commit 0b39b2e2ddb2df1d1325e042893ddcb1a1c12b8e) (cherry picked from commit da384ffbd5adebd7079b4dadd2592e82232566e0) --- 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}" }