]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/acltools/tools-crossfs.test
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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@:rw-p--aARWcCos:------:allow
47 >             group@:r-----a-R-c--s:------:allow
48 >          everyone@:r-----a-R-c--s:------:allow
49
50 $ touch posix/xxx
51 $ getfacl -nq posix/xxx
52 > user::rw-
53 > group::r--
54 > other::r--
55
56 # mv with POSIX.1e ACLs.
57 $ rm -f posix/xxx
58 $ rm -f posix/yyy
59 $ touch posix/xxx
60 $ chmod 456 posix/xxx
61 $ ls -l posix/xxx | cut -d' ' -f1
62 > -r--r-xrw-
63 $ setfacl -m u:42:x,g:43:w posix/xxx
64 $ mv posix/xxx posix/yyy
65 $ getfacl -nq posix/yyy
66 > user::r--
67 > user:42:--x
68 > group::r-x
69 > group:43:-w-
70 > mask::rwx
71 > other::rw-
72 $ ls -l posix/yyy | cut -d' ' -f1
73 > -r--rwxrw-+
74
75 # mv from POSIX.1e to none.
76 $ rm -f posix/xxx
77 $ rm -f none/xxx
78 $ touch posix/xxx
79 $ chmod 345 posix/xxx
80 $ setfacl -m u:42:x,g:43:w posix/xxx
81 $ ls -l posix/xxx | cut -d' ' -f1
82 > --wxrwxr-x+
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
86 > --wxrwxr-x
87
88 # mv from POSIX.1e to NFSv4.
89 $ rm -f posix/xxx
90 $ rm -f nfs4/xxx
91 $ touch posix/xxx
92 $ chmod 456 posix/xxx
93 $ setfacl -m u:42:x,g:43:w posix/xxx
94 $ ls -l posix/xxx | cut -d' ' -f1
95 > -r--rwxrw-+
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
104 > -r--rwxrw-
105
106 # mv with NFSv4 ACLs.
107 $ rm -f nfs4/xxx
108 $ rm -f nfs4/yyy
109 $ touch nfs4/xxx
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
119 > -rw-r--r--+
120
121 # mv from NFSv4 to POSIX.1e without any ACLs.
122 $ rm -f nfs4/xxx
123 $ rm -f posix/xxx
124 $ touch nfs4/xxx
125 $ chmod 456 nfs4/xxx
126 $ ls -l nfs4/xxx | cut -d' ' -f1
127 > -r--r-xrw-
128 $ mv nfs4/xxx posix/xxx
129 $ ls -l posix/xxx | cut -d' ' -f1
130 > -r--r-xrw-
131
132 # mv from NFSv4 to none.
133 $ rm -f nfs4/xxx
134 $ rm -f none/xxx
135 $ touch nfs4/xxx
136 $ chmod 345 nfs4/xxx
137 $ ls -l nfs4/xxx | cut -d' ' -f1
138 > --wxr--r-x
139 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
140 $ ls -l nfs4/xxx | cut -d' ' -f1
141 > --wxr--r-x+
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
145 > --wxr--r-x
146
147 # mv from NFSv4 to POSIX.1e.
148 $ rm -f nfs4/xxx
149 $ rm -f posix/xxx
150 $ touch nfs4/xxx
151 $ chmod 345 nfs4/xxx
152 $ ls -l nfs4/xxx | cut -d' ' -f1
153 > --wxr--r-x
154 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
155 $ ls -l nfs4/xxx | cut -d' ' -f1
156 > --wxr--r-x+
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
160 > --wxr--r-x
161
162 # cp with POSIX.1e ACLs.
163 $ rm -f posix/xxx
164 $ rm -f posix/yyy
165 $ touch posix/xxx
166 $ setfacl -m u:42:x,g:43:w posix/xxx
167 $ ls -l posix/xxx | cut -d' ' -f1
168 > -rw-rwxr--+
169 $ cp posix/xxx posix/yyy
170 $ ls -l posix/yyy | cut -d' ' -f1
171 > -rw-r-xr--
172
173 # cp -p with POSIX.1e ACLs.
174 $ rm -f posix/xxx
175 $ rm -f posix/yyy
176 $ touch posix/xxx
177 $ setfacl -m u:42:x,g:43:w posix/xxx
178 $ getfacl -nq posix/xxx
179 > user::rw-
180 > user:42:--x
181 > group::r--
182 > group:43:-w-
183 > mask::rwx
184 > other::r--
185 $ ls -l posix/xxx | cut -d' ' -f1
186 > -rw-rwxr--+
187 $ cp -p posix/xxx posix/yyy
188 $ getfacl -nq posix/yyy
189 > user::rw-
190 > user:42:--x
191 > group::r--
192 > group:43:-w-
193 > mask::rwx
194 > other::r--
195 $ ls -l posix/yyy | cut -d' ' -f1
196 > -rw-rwxr--+
197
198 # cp from POSIX.1e to none.
199 $ rm -f posix/xxx
200 $ rm -f none/xxx
201 $ touch posix/xxx
202 $ setfacl -m u:42:x,g:43:w posix/xxx
203 $ ls -l posix/xxx | cut -d' ' -f1
204 > -rw-rwxr--+
205 $ cp posix/xxx none/xxx
206 $ ls -l none/xxx | cut -d' ' -f1
207 > -rw-r-xr--
208
209 # cp -p from POSIX.1e to none.
210 $ rm -f posix/xxx
211 $ rm -f none/xxx
212 $ touch posix/xxx
213 $ setfacl -m u:42:x,g:43:w posix/xxx
214 $ ls -l posix/xxx | cut -d' ' -f1
215 > -rw-rwxr--+
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
219 > -rw-rwxr--
220
221 # cp from POSIX.1e to NFSv4.
222 $ rm -f posix/xxx
223 $ rm -f nfs4/xxx
224 $ touch posix/xxx
225 $ setfacl -m u:42:x,g:43:w posix/xxx
226 $ ls -l posix/xxx | cut -d' ' -f1
227 > -rw-rwxr--+
228 $ cp posix/xxx nfs4/xxx
229 $ ls -l nfs4/xxx | cut -d' ' -f1
230 > -rw-r-xr--
231
232 # cp -p from POSIX.1e to NFSv4.
233 $ rm -f posix/xxx
234 $ rm -f nfs4/xxx
235 $ touch posix/xxx
236 $ setfacl -m u:42:x,g:43:w posix/xxx
237 $ ls -l posix/xxx | cut -d' ' -f1
238 > -rw-rwxr--+
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
242 > -rw-rwxr--
243
244 # cp with NFSv4 ACLs.
245 $ rm -f nfs4/xxx
246 $ rm -f nfs4/yyy
247 $ touch nfs4/xxx
248 $ chmod 543 nfs4/xxx
249 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
250 $ ls -l nfs4/xxx | cut -d' ' -f1
251 > -r-xr---wx+
252 $ cp nfs4/xxx nfs4/yyy
253 $ ls -l nfs4/yyy | cut -d' ' -f1
254 > -r-xr----x
255
256 # cp -p with NFSv4 ACLs.
257 $ rm -f nfs4/xxx
258 $ rm -f nfs4/yyy
259 $ touch nfs4/xxx
260 $ chmod 543 nfs4/xxx
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
273 > -r-xr---wx+
274
275 # cp from NFSv4 to none.
276 $ rm -f nfs4/xxx
277 $ rm -f none/xxx
278 $ touch nfs4/xxx
279 $ chmod 543 nfs4/xxx
280 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
281 $ ls -l nfs4/xxx | cut -d' ' -f1
282 > -r-xr---wx+
283 $ cp nfs4/xxx none/xxx
284 $ ls -l none/xxx | cut -d' ' -f1
285 > -r-xr----x
286
287 # cp -p from NFSv4 to none.
288 $ rm -f nfs4/xxx
289 $ rm -f none/xxx
290 $ touch nfs4/xxx
291 $ chmod 543 nfs4/xxx
292 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
293 $ ls -l nfs4/xxx | cut -d' ' -f1
294 > -r-xr---wx+
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
298 > -r-xr---wx
299
300 # cp from NFSv4 to POSIX.1e.
301 $ rm -f nfs4/xxx
302 $ rm -f posix/xxx
303 $ touch nfs4/xxx
304 $ chmod 543 nfs4/xxx
305 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
306 $ ls -l nfs4/xxx | cut -d' ' -f1
307 > -r-xr---wx+
308 $ cp nfs4/xxx posix/xxx
309 $ ls -l posix/xxx | cut -d' ' -f1
310 > -r-xr----x
311
312 # cp -p from NFSv4 to POSIX.1e.
313 $ rm -f nfs4/xxx
314 $ rm -f posix/xxx
315 $ touch nfs4/xxx
316 $ chmod 543 nfs4/xxx
317 $ setfacl -a0 u:42:x:allow,g:43:w:allow nfs4/xxx
318 $ ls -l nfs4/xxx | cut -d' ' -f1
319 > -r-xr---wx+
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
323 > -r-xr---wx