2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
11 _begin_fstest acl auto quick
13 # Import common functions.
17 # Override the default cleanup function.
22 [ -n "$TEST_DIR" ] && rm -rf $TEST_DIR/$seq.dir1
26 # minimal access ACL has ACEs: USER_OBJ, GROUP_OBJ, OTHER_OBJ
27 # This is set with chacl(1) and can be changed by chmod(1).
29 # Test that this is being set for ACL and for std unix permissions
30 # Test that we can get back the same ACL.
31 # Test std permissions for rwx.
34 # Test out default ACLs and that the ACL is being PASSed
35 # onto the children of the dir.
38 # Test out access check for extended ACLs.
39 # -> 3 extra ACEs: MASK, GROUP, USER
40 # -> the GROUP compares with egid of process _and_ the supplementary
41 # groups (as found in /etc/group)
43 # Test that mask works for USER, GROUP, GROUP_OBJ
44 # Test that the ACE type priority is working
45 # -> this would be done by simultaneously matching on ACEs
46 # -> interesting if it allows user to specify ACEs in any order
49 # real QA test starts here
64 echo "=== Test minimal ACE ==="
67 # Note: as this is a shell script,
68 # will need read and execute permission set
69 # in order to execute it.
72 echo "Test was executed"
77 chown $acl1.$acl2 file1
81 echo "--- Test get and set of ACL ---"
82 echo "Note: Old interface gave an empty ACL - now output an ACL"
83 chacl -l file1 | _acl_filter_id
84 echo "Try using single colon separator"
85 echo "Note: Old interface FAILed because of single colon - new one allows it"
86 chacl u::r--,g::rwx,o:rw- file1 2>&1
88 chacl u::r--,g::rwx,o::rw- file1 2>&1
89 chacl -l file1 | _acl_filter_id
92 echo "--- Test sync of ACL with std permissions ---"
96 chacl -l file1 | _acl_filter_id
99 echo "--- Test owner permissions ---"
100 chacl u::r-x,g::---,o::--- file1 2>&1
101 chacl -l file1 | _acl_filter_id
103 echo "Expect to PASS"
104 _runas -u $acl1 -g $acl1 ./file1 2>&1
105 echo "Expect to FAIL"
106 _runas -u $acl2 -g $acl2 ./file1 2>&1
109 echo "--- Test group permissions ---"
110 chacl u::---,g::r-x,o::--- file1 2>&1
111 chacl -l file1 | _acl_filter_id
112 echo "Expect to FAIL - acl1 is owner"
113 _runas -u $acl1 -g $acl1 ./file1 2>&1
114 echo "Expect to PASS - acl2 matches group"
115 _runas -u $acl2 -g $acl2 ./file1 2>&1
116 echo "Expect to PASS - acl2 matches sup group"
117 _runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
118 echo "Expect to FAIL - acl3 is not in group"
119 _runas -u $acl3 -g $acl3 ./file1 2>&1
122 echo "--- Test other permissions ---"
123 chacl u::---,g::---,o::r-x file1 2>&1
124 chacl -l file1 | _acl_filter_id
125 echo "Expect to FAIL - acl1 is owner"
126 _runas -u $acl1 -g $acl1 ./file1 2>&1
127 echo "Expect to FAIL - acl2 is in group"
128 _runas -u $acl2 -g $acl2 ./file1 2>&1
129 echo "Expect to FAIL - acl2 is in sup. group"
130 _runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
131 echo "Expect to PASS - acl3 is not owner or in group"
132 _runas -u $acl3 -g $acl3 ./file1 2>&1
134 #-------------------------------------------------------
137 echo "=== Test Extended ACLs ==="
140 echo "--- Test adding a USER ACE ---"
141 echo "Expect to FAIL as no MASK provided"
142 chacl u::---,g::---,o::---,u:$acl2:r-x file1 2>&1 | _acl_filter_id
143 echo "Ensure that ACL has not been changed"
144 chacl -l file1 | _acl_filter_id
145 echo "Expect to PASS - USER ACE matches user"
146 chacl u::---,g::---,o::---,u:$acl2:r-x,m::rwx file1 2>&1
147 chacl -l file1 | _acl_filter_id
148 _runas -u $acl2 -g $acl2 ./file1 2>&1
149 echo "Expect to FAIL - USER ACE does not match user"
150 _runas -u $acl3 -g $acl3 ./file1 2>&1
153 echo "--- Test adding a GROUP ACE ---"
154 echo "Expect to FAIL as no MASK provided"
155 chacl u::---,g::---,o::---,g:$acl2:r-x file1 2>&1 | _acl_filter_id
156 echo "Ensure that ACL has not been changed"
157 chacl -l file1 | _acl_filter_id
158 chacl u::---,g::---,o::---,g:$acl2:r-x,m::rwx file1 2>&1
159 chacl -l file1 | _acl_filter_id
160 echo "Expect to PASS - GROUP ACE matches group"
161 _runas -u $acl2 -g $acl2 ./file1 2>&1
162 echo "Expect to PASS - GROUP ACE matches sup group"
163 _runas -u $acl2 -g $acl1 -s $acl2 ./file1 2>&1
164 echo "Expect to FAIL - GROUP ACE does not match group"
165 _runas -u $acl3 -g $acl3 ./file1 2>&1
167 #-------------------------------------------------------
170 echo "--- Test MASK ---"
173 chacl u::---,g::---,o::---,g:$acl2:r-x,m::-w- file1 2>&1
174 chacl -l file1 | _acl_filter_id
175 echo "Expect to FAIL as MASK prohibits execution"
176 _runas -u $acl2 -g $acl2 ./file1 2>&1
179 chacl u::---,g::---,o::---,u:$acl2:r-x,m::-w- file1 2>&1
180 echo "Expect to FAIL as MASK prohibits execution"
181 _runas -u $acl2 -g $acl2 ./file1 2>&1
184 chacl u::---,g::---,o::---,u:$acl2:r-x,m::r-x file1 2>&1
185 echo "Expect to PASS as MASK allows execution"
186 _runas -u $acl2 -g $acl2 ./file1 2>&1
188 #-------------------------------------------------------
191 echo "--- Test ACE priority ---"
193 chacl o::rwx,g::rwx,u:$acl1:rwx,u::---,m::rwx file1 2>&1
194 echo "Expect to FAIL as should match on owner"
195 _runas -u $acl1 -g $acl2 ./file1 2>&1
197 chacl o::---,g::---,u:$acl2:rwx,u::---,m::rwx file1 2>&1
198 echo "Expect to PASS as should match on user"
199 _runas -u $acl2 -g $acl2 ./file1 2>&1
201 #-------------------------------------------------------
204 echo "=== Test can read ACLs without access permissions ==="
205 # This was a bug in kernel code where syscred wasn't being used
206 # to override the capabilities
207 chacl o::---,g::---,u::--- file1 2>&1
208 chacl -l file1 | _acl_filter_id
210 #-------------------------------------------------------
213 echo "=== Test Default ACLs ==="
214 # make test clearer by testing with and without umask
218 chacl -b "u::rwx,g::rwx,o::rwx" "u::r-x,g::r--,o::---" acldir 2>&1
219 chacl -l acldir | _acl_filter_id
224 chacl -l file2 | _acl_filter_id
226 #ensure that umask is not having an effect
231 chacl -l file3 | _acl_filter_id
236 #-------------------------------------------------------
239 echo "=== Removing ACLs ==="
240 chacl -l file1 | _acl_filter_id
241 chacl -l acldir | _acl_filter_id
242 chacl -l acldir/file2 | _acl_filter_id
243 echo "Remove ACLs..."
246 chacl -R acldir/file2
247 echo "Note: Old interface would mean empty ACLs - now we show mode ACLs"
248 chacl -l file1 | _acl_filter_id
249 chacl -l acldir | _acl_filter_id
250 chacl -l acldir/file2 | _acl_filter_id
252 #-------------------------------------------------------
255 echo "=== Recursive change ACL ==="
258 pushd root >/dev/null
259 # create an arbitrary little tree
260 for i in 1 2 3 4 5 6 7 8 9 0
267 chown -R 12345.54321 root
269 _runas -u 12345 -g 54321 -- chacl -r u::rwx,g::-w-,o::--x root
270 find root -print | sort | xargs chacl -l
272 _runas -u 12345 -g 54321 -- chacl -r u::---,g::---,o::--- root
273 find root -print | sort | xargs chacl -l
275 #-------------------------------------------------------
278 echo "=== Test out error messages for ACL text parsing ==="
279 echo "Note: Old interface gave more informative error msgs"
285 chacl u:rumpledumpleunknownuser file1
286 chacl u:rumpledumpleunknownuser: file1
287 chacl g:rumpledumpleunknowngrp file1
288 chacl g:rumpledumpleunknowngrp: file1
289 chacl o:user1:rwx file1
290 chacl m:user1:rwx file1