From nobody Tue May 23 12:24:14 2023 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 4QQYQl1hqcz4CQM9; Tue, 23 May 2023 12:24:15 +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 4QQYQl15hvz3l5M; Tue, 23 May 2023 12:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684844655; 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=pBta01M/PTrKf+MbxCgnY+WWDRmxVQsJn06y9sVFw7Q=; b=EbxjGZ1neSDo1ydad7xjIkq4qCFN5i1wig9AYtq6PAJcYQHSnxSerXNocxi7NPy0qiuUp7 /4yIoMuSUeG8K0IcISu9fMqiRjqSpsjZxgits4+d+csMrJiDWNYm+8d8c5Nz2hXyVKDKt8 4Qyadoha6rMI1eUNeBZAYvXFc1/q+lIkkOe6KUig+qr2hIkbpX1k+uo+tYX+p35VATjdU3 TOXKQklDJxPmXYOw8EIS3QWHk/CEDlzPNmEdPGhvXpJ4qNbgzuN9j2upse07ybyDKJUtNA nNbiwEel3xsW8mxccKd8c1H+FXTihHgRSor/AsubqWXVKmbzEx5qqF9/x80CoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684844655; 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=pBta01M/PTrKf+MbxCgnY+WWDRmxVQsJn06y9sVFw7Q=; b=BNjOxq8FPhUNxKpockIMpmtq+Q478w4ZE3YLehpz9GF8Y3fdBw6NqWBEAnr0khR9ghaCOI QGTrmKbR5sHe4CXyKKdrpYyvqNi24BekCK3xJNL01Fhyqipt7rZHcqFnQObXsv/nHLKHTd 63SpTJTCeNAqo/l9whJmFk/z/wDsLGZA77CxAeZuyQJjHPf0nINTuKgRNUVmF7KHyGBdCP zwxMK1miqBQ1iRrliFz0p8eN4X7uhMVziL00DAeSp3oxCPFF8T2Gv+UHKsH3mmPKP7kazN uw8htEHMFh2uI8RLvET/pHnhAtqrjY40/3ReNxR8LVGA5ffNcXQ3B0vKnIydLQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684844655; a=rsa-sha256; cv=none; b=Hk1DNylxglAOsy+G0uwztaIemA9a0TyYzzvPImhkmNE1wsTDCH3vmpYKiisfmN0HUbchLK a/SdLqaNBt0gw5+g/ugIwIKPe1txnM6Ry+c1+kMRWcHcTOlLoqaj1cgMojE3AQp9eYikDf q3bHWj1hUcn98XQ2XSVseZncDIA6rUAEbyYmbUCxS7qgevRTwcpz10pyZurzXBEydeZPkE /zG7/xSmGSJD79T9yJXP8sK+yBgdHon1EF91BQZ9vUbGqZRzWHJj0s6426m6URacvGmuHr EF5O/QAg88tOfEuo0q8/3LIrH/NWr5FWemmHLXtJhMUiafUN/rzZ+nMbuRKnmQ== 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 4QQYQl07QTz10T4; Tue, 23 May 2023 12:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34NCOESC017535; Tue, 23 May 2023 12:24:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34NCOEkA017534; Tue, 23 May 2023 12:24:14 GMT (envelope-from git) Date: Tue, 23 May 2023 12:24:14 GMT Message-Id: <202305231224.34NCOEkA017534@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: bbb2d2ce4220 - main - pw: do not move /home/$user to /usr/home 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: bbb2d2ce422070869bd93a0771251e654c07b13d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=bbb2d2ce422070869bd93a0771251e654c07b13d commit bbb2d2ce422070869bd93a0771251e654c07b13d Author: Mike Karels AuthorDate: 2023-05-23 12:17:42 +0000 Commit: Mike Karels CommitDate: 2023-05-23 12:17:42 +0000 pw: do not move /home/$user to /usr/home When adding a user, pw will create the path to the home directory if needed. However, if creating a path with just one component, i.e. that appears to be in the root directory, pw would create the directory in /usr, and create a symlink from the root directory. Most commonly, this meant that the default of /home/$user would turn into /usr/home/$user. This was added in a self-described kludge 26 years ago. It made (some) sense when root was generally a small partition, with most of the space in /usr. However, the default is now one large partition. /home really doesn't belong under /usr, and anyone who wants to use /usr/home can specify it explicitly. Remove the kludge to move /home under /usr and create the symlink, and just use the specified path. Note that this operation was done only on the first invocation for a path, and this happened most commonly when adding a user during the install. Modify the test that checked for the creation of the symlink to verify that the symlink is *not* made, but rather a directory. Add a test that intermediate directories are still created. Reviewed by: rgrimes, bapt Differential Revision: https://reviews.freebsd.org/D40085 --- usr.sbin/pw/pw_user.c | 20 ++------------------ usr.sbin/pw/tests/pw_useradd_test.sh | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c index c8e8de1fc46a..bea248c802ed 100644 --- a/usr.sbin/pw/pw_user.c +++ b/usr.sbin/pw/pw_user.c @@ -114,36 +114,20 @@ mkdir_home_parents(int dfd, const char *dir) } tmp[0] = '\0'; - /* - * This is a kludge especially for Joerg :) - * If the home directory would be created in the root partition, then - * we really create it under /usr which is likely to have more space. - * But we create a symlink from cnf->home -> "/usr" -> cnf->home - */ - if (strchr(dirs, '/') == NULL) { - asprintf(&tmp, "usr/%s", dirs); - if (tmp == NULL) - errx(EX_UNAVAILABLE, "out of memory"); - if (mkdirat(dfd, tmp, _DEF_DIRMODE) != -1 || errno == EEXIST) { - fchownat(dfd, tmp, 0, 0, 0); - symlinkat(tmp, dfd, dirs); - } - free(tmp); - } tmp = dirs; if (fstatat(dfd, dirs, &st, 0) == -1) { while ((tmp = strchr(tmp + 1, '/')) != NULL) { *tmp = '\0'; if (fstatat(dfd, dirs, &st, 0) == -1) { if (mkdirat(dfd, dirs, _DEF_DIRMODE) == -1) - err(EX_OSFILE, "'%s' (root home parent) is not a directory", dirs); + err(EX_OSFILE, "'%s' (home parent) is not a directory", dirs); } *tmp = '/'; } } if (fstatat(dfd, dirs, &st, 0) == -1) { if (mkdirat(dfd, dirs, _DEF_DIRMODE) == -1) - err(EX_OSFILE, "'%s' (root home parent) is not a directory", dirs); + err(EX_OSFILE, "'%s' (home parent) is not a directory", dirs); fchownat(dfd, dirs, 0, 0, 0); } diff --git a/usr.sbin/pw/tests/pw_useradd_test.sh b/usr.sbin/pw/tests/pw_useradd_test.sh index a50f018ab99d..e9d0a3aa20af 100755 --- a/usr.sbin/pw/tests/pw_useradd_test.sh +++ b/usr.sbin/pw/tests/pw_useradd_test.sh @@ -295,15 +295,23 @@ user_add_R_body() { [ ! -d ${HOME}/home/bar ] || atf_fail "Directory not removed" } -atf_test_case user_add_R_symlink -user_add_R_symlink_body() { +atf_test_case user_add_R_no_symlink +user_add_R_no_symlink_body() { populate_root_etc_skel mkdir ${HOME}/usr atf_check -s exit:0 ${RPW} useradd foo -m - test -d ${HOME}/usr/home || atf_fail "Home parent directory not created" - test -h ${HOME}/home || atf_fail "/home directory is not a symlink" - atf_check -s exit:0 -o inline:"usr/home\n" readlink ${HOME}/home + [ ! -d ${HOME}/usr/home ] || atf_fail "/usr/home created" + test -d ${HOME}/home || atf_fail "/home directory not created" +} + +atf_test_case user_add_R_intermed +user_add_R_intermed_body() { + populate_root_etc_skel + + atf_check -s exit:0 ${RPW} useradd foo -m -d /a/b/c/foo + test -d ${HOME}/a/b/c || atf_fail "intermediate directories not created" + test -d ${HOME}/a/b/c/foo || atf_fail "user directory not created" } atf_test_case user_add_skel @@ -479,7 +487,8 @@ atf_init_test_cases() { atf_add_test_case user_add_invalid_group_entry atf_add_test_case user_add_password_from_h atf_add_test_case user_add_R - atf_add_test_case user_add_R_symlink + atf_add_test_case user_add_R_no_symlink + atf_add_test_case user_add_R_intermed atf_add_test_case user_add_skel atf_add_test_case user_add_uid0 atf_add_test_case user_add_uid_too_large