]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - tools/regression/acltools/tools-crossfs.test
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / tools / regression / acltools / tools-crossfs.test
1 # Copyright (c) 2008, 2009 Edward Tomasz NapieraƂa <trasz@FreeBSD.org>
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
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.
12 #
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
23 # SUCH DAMAGE.
24 #
25 # $FreeBSD$
26 #
27
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
30 # ACL-enabled kernel:
31 #
32 # /usr/src/tools/regression/acltools/run /usr/src/tools/regression/acltools/tools-nfs4.test
33 #
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.
37 #
38 # WARNING: Creates files in unsafe way.
39
40 $ whoami
41 > root
42 $ umask 022
43
44 $ touch nfs4/xxx
45 $ getfacl -nq nfs4/xxx
46 >             owner@:--x-----------:------:deny
47 >             owner@:rw-p---A-W-Co-:------:allow
48 >             group@:-wxp----------:------:deny
49 >             group@:r-------------:------:allow
50 >          everyone@:-wxp---A-W-Co-:------:deny
51 >          everyone@:r-----a-R-c--s:------:allow
52
53 $ touch posix/xxx
54 $ getfacl -nq posix/xxx
55 > user::rw-
56 > group::r--
57 > other::r--
58
59 # mv with POSIX.1e ACLs.
60 $ rm -f posix/xxx
61 $ rm -f posix/yyy
62 $ touch posix/xxx
63 $ chmod 456 posix/xxx
64 $ ls -l posix/xxx | cut -d' ' -f1
65 > -r--r-xrw-
66 $ setfacl -m u:42:x,g:43:w posix/xxx
67 $ mv posix/xxx posix/yyy
68 $ getfacl -nq posix/yyy
69 > user::r--
70 > user:42:--x
71 > group::r-x
72 > group:43:-w-
73 > mask::rwx
74 > other::rw-
75 $ ls -l posix/yyy | cut -d' ' -f1
76 > -r--rwxrw-+
77
78 # mv from POSIX.1e to none.
79 $ rm -f posix/xxx
80 $ rm -f none/xxx
81 $ touch posix/xxx
82 $ chmod 345 posix/xxx
83 $ setfacl -m u:42:x,g:43:w posix/xxx
84 $ ls -l posix/xxx | cut -d' ' -f1
85 > --wxrwxr-x+
86 $ mv posix/xxx none/xxx
87 > mv: failed to set acl entries for none/xxx: Operation not supported
88 $ ls -l none/xxx | cut -d' ' -f1
89 > --wxrwxr-x
90
91 # mv from POSIX.1e to NFSv4.
92 $ rm -f posix/xxx
93 $ rm -f nfs4/xxx
94 $ touch posix/xxx
95 $ chmod 456 posix/xxx
96 $ setfacl -m u:42:x,g:43:w posix/xxx
97 $ ls -l posix/xxx | cut -d' ' -f1
98 > -r--rwxrw-+
99 $ mv posix/yyy nfs4/xxx
100 > mv: failed to set acl entries for nfs4/xxx: Invalid argument
101 $ getfacl -nq nfs4/xxx
102 >             owner@:-wxp----------:------:deny
103 >             owner@:r------A-W-Co-:------:allow
104 >             group@:--------------:------:deny
105 >             group@:rwxp----------:------:allow
106 >          everyone@:--x----A-W-Co-:------:deny
107 >          everyone@:rw-p--a-R-c--s:------:allow
108 $ ls -l nfs4/xxx | cut -d' ' -f1
109 > -r--rwxrw-
110
111 # mv with NFSv4 ACLs.
112 $ rm -f nfs4/xxx
113 $ rm -f nfs4/yyy
114 $ touch nfs4/xxx
115 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
116 $ mv nfs4/xxx nfs4/yyy
117 $ getfacl -nq nfs4/yyy
118 >            user:42:--x-----------:------:allow
119 >           group:43:-w------------:------:allow
120 >             owner@:--x-----------:------:deny
121 >             owner@:rw-p---A-W-Co-:------:allow
122 >             group@:-wxp----------:------:deny
123 >             group@:r-------------:------:allow
124 >          everyone@:-wxp---A-W-Co-:------:deny
125 >          everyone@:r-----a-R-c--s:------:allow
126 $ ls -l nfs4/yyy | cut -d' ' -f1
127 > -rw-r--r--+
128
129 # mv from NFSv4 to POSIX.1e without any ACLs.
130 $ rm -f nfs4/xxx
131 $ rm -f posix/xxx
132 $ touch nfs4/xxx
133 $ chmod 456 nfs4/xxx
134 $ ls -l nfs4/xxx | cut -d' ' -f1
135 > -r--r-xrw-
136 $ mv nfs4/xxx posix/xxx
137 $ ls -l posix/xxx | cut -d' ' -f1
138 > -r--r-xrw-
139
140 # mv from NFSv4 to none.
141 $ rm -f nfs4/xxx
142 $ rm -f none/xxx
143 $ touch nfs4/xxx
144 $ chmod 345 nfs4/xxx
145 $ ls -l nfs4/xxx | cut -d' ' -f1
146 > --wxr--r-x
147 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
148 $ ls -l nfs4/xxx | cut -d' ' -f1
149 > --wxr--r-x+
150 $ mv nfs4/xxx none/xxx
151 > mv: failed to set acl entries for none/xxx: Operation not supported
152 $ ls -l none/xxx | cut -d' ' -f1
153 > --wxr--r-x
154
155 # mv from NFSv4 to POSIX.1e.
156 $ rm -f nfs4/xxx
157 $ rm -f posix/xxx
158 $ touch nfs4/xxx
159 $ chmod 345 nfs4/xxx
160 $ ls -l nfs4/xxx | cut -d' ' -f1
161 > --wxr--r-x
162 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
163 $ ls -l nfs4/xxx | cut -d' ' -f1
164 > --wxr--r-x+
165 $ mv nfs4/xxx posix/xxx
166 > mv: failed to set acl entries for posix/xxx: Invalid argument
167 $ ls -l posix/xxx | cut -d' ' -f1
168 > --wxr--r-x
169
170 # cp with POSIX.1e ACLs.
171 $ rm -f posix/xxx
172 $ rm -f posix/yyy
173 $ touch posix/xxx
174 $ setfacl -m u:42:x,g:43:w posix/xxx
175 $ ls -l posix/xxx | cut -d' ' -f1
176 > -rw-rwxr--+
177 $ cp posix/xxx posix/yyy
178 $ ls -l posix/yyy | cut -d' ' -f1
179 > -rw-r-xr--
180
181 # cp -p with POSIX.1e ACLs.
182 $ rm -f posix/xxx
183 $ rm -f posix/yyy
184 $ touch posix/xxx
185 $ setfacl -m u:42:x,g:43:w posix/xxx
186 $ getfacl -nq posix/xxx
187 > user::rw-
188 > user:42:--x
189 > group::r--
190 > group:43:-w-
191 > mask::rwx
192 > other::r--
193 $ ls -l posix/xxx | cut -d' ' -f1
194 > -rw-rwxr--+
195 $ cp -p posix/xxx posix/yyy
196 $ getfacl -nq posix/yyy
197 > user::rw-
198 > user:42:--x
199 > group::r--
200 > group:43:-w-
201 > mask::rwx
202 > other::r--
203 $ ls -l posix/yyy | cut -d' ' -f1
204 > -rw-rwxr--+
205
206 # cp from POSIX.1e to none.
207 $ rm -f posix/xxx
208 $ rm -f none/xxx
209 $ touch posix/xxx
210 $ setfacl -m u:42:x,g:43:w posix/xxx
211 $ ls -l posix/xxx | cut -d' ' -f1
212 > -rw-rwxr--+
213 $ cp posix/xxx none/xxx
214 $ ls -l none/xxx | cut -d' ' -f1
215 > -rw-r-xr--
216
217 # cp -p from POSIX.1e to none.
218 $ rm -f posix/xxx
219 $ rm -f none/xxx
220 $ touch posix/xxx
221 $ setfacl -m u:42:x,g:43:w posix/xxx
222 $ ls -l posix/xxx | cut -d' ' -f1
223 > -rw-rwxr--+
224 $ cp -p posix/xxx none/xxx
225 > cp: failed to set acl entries for none/xxx: Operation not supported
226 $ ls -l none/xxx | cut -d' ' -f1
227 > -rw-rwxr--
228
229 # cp from POSIX.1e to NFSv4.
230 $ rm -f posix/xxx
231 $ rm -f nfs4/xxx
232 $ touch posix/xxx
233 $ setfacl -m u:42:x,g:43:w posix/xxx
234 $ ls -l posix/xxx | cut -d' ' -f1
235 > -rw-rwxr--+
236 $ cp posix/xxx nfs4/xxx
237 $ ls -l nfs4/xxx | cut -d' ' -f1
238 > -rw-r-xr--
239
240 # cp -p from POSIX.1e to NFSv4.
241 $ rm -f posix/xxx
242 $ rm -f nfs4/xxx
243 $ touch posix/xxx
244 $ setfacl -m u:42:x,g:43:w posix/xxx
245 $ ls -l posix/xxx | cut -d' ' -f1
246 > -rw-rwxr--+
247 $ cp -p posix/xxx nfs4/xxx
248 > cp: failed to set acl entries for nfs4/xxx: Invalid argument
249 $ ls -l nfs4/xxx | cut -d' ' -f1
250 > -rw-rwxr--
251
252 # cp with NFSv4 ACLs.
253 $ rm -f nfs4/xxx
254 $ rm -f nfs4/yyy
255 $ touch nfs4/xxx
256 $ chmod 543 nfs4/xxx
257 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
258 $ ls -l nfs4/xxx | cut -d' ' -f1
259 > -r-xr---wx+
260 $ cp nfs4/xxx nfs4/yyy
261 $ ls -l nfs4/yyy | cut -d' ' -f1
262 > -r-xr----x
263
264 # cp -p with NFSv4 ACLs.
265 $ rm -f nfs4/xxx
266 $ rm -f nfs4/yyy
267 $ touch nfs4/xxx
268 $ chmod 543 nfs4/xxx
269 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
270 $ cp -p nfs4/xxx nfs4/yyy
271 $ getfacl -nq nfs4/yyy
272 >            user:42:--x-----------:------:allow
273 >           group:43:-w------------:------:allow
274 >             owner@:-w-p----------:------:deny
275 >             owner@:r-x----A-W-Co-:------:allow
276 >             group@:-wxp----------:------:deny
277 >             group@:r-------------:------:allow
278 >          everyone@:r------A-W-Co-:------:deny
279 >          everyone@:-wxp--a-R-c--s:------:allow
280 $ ls -l nfs4/yyy | cut -d' ' -f1
281 > -r-xr---wx+
282
283 # cp from NFSv4 to none.
284 $ rm -f nfs4/xxx
285 $ rm -f none/xxx
286 $ touch nfs4/xxx
287 $ chmod 543 nfs4/xxx
288 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
289 $ ls -l nfs4/xxx | cut -d' ' -f1
290 > -r-xr---wx+
291 $ cp nfs4/xxx none/xxx
292 $ ls -l none/xxx | cut -d' ' -f1
293 > -r-xr----x
294
295 # cp -p from NFSv4 to none.
296 $ rm -f nfs4/xxx
297 $ rm -f none/xxx
298 $ touch nfs4/xxx
299 $ chmod 543 nfs4/xxx
300 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
301 $ ls -l nfs4/xxx | cut -d' ' -f1
302 > -r-xr---wx+
303 $ cp -p nfs4/xxx none/xxx
304 > cp: failed to set acl entries for none/xxx: Operation not supported
305 $ ls -l none/xxx | cut -d' ' -f1
306 > -r-xr---wx
307
308 # cp from NFSv4 to POSIX.1e.
309 $ rm -f nfs4/xxx
310 $ rm -f posix/xxx
311 $ touch nfs4/xxx
312 $ chmod 543 nfs4/xxx
313 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
314 $ ls -l nfs4/xxx | cut -d' ' -f1
315 > -r-xr---wx+
316 $ cp nfs4/xxx posix/xxx
317 $ ls -l posix/xxx | cut -d' ' -f1
318 > -r-xr----x
319
320 # cp -p from NFSv4 to POSIX.1e.
321 $ rm -f nfs4/xxx
322 $ rm -f posix/xxx
323 $ touch nfs4/xxx
324 $ chmod 543 nfs4/xxx
325 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
326 $ ls -l nfs4/xxx | cut -d' ' -f1
327 > -r-xr---wx+
328 $ cp -p nfs4/xxx posix/xxx
329 > cp: failed to set acl entries for posix/xxx: Invalid argument
330 $ ls -l posix/xxx | cut -d' ' -f1
331 > -r-xr---wx