lib/: spdx license conversion
[xfstests-dev.git] / tests / generic / 375
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat.  All Rights Reserved.
4 #
5 # FS QA Test 375
6 #
7 # Check if SGID is cleared upon chmod / setfacl when the owner is not in the
8 # owning group.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/attr
29
30 # real QA test starts here
31 _supported_fs generic
32 _supported_os Linux
33 _require_test
34 _require_runas
35 _require_acls
36
37 cd $TEST_DIR
38
39 # try with both regular file and directory
40 for filetype in regular dir; do
41
42         case $filetype in
43         regular)
44                 testfile=testfile.$seq
45                 rm -f $testfile
46                 touch $testfile
47                 ;;
48         *)
49                 testfile=testdir.$seq
50                 rm -rf $testfile
51                 mkdir $testfile
52                 ;;
53         esac
54
55         chown 100:100 $testfile
56
57         echo '*** SGID should remain set (twice)'
58         chmod 2755 $testfile
59         _runas -u 100 -g 100 -- chmod 2777 $testfile
60         stat -c %A $testfile
61         chmod 2755 $testfile
62         _runas -u 100 -g 100 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
63         stat -c %A $testfile
64
65         echo '*** SGID should be cleared (twice)'
66         chmod 2755 $testfile
67         _runas -u 100 -g 101 -- chmod 2777 $testfile
68         stat -c %A $testfile
69         chmod 2755 $testfile
70         _runas -u 100 -g 101 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
71         stat -c %A $testfile
72
73         echo '*** Expected failure'
74         _runas -u 101 -g 101 -- chmod 2777 $testfile
75 done
76
77 status=0
78 exit