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