fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 355
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
4 #
5 # FS QA Test 355
6 #
7 # Test clear of suid/sgid on direct write.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 rm -f $seqres.full
29
30 # real QA test starts here
31 _supported_fs generic
32 _supported_os Linux
33 _require_test
34 _require_user
35 _require_odirect
36
37 testfile=$TEST_DIR/$seq.test
38 rm -f $testfile
39
40 do_io()
41 {
42         su $qa_user -c "$XFS_IO_PROG -d -c 'pwrite 0 4k' $testfile" \
43                 >>$seqres.full
44 }
45
46 echo "Check that suid/sgid bits are cleared after direct write"
47
48 # create testfile and set base ownership & permission
49 echo "this is a test" >> $testfile
50 chmod 644 $testfile
51 chown $qa_user:$qa_user $testfile
52
53 echo "== with no exec perm"
54 chmod ug+s $testfile
55 echo -n "before: "; stat -c '%A' $testfile
56 do_io
57 echo -n "after:  "; stat -c '%A' $testfile
58
59 echo "== with user exec perm"
60 chmod ug+s $testfile
61 chmod u+x $testfile
62 echo -n "before: "; stat -c '%A' $testfile
63 do_io
64 echo -n "after:  "; stat -c '%A' $testfile
65
66 echo "== with group exec perm"
67 chmod ug+s $testfile
68 chmod g+x $testfile
69 chmod u-x $testfile
70 echo -n "before: "; stat -c '%A' $testfile
71 do_io
72 echo -n "after:  "; stat -c '%A' $testfile
73
74 echo "== with user+group exec perm"
75 chmod ug+s $testfile
76 chmod u+x $testfile
77 echo -n "before: "; stat -c '%A' $testfile
78 do_io
79 echo -n "after:  "; stat -c '%A' $testfile
80
81 # success, all done
82 status=0
83 exit