1 # Copyright (c) 2008, 2009 Edward Tomasz NapieraĆa <trasz@FreeBSD.org>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
13 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # This is a tools-level test intended to verify that cp(1) and mv(1)
29 # do the right thing with respect to ACLs. Run it as root using
32 # /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-nfs4.test
34 # You need to have three subdirectories, named nfs4, posix and none,
35 # with filesystems with NFSv4 ACLs, POSIX.1e ACLs and no ACLs enabled,
36 # respectively, mounted on them, in your current directory.
38 # WARNING: Creates files in unsafe way.
45 $ getfacl -nq nfs4/xxx
46 > owner@:rw-p--aARWcCos:------:allow
47 > group@:r-----a-R-c--s:------:allow
48 > everyone@:r-----a-R-c--s:------:allow
51 $ getfacl -nq posix/xxx
56 # mv with POSIX.1e ACLs.
61 $ ls -l posix/xxx | cut -d' ' -f1
63 $ setfacl -m u:42:x,g:43:w posix/xxx
64 $ mv posix/xxx posix/yyy
65 $ getfacl -nq posix/yyy
72 $ ls -l posix/yyy | cut -d' ' -f1
75 # mv from POSIX.1e to none.
80 $ setfacl -m u:42:x,g:43:w posix/xxx
81 $ ls -l posix/xxx | cut -d' ' -f1
83 $ mv posix/xxx none/xxx
84 > mv: failed to set acl entries for none/xxx: Operation not supported
85 $ ls -l none/xxx | cut -d' ' -f1
88 # mv from POSIX.1e to NFSv4.
93 $ setfacl -m u:42:x,g:43:w posix/xxx
94 $ ls -l posix/xxx | cut -d' ' -f1
96 $ mv posix/yyy nfs4/xxx
97 > mv: failed to set acl entries for nfs4/xxx: Invalid argument
98 $ getfacl -nq nfs4/xxx
99 > owner@:-wxp----------:------:deny
100 > owner@:r-----aARWcCos:------:allow
101 > group@:rwxp--a-R-c--s:------:allow
102 > everyone@:rw-p--a-R-c--s:------:allow
103 $ ls -l nfs4/xxx | cut -d' ' -f1
106 # mv with NFSv4 ACLs.
110 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
111 $ mv nfs4/xxx nfs4/yyy
112 $ getfacl -nq nfs4/yyy
113 > user:42:--x-----------:------:allow
114 > group:43:-w------------:------:allow
115 > owner@:rw-p--aARWcCos:------:allow
116 > group@:r-----a-R-c--s:------:allow
117 > everyone@:r-----a-R-c--s:------:allow
118 $ ls -l nfs4/yyy | cut -d' ' -f1
121 # mv from NFSv4 to POSIX.1e without any ACLs.
126 $ ls -l nfs4/xxx | cut -d' ' -f1
128 $ mv nfs4/xxx posix/xxx
129 $ ls -l posix/xxx | cut -d' ' -f1
132 # mv from NFSv4 to none.
137 $ ls -l nfs4/xxx | cut -d' ' -f1
139 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
140 $ ls -l nfs4/xxx | cut -d' ' -f1
142 $ mv nfs4/xxx none/xxx
143 > mv: failed to set acl entries for none/xxx: Operation not supported
144 $ ls -l none/xxx | cut -d' ' -f1
147 # mv from NFSv4 to POSIX.1e.
152 $ ls -l nfs4/xxx | cut -d' ' -f1
154 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
155 $ ls -l nfs4/xxx | cut -d' ' -f1
157 $ mv nfs4/xxx posix/xxx
158 > mv: failed to set acl entries for posix/xxx: Invalid argument
159 $ ls -l posix/xxx | cut -d' ' -f1
162 # cp with POSIX.1e ACLs.
166 $ setfacl -m u:42:x,g:43:w posix/xxx
167 $ ls -l posix/xxx | cut -d' ' -f1
169 $ cp posix/xxx posix/yyy
170 $ ls -l posix/yyy | cut -d' ' -f1
173 # cp -p with POSIX.1e ACLs.
177 $ setfacl -m u:42:x,g:43:w posix/xxx
178 $ getfacl -nq posix/xxx
185 $ ls -l posix/xxx | cut -d' ' -f1
187 $ cp -p posix/xxx posix/yyy
188 $ getfacl -nq posix/yyy
195 $ ls -l posix/yyy | cut -d' ' -f1
198 # cp from POSIX.1e to none.
202 $ setfacl -m u:42:x,g:43:w posix/xxx
203 $ ls -l posix/xxx | cut -d' ' -f1
205 $ cp posix/xxx none/xxx
206 $ ls -l none/xxx | cut -d' ' -f1
209 # cp -p from POSIX.1e to none.
213 $ setfacl -m u:42:x,g:43:w posix/xxx
214 $ ls -l posix/xxx | cut -d' ' -f1
216 $ cp -p posix/xxx none/xxx
217 > cp: failed to set acl entries for none/xxx: Operation not supported
218 $ ls -l none/xxx | cut -d' ' -f1
221 # cp from POSIX.1e to NFSv4.
225 $ setfacl -m u:42:x,g:43:w posix/xxx
226 $ ls -l posix/xxx | cut -d' ' -f1
228 $ cp posix/xxx nfs4/xxx
229 $ ls -l nfs4/xxx | cut -d' ' -f1
232 # cp -p from POSIX.1e to NFSv4.
236 $ setfacl -m u:42:x,g:43:w posix/xxx
237 $ ls -l posix/xxx | cut -d' ' -f1
239 $ cp -p posix/xxx nfs4/xxx
240 > cp: failed to set acl entries for nfs4/xxx: Invalid argument
241 $ ls -l nfs4/xxx | cut -d' ' -f1
244 # cp with NFSv4 ACLs.
249 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
250 $ ls -l nfs4/xxx | cut -d' ' -f1
252 $ cp nfs4/xxx nfs4/yyy
253 $ ls -l nfs4/yyy | cut -d' ' -f1
256 # cp -p with NFSv4 ACLs.
261 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
262 $ cp -p nfs4/xxx nfs4/yyy
263 $ getfacl -nq nfs4/yyy
264 > user:42:--x-----------:------:allow
265 > group:43:-w------------:------:allow
266 > owner@:--x-----------:------:allow
267 > owner@:-w-p----------:------:deny
268 > group@:-wxp----------:------:deny
269 > owner@:r-x---aARWcCos:------:allow
270 > group@:r-----a-R-c--s:------:allow
271 > everyone@:-wxp--a-R-c--s:------:allow
272 $ ls -l nfs4/yyy | cut -d' ' -f1
275 # cp from NFSv4 to none.
280 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
281 $ ls -l nfs4/xxx | cut -d' ' -f1
283 $ cp nfs4/xxx none/xxx
284 $ ls -l none/xxx | cut -d' ' -f1
287 # cp -p from NFSv4 to none.
292 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
293 $ ls -l nfs4/xxx | cut -d' ' -f1
295 $ cp -p nfs4/xxx none/xxx
296 > cp: failed to set acl entries for none/xxx: Operation not supported
297 $ ls -l none/xxx | cut -d' ' -f1
300 # cp from NFSv4 to POSIX.1e.
305 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
306 $ ls -l nfs4/xxx | cut -d' ' -f1
308 $ cp nfs4/xxx posix/xxx
309 $ ls -l posix/xxx | cut -d' ' -f1
312 # cp -p from NFSv4 to POSIX.1e.
317 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
318 $ ls -l nfs4/xxx | cut -d' ' -f1
320 $ cp -p nfs4/xxx posix/xxx
321 > cp: failed to set acl entries for posix/xxx: Invalid argument
322 $ ls -l posix/xxx | cut -d' ' -f1