1 # Copyright (c) 2008, 2009 Edward Tomasz NapieraĆa <trasz@FreeBSD.org>
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
12 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 # This is a tools-level test intended to verify that cp(1) and mv(1)
27 # do the right thing with respect to ACLs. Run it as root using
30 # /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-nfs4.test
32 # You need to have three subdirectories, named nfs4, posix and none,
33 # with filesystems with NFSv4 ACLs, POSIX.1e ACLs and no ACLs enabled,
34 # respectively, mounted on them, in your current directory.
36 # WARNING: Creates files in unsafe way.
43 $ getfacl -nq nfs4/xxx
44 > owner@:rw-p--aARWcCos:-------:allow
45 > group@:r-----a-R-c--s:-------:allow
46 > everyone@:r-----a-R-c--s:-------:allow
49 $ getfacl -nq posix/xxx
54 # mv with POSIX.1e ACLs.
59 $ ls -l posix/xxx | cut -d' ' -f1
61 $ setfacl -m u:42:x,g:43:w posix/xxx
62 $ mv posix/xxx posix/yyy
63 $ getfacl -nq posix/yyy
70 $ ls -l posix/yyy | cut -d' ' -f1
73 # mv from POSIX.1e to none.
78 $ setfacl -m u:42:x,g:43:w posix/xxx
79 $ ls -l posix/xxx | cut -d' ' -f1
81 $ mv posix/xxx none/xxx
82 > mv: failed to set acl entries for none/xxx: Operation not supported
83 $ ls -l none/xxx | cut -d' ' -f1
86 # mv from POSIX.1e to NFSv4.
91 $ setfacl -m u:42:x,g:43:w posix/xxx
92 $ ls -l posix/xxx | cut -d' ' -f1
94 $ mv posix/yyy nfs4/xxx
95 > mv: failed to set acl entries for nfs4/xxx: Invalid argument
96 $ getfacl -nq nfs4/xxx
97 > owner@:-wxp----------:-------:deny
98 > owner@:r-----aARWcCos:-------:allow
99 > group@:rwxp--a-R-c--s:-------:allow
100 > everyone@:rw-p--a-R-c--s:-------:allow
101 $ ls -l nfs4/xxx | cut -d' ' -f1
104 # mv with NFSv4 ACLs.
108 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
109 $ mv nfs4/xxx nfs4/yyy
110 $ getfacl -nq nfs4/yyy
111 > user:42:--x-----------:-------:allow
112 > group:43:-w------------:-------:allow
113 > owner@:rw-p--aARWcCos:-------:allow
114 > group@:r-----a-R-c--s:-------:allow
115 > everyone@:r-----a-R-c--s:-------:allow
116 $ ls -l nfs4/yyy | cut -d' ' -f1
119 # mv from NFSv4 to POSIX.1e without any ACLs.
124 $ ls -l nfs4/xxx | cut -d' ' -f1
126 $ mv nfs4/xxx posix/xxx
127 $ ls -l posix/xxx | cut -d' ' -f1
130 # mv from NFSv4 to none.
135 $ ls -l nfs4/xxx | cut -d' ' -f1
137 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
138 $ ls -l nfs4/xxx | cut -d' ' -f1
140 $ mv nfs4/xxx none/xxx
141 > mv: failed to set acl entries for none/xxx: Operation not supported
142 $ ls -l none/xxx | cut -d' ' -f1
145 # mv from NFSv4 to POSIX.1e.
150 $ ls -l nfs4/xxx | cut -d' ' -f1
152 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
153 $ ls -l nfs4/xxx | cut -d' ' -f1
155 $ mv nfs4/xxx posix/xxx
156 > mv: failed to set acl entries for posix/xxx: Invalid argument
157 $ ls -l posix/xxx | cut -d' ' -f1
160 # cp with POSIX.1e ACLs.
164 $ setfacl -m u:42:x,g:43:w posix/xxx
165 $ ls -l posix/xxx | cut -d' ' -f1
167 $ cp posix/xxx posix/yyy
168 $ ls -l posix/yyy | cut -d' ' -f1
171 # cp -p with POSIX.1e ACLs.
175 $ setfacl -m u:42:x,g:43:w posix/xxx
176 $ getfacl -nq posix/xxx
183 $ ls -l posix/xxx | cut -d' ' -f1
185 $ cp -p posix/xxx posix/yyy
186 $ getfacl -nq posix/yyy
193 $ ls -l posix/yyy | cut -d' ' -f1
196 # cp from POSIX.1e to none.
200 $ setfacl -m u:42:x,g:43:w posix/xxx
201 $ ls -l posix/xxx | cut -d' ' -f1
203 $ cp posix/xxx none/xxx
204 $ ls -l none/xxx | cut -d' ' -f1
207 # cp -p from POSIX.1e to none.
211 $ setfacl -m u:42:x,g:43:w posix/xxx
212 $ ls -l posix/xxx | cut -d' ' -f1
214 $ cp -p posix/xxx none/xxx
215 > cp: failed to set acl entries for none/xxx: Operation not supported
216 $ ls -l none/xxx | cut -d' ' -f1
219 # cp from POSIX.1e to NFSv4.
223 $ setfacl -m u:42:x,g:43:w posix/xxx
224 $ ls -l posix/xxx | cut -d' ' -f1
226 $ cp posix/xxx nfs4/xxx
227 $ ls -l nfs4/xxx | cut -d' ' -f1
230 # cp -p from POSIX.1e to NFSv4.
234 $ setfacl -m u:42:x,g:43:w posix/xxx
235 $ ls -l posix/xxx | cut -d' ' -f1
237 $ cp -p posix/xxx nfs4/xxx
238 > cp: failed to set acl entries for nfs4/xxx: Invalid argument
239 $ ls -l nfs4/xxx | cut -d' ' -f1
242 # cp with NFSv4 ACLs.
247 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
248 $ ls -l nfs4/xxx | cut -d' ' -f1
250 $ cp nfs4/xxx nfs4/yyy
251 $ ls -l nfs4/yyy | cut -d' ' -f1
254 # cp -p with NFSv4 ACLs.
259 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
260 $ cp -p nfs4/xxx nfs4/yyy
261 $ getfacl -nq nfs4/yyy
262 > user:42:--x-----------:-------:allow
263 > group:43:-w------------:-------:allow
264 > owner@:--x-----------:-------:allow
265 > owner@:-w-p----------:-------:deny
266 > group@:-wxp----------:-------:deny
267 > owner@:r-x---aARWcCos:-------:allow
268 > group@:r-----a-R-c--s:-------:allow
269 > everyone@:-wxp--a-R-c--s:-------:allow
270 $ ls -l nfs4/yyy | cut -d' ' -f1
273 # cp from NFSv4 to none.
278 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
279 $ ls -l nfs4/xxx | cut -d' ' -f1
281 $ cp nfs4/xxx none/xxx
282 $ ls -l none/xxx | cut -d' ' -f1
285 # cp -p from NFSv4 to none.
290 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
291 $ ls -l nfs4/xxx | cut -d' ' -f1
293 $ cp -p nfs4/xxx none/xxx
294 > cp: failed to set acl entries for none/xxx: Operation not supported
295 $ ls -l none/xxx | cut -d' ' -f1
298 # cp from NFSv4 to POSIX.1e.
303 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
304 $ ls -l nfs4/xxx | cut -d' ' -f1
306 $ cp nfs4/xxx posix/xxx
307 $ ls -l posix/xxx | cut -d' ' -f1
310 # cp -p from NFSv4 to POSIX.1e.
315 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
316 $ ls -l nfs4/xxx | cut -d' ' -f1
318 $ cp -p nfs4/xxx posix/xxx
319 > cp: failed to set acl entries for posix/xxx: Invalid argument
320 $ ls -l posix/xxx | cut -d' ' -f1