The branch stable/14 has been updated by markj:

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

commit 5a36abc2034805cec066cf0ac54ec4d25e4a22c4
Author:     Mark Johnston <[email protected]>
AuthorDate: 2023-11-08 12:04:33 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2023-11-09 14:41:10 +0000

    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)
---
 usr.sbin/makefs/tests/makefs_zfs_tests.sh | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

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

Reply via email to