From: Yang Xu Date: Tue, 10 May 2022 05:24:50 +0000 (+0800) Subject: generic/68[3-7]: Add separate sgid stripping sub-tests X-Git-Tag: v2022.05.15~15 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=653da5b6616027bb6f3a4061a5b36fa6785e80dc;p=xfstests-dev.git generic/68[3-7]: Add separate sgid stripping sub-tests Like xfstests commit 298f60c ("generic/673: Add separate sgid stripping sub-tests"), we should also add separate sgid stripping sub-tests for each fallocate operation. Signed-off-by: Yang Xu Reviewed-by: Darrick J. Wong Signed-off-by: Zorro Lang --- diff --git a/tests/generic/683 b/tests/generic/683 index c512989b..746ead86 100755 --- a/tests/generic/683 +++ b/tests/generic/683 @@ -61,67 +61,78 @@ commit_and_check() { echo } -nr=0 -# Commit to a non-exec file by an unprivileged user clears suid but -# leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, non-exec file $verb" +# Commit to a non-exec file by an unprivileged user clears suid and sgid. +echo "Test 1 - qa_user, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a group-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, group-exec file $verb" +# Commit to a group-exec file by an unprivileged user clears suid and sgid. +echo "Test 2 - qa_user, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a user-exec file by an unprivileged user clears suid but -# not sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, user-exec file $verb" +# Commit to a user-exec file by an unprivileged user clears suid and sgid. +echo "Test 3 - qa_user, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a all-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, all-exec file $verb" +# Commit to a all-exec file by an unprivileged user clears suid and sgid. +echo "Test 4 - qa_user, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a non-exec file by root clears suid but leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - root, non-exec file $verb" +# Commit to a non-exec file by root leaves suid and sgid. +echo "Test 5 - root, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a group-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, group-exec file $verb" +# Commit to a group-exec file by root leaves suid and sgid. +echo "Test 6 - root, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a user-exec file by root clears suid but not sgid. -nr=$((nr + 1)) -echo "Test $nr - root, user-exec file $verb" +# Commit to a user-exec file by root leaves suid and sgid. +echo "Test 7 - root, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a all-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, all-exec file $verb" +# Commit to a all-exec file by root leaves suid and sgid. +echo "Test 8 - root, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "" "$verb" 64k 64k +# Commit to a non-exec file by an unprivileged user leaves sgid. +echo "Test 9 - qa_user, non-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a group-exec file by an unprivileged user clears sgid +echo "Test 10 - qa_user, group-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a user-exec file by an unprivileged user clears sgid +echo "Test 11 - qa_user, user-exec file $verb, only sgid" +setup_testfile +chmod a+rw,u+x,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a all-exec file by an unprivileged user clears sgid. +echo "Test 12 - qa_user, all-exec file $verb, only sgid" +setup_testfile +chmod a+rwx,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + # success, all done status=0 exit diff --git a/tests/generic/683.out b/tests/generic/683.out index 9d1c9f80..ca29f6e6 100644 --- a/tests/generic/683.out +++ b/tests/generic/683.out @@ -31,3 +31,19 @@ Test 8 - root, all-exec file falloc 6777 -rwsrwsrwx TEST_DIR/683/a 6777 -rwsrwsrwx TEST_DIR/683/a +Test 9 - qa_user, non-exec file falloc, only sgid +2666 -rw-rwSrw- TEST_DIR/683/a +2666 -rw-rwSrw- TEST_DIR/683/a + +Test 10 - qa_user, group-exec file falloc, only sgid +2676 -rw-rwsrw- TEST_DIR/683/a +676 -rw-rwxrw- TEST_DIR/683/a + +Test 11 - qa_user, user-exec file falloc, only sgid +2766 -rwxrwSrw- TEST_DIR/683/a +2766 -rwxrwSrw- TEST_DIR/683/a + +Test 12 - qa_user, all-exec file falloc, only sgid +2777 -rwxrwsrwx TEST_DIR/683/a +777 -rwxrwxrwx TEST_DIR/683/a + diff --git a/tests/generic/684 b/tests/generic/684 index d59f4239..4bebeff0 100755 --- a/tests/generic/684 +++ b/tests/generic/684 @@ -61,67 +61,78 @@ commit_and_check() { echo } -nr=0 -# Commit to a non-exec file by an unprivileged user clears suid but -# leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, non-exec file $verb" +# Commit to a non-exec file by an unprivileged user clears suid and sgid. +echo "Test 1 - qa_user, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a group-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, group-exec file $verb" +# Commit to a group-exec file by an unprivileged user clears suid and sgid. +echo "Test 2 - qa_user, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a user-exec file by an unprivileged user clears suid but -# not sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, user-exec file $verb" +# Commit to a user-exec file by an unprivileged user clears suid and sgid. +echo "Test 3 - qa_user, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a all-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, all-exec file $verb" +# Commit to a all-exec file by an unprivileged user clears suid and sgid. +echo "Test 4 - qa_user, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a non-exec file by root clears suid but leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - root, non-exec file $verb" +# Commit to a non-exec file by root leaves suid and sgid. +echo "Test 5 - root, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a group-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, group-exec file $verb" +# Commit to a group-exec file by root leaves suid and sgid. +echo "Test 6 - root, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a user-exec file by root clears suid but not sgid. -nr=$((nr + 1)) -echo "Test $nr - root, user-exec file $verb" +# Commit to a user-exec file by root leaves suid and sgid. +echo "Test 7 - root, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a all-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, all-exec file $verb" +# Commit to a all-exec file by root leaves suid and sgid. +echo "Test 8 - root, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "" "$verb" 64k 64k +# Commit to a non-exec file by an unprivileged user leaves sgid. +echo "Test 9 - qa_user, non-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a group-exec file by an unprivileged user clears sgid +echo "Test 10 - qa_user, group-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a user-exec file by an unprivileged user clears sgid +echo "Test 11 - qa_user, user-exec file $verb, only sgid" +setup_testfile +chmod a+rw,u+x,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a all-exec file by an unprivileged user clears sgid. +echo "Test 12 - qa_user, all-exec file $verb, only sgid" +setup_testfile +chmod a+rwx,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + # success, all done status=0 exit diff --git a/tests/generic/684.out b/tests/generic/684.out index df5b3788..2e084ced 100644 --- a/tests/generic/684.out +++ b/tests/generic/684.out @@ -31,3 +31,19 @@ Test 8 - root, all-exec file fpunch 6777 -rwsrwsrwx TEST_DIR/684/a 6777 -rwsrwsrwx TEST_DIR/684/a +Test 9 - qa_user, non-exec file fpunch, only sgid +2666 -rw-rwSrw- TEST_DIR/684/a +2666 -rw-rwSrw- TEST_DIR/684/a + +Test 10 - qa_user, group-exec file fpunch, only sgid +2676 -rw-rwsrw- TEST_DIR/684/a +676 -rw-rwxrw- TEST_DIR/684/a + +Test 11 - qa_user, user-exec file fpunch, only sgid +2766 -rwxrwSrw- TEST_DIR/684/a +2766 -rwxrwSrw- TEST_DIR/684/a + +Test 12 - qa_user, all-exec file fpunch, only sgid +2777 -rwxrwsrwx TEST_DIR/684/a +777 -rwxrwxrwx TEST_DIR/684/a + diff --git a/tests/generic/685 b/tests/generic/685 index 2e990465..03447e00 100755 --- a/tests/generic/685 +++ b/tests/generic/685 @@ -61,67 +61,78 @@ commit_and_check() { echo } -nr=0 -# Commit to a non-exec file by an unprivileged user clears suid but -# leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, non-exec file $verb" +# Commit to a non-exec file by an unprivileged user clears suid and sgid. +echo "Test 1 - qa_user, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a group-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, group-exec file $verb" +# Commit to a group-exec file by an unprivileged user clears suid and sgid. +echo "Test 2 - qa_user, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a user-exec file by an unprivileged user clears suid but -# not sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, user-exec file $verb" +# Commit to a user-exec file by an unprivileged user clears suid and sgid. +echo "Test 3 - qa_user, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a all-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, all-exec file $verb" +# Commit to a all-exec file by an unprivileged user clears suid and sgid. +echo "Test 4 - qa_user, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a non-exec file by root clears suid but leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - root, non-exec file $verb" +# Commit to a non-exec file by root leaves suid and sgid. +echo "Test 5 - root, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a group-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, group-exec file $verb" +# Commit to a group-exec file by root leaves suid and sgid. +echo "Test 6 - root, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a user-exec file by root clears suid but not sgid. -nr=$((nr + 1)) -echo "Test $nr - root, user-exec file $verb" +# Commit to a user-exec file by root leaves suid and sgid. +echo "Test 7 - root, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a all-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, all-exec file $verb" +# Commit to a all-exec file by root leaves suid and sgid. +echo "Test 8 - root, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "" "$verb" 64k 64k +# Commit to a non-exec file by an unprivileged user leaves sgid. +echo "Test 9 - qa_user, non-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a group-exec file by an unprivileged user clears sgid +echo "Test 10 - qa_user, group-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a user-exec file by an unprivileged user clears sgid +echo "Test 11 - qa_user, user-exec file $verb, only sgid" +setup_testfile +chmod a+rw,u+x,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a all-exec file by an unprivileged user clears sgid. +echo "Test 12 - qa_user, all-exec file $verb, only sgid" +setup_testfile +chmod a+rwx,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + # success, all done status=0 exit diff --git a/tests/generic/685.out b/tests/generic/685.out index 90b7a0de..e611da3e 100644 --- a/tests/generic/685.out +++ b/tests/generic/685.out @@ -31,3 +31,19 @@ Test 8 - root, all-exec file fzero 6777 -rwsrwsrwx TEST_DIR/685/a 6777 -rwsrwsrwx TEST_DIR/685/a +Test 9 - qa_user, non-exec file fzero, only sgid +2666 -rw-rwSrw- TEST_DIR/685/a +2666 -rw-rwSrw- TEST_DIR/685/a + +Test 10 - qa_user, group-exec file fzero, only sgid +2676 -rw-rwsrw- TEST_DIR/685/a +676 -rw-rwxrw- TEST_DIR/685/a + +Test 11 - qa_user, user-exec file fzero, only sgid +2766 -rwxrwSrw- TEST_DIR/685/a +2766 -rwxrwSrw- TEST_DIR/685/a + +Test 12 - qa_user, all-exec file fzero, only sgid +2777 -rwxrwsrwx TEST_DIR/685/a +777 -rwxrwxrwx TEST_DIR/685/a + diff --git a/tests/generic/686 b/tests/generic/686 index 71c3aebb..eae3cbda 100755 --- a/tests/generic/686 +++ b/tests/generic/686 @@ -61,67 +61,78 @@ commit_and_check() { echo } -nr=0 -# Commit to a non-exec file by an unprivileged user clears suid but -# leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, non-exec file $verb" +# Commit to a non-exec file by an unprivileged user clears suid and sgid. +echo "Test 1 - qa_user, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a group-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, group-exec file $verb" +# Commit to a group-exec file by an unprivileged user clears suid and sgid. +echo "Test 2 - qa_user, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a user-exec file by an unprivileged user clears suid but -# not sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, user-exec file $verb" +# Commit to a user-exec file by an unprivileged user clears suid and sgid. +echo "Test 3 - qa_user, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a all-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, all-exec file $verb" +# Commit to a all-exec file by an unprivileged user clears suid and sgid. +echo "Test 4 - qa_user, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a non-exec file by root clears suid but leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - root, non-exec file $verb" +# Commit to a non-exec file by root leaves suid and sgid. +echo "Test 5 - root, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a group-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, group-exec file $verb" +# Commit to a group-exec file by root leaves suid and sgid. +echo "Test 6 - root, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a user-exec file by root clears suid but not sgid. -nr=$((nr + 1)) -echo "Test $nr - root, user-exec file $verb" +# Commit to a user-exec file by root leaves suid and sgid. +echo "Test 7 - root, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a all-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, all-exec file $verb" +# Commit to a all-exec file by root leaves suid and sgid. +echo "Test 8 - root, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "" "$verb" 64k 64k +# Commit to a non-exec file by an unprivileged user leaves sgid. +echo "Test 9 - qa_user, non-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a group-exec file by an unprivileged user clears sgid +echo "Test 10 - qa_user, group-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a user-exec file by an unprivileged user clears sgid +echo "Test 11 - qa_user, user-exec file $verb, only sgid" +setup_testfile +chmod a+rw,u+x,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a all-exec file by an unprivileged user clears sgid. +echo "Test 12 - qa_user, all-exec file $verb, only sgid" +setup_testfile +chmod a+rwx,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + # success, all done status=0 exit diff --git a/tests/generic/686.out b/tests/generic/686.out index 6a1179f1..aa1e6471 100644 --- a/tests/generic/686.out +++ b/tests/generic/686.out @@ -31,3 +31,19 @@ Test 8 - root, all-exec file finsert 6777 -rwsrwsrwx TEST_DIR/686/a 6777 -rwsrwsrwx TEST_DIR/686/a +Test 9 - qa_user, non-exec file finsert, only sgid +2666 -rw-rwSrw- TEST_DIR/686/a +2666 -rw-rwSrw- TEST_DIR/686/a + +Test 10 - qa_user, group-exec file finsert, only sgid +2676 -rw-rwsrw- TEST_DIR/686/a +676 -rw-rwxrw- TEST_DIR/686/a + +Test 11 - qa_user, user-exec file finsert, only sgid +2766 -rwxrwSrw- TEST_DIR/686/a +2766 -rwxrwSrw- TEST_DIR/686/a + +Test 12 - qa_user, all-exec file finsert, only sgid +2777 -rwxrwsrwx TEST_DIR/686/a +777 -rwxrwxrwx TEST_DIR/686/a + diff --git a/tests/generic/687 b/tests/generic/687 index 7bdfcd5c..0bd421e5 100755 --- a/tests/generic/687 +++ b/tests/generic/687 @@ -61,67 +61,78 @@ commit_and_check() { echo } -nr=0 -# Commit to a non-exec file by an unprivileged user clears suid but -# leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, non-exec file $verb" +# Commit to a non-exec file by an unprivileged user clears suid and sgid. +echo "Test 1 - qa_user, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a group-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, group-exec file $verb" +# Commit to a group-exec file by an unprivileged user clears suid and sgid. +echo "Test 2 - qa_user, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a user-exec file by an unprivileged user clears suid but -# not sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, user-exec file $verb" +# Commit to a user-exec file by an unprivileged user clears suid and sgid. +echo "Test 3 - qa_user, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a all-exec file by an unprivileged user clears suid and -# sgid. -nr=$((nr + 1)) -echo "Test $nr - qa_user, all-exec file $verb" +# Commit to a all-exec file by an unprivileged user clears suid and sgid. +echo "Test 4 - qa_user, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "$qa_user" "$verb" 64k 64k -# Commit to a non-exec file by root clears suid but leaves sgid. -nr=$((nr + 1)) -echo "Test $nr - root, non-exec file $verb" +# Commit to a non-exec file by root leaves suid and sgid. +echo "Test 5 - root, non-exec file $verb" setup_testfile chmod a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a group-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, group-exec file $verb" +# Commit to a group-exec file by root leaves suid and sgid. +echo "Test 6 - root, group-exec file $verb" setup_testfile chmod g+x,a+rws $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a user-exec file by root clears suid but not sgid. -nr=$((nr + 1)) -echo "Test $nr - root, user-exec file $verb" +# Commit to a user-exec file by root leaves suid and sgid. +echo "Test 7 - root, user-exec file $verb" setup_testfile chmod u+x,a+rws,g-x $junk_file commit_and_check "" "$verb" 64k 64k -# Commit to a all-exec file by root clears suid and sgid. -nr=$((nr + 1)) -echo "Test $nr - root, all-exec file $verb" +# Commit to a all-exec file by root leaves suid and sgid. +echo "Test 8 - root, all-exec file $verb" setup_testfile chmod a+rwxs $junk_file commit_and_check "" "$verb" 64k 64k +# Commit to a non-exec file by an unprivileged user leaves sgid. +echo "Test 9 - qa_user, non-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a group-exec file by an unprivileged user clears sgid +echo "Test 10 - qa_user, group-exec file $verb, only sgid" +setup_testfile +chmod a+rw,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a user-exec file by an unprivileged user clears sgid +echo "Test 11 - qa_user, user-exec file $verb, only sgid" +setup_testfile +chmod a+rw,u+x,g+rws $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + +# Commit to a all-exec file by an unprivileged user clears sgid. +echo "Test 12 - qa_user, all-exec file $verb, only sgid" +setup_testfile +chmod a+rwx,g+rwxs $junk_file +commit_and_check "$qa_user" "$verb" 64k 64k + # success, all done status=0 exit diff --git a/tests/generic/687.out b/tests/generic/687.out index 7f945d72..c5116c27 100644 --- a/tests/generic/687.out +++ b/tests/generic/687.out @@ -31,3 +31,19 @@ Test 8 - root, all-exec file fcollapse 6777 -rwsrwsrwx TEST_DIR/687/a 6777 -rwsrwsrwx TEST_DIR/687/a +Test 9 - qa_user, non-exec file fcollapse, only sgid +2666 -rw-rwSrw- TEST_DIR/687/a +2666 -rw-rwSrw- TEST_DIR/687/a + +Test 10 - qa_user, group-exec file fcollapse, only sgid +2676 -rw-rwsrw- TEST_DIR/687/a +676 -rw-rwxrw- TEST_DIR/687/a + +Test 11 - qa_user, user-exec file fcollapse, only sgid +2766 -rwxrwSrw- TEST_DIR/687/a +2766 -rwxrwSrw- TEST_DIR/687/a + +Test 12 - qa_user, all-exec file fcollapse, only sgid +2777 -rwxrwsrwx TEST_DIR/687/a +777 -rwxrwxrwx TEST_DIR/687/a +