]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/acl/tools-crossfs.test
zfs: merge openzfs/zfs@41e55b476
[FreeBSD/FreeBSD.git] / tests / sys / acl / tools-crossfs.test
1 # Copyright (c) 2008, 2009 Edward Tomasz NapieraƂa <trasz@FreeBSD.org>
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
5 # are met:
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.
11 #
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
22 # SUCH DAMAGE.
23 #
24 #
25
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
28 # ACL-enabled kernel:
29 #
30 # /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-nfs4.test
31 #
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.
35 #
36 # WARNING: Creates files in unsafe way.
37
38 $ whoami
39 > root
40 $ umask 022
41
42 $ touch nfs4/xxx
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
47
48 $ touch posix/xxx
49 $ getfacl -nq posix/xxx
50 > user::rw-
51 > group::r--
52 > other::r--
53
54 # mv with POSIX.1e ACLs.
55 $ rm -f posix/xxx
56 $ rm -f posix/yyy
57 $ touch posix/xxx
58 $ chmod 456 posix/xxx
59 $ ls -l posix/xxx | cut -d' ' -f1
60 > -r--r-xrw-
61 $ setfacl -m u:42:x,g:43:w posix/xxx
62 $ mv posix/xxx posix/yyy
63 $ getfacl -nq posix/yyy
64 > user::r--
65 > user:42:--x
66 > group::r-x
67 > group:43:-w-
68 > mask::rwx
69 > other::rw-
70 $ ls -l posix/yyy | cut -d' ' -f1
71 > -r--rwxrw-+
72
73 # mv from POSIX.1e to none.
74 $ rm -f posix/xxx
75 $ rm -f none/xxx
76 $ touch posix/xxx
77 $ chmod 345 posix/xxx
78 $ setfacl -m u:42:x,g:43:w posix/xxx
79 $ ls -l posix/xxx | cut -d' ' -f1
80 > --wxrwxr-x+
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
84 > --wxrwxr-x
85
86 # mv from POSIX.1e to NFSv4.
87 $ rm -f posix/xxx
88 $ rm -f nfs4/xxx
89 $ touch posix/xxx
90 $ chmod 456 posix/xxx
91 $ setfacl -m u:42:x,g:43:w posix/xxx
92 $ ls -l posix/xxx | cut -d' ' -f1
93 > -r--rwxrw-+
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
102 > -r--rwxrw-
103
104 # mv with NFSv4 ACLs.
105 $ rm -f nfs4/xxx
106 $ rm -f nfs4/yyy
107 $ touch nfs4/xxx
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
117 > -rw-r--r--+
118
119 # mv from NFSv4 to POSIX.1e without any ACLs.
120 $ rm -f nfs4/xxx
121 $ rm -f posix/xxx
122 $ touch nfs4/xxx
123 $ chmod 456 nfs4/xxx
124 $ ls -l nfs4/xxx | cut -d' ' -f1
125 > -r--r-xrw-
126 $ mv nfs4/xxx posix/xxx
127 $ ls -l posix/xxx | cut -d' ' -f1
128 > -r--r-xrw-
129
130 # mv from NFSv4 to none.
131 $ rm -f nfs4/xxx
132 $ rm -f none/xxx
133 $ touch nfs4/xxx
134 $ chmod 345 nfs4/xxx
135 $ ls -l nfs4/xxx | cut -d' ' -f1
136 > --wxr--r-x
137 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
138 $ ls -l nfs4/xxx | cut -d' ' -f1
139 > --wxr--r-x+
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
143 > --wxr--r-x
144
145 # mv from NFSv4 to POSIX.1e.
146 $ rm -f nfs4/xxx
147 $ rm -f posix/xxx
148 $ touch nfs4/xxx
149 $ chmod 345 nfs4/xxx
150 $ ls -l nfs4/xxx | cut -d' ' -f1
151 > --wxr--r-x
152 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
153 $ ls -l nfs4/xxx | cut -d' ' -f1
154 > --wxr--r-x+
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
158 > --wxr--r-x
159
160 # cp with POSIX.1e ACLs.
161 $ rm -f posix/xxx
162 $ rm -f posix/yyy
163 $ touch posix/xxx
164 $ setfacl -m u:42:x,g:43:w posix/xxx
165 $ ls -l posix/xxx | cut -d' ' -f1
166 > -rw-rwxr--+
167 $ cp posix/xxx posix/yyy
168 $ ls -l posix/yyy | cut -d' ' -f1
169 > -rw-r-xr--
170
171 # cp -p with POSIX.1e ACLs.
172 $ rm -f posix/xxx
173 $ rm -f posix/yyy
174 $ touch posix/xxx
175 $ setfacl -m u:42:x,g:43:w posix/xxx
176 $ getfacl -nq posix/xxx
177 > user::rw-
178 > user:42:--x
179 > group::r--
180 > group:43:-w-
181 > mask::rwx
182 > other::r--
183 $ ls -l posix/xxx | cut -d' ' -f1
184 > -rw-rwxr--+
185 $ cp -p posix/xxx posix/yyy
186 $ getfacl -nq posix/yyy
187 > user::rw-
188 > user:42:--x
189 > group::r--
190 > group:43:-w-
191 > mask::rwx
192 > other::r--
193 $ ls -l posix/yyy | cut -d' ' -f1
194 > -rw-rwxr--+
195
196 # cp from POSIX.1e to none.
197 $ rm -f posix/xxx
198 $ rm -f none/xxx
199 $ touch posix/xxx
200 $ setfacl -m u:42:x,g:43:w posix/xxx
201 $ ls -l posix/xxx | cut -d' ' -f1
202 > -rw-rwxr--+
203 $ cp posix/xxx none/xxx
204 $ ls -l none/xxx | cut -d' ' -f1
205 > -rw-r-xr--
206
207 # cp -p from POSIX.1e to none.
208 $ rm -f posix/xxx
209 $ rm -f none/xxx
210 $ touch posix/xxx
211 $ setfacl -m u:42:x,g:43:w posix/xxx
212 $ ls -l posix/xxx | cut -d' ' -f1
213 > -rw-rwxr--+
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
217 > -rw-rwxr--
218
219 # cp from POSIX.1e to NFSv4.
220 $ rm -f posix/xxx
221 $ rm -f nfs4/xxx
222 $ touch posix/xxx
223 $ setfacl -m u:42:x,g:43:w posix/xxx
224 $ ls -l posix/xxx | cut -d' ' -f1
225 > -rw-rwxr--+
226 $ cp posix/xxx nfs4/xxx
227 $ ls -l nfs4/xxx | cut -d' ' -f1
228 > -rw-r-xr--
229
230 # cp -p from POSIX.1e to NFSv4.
231 $ rm -f posix/xxx
232 $ rm -f nfs4/xxx
233 $ touch posix/xxx
234 $ setfacl -m u:42:x,g:43:w posix/xxx
235 $ ls -l posix/xxx | cut -d' ' -f1
236 > -rw-rwxr--+
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
240 > -rw-rwxr--
241
242 # cp with NFSv4 ACLs.
243 $ rm -f nfs4/xxx
244 $ rm -f nfs4/yyy
245 $ touch nfs4/xxx
246 $ chmod 543 nfs4/xxx
247 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
248 $ ls -l nfs4/xxx | cut -d' ' -f1
249 > -r-xr---wx+
250 $ cp nfs4/xxx nfs4/yyy
251 $ ls -l nfs4/yyy | cut -d' ' -f1
252 > -r-xr----x
253
254 # cp -p with NFSv4 ACLs.
255 $ rm -f nfs4/xxx
256 $ rm -f nfs4/yyy
257 $ touch nfs4/xxx
258 $ chmod 543 nfs4/xxx
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
271 > -r-xr---wx+
272
273 # cp from NFSv4 to none.
274 $ rm -f nfs4/xxx
275 $ rm -f none/xxx
276 $ touch nfs4/xxx
277 $ chmod 543 nfs4/xxx
278 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
279 $ ls -l nfs4/xxx | cut -d' ' -f1
280 > -r-xr---wx+
281 $ cp nfs4/xxx none/xxx
282 $ ls -l none/xxx | cut -d' ' -f1
283 > -r-xr----x
284
285 # cp -p from NFSv4 to none.
286 $ rm -f nfs4/xxx
287 $ rm -f none/xxx
288 $ touch nfs4/xxx
289 $ chmod 543 nfs4/xxx
290 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
291 $ ls -l nfs4/xxx | cut -d' ' -f1
292 > -r-xr---wx+
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
296 > -r-xr---wx
297
298 # cp from NFSv4 to POSIX.1e.
299 $ rm -f nfs4/xxx
300 $ rm -f posix/xxx
301 $ touch nfs4/xxx
302 $ chmod 543 nfs4/xxx
303 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
304 $ ls -l nfs4/xxx | cut -d' ' -f1
305 > -r-xr---wx+
306 $ cp nfs4/xxx posix/xxx
307 $ ls -l posix/xxx | cut -d' ' -f1
308 > -r-xr----x
309
310 # cp -p from NFSv4 to POSIX.1e.
311 $ rm -f nfs4/xxx
312 $ rm -f posix/xxx
313 $ touch nfs4/xxx
314 $ chmod 543 nfs4/xxx
315 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
316 $ ls -l nfs4/xxx | cut -d' ' -f1
317 > -r-xr---wx+
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
321 > -r-xr---wx