A bit of a cleanup of common.config and add new QA host.
[xfstests-dev.git] / 099
1 #! /bin/sh
2 # FS QA Test No. 099. Modified from UDFQA test 036.
3 #
4 # ACL test
5 #-----------------------------------------------------------------------
6 #  Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
7 #-----------------------------------------------------------------------
8 #_acl_list
9 # modifier
10 owner=ajones@sgi.com
11
12 seq=`basename $0`
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 # get standard environment, filters and checks
21 . ./common.rc
22 . ./common.filter
23 . ./common.attr
24
25 runas=$here/src/runas
26
27 TARGET_DIR=$SCRATCH_MNT
28 [ "$FSTYP" == "xfs" ] && TARGET_DIR=$TEST_DIR
29
30 _cleanup()
31 {
32     rm -f $tmp.*
33     cd $TARGET_DIR
34     rm -rf $seq.dir1
35     cd /
36 }
37
38 # -----
39 # minimal access ACL has ACEs: USER_OBJ, GROUP_OBJ, OTHER_OBJ
40 # This is set with chacl(1) and can be changed by chmod(1).
41 #
42 # Test that this is being set for ACL and for std unix permissions
43 # Test that we can get back the same ACL.
44 # Test std permissions for rwx.
45 # -----
46 #
47 # Test out default ACLs and that the ACL is being PASSed
48 # onto the children of the dir.
49 #
50 # -----
51 # Test out access check for extended ACLs.
52 # -> 3 extra ACEs: MASK, GROUP, USER
53 # -> the GROUP compares with egid of process _and_ the supplementary
54 #    groups (as found in /etc/group)
55 #
56 # Test that mask works for USER, GROUP, GROUP_OBJ
57 # Test that the ACE type priority is working
58 #   -> this would be done by simultaneously matching on ACEs
59 #   -> interesting if it allows user to specify ACEs in any order
60 #
61 rm -f $seq.full
62
63 #-------------------------------------------------------
64 # real QA test starts here
65 _supported_fs xfs udf
66 _supported_os IRIX
67
68 _acl_setup_ids
69 _acl_requirements
70 [ -x $runas ] || _notrun "$runas executable not found"
71
72 # get dir
73 #export FILE_SYS=xfs
74 _require_scratch
75 _setup_testdir
76
77 cd $TARGET_DIR
78 rm -rf $seq.dir1 # in case file is left over from previous runs.
79 mkdir $seq.dir1
80 cd $seq.dir1
81
82 echo ""
83 echo "=== Test minimal ACE ==="
84
85 echo "Setup file"
86 # Note: as this is a shell script,
87 #       will need read and execute permission set
88 #       in order to execute it.
89 touch file1
90 cat <<EOF >file1
91 #!/bin/sh
92 echo "Test was executed"
93 EOF
94 chmod u=rwx file1
95 chmod g=rw- file1
96 chmod o=r-- file1
97 chown $acl1.$acl2 file1
98 _acl_ls file1
99
100 echo ""
101 echo "--- Test get and set of ACL ---"
102 echo "Note: IRIX interface gave an empty ACL - Linux outputs an ACL"
103 _acl_list file1
104 echo "Try using single colon separator"
105 echo "Note: IRIX interface FAILs because of single colon - Linux one allows it" 
106 chacl u::r--,g::rwx,o:rw- file1 2>&1
107 echo "Expect to PASS" 
108 chacl u::r--,g::rwx,o::rw- file1 2>&1
109 _acl_list file1
110
111 echo ""
112 echo "--- Test sync of ACL with std permissions ---"
113 _acl_ls file1
114 chmod u+w file1
115 _acl_ls file1
116 _acl_list file1
117
118 echo ""
119 echo "--- Test owner permissions ---"
120 chacl u::r-x,g::---,o::--- file1 2>&1
121 _acl_list file1
122 # change to owner
123 echo "Expect to PASS" 
124 $runas -u $acl1 -g $acl1 ./file1 2>&1
125 echo "Expect to FAIL" 
126 $runas -u $acl2 -g $acl2 ./file1 2>&1
127
128 echo ""
129 echo "--- Test group permissions ---"
130 chacl u::---,g::r-x,o::--- file1 2>&1
131 _acl_list file1
132 echo "Expect to FAIL - acl1 is owner" 
133 $runas -u $acl1 -g $acl1 ./file1 2>&1
134 echo "Expect to PASS - acl2 matches group" 
135 $runas -u $acl2 -g $acl2 ./file1 2>&1
136 echo "Expect to PASS - acl2 matches sup group" 
137 $runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
138 echo "Expect to FAIL - acl3 is not in group" 
139 $runas -u $acl3 -g $acl3 ./file1 2>&1
140
141 echo ""
142 echo "--- Test other permissions ---"
143 chacl u::---,g::---,o::r-x file1 2>&1
144 _acl_list file1
145 echo "Expect to FAIL - acl1 is owner" 
146 $runas -u $acl1 -g $acl1 ./file1 2>&1
147 echo "Expect to FAIL - acl2 is in group" 
148 $runas -u $acl2 -g $acl2 ./file1 2>&1
149 echo "Expect to FAIL - acl2 is in sup. group" 
150 $runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
151 echo "Expect to PASS - acl3 is not owner or in group" 
152 $runas -u $acl3 -g $acl3 ./file1 2>&1
153
154 #-------------------------------------------------------
155
156 echo ""
157 echo "=== Test Extended ACLs ==="
158
159 echo ""
160 echo "--- Test adding a USER ACE ---"
161 echo "Expect to FAIL as no MASK provided"
162 chacl u::---,g::---,o::---,u:$acl2:r-x file1 2>&1 | _acl_filter_id
163 echo "Ensure that ACL has not been changed"
164 _acl_list file1
165 echo "Expect to PASS - USER ACE matches user"
166 chacl u::---,g::---,o::---,u:$acl2:r-x,m::rwx file1 2>&1
167 _acl_list file1
168 $runas -u $acl2 -g $acl2 ./file1 2>&1
169 echo "Expect to FAIL - USER ACE does not match user"
170 $runas -u $acl3 -g $acl3 ./file1 2>&1
171
172 echo ""
173 echo "--- Test adding a GROUP ACE ---"
174 echo "Expect to FAIL as no MASK provided"
175 chacl u::---,g::---,o::---,g:$acl2:r-x file1 2>&1 | _acl_filter_id
176 echo "Ensure that ACL has not been changed"
177 _acl_list file1
178 chacl u::---,g::---,o::---,g:$acl2:r-x,m::rwx file1 2>&1
179 _acl_list file1 | _acl_filter_id
180 echo "Expect to PASS - GROUP ACE matches group"
181 $runas -u $acl2 -g $acl2 ./file1 2>&1
182 echo "Expect to PASS - GROUP ACE matches sup group"
183 $runas -u $acl2 -g $acl1 -s $acl2 ./file1 2>&1
184 echo "Expect to FAIL - GROUP ACE does not match group"
185 $runas -u $acl3 -g $acl3 ./file1 2>&1
186
187 #-------------------------------------------------------
188
189 echo ""
190 echo "--- Test MASK ---"
191
192 # group
193 chacl u::---,g::---,o::---,g:$acl2:r-x,m::-w- file1 2>&1
194 _acl_list file1
195 echo "Expect to FAIL as MASK prohibits execution"
196 $runas -u $acl2 -g $acl2 ./file1 2>&1
197
198 # user
199 chacl u::---,g::---,o::---,u:$acl2:r-x,m::-w- file1 2>&1
200 echo "Expect to FAIL as MASK prohibits execution"
201 $runas -u $acl2 -g $acl2 ./file1 2>&1
202
203 # user
204 chacl u::---,g::---,o::---,u:$acl2:r-x,m::r-x file1 2>&1
205 echo "Expect to PASS as MASK allows execution"
206 $runas -u $acl2 -g $acl2 ./file1 2>&1
207
208 #-------------------------------------------------------
209
210 echo ""
211 echo "--- Test ACE priority ---"
212
213 chacl o::rwx,g::rwx,u:$acl1:rwx,u::---,m::rwx file1 2>&1
214 echo "Expect to FAIL as should match on owner"
215 $runas -u $acl1 -g $acl2 ./file1 2>&1
216
217 chacl o::---,g::---,u:$acl2:rwx,u::---,m::rwx file1 2>&1
218 echo "Expect to PASS as should match on user"
219 $runas -u $acl2 -g $acl2 ./file1 2>&1
220
221
222 #-------------------------------------------------------
223
224 echo ""
225 echo "=== Test can read ACLs without access permissions ==="
226 # This was a bug in kernel code where syscred wasn't being used
227 # to override the capabilities
228 chacl o::---,g::---,u::--- file1 2>&1
229 _acl_list file1
230
231 #-------------------------------------------------------
232
233 echo ""
234 echo "=== Test Default ACLs ==="
235 # make test clearer by testing with and without umask
236 umask 0
237
238 mkdir acldir
239 chacl -b "u::rwx,g::rwx,o::rwx" "u::r-x,g::r--,o::---" acldir 2>&1
240 _acl_list acldir
241 cd acldir
242
243 touch file2
244 _acl_ls file2
245 _acl_list file2
246
247 #ensure that umask is not having an effect 
248 #so set it and see
249 umask 722
250 touch file3
251 _acl_ls file3
252 _acl_list file3
253
254 cd ..
255 umask 022
256
257
258 #-------------------------------------------------------
259
260 echo ""
261 echo "=== Removing ACLs ==="
262 _acl_list file1
263 _acl_list acldir
264 _acl_list acldir/file2
265 echo "Remove ACLs..."
266 chacl -R file1
267 chacl -B acldir
268 chacl -R acldir/file2
269 echo "Note: IRIX interface would mean empty ACLs - Linux would show mode ACLs" 
270 _acl_list file1
271 _acl_list acldir
272 _acl_list acldir/file2
273
274 #-------------------------------------------------------
275
276 echo ""
277 echo "=== Test out error messages for ACL text parsing  ==="
278
279 touch file1
280 set -x
281 chacl u file1
282 chacl u: file1
283 chacl u:rumpledumpleunknownuser file1
284 chacl u:rumpledumpleunknownuser: file1
285 chacl g:rumpledumpleunknowngrp file1
286 chacl g:rumpledumpleunknowngrp: file1
287 chacl o:user1:rwx file1
288 chacl m:user1:rwx file1
289 chacl a::rwx file1
290 set +x
291
292 #-------------------------------------------------------
293
294 echo ""
295 echo "=== Test out large ACLs  ==="
296 touch largeaclfile
297 XFS_ACL_MAX_ENTRIES=25
298 num_aces_pre=`expr $XFS_ACL_MAX_ENTRIES - 1`
299 num_aces_post=`expr $XFS_ACL_MAX_ENTRIES + 1`
300
301 acl1=`_create_n_aces $num_aces_pre`
302 acl2=`_create_n_aces $XFS_ACL_MAX_ENTRIES`
303 acl3=`_create_n_aces $num_aces_post`
304
305 echo "1 below xfs acl max"
306 chacl $acl1 largeaclfile
307 _acl_list largeaclfile | _filter_aces_notypes
308
309 echo "xfs acl max"
310 chacl $acl2 largeaclfile
311 _acl_list largeaclfile | _filter_aces_notypes
312
313 echo "1 above xfs acl max"
314 chacl $acl3 largeaclfile
315 _acl_list largeaclfile | _filter_aces_notypes
316
317 #-------------------------------------------------------
318
319 if [ "$FSTYP" == "udf" ]; then
320     cd /
321     umount $TARGET_DIR
322     # Check the filesystem
323     _check_scratch_fs
324 fi
325 # success, all done
326 status=0
327 exit