generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 369
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 369
6 #
7 # RichACL delete test
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
27 # remove previous $seqres.full before test
28 rm -f $seqres.full
29
30 # real QA test starts here
31
32 _supported_fs generic
33 _supported_os Linux
34
35 _require_scratch
36 _require_scratch_richacl
37 _require_richacl_prog
38 _require_runas
39
40 _scratch_mkfs_richacl >> $seqres.full
41 _scratch_mount
42
43 cd $SCRATCH_MNT
44
45 r()
46 {
47         echo "--- runas -u 99 -g 99 $*"
48         _runas -u 99 -g 99 -- "$@"
49 }
50
51 umask 022
52
53 chmod go+w .
54 mkdir d1 d2 d3 d4 d5 d6 d7
55 touch d1/f d1/g d2/f d3/f d4/f d5/f d6/f d7/f d7/g d7/h
56 chmod o+w d1/g
57 chown 99 d2
58 chgrp 99 d3
59 chmod g+w d3
60 $SETRICHACL_PROG --set 'u:99:wx::allow' d4
61 $SETRICHACL_PROG --set 'u:99:d::allow' d5
62 $SETRICHACL_PROG --set 'u:99:xd::allow' d6
63 $SETRICHACL_PROG --set 'u:99:D::allow' d7/f d7/g d7/h
64 chmod 664 d7/g
65
66 mkdir s2 s3 s4 s5 s6 s7
67 chmod +t s2 s3 s4 s5 s6 s7
68 touch s2/f s3/f s4/f s5/f s6/f s7/f s7/g s7/h
69 chown 99 s2
70 chgrp 99 s3
71 chmod g+w s3
72 $SETRICHACL_PROG --set 'u:99:wx::allow' s4
73 $SETRICHACL_PROG --set 'u:99:d::allow' s5
74 $SETRICHACL_PROG --set 'u:99:xd::allow' s6
75 $SETRICHACL_PROG --set 'u:99:D::allow' s7/f s7/g s7/h
76 chmod 664 s7/g
77
78 # Cannot delete files with no or only with write permissions on the directory
79 r rm -f d1/f d1/g
80
81 # Can delete files in directories we own
82 r rm -f d2/f s2/f
83
84 # Can delete files in non-sticky directories we have write access to
85 r rm -f d3/f s3/f
86
87 # "Write_data/execute" access does not include delete_child access, so deleting
88 # is not allowed:
89 r rm -f d4/f s4/f
90
91 # "Delete_child" access alone also is not sufficient
92 r rm -f d5/f s5/f
93
94 # "Execute/delete_child" access is sufficient for non-sticky directories
95 r rm -f d6/f s6/f
96
97 # "Delete" access on the child is sufficient, even in sticky directories.
98 r rm -f d7/f s7/f
99
100 # Regression: Delete access must not override add_file / add_subdirectory
101 # access.
102 r touch h
103 r mv -f h d7/
104 r mv -f h s7/
105
106 # A chmod turns off the "delete" permission
107 r rm -f d7/g s7/g
108
109 # success, all done
110 status=0
111 exit