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
27 # This is a tools-level test intended to verify that cp(1) and mv(1)
28 # do the right thing with respect to ACLs. Run it as root using
31 # /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-nfs4.test
33 # You need to have three subdirectories, named nfs4, posix and none,
34 # with filesystems with NFSv4 ACLs, POSIX.1e ACLs and no ACLs enabled,
35 # respectively, mounted on them, in your current directory.
37 # WARNING: Creates files in unsafe way.
44 $ getfacl -nq nfs4/xxx
45 > owner@:rw-p--aARWcCos:-------:allow
46 > group@:r-----a-R-c--s:-------:allow
47 > everyone@:r-----a-R-c--s:-------:allow
50 $ getfacl -nq posix/xxx
55 # mv with POSIX.1e ACLs.
60 $ ls -l posix/xxx | cut -d' ' -f1
62 $ setfacl -m u:42:x,g:43:w posix/xxx
63 $ mv posix/xxx posix/yyy
64 $ getfacl -nq posix/yyy
71 $ ls -l posix/yyy | cut -d' ' -f1
74 # mv from POSIX.1e to none.
79 $ setfacl -m u:42:x,g:43:w posix/xxx
80 $ ls -l posix/xxx | cut -d' ' -f1
82 $ mv posix/xxx none/xxx
83 > mv: failed to set acl entries for none/xxx: Operation not supported
84 $ ls -l none/xxx | cut -d' ' -f1
87 # mv from POSIX.1e to NFSv4.
92 $ setfacl -m u:42:x,g:43:w posix/xxx
93 $ ls -l posix/xxx | cut -d' ' -f1
95 $ mv posix/yyy nfs4/xxx
96 > mv: failed to set acl entries for nfs4/xxx: Invalid argument
97 $ getfacl -nq nfs4/xxx
98 > owner@:-wxp----------:-------:deny
99 > owner@:r-----aARWcCos:-------:allow
100 > group@:rwxp--a-R-c--s:-------:allow
101 > everyone@:rw-p--a-R-c--s:-------:allow
102 $ ls -l nfs4/xxx | cut -d' ' -f1
105 # mv with NFSv4 ACLs.
109 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
110 $ mv nfs4/xxx nfs4/yyy
111 $ getfacl -nq nfs4/yyy
112 > user:42:--x-----------:-------:allow
113 > group:43:-w------------:-------:allow
114 > owner@:rw-p--aARWcCos:-------:allow
115 > group@:r-----a-R-c--s:-------:allow
116 > everyone@:r-----a-R-c--s:-------:allow
117 $ ls -l nfs4/yyy | cut -d' ' -f1
120 # mv from NFSv4 to POSIX.1e without any ACLs.
125 $ ls -l nfs4/xxx | cut -d' ' -f1
127 $ mv nfs4/xxx posix/xxx
128 $ ls -l posix/xxx | cut -d' ' -f1
131 # mv from NFSv4 to none.
136 $ ls -l nfs4/xxx | cut -d' ' -f1
138 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
139 $ ls -l nfs4/xxx | cut -d' ' -f1
141 $ mv nfs4/xxx none/xxx
142 > mv: failed to set acl entries for none/xxx: Operation not supported
143 $ ls -l none/xxx | cut -d' ' -f1
146 # mv from NFSv4 to POSIX.1e.
151 $ ls -l nfs4/xxx | cut -d' ' -f1
153 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
154 $ ls -l nfs4/xxx | cut -d' ' -f1
156 $ mv nfs4/xxx posix/xxx
157 > mv: failed to set acl entries for posix/xxx: Invalid argument
158 $ ls -l posix/xxx | cut -d' ' -f1
161 # cp with POSIX.1e ACLs.
165 $ setfacl -m u:42:x,g:43:w posix/xxx
166 $ ls -l posix/xxx | cut -d' ' -f1
168 $ cp posix/xxx posix/yyy
169 $ ls -l posix/yyy | cut -d' ' -f1
172 # cp -p with POSIX.1e ACLs.
176 $ setfacl -m u:42:x,g:43:w posix/xxx
177 $ getfacl -nq posix/xxx
184 $ ls -l posix/xxx | cut -d' ' -f1
186 $ cp -p posix/xxx posix/yyy
187 $ getfacl -nq posix/yyy
194 $ ls -l posix/yyy | cut -d' ' -f1
197 # cp from POSIX.1e to none.
201 $ setfacl -m u:42:x,g:43:w posix/xxx
202 $ ls -l posix/xxx | cut -d' ' -f1
204 $ cp posix/xxx none/xxx
205 $ ls -l none/xxx | cut -d' ' -f1
208 # cp -p from POSIX.1e to none.
212 $ setfacl -m u:42:x,g:43:w posix/xxx
213 $ ls -l posix/xxx | cut -d' ' -f1
215 $ cp -p posix/xxx none/xxx
216 > cp: failed to set acl entries for none/xxx: Operation not supported
217 $ ls -l none/xxx | cut -d' ' -f1
220 # cp from POSIX.1e to NFSv4.
224 $ setfacl -m u:42:x,g:43:w posix/xxx
225 $ ls -l posix/xxx | cut -d' ' -f1
227 $ cp posix/xxx nfs4/xxx
228 $ ls -l nfs4/xxx | cut -d' ' -f1
231 # cp -p from POSIX.1e to NFSv4.
235 $ setfacl -m u:42:x,g:43:w posix/xxx
236 $ ls -l posix/xxx | cut -d' ' -f1
238 $ cp -p posix/xxx nfs4/xxx
239 > cp: failed to set acl entries for nfs4/xxx: Invalid argument
240 $ ls -l nfs4/xxx | cut -d' ' -f1
243 # cp with NFSv4 ACLs.
248 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
249 $ ls -l nfs4/xxx | cut -d' ' -f1
251 $ cp nfs4/xxx nfs4/yyy
252 $ ls -l nfs4/yyy | cut -d' ' -f1
255 # cp -p with NFSv4 ACLs.
260 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
261 $ cp -p nfs4/xxx nfs4/yyy
262 $ getfacl -nq nfs4/yyy
263 > user:42:--x-----------:-------:allow
264 > group:43:-w------------:-------:allow
265 > owner@:--x-----------:-------:allow
266 > owner@:-w-p----------:-------:deny
267 > group@:-wxp----------:-------:deny
268 > owner@:r-x---aARWcCos:-------:allow
269 > group@:r-----a-R-c--s:-------:allow
270 > everyone@:-wxp--a-R-c--s:-------:allow
271 $ ls -l nfs4/yyy | cut -d' ' -f1
274 # cp from NFSv4 to none.
279 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
280 $ ls -l nfs4/xxx | cut -d' ' -f1
282 $ cp nfs4/xxx none/xxx
283 $ ls -l none/xxx | cut -d' ' -f1
286 # cp -p from NFSv4 to none.
291 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
292 $ ls -l nfs4/xxx | cut -d' ' -f1
294 $ cp -p nfs4/xxx none/xxx
295 > cp: failed to set acl entries for none/xxx: Operation not supported
296 $ ls -l none/xxx | cut -d' ' -f1
299 # cp from NFSv4 to POSIX.1e.
304 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
305 $ ls -l nfs4/xxx | cut -d' ' -f1
307 $ cp nfs4/xxx posix/xxx
308 $ ls -l posix/xxx | cut -d' ' -f1
311 # cp -p from NFSv4 to POSIX.1e.
316 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
317 $ ls -l nfs4/xxx | cut -d' ' -f1
319 $ cp -p nfs4/xxx posix/xxx
320 > cp: failed to set acl entries for posix/xxx: Invalid argument
321 $ ls -l posix/xxx | cut -d' ' -f1