git: 9d8a178b38ed - stable/13 - pw: tests: add a test for -M with a pre-existing home directory
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Dec 2024 23:38:10 UTC
The branch stable/13 has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=9d8a178b38ed0953f2beaa49c0dd3981cce56179
commit 9d8a178b38ed0953f2beaa49c0dd3981cce56179
Author: Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2024-12-01 19:05:58 +0000
Commit: Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-12-10 23:06:16 +0000
pw: tests: add a test for -M with a pre-existing home directory
Previous versions of pw(8) wouldn't chmod the home directory if it
already existed prior to user creation, rendering adduser(8) -M
ineffective in some cases. Add a test to cover that situation.
PR: 280099
Reviewed by: kevans
(cherry picked from commit f7cf62cf728a942e494a5b58438600998606617a)
---
usr.sbin/pw/tests/pw_useradd_test.sh | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/usr.sbin/pw/tests/pw_useradd_test.sh b/usr.sbin/pw/tests/pw_useradd_test.sh
index 93a192c59409..0da1877c3283 100755
--- a/usr.sbin/pw/tests/pw_useradd_test.sh
+++ b/usr.sbin/pw/tests/pw_useradd_test.sh
@@ -321,6 +321,21 @@ user_add_dir_body() {
stat -f '%p' ${HOME}/home/foo
}
+atf_test_case user_add_existing_dir
+user_add_existing_dir_body() {
+ populate_root_etc_skel
+
+ mkdir -p -m 0777 ${HOME}/home/foo
+ atf_check -o inline:"40777\n" \
+ stat -f '%p' ${HOME}/home/foo
+
+ 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 inline:"40705\n" \
+ stat -f '%p' ${HOME}/home/foo
+}
+
atf_test_case user_add_skel
user_add_skel_body() {
populate_root_etc_skel
@@ -496,6 +511,7 @@ atf_init_test_cases() {
atf_add_test_case user_add_R
atf_add_test_case user_add_R_symlink
atf_add_test_case user_add_dir
+ atf_add_test_case user_add_existing_dir
atf_add_test_case user_add_skel
atf_add_test_case user_add_uid0
atf_add_test_case user_add_uid_too_large