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