generic/405: test mkfs against thin provision device
[xfstests-dev.git] / tests / generic / 375
1 #! /bin/bash
2 # FS QA Test 375
3 #
4 # Check if SGID is cleared upon chmod / setfacl when the owner is not in the
5 # owning group.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2016 Red Hat.  All Rights Reserved.
9 #
10 # Author: Andreas gruenbacher <agruenba@redhat.com>
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45 . ./common/attr
46
47 # real QA test starts here
48 _supported_fs generic
49 _supported_os Linux
50 _require_test
51 _require_runas
52 _require_acls
53
54 cd $TEST_DIR
55
56 # try with both regular file and directory
57 for filetype in regular dir; do
58
59         case $filetype in
60         regular)
61                 testfile=testfile.$seq
62                 rm -f $testfile
63                 touch $testfile
64                 ;;
65         *)
66                 testfile=testdir.$seq
67                 rm -rf $testfile
68                 mkdir $testfile
69                 ;;
70         esac
71
72         chown 100:100 $testfile
73
74         echo '*** SGID should remain set (twice)'
75         chmod 2755 $testfile
76         _runas -u 100 -g 100 -- chmod 2777 $testfile
77         stat -c %A $testfile
78         chmod 2755 $testfile
79         _runas -u 100 -g 100 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
80         stat -c %A $testfile
81
82         echo '*** SGID should be cleared (twice)'
83         chmod 2755 $testfile
84         _runas -u 100 -g 101 -- chmod 2777 $testfile
85         stat -c %A $testfile
86         chmod 2755 $testfile
87         _runas -u 100 -g 101 -- setfacl -m u::rwx,g::rwx,o::rwx $testfile
88         stat -c %A $testfile
89
90         echo '*** Expected failure'
91         _runas -u 101 -g 101 -- chmod 2777 $testfile
92 done
93
94 status=0
95 exit