6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
30 status=1 # FAILure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
33 # get standard environment, filters and checks
42 [ -n "$TEST_DIR" ] && rm -rf $TEST_DIR/$seq.dir1
46 # minimal access ACL has ACEs: USER_OBJ, GROUP_OBJ, OTHER_OBJ
47 # This is set with chacl(1) and can be changed by chmod(1).
49 # Test that this is being set for ACL and for std unix permissions
50 # Test that we can get back the same ACL.
51 # Test std permissions for rwx.
54 # Test out default ACLs and that the ACL is being PASSed
55 # onto the children of the dir.
58 # Test out access check for extended ACLs.
59 # -> 3 extra ACEs: MASK, GROUP, USER
60 # -> the GROUP compares with egid of process _and_ the supplementary
61 # groups (as found in /etc/group)
63 # Test that mask works for USER, GROUP, GROUP_OBJ
64 # Test that the ACE type priority is working
65 # -> this would be done by simultaneously matching on ACEs
66 # -> interesting if it allows user to specify ACEs in any order
69 # real QA test starts here
86 echo "QA output created by $seq"
88 echo "=== Test minimal ACE ==="
91 # Note: as this is a shell script,
92 # will need read and execute permission set
93 # in order to execute it.
97 echo "Test was executed"
102 chown $acl1.$acl2 file1
106 echo "--- Test get and set of ACL ---"
107 echo "Note: Old interface gave an empty ACL - now output an ACL"
108 chacl -l file1 | _acl_filter_id
109 echo "Try using single colon separator"
110 echo "Note: Old interface FAILed because of single colon - new one allows it"
111 chacl u::r--,g::rwx,o:rw- file1 2>&1
112 echo "Expect to PASS"
113 chacl u::r--,g::rwx,o::rw- file1 2>&1
114 chacl -l file1 | _acl_filter_id
117 echo "--- Test sync of ACL with std permissions ---"
121 chacl -l file1 | _acl_filter_id
124 echo "--- Test owner permissions ---"
125 chacl u::r-x,g::---,o::--- file1 2>&1
126 chacl -l file1 | _acl_filter_id
128 echo "Expect to PASS"
129 _runas -u $acl1 -g $acl1 ./file1 2>&1
130 echo "Expect to FAIL"
131 _runas -u $acl2 -g $acl2 ./file1 2>&1
134 echo "--- Test group permissions ---"
135 chacl u::---,g::r-x,o::--- file1 2>&1
136 chacl -l file1 | _acl_filter_id
137 echo "Expect to FAIL - acl1 is owner"
138 _runas -u $acl1 -g $acl1 ./file1 2>&1
139 echo "Expect to PASS - acl2 matches group"
140 _runas -u $acl2 -g $acl2 ./file1 2>&1
141 echo "Expect to PASS - acl2 matches sup group"
142 _runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
143 echo "Expect to FAIL - acl3 is not in group"
144 _runas -u $acl3 -g $acl3 ./file1 2>&1
147 echo "--- Test other permissions ---"
148 chacl u::---,g::---,o::r-x file1 2>&1
149 chacl -l file1 | _acl_filter_id
150 echo "Expect to FAIL - acl1 is owner"
151 _runas -u $acl1 -g $acl1 ./file1 2>&1
152 echo "Expect to FAIL - acl2 is in group"
153 _runas -u $acl2 -g $acl2 ./file1 2>&1
154 echo "Expect to FAIL - acl2 is in sup. group"
155 _runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
156 echo "Expect to PASS - acl3 is not owner or in group"
157 _runas -u $acl3 -g $acl3 ./file1 2>&1
159 #-------------------------------------------------------
162 echo "=== Test Extended ACLs ==="
165 echo "--- Test adding a USER ACE ---"
166 echo "Expect to FAIL as no MASK provided"
167 chacl u::---,g::---,o::---,u:$acl2:r-x file1 2>&1 | _acl_filter_id
168 echo "Ensure that ACL has not been changed"
169 chacl -l file1 | _acl_filter_id
170 echo "Expect to PASS - USER ACE matches user"
171 chacl u::---,g::---,o::---,u:$acl2:r-x,m::rwx file1 2>&1
172 chacl -l file1 | _acl_filter_id
173 _runas -u $acl2 -g $acl2 ./file1 2>&1
174 echo "Expect to FAIL - USER ACE does not match user"
175 _runas -u $acl3 -g $acl3 ./file1 2>&1
178 echo "--- Test adding a GROUP ACE ---"
179 echo "Expect to FAIL as no MASK provided"
180 chacl u::---,g::---,o::---,g:$acl2:r-x file1 2>&1 | _acl_filter_id
181 echo "Ensure that ACL has not been changed"
182 chacl -l file1 | _acl_filter_id
183 chacl u::---,g::---,o::---,g:$acl2:r-x,m::rwx file1 2>&1
184 chacl -l file1 | _acl_filter_id
185 echo "Expect to PASS - GROUP ACE matches group"
186 _runas -u $acl2 -g $acl2 ./file1 2>&1
187 echo "Expect to PASS - GROUP ACE matches sup group"
188 _runas -u $acl2 -g $acl1 -s $acl2 ./file1 2>&1
189 echo "Expect to FAIL - GROUP ACE does not match group"
190 _runas -u $acl3 -g $acl3 ./file1 2>&1
192 #-------------------------------------------------------
195 echo "--- Test MASK ---"
198 chacl u::---,g::---,o::---,g:$acl2:r-x,m::-w- file1 2>&1
199 chacl -l file1 | _acl_filter_id
200 echo "Expect to FAIL as MASK prohibits execution"
201 _runas -u $acl2 -g $acl2 ./file1 2>&1
204 chacl u::---,g::---,o::---,u:$acl2:r-x,m::-w- file1 2>&1
205 echo "Expect to FAIL as MASK prohibits execution"
206 _runas -u $acl2 -g $acl2 ./file1 2>&1
209 chacl u::---,g::---,o::---,u:$acl2:r-x,m::r-x file1 2>&1
210 echo "Expect to PASS as MASK allows execution"
211 _runas -u $acl2 -g $acl2 ./file1 2>&1
213 #-------------------------------------------------------
216 echo "--- Test ACE priority ---"
218 chacl o::rwx,g::rwx,u:$acl1:rwx,u::---,m::rwx file1 2>&1
219 echo "Expect to FAIL as should match on owner"
220 _runas -u $acl1 -g $acl2 ./file1 2>&1
222 chacl o::---,g::---,u:$acl2:rwx,u::---,m::rwx file1 2>&1
223 echo "Expect to PASS as should match on user"
224 _runas -u $acl2 -g $acl2 ./file1 2>&1
226 #-------------------------------------------------------
229 echo "=== Test can read ACLs without access permissions ==="
230 # This was a bug in kernel code where syscred wasn't being used
231 # to override the capabilities
232 chacl o::---,g::---,u::--- file1 2>&1
233 chacl -l file1 | _acl_filter_id
235 #-------------------------------------------------------
238 echo "=== Test Default ACLs ==="
239 # make test clearer by testing with and without umask
243 chacl -b "u::rwx,g::rwx,o::rwx" "u::r-x,g::r--,o::---" acldir 2>&1
244 chacl -l acldir | _acl_filter_id
249 chacl -l file2 | _acl_filter_id
251 #ensure that umask is not having an effect
256 chacl -l file3 | _acl_filter_id
261 #-------------------------------------------------------
264 echo "=== Removing ACLs ==="
265 chacl -l file1 | _acl_filter_id
266 chacl -l acldir | _acl_filter_id
267 chacl -l acldir/file2 | _acl_filter_id
268 echo "Remove ACLs..."
271 chacl -R acldir/file2
272 echo "Note: Old interface would mean empty ACLs - now we show mode ACLs"
273 chacl -l file1 | _acl_filter_id
274 chacl -l acldir | _acl_filter_id
275 chacl -l acldir/file2 | _acl_filter_id
277 #-------------------------------------------------------
280 echo "=== Recursive change ACL ==="
283 pushd root >/dev/null
284 # create an arbitrary little tree
285 for i in 1 2 3 4 5 6 7 8 9 0
292 chown -R 12345.54321 root
294 _runas -u 12345 -g 54321 -- chacl -r u::rwx,g::-w-,o::--x root
295 find root -print | xargs chacl -l
297 _runas -u 12345 -g 54321 -- chacl -r u::---,g::---,o::--- root
298 find root -print | xargs chacl -l
300 #-------------------------------------------------------
303 echo "=== Test out error messages for ACL text parsing ==="
304 echo "Note: Old interface gave more informative error msgs"
310 chacl u:rumpledumpleunknownuser file1
311 chacl u:rumpledumpleunknownuser: file1
312 chacl g:rumpledumpleunknowngrp file1
313 chacl g:rumpledumpleunknowngrp: file1
314 chacl o:user1:rwx file1
315 chacl m:user1:rwx file1