git: e12b7446bddc - main - pw: Test home directory ownership and mode.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Mon, 06 May 2024 16:19:23 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=e12b7446bddcb91b869abef6048910cc15185a33

commit e12b7446bddcb91b869abef6048910cc15185a33
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-05-06 16:18:50 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-05-06 16:18:50 +0000

    pw: Test home directory ownership and mode.
    
    MFC after:      3 days
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D45099
---
 usr.sbin/pw/tests/pw_useradd_test.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/usr.sbin/pw/tests/pw_useradd_test.sh b/usr.sbin/pw/tests/pw_useradd_test.sh
index 3b495482eb05..b4efa42bada7 100755
--- a/usr.sbin/pw/tests/pw_useradd_test.sh
+++ b/usr.sbin/pw/tests/pw_useradd_test.sh
@@ -313,6 +313,22 @@ user_add_R_intermed_body() {
 	test -d ${HOME}/a/b/c/foo || atf_fail "user directory not created"
 }
 
+atf_test_case user_add_dir
+user_add_dir_body() {
+	populate_root_etc_skel
+
+	atf_check -s exit:0 ${RPW} useradd foo -M 0705 -m
+	atf_check grep -q '^foo:' $HOME/etc/master.passwd
+	atf_check test -d ${HOME}/home/foo
+	atf_check -o save:ugid \
+	      awk -F: '$1 == "foo" { print $3, $4 }' \
+	      $HOME/etc/master.passwd
+	atf_check -o file:ugid \
+	    stat -f '%u %g' ${HOME}/home/foo
+	atf_check -o inline:"40705\n" \
+	    stat -f '%p' ${HOME}/home/foo
+}
+
 atf_test_case user_add_skel
 user_add_skel_body() {
 	populate_root_etc_skel
@@ -511,6 +527,7 @@ atf_init_test_cases() {
 	atf_add_test_case user_add_R
 	atf_add_test_case user_add_R_no_symlink
 	atf_add_test_case user_add_R_intermed
+	atf_add_test_case user_add_dir
 	atf_add_test_case user_add_skel
 	atf_add_test_case user_add_uid0
 	atf_add_test_case user_add_uid_too_large