aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-11-08 12:04:33 +0000
committerMark Johnston <markj@FreeBSD.org>2023-11-09 14:41:10 +0000
commit5a36abc2034805cec066cf0ac54ec4d25e4a22c4 (patch)
treea40518f205b4757ac6b6641d16794110904c52b3
parenta8043cc0d49bec7bebc4afc43b8bf5f6ab730b23 (diff)
downloadsrc-5a36abc2034805cec066cf0ac54ec4d25e4a22c4.tar.gz
src-5a36abc2034805cec066cf0ac54ec4d25e4a22c4.zip
makefs/zfs: Add a regression test which checks file access permissions
MFC after: 3 days Sponsored by: The FreeBSD Foundation (cherry picked from commit 7e5002e3d6038b69e23f6c1982caf20cd62139f7)
-rw-r--r--usr.sbin/makefs/tests/makefs_zfs_tests.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/usr.sbin/makefs/tests/makefs_zfs_tests.sh b/usr.sbin/makefs/tests/makefs_zfs_tests.sh
index 1811b1bc8a8c..6e20ae33b354 100644
--- a/usr.sbin/makefs/tests/makefs_zfs_tests.sh
+++ b/usr.sbin/makefs/tests/makefs_zfs_tests.sh
@@ -794,6 +794,49 @@ used_space_props_cleanup()
common_cleanup
}
+# Verify that file permissions are set properly. Make sure that non-executable
+# files can't be executed.
+atf_test_case perms cleanup
+perms_body()
+{
+ local mode
+
+ create_test_dirs
+ cd $TEST_INPUTS_DIR
+
+ for mode in $(seq 0 511); do
+ mode=$(printf "%04o\n" $mode)
+ echo 'echo a' > $mode
+ atf_check chmod $mode $mode
+ done
+
+ cd -
+
+ atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \
+ $TEST_IMAGE $TEST_INPUTS_DIR
+
+ import_image
+
+ check_image_contents
+
+ for mode in $(seq 0 511); do
+ mode=$(printf "%04o\n" $mode)
+ if [ $(($mode & 0111)) -eq 0 ]; then
+ atf_check -s not-exit:0 -e match:"Permission denied" \
+ ${TEST_INPUTS_DIR}/$mode
+ fi
+ if [ $(($mode & 0001)) -eq 0 ]; then
+ atf_check -s not-exit:0 -e match:"Permission denied" \
+ su -m tests -c ${TEST_INPUTS_DIR}/$mode
+ fi
+ done
+
+}
+perms_cleanup()
+{
+ common_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case autoexpand
@@ -817,6 +860,7 @@ atf_init_test_cases()
atf_add_test_case soft_links
atf_add_test_case root_props
atf_add_test_case used_space_props
+ atf_add_test_case perms
# XXXMJ tests:
# - test with different ashifts (at least, 9 and 12), different image sizes