2 Unix SMB/CIFS implementation.
6 Copyright (C) Ralph Boehme 2014
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "system/filesys.h"
24 #include "libcli/libcli.h"
25 #include "libcli/smb2/smb2.h"
26 #include "libcli/smb2/smb2_calls.h"
27 #include "libcli/smb/smb2_create_ctx.h"
28 #include "lib/cmdline/popt_common.h"
29 #include "param/param.h"
30 #include "libcli/resolve/resolve.h"
31 #include "MacExtensions.h"
32 #include "lib/util/tsort.h"
34 #include "torture/torture.h"
35 #include "torture/util.h"
36 #include "torture/smb2/proto.h"
37 #include "torture/vfs/proto.h"
38 #include "librpc/gen_ndr/ndr_ioctl.h"
40 #define BASEDIR "vfs_fruit_dir"
41 #define FNAME_CC_SRC "testfsctl.dat"
42 #define FNAME_CC_DST "testfsctl2.dat"
44 #define CHECK_STATUS(status, correct) do { \
45 if (!NT_STATUS_EQUAL(status, correct)) { \
46 torture_result(tctx, TORTURE_FAIL, \
47 "(%s) Incorrect status %s - should be %s\n", \
48 __location__, nt_errstr(status), nt_errstr(correct)); \
53 #define CHECK_VALUE(v, correct) do { \
54 if ((v) != (correct)) { \
55 torture_result(tctx, TORTURE_FAIL, \
56 "(%s) Incorrect value %s=%u - should be %u\n", \
57 __location__, #v, (unsigned)v, (unsigned)correct); \
62 static bool check_stream_list(struct smb2_tree *tree,
63 struct torture_context *tctx,
67 struct smb2_handle h);
69 static int qsort_string(char * const *s1, char * const *s2)
71 return strcmp(*s1, *s2);
74 static int qsort_stream(const struct stream_struct * s1, const struct stream_struct *s2)
76 return strcmp(s1->stream_name.s, s2->stream_name.s);
81 * This is hokey, but what else can we do?
83 #if defined(HAVE_ATTROPEN) || defined(FREEBSD)
84 #define AFPINFO_EA_NETATALK "org.netatalk.Metadata"
85 #define AFPRESOURCE_EA_NETATALK "org.netatalk.ResourceFork"
87 #define AFPINFO_EA_NETATALK "user.org.netatalk.Metadata"
88 #define AFPRESOURCE_EA_NETATALK "user.org.netatalk.ResourceFork"
92 The metadata xattr char buf below contains the following attributes:
94 -------------------------------------------------------------------------------
95 Entry ID : 00000008 : File Dates Info
96 Offset : 00000162 : 354
97 Length : 00000010 : 16
99 -DATE------: : (GMT) : (Local)
100 create : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
101 modify : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
102 backup : 80000000 : Unknown or Initial
103 access : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
105 -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
106 00000000 : 1B 44 21 69 1B 44 21 69 80 00 00 00 1B 44 21 69 : .D!i.D!i.....D!i
108 -------------------------------------------------------------------------------
109 Entry ID : 00000009 : Finder Info
110 Offset : 0000007A : 122
111 Length : 00000020 : 32
114 Type : 42415252 : BARR
115 Creator : 464F4F4F : FOOO
130 Location v : 0000 : 0
131 Location h : 0000 : 0
135 Rsvd|IconID: 0000 : 0
155 Rsvd|commnt: 0000 : 0
156 PutAway : 00000000 : 0
158 -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
159 00000000 : 42 41 52 52 46 4F 4F 4F 40 00 00 00 00 00 00 00 : BARRFOOO@.......
160 00000010 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
162 -------------------------------------------------------------------------------
163 Entry ID : 0000000E : AFP File Info
164 Offset : 00000172 : 370
165 Length : 00000004 : 4
167 -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
168 00000000 : 00 00 01 A1 : ....
171 char metadata_xattr[] = {
172 0x00, 0x05, 0x16, 0x07, 0x00, 0x02, 0x00, 0x00,
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
176 0x00, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x08, 0x00, 0x00, 0x01, 0x62, 0x00, 0x00,
178 0x00, 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
179 0x00, 0x7a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
180 0x00, 0x0e, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00,
181 0x00, 0x04, 0x80, 0x44, 0x45, 0x56, 0x00, 0x00,
182 0x01, 0x76, 0x00, 0x00, 0x00, 0x08, 0x80, 0x49,
183 0x4e, 0x4f, 0x00, 0x00, 0x01, 0x7e, 0x00, 0x00,
184 0x00, 0x08, 0x80, 0x53, 0x59, 0x4e, 0x00, 0x00,
185 0x01, 0x86, 0x00, 0x00, 0x00, 0x08, 0x80, 0x53,
186 0x56, 0x7e, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00,
187 0x00, 0x04, 0x42, 0x41, 0x52, 0x52, 0x46, 0x4f,
188 0x4f, 0x4f, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
192 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
194 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
216 0x00, 0x00, 0x1b, 0x44, 0x21, 0x69, 0x1b, 0x44,
217 0x21, 0x69, 0x80, 0x00, 0x00, 0x00, 0x1b, 0x44,
218 0x21, 0x69, 0x00, 0x00, 0x01, 0xa1, 0x00, 0xfd,
219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x20,
220 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0xe3,
221 0x86, 0x53, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x01,
226 The buf below contains the following AppleDouble encoded data:
228 -------------------------------------------------------------------------------
229 MagicNumber: 00051607 : AppleDouble
230 Version : 00020000 : Version 2
231 Filler : 4D 61 63 20 4F 53 20 58 20 20 20 20 20 20 20 20 : Mac OS X
232 Num. of ent: 0002 : 2
234 -------------------------------------------------------------------------------
235 Entry ID : 00000009 : Finder Info
236 Offset : 00000032 : 50
237 Length : 00000EB0 : 3760
240 Type : 54455854 : TEXT
241 Creator : 21526368 : !Rch
246 magic : 41545452 : ATTR
247 debug_tag : 0007F98E : 522638
248 total_size : 00000EE2 : 3810
249 data_start : 00000078 : 120
250 data_length: 00000000 : 0
251 reserved[0]: 00000000 : ....
252 reserved[1]: 00000000 : ....
253 reserved[2]: 00000000 : ....
257 -------------------------------------------------------------------------------
258 Entry ID : 00000002 : Resource Fork
259 Offset : 00000EE2 : 3810
260 Length : 0000011E : 286
262 -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
263 00000000 : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
264 00000010 : 54 68 69 73 20 72 65 73 6F 75 72 63 65 20 66 6F : This resource fo
265 00000020 : 72 6B 20 69 6E 74 65 6E 74 69 6F 6E 61 6C 6C 79 : rk intentionally
266 00000030 : 20 6C 65 66 74 20 62 6C 61 6E 6B 20 20 20 00 00 : left blank ..
268 00000110 : 00 00 00 00 00 00 00 00 00 1C 00 1E FF FF : ..............
270 static char osx_adouble_w_xattr[] = {
271 0x00, 0x05, 0x16, 0x07, 0x00, 0x02, 0x00, 0x00,
272 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x58,
273 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
274 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
275 0x00, 0x32, 0x00, 0x00, 0x0e, 0xb0, 0x00, 0x00,
276 0x00, 0x02, 0x00, 0x00, 0x0e, 0xe2, 0x00, 0x00,
277 0x01, 0x1e, 0x54, 0x45, 0x58, 0x54, 0x21, 0x52,
278 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
281 0x00, 0x00, 0x00, 0x00, 0x41, 0x54, 0x54, 0x52,
282 0x00, 0x07, 0xf9, 0x8e, 0x00, 0x00, 0x0e, 0xe2,
283 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
286 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
288 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
291 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
298 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
300 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
301 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
302 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
303 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
304 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
309 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
311 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
313 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
315 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
316 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
317 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
318 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
319 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
320 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
321 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
322 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
323 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
324 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
325 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
326 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
331 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
332 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
333 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
334 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
335 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
336 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
339 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
341 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
342 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
343 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
344 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
345 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
346 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
347 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
348 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
349 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
350 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
351 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
352 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
353 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
354 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
355 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
358 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
360 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
363 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
364 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
365 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
366 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
367 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
368 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
369 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
370 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
374 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
375 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
376 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
377 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
378 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
380 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
381 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
382 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
383 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
384 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
385 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
386 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
388 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
389 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
390 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
391 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
392 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
393 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
394 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
395 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
396 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
397 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
398 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
399 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
400 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
401 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
402 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
403 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
404 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
405 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
406 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
407 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
408 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
409 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
410 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
411 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
412 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
413 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
414 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
415 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
416 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
417 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
418 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
419 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
420 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
421 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
422 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
423 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
424 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
425 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
426 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
427 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
428 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
429 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
430 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
431 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
432 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
433 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
434 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
435 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
436 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
437 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
438 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
439 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
440 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
441 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
442 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
443 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
444 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
445 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
446 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
447 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
448 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
449 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
450 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
451 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
452 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
453 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
454 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
455 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
456 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
457 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
458 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
460 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
461 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
462 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
463 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
464 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
465 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
466 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
467 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
468 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
469 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
470 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
471 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
472 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
474 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
475 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
476 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
477 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
478 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
479 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
480 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
481 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
482 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
483 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
484 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
485 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
486 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
487 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
488 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
489 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
490 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
491 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
492 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
493 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
494 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
495 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
496 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
497 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
498 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
499 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
500 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
501 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
502 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
503 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
504 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
505 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
506 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
507 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
508 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
509 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
510 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
511 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
512 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
513 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
514 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
515 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
516 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
517 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
518 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
519 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
520 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
521 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
522 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
523 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
524 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
525 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
526 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
527 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
528 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
529 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
530 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
531 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
532 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
533 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
534 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
535 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
536 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
537 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
538 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
539 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
540 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
541 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
542 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
543 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
544 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
545 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
546 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
547 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
548 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
549 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
550 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
551 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
552 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
553 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
554 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
555 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
556 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
557 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
558 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
559 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
560 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
561 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
562 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
563 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
564 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
565 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
566 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
567 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
568 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
569 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
570 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
571 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
572 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
573 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
574 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
575 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
576 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
577 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
578 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
579 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
580 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
581 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
582 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
583 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
584 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
585 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
586 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
587 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
588 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
589 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
590 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
591 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
592 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
593 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
594 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
595 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
596 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
597 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
598 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
599 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
600 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
601 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
602 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
603 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
604 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
605 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
606 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
607 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
608 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
609 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
610 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
611 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
612 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
613 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
614 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
615 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
616 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
617 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
618 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
619 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
620 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
621 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
622 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
623 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
624 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
625 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
626 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
627 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
628 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
629 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
630 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
631 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
632 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
633 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
634 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
635 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
636 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
637 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
638 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
639 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
640 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
641 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
642 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
643 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
644 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
645 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
646 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
647 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
648 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
649 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
650 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
651 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
652 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
653 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
654 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
655 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
656 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
657 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
658 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
659 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
660 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
661 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
662 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
663 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
664 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
665 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
666 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
667 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
668 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
669 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
670 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
671 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
672 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
673 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
674 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
675 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
676 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
677 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
678 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
679 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
680 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
681 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
682 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
683 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
684 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
685 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
686 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
687 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
688 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
689 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
690 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
691 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
692 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
693 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
694 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
695 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
696 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
697 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
698 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
699 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
700 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
701 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
702 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
703 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
704 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
705 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
706 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
707 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
708 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
709 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
710 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
711 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
712 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
713 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
714 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
715 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
716 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
717 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
718 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
719 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
720 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
721 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
722 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
723 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
724 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
725 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
726 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
727 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
728 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
729 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
730 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
731 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
732 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
733 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
734 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
735 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
736 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
737 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
738 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
739 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
740 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
741 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
742 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
743 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
744 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
745 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
746 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
747 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
748 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
749 0x00, 0x1e, 0x54, 0x68, 0x69, 0x73, 0x20, 0x72,
750 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20,
751 0x66, 0x6f, 0x72, 0x6b, 0x20, 0x69, 0x6e, 0x74,
752 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
753 0x6c, 0x79, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x20,
754 0x62, 0x6c, 0x61, 0x6e, 0x6b, 0x20, 0x20, 0x20,
755 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
756 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
757 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
758 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
759 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
760 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
761 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
762 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
763 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
764 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
765 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
766 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
767 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
768 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
769 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
770 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
771 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
772 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
773 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
774 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
775 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
776 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
777 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
778 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
779 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
780 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
781 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
782 0x00, 0x00, 0x00, 0x1c, 0x00, 0x1e, 0xff, 0xff
786 * talloc and intialize an AfpInfo
788 static AfpInfo *torture_afpinfo_new(TALLOC_CTX *mem_ctx)
792 info = talloc_zero(mem_ctx, AfpInfo);
797 info->afpi_Signature = AFP_Signature;
798 info->afpi_Version = AFP_Version;
799 info->afpi_BackupTime = AFP_BackupTime;
805 * Pack AfpInfo into a talloced buffer
807 static char *torture_afpinfo_pack(TALLOC_CTX *mem_ctx,
812 buf = talloc_array(mem_ctx, char, AFP_INFO_SIZE);
817 RSIVAL(buf, 0, info->afpi_Signature);
818 RSIVAL(buf, 4, info->afpi_Version);
819 RSIVAL(buf, 12, info->afpi_BackupTime);
820 memcpy(buf + 16, info->afpi_FinderInfo, sizeof(info->afpi_FinderInfo));
829 static void torture_afpinfo_unpack(AfpInfo *info, char *data)
831 info->afpi_Signature = RIVAL(data, 0);
832 info->afpi_Version = RIVAL(data, 4);
833 info->afpi_BackupTime = RIVAL(data, 12);
834 memcpy(info->afpi_FinderInfo, (const char *)data + 16,
835 sizeof(info->afpi_FinderInfo));
839 static bool torture_write_afpinfo(struct smb2_tree *tree,
840 struct torture_context *tctx,
845 struct smb2_handle handle;
846 struct smb2_create io;
848 const char *full_name;
852 full_name = talloc_asprintf(mem_ctx, "%s%s", fname, AFPINFO_STREAM);
853 if (full_name == NULL) {
854 torture_comment(tctx, "talloc_asprintf error\n");
858 io.in.desired_access = SEC_FILE_WRITE_DATA;
859 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
860 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
861 io.in.create_options = 0;
862 io.in.fname = full_name;
864 status = smb2_create(tree, mem_ctx, &io);
865 CHECK_STATUS(status, NT_STATUS_OK);
867 handle = io.out.file.handle;
869 infobuf = torture_afpinfo_pack(mem_ctx, info);
870 if (infobuf == NULL) {
874 status = smb2_util_write(tree, handle, infobuf, 0, AFP_INFO_SIZE);
875 CHECK_STATUS(status, NT_STATUS_OK);
877 smb2_util_close(tree, handle);
884 * Read 'count' bytes at 'offset' from stream 'fname:sname' and
885 * compare against buffer 'value'
887 static bool check_stream(struct smb2_tree *tree,
888 const char *location,
889 struct torture_context *tctx,
899 struct smb2_handle handle;
900 struct smb2_create create;
903 const char *full_name;
905 full_name = talloc_asprintf(mem_ctx, "%s%s", fname, sname);
906 if (full_name == NULL) {
907 torture_comment(tctx, "talloc_asprintf error\n");
911 create.in.desired_access = SEC_FILE_READ_DATA;
912 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
913 create.in.create_disposition = NTCREATEX_DISP_OPEN;
914 create.in.fname = full_name;
916 torture_comment(tctx, "Open stream %s\n", full_name);
918 status = smb2_create(tree, mem_ctx, &create);
919 if (!NT_STATUS_IS_OK(status)) {
923 torture_comment(tctx, "Unable to open stream %s\n",
930 handle = create.out.file.handle;
937 r.in.file.handle = handle;
938 r.in.length = read_count;
939 r.in.offset = read_offset;
941 status = smb2_read(tree, tree, &r);
943 if (!NT_STATUS_IS_OK(status)) {
944 torture_comment(tctx, "(%s) Failed to read %lu bytes from "
945 "stream '%s'\n", location, (long)strlen(value), full_name);
949 if (memcmp(r.out.data.data + comp_offset, value, comp_count) != 0) {
950 torture_comment(tctx, "(%s) Bad data in stream\n", location);
954 smb2_util_close(tree, handle);
959 * Read 'count' bytes at 'offset' from stream 'fname:sname' and
960 * compare against buffer 'value'
962 static ssize_t read_stream(struct smb2_tree *tree,
963 const char *location,
964 struct torture_context *tctx,
971 struct smb2_handle handle;
972 struct smb2_create create;
975 const char *full_name;
978 full_name = talloc_asprintf(mem_ctx, "%s%s", fname, sname);
979 if (full_name == NULL) {
980 torture_comment(tctx, "talloc_asprintf error\n");
984 create.in.desired_access = SEC_FILE_READ_DATA;
985 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
986 create.in.create_disposition = NTCREATEX_DISP_OPEN;
987 create.in.fname = full_name;
989 torture_comment(tctx, "Open stream %s\n", full_name);
991 status = smb2_create(tree, mem_ctx, &create);
992 if (!NT_STATUS_IS_OK(status)) {
993 torture_comment(tctx, "Unable to open stream %s\n",
998 handle = create.out.file.handle;
1001 r.in.file.handle = handle;
1002 r.in.length = read_count;
1003 r.in.offset = read_offset;
1005 status = smb2_read(tree, tree, &r);
1006 if (!NT_STATUS_IS_OK(status)) {
1007 CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
1010 smb2_util_close(tree, handle);
1016 return r.out.data.length;
1020 * Read 'count' bytes at 'offset' from stream 'fname:sname' and
1021 * compare against buffer 'value'
1023 static bool write_stream(struct smb2_tree *tree,
1024 const char *location,
1025 struct torture_context *tctx,
1026 TALLOC_CTX *mem_ctx,
1033 struct smb2_handle handle;
1034 struct smb2_create create;
1036 const char *full_name;
1038 full_name = talloc_asprintf(mem_ctx, "%s%s", fname, sname);
1039 if (full_name == NULL) {
1040 torture_comment(tctx, "talloc_asprintf error\n");
1043 ZERO_STRUCT(create);
1044 create.in.desired_access = SEC_FILE_WRITE_DATA;
1045 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1046 create.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
1047 create.in.fname = full_name;
1049 status = smb2_create(tree, mem_ctx, &create);
1050 if (!NT_STATUS_IS_OK(status)) {
1051 if (value == NULL) {
1054 torture_comment(tctx, "Unable to open stream %s\n",
1061 handle = create.out.file.handle;
1062 if (value == NULL) {
1066 status = smb2_util_write(tree, handle, value, offset, size);
1068 if (!NT_STATUS_IS_OK(status)) {
1069 torture_comment(tctx, "(%s) Failed to write %lu bytes to "
1070 "stream '%s'\n", location, (long)size, full_name);
1074 smb2_util_close(tree, handle);
1078 static bool torture_setup_local_xattr(struct torture_context *tctx,
1079 const char *path_option,
1082 const char *metadata,
1090 spath = torture_setting_string(tctx, path_option, NULL);
1091 if (spath == NULL) {
1092 printf("No sharepath for option %s\n", path_option);
1096 path = talloc_asprintf(tctx, "%s/%s", spath, name);
1098 result = setxattr(path, xattr, metadata, size, 0);
1108 static bool torture_setup_local_file(struct torture_context *tctx,
1109 const char *path_option,
1119 spath = torture_setting_string(tctx, path_option, NULL);
1120 if (spath == NULL) {
1121 printf("No sharepath for option %s\n", path_option);
1125 path = talloc_asprintf(tctx, "%s/%s", spath, name);
1130 fd = creat(path, S_IRWXU);
1136 if ((buf == NULL) || (size == 0)) {
1141 rsize = write(fd, buf, size);
1142 if (rsize != size) {
1152 * Create a file or directory
1154 static bool torture_setup_file(TALLOC_CTX *mem_ctx, struct smb2_tree *tree,
1155 const char *name, bool dir)
1157 struct smb2_create io;
1160 smb2_util_unlink(tree, name);
1162 io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
1163 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1164 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
1165 io.in.share_access =
1166 NTCREATEX_SHARE_ACCESS_DELETE|
1167 NTCREATEX_SHARE_ACCESS_READ|
1168 NTCREATEX_SHARE_ACCESS_WRITE;
1169 io.in.create_options = 0;
1172 io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
1173 io.in.share_access &= ~NTCREATEX_SHARE_ACCESS_DELETE;
1174 io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
1175 io.in.create_disposition = NTCREATEX_DISP_CREATE;
1178 status = smb2_create(tree, mem_ctx, &io);
1179 if (!NT_STATUS_IS_OK(status)) {
1183 status = smb2_util_close(tree, io.out.file.handle);
1184 if (!NT_STATUS_IS_OK(status)) {
1191 static bool enable_aapl(struct torture_context *tctx,
1192 struct smb2_tree *tree1)
1194 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1197 struct smb2_create io;
1199 struct smb2_create_blob *aapl = NULL;
1200 uint32_t aapl_server_caps;
1201 uint32_t expexted_scaps = (SMB2_CRTCTX_AAPL_UNIX_BASED |
1202 SMB2_CRTCTX_AAPL_SUPPORTS_READ_DIR_ATTR |
1203 SMB2_CRTCTX_AAPL_SUPPORTS_NFS_ACE |
1204 SMB2_CRTCTX_AAPL_SUPPORTS_OSX_COPYFILE);
1207 io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
1208 io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
1209 io.in.create_disposition = NTCREATEX_DISP_OPEN;
1210 io.in.share_access = (NTCREATEX_SHARE_ACCESS_DELETE |
1211 NTCREATEX_SHARE_ACCESS_READ |
1212 NTCREATEX_SHARE_ACCESS_WRITE);
1216 * Issuing an SMB2/CREATE with a suitably formed AAPL context,
1217 * controls behaviour of Apple's SMB2 extensions for the whole
1221 data = data_blob_talloc(mem_ctx, NULL, 3 * sizeof(uint64_t));
1222 SBVAL(data.data, 0, SMB2_CRTCTX_AAPL_SERVER_QUERY);
1223 SBVAL(data.data, 8, (SMB2_CRTCTX_AAPL_SERVER_CAPS |
1224 SMB2_CRTCTX_AAPL_VOLUME_CAPS |
1225 SMB2_CRTCTX_AAPL_MODEL_INFO));
1226 SBVAL(data.data, 16, (SMB2_CRTCTX_AAPL_SUPPORTS_READ_DIR_ATTR |
1227 SMB2_CRTCTX_AAPL_UNIX_BASED |
1228 SMB2_CRTCTX_AAPL_SUPPORTS_NFS_ACE));
1230 status = smb2_create_blob_add(tctx, &io.in.blobs, "AAPL", data);
1231 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create_blob_add");
1233 status = smb2_create(tree1, tctx, &io);
1234 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create");
1236 status = smb2_util_close(tree1, io.out.file.handle);
1237 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_util_close");
1240 * Now check returned AAPL context
1242 torture_comment(tctx, "Comparing returned AAPL capabilities\n");
1244 aapl = smb2_create_blob_find(&io.out.blobs,
1245 SMB2_CREATE_TAG_AAPL);
1246 torture_assert_goto(tctx, aapl != NULL, ret, done, "missing AAPL context");
1247 torture_assert_goto(tctx, aapl->data.length == 50, ret, done, "bad AAPL size");
1249 aapl_server_caps = BVAL(aapl->data.data, 16);
1250 torture_assert_goto(tctx, aapl_server_caps == expexted_scaps,
1251 ret, done, "bad AAPL caps");
1254 talloc_free(mem_ctx);
1258 static bool test_read_atalk_metadata(struct torture_context *tctx,
1259 struct smb2_tree *tree1)
1261 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1262 const char *fname = BASEDIR "\\torture_read_metadata";
1264 struct smb2_handle testdirh;
1268 torture_comment(tctx, "Checking metadata access\n");
1270 smb2_util_unlink(tree1, fname);
1272 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1273 CHECK_STATUS(status, NT_STATUS_OK);
1274 smb2_util_close(tree1, testdirh);
1276 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1281 ret = torture_setup_local_xattr(tctx, "localdir",
1282 BASEDIR "/torture_read_metadata",
1283 AFPINFO_EA_NETATALK,
1284 metadata_xattr, sizeof(metadata_xattr));
1289 ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1290 0, 60, 0, 4, "AFP");
1292 ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1293 0, 60, 16, 8, "BARRFOOO");
1295 ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1296 16, 8, 0, 8, "BARRFOOO");
1298 /* Check reading offset and read size > sizeof(AFPINFO_STREAM) */
1300 len = read_stream(tree1, __location__, tctx, mem_ctx, fname,
1301 AFPINFO_STREAM, 0, 61);
1302 CHECK_VALUE(len, 60);
1304 len = read_stream(tree1, __location__, tctx, mem_ctx, fname,
1305 AFPINFO_STREAM, 59, 2);
1306 CHECK_VALUE(len, 1);
1308 len = read_stream(tree1, __location__, tctx, mem_ctx, fname,
1309 AFPINFO_STREAM, 60, 1);
1310 CHECK_VALUE(len, 0);
1312 len = read_stream(tree1, __location__, tctx, mem_ctx, fname,
1313 AFPINFO_STREAM, 61, 1);
1314 CHECK_VALUE(len, 0);
1317 smb2_deltree(tree1, BASEDIR);
1318 talloc_free(mem_ctx);
1322 static bool test_write_atalk_metadata(struct torture_context *tctx,
1323 struct smb2_tree *tree1)
1325 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1326 const char *fname = BASEDIR "\\torture_write_metadata";
1327 const char *type_creator = "SMB,OLE!";
1329 struct smb2_handle testdirh;
1333 smb2_util_unlink(tree1, fname);
1335 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1336 CHECK_STATUS(status, NT_STATUS_OK);
1337 smb2_util_close(tree1, testdirh);
1339 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1344 info = torture_afpinfo_new(mem_ctx);
1349 memcpy(info->afpi_FinderInfo, type_creator, 8);
1350 ret = torture_write_afpinfo(tree1, tctx, mem_ctx, fname, info);
1351 ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1352 0, 60, 16, 8, type_creator);
1355 smb2_deltree(tree1, BASEDIR);
1356 talloc_free(mem_ctx);
1360 static bool test_write_atalk_rfork_io(struct torture_context *tctx,
1361 struct smb2_tree *tree1)
1363 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1364 const char *fname = BASEDIR "\\torture_write_rfork_io";
1365 const char *rfork = BASEDIR "\\torture_write_rfork_io" AFPRESOURCE_STREAM;
1366 const char *rfork_content = "1234567890";
1368 struct smb2_handle testdirh;
1372 struct smb2_handle filehandle;
1373 union smb_fileinfo finfo;
1374 union smb_setfileinfo sinfo;
1376 smb2_util_unlink(tree1, fname);
1378 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1379 CHECK_STATUS(status, NT_STATUS_OK);
1380 smb2_util_close(tree1, testdirh);
1382 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1387 torture_comment(tctx, "(%s) writing to resource fork\n",
1390 ret &= write_stream(tree1, __location__, tctx, mem_ctx,
1391 fname, AFPRESOURCE_STREAM,
1392 10, 10, rfork_content);
1394 ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1395 fname, AFPRESOURCE_STREAM,
1396 0, 20, 10, 10, rfork_content);
1398 /* Check size after write */
1401 io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1402 io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1403 SEC_FILE_WRITE_ATTRIBUTE;
1404 io.smb2.in.fname = rfork;
1405 status = smb2_create(tree1, mem_ctx, &(io.smb2));
1406 CHECK_STATUS(status, NT_STATUS_OK);
1407 filehandle = io.smb2.out.file.handle;
1409 torture_comment(tctx, "(%s) check resource fork size after write\n",
1413 finfo.generic.level = RAW_FILEINFO_ALL_INFORMATION;
1414 finfo.generic.in.file.handle = filehandle;
1415 status = smb2_getinfo_file(tree1, mem_ctx, &finfo);
1416 CHECK_STATUS(status, NT_STATUS_OK);
1417 if (finfo.all_info.out.size != 20) {
1418 torture_result(tctx, TORTURE_FAIL,
1419 "(%s) Incorrect resource fork size\n",
1422 smb2_util_close(tree1, filehandle);
1425 smb2_util_close(tree1, filehandle);
1427 /* Write at large offset */
1429 torture_comment(tctx, "(%s) writing to resource fork at large offset\n",
1432 ret &= write_stream(tree1, __location__, tctx, mem_ctx,
1433 fname, AFPRESOURCE_STREAM,
1434 (off_t)1<<32, 10, rfork_content);
1436 ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1437 fname, AFPRESOURCE_STREAM,
1438 (off_t)1<<32, 10, 0, 10, rfork_content);
1440 /* Truncate back to size of 1 byte */
1442 torture_comment(tctx, "(%s) truncate resource fork and check size\n",
1446 io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1447 io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1448 SEC_FILE_WRITE_ATTRIBUTE;
1449 io.smb2.in.fname = rfork;
1450 status = smb2_create(tree1, mem_ctx, &(io.smb2));
1451 CHECK_STATUS(status, NT_STATUS_OK);
1452 filehandle = io.smb2.out.file.handle;
1455 sinfo.end_of_file_info.level =
1456 RAW_SFILEINFO_END_OF_FILE_INFORMATION;
1457 sinfo.end_of_file_info.in.file.handle = filehandle;
1458 sinfo.end_of_file_info.in.size = 1;
1459 status = smb2_setinfo_file(tree1, &sinfo);
1460 CHECK_STATUS(status, NT_STATUS_OK);
1462 smb2_util_close(tree1, filehandle);
1464 /* Now check size */
1466 io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1467 io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1468 SEC_FILE_WRITE_ATTRIBUTE;
1469 io.smb2.in.fname = rfork;
1470 status = smb2_create(tree1, mem_ctx, &(io.smb2));
1471 CHECK_STATUS(status, NT_STATUS_OK);
1472 filehandle = io.smb2.out.file.handle;
1475 finfo.generic.level = RAW_FILEINFO_ALL_INFORMATION;
1476 finfo.generic.in.file.handle = filehandle;
1477 status = smb2_getinfo_file(tree1, mem_ctx, &finfo);
1478 CHECK_STATUS(status, NT_STATUS_OK);
1479 if (finfo.all_info.out.size != 1) {
1480 torture_result(tctx, TORTURE_FAIL,
1481 "(%s) Incorrect resource fork size\n",
1484 smb2_util_close(tree1, filehandle);
1487 smb2_util_close(tree1, filehandle);
1490 smb2_deltree(tree1, BASEDIR);
1491 talloc_free(mem_ctx);
1495 static bool test_rfork_truncate(struct torture_context *tctx,
1496 struct smb2_tree *tree1)
1498 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1499 const char *fname = BASEDIR "\\torture_rfork_truncate";
1500 const char *rfork = BASEDIR "\\torture_rfork_truncate" AFPRESOURCE_STREAM;
1501 const char *rfork_content = "1234567890";
1503 struct smb2_handle testdirh;
1505 struct smb2_create create;
1506 struct smb2_handle fh1, fh2, fh3;
1507 union smb_setfileinfo sinfo;
1509 smb2_util_unlink(tree1, fname);
1511 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1512 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "torture_smb2_testdir");
1513 smb2_util_close(tree1, testdirh);
1515 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1520 ret &= write_stream(tree1, __location__, tctx, mem_ctx,
1521 fname, AFPRESOURCE_STREAM,
1522 10, 10, rfork_content);
1524 /* Truncate back to size 0, further access MUST return ENOENT */
1526 torture_comment(tctx, "(%s) truncate resource fork to size 0\n",
1529 ZERO_STRUCT(create);
1530 create.in.create_disposition = NTCREATEX_DISP_OPEN;
1531 create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
1532 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1533 create.in.fname = fname;
1534 create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
1535 NTCREATEX_SHARE_ACCESS_READ |
1536 NTCREATEX_SHARE_ACCESS_WRITE;
1537 status = smb2_create(tree1, mem_ctx, &create);
1538 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create");
1539 fh1 = create.out.file.handle;
1541 ZERO_STRUCT(create);
1542 create.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
1543 create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
1544 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1545 create.in.fname = rfork;
1546 create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
1547 NTCREATEX_SHARE_ACCESS_READ |
1548 NTCREATEX_SHARE_ACCESS_WRITE;
1549 status = smb2_create(tree1, mem_ctx, &create);
1550 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create");
1551 fh2 = create.out.file.handle;
1554 sinfo.end_of_file_info.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION;
1555 sinfo.end_of_file_info.in.file.handle = fh2;
1556 sinfo.end_of_file_info.in.size = 0;
1557 status = smb2_setinfo_file(tree1, &sinfo);
1558 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_setinfo_file");
1561 * Now check size, we should get OBJECT_NAME_NOT_FOUND (!)
1563 ZERO_STRUCT(create);
1564 create.in.create_disposition = NTCREATEX_DISP_OPEN;
1565 create.in.desired_access = SEC_FILE_ALL;
1566 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1567 create.in.fname = rfork;
1568 create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
1569 NTCREATEX_SHARE_ACCESS_READ |
1570 NTCREATEX_SHARE_ACCESS_WRITE;
1571 status = smb2_create(tree1, mem_ctx, &create);
1572 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done, "smb2_create");
1575 * Do another open on the rfork and write to the new handle. A
1576 * naive server might unlink the AppleDouble resource fork
1577 * file when its truncated to 0 bytes above, so in case both
1578 * open handles share the same underlying fd, the unlink would
1579 * cause the below write to be lost.
1581 ZERO_STRUCT(create);
1582 create.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
1583 create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
1584 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1585 create.in.fname = rfork;
1586 create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
1587 NTCREATEX_SHARE_ACCESS_READ |
1588 NTCREATEX_SHARE_ACCESS_WRITE;
1589 status = smb2_create(tree1, mem_ctx, &create);
1590 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create");
1591 fh3 = create.out.file.handle;
1593 status = smb2_util_write(tree1, fh3, "foo", 0, 3);
1594 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_util_write");
1596 smb2_util_close(tree1, fh3);
1597 smb2_util_close(tree1, fh2);
1598 smb2_util_close(tree1, fh1);
1600 ret = check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPRESOURCE_STREAM,
1602 torture_assert_goto(tctx, ret == true, ret, done, "check_stream");
1605 smb2_util_unlink(tree1, fname);
1606 smb2_deltree(tree1, BASEDIR);
1607 talloc_free(mem_ctx);
1611 static bool test_rfork_create(struct torture_context *tctx,
1612 struct smb2_tree *tree1)
1614 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1615 const char *fname = BASEDIR "\\torture_rfork_create";
1616 const char *rfork = BASEDIR "\\torture_rfork_create" AFPRESOURCE_STREAM;
1618 struct smb2_handle testdirh;
1620 struct smb2_create create;
1621 struct smb2_handle fh1;
1622 const char *streams[] = {
1625 union smb_fileinfo finfo;
1627 smb2_util_unlink(tree1, fname);
1629 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1630 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "torture_smb2_testdir");
1631 smb2_util_close(tree1, testdirh);
1633 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1638 torture_comment(tctx, "(%s) open rfork, should return ENOENT\n",
1641 ZERO_STRUCT(create);
1642 create.in.create_disposition = NTCREATEX_DISP_OPEN;
1643 create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
1644 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1645 create.in.fname = rfork;
1646 create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
1647 NTCREATEX_SHARE_ACCESS_READ |
1648 NTCREATEX_SHARE_ACCESS_WRITE;
1649 status = smb2_create(tree1, mem_ctx, &create);
1650 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done, "smb2_create");
1652 torture_comment(tctx, "(%s) create resource fork\n", __location__);
1654 ZERO_STRUCT(create);
1655 create.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
1656 create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
1657 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1658 create.in.fname = rfork;
1659 create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
1660 NTCREATEX_SHARE_ACCESS_READ |
1661 NTCREATEX_SHARE_ACCESS_WRITE;
1662 status = smb2_create(tree1, mem_ctx, &create);
1663 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create");
1664 fh1 = create.out.file.handle;
1666 torture_comment(tctx, "(%s) getinfo on create handle\n",
1670 finfo.generic.level = RAW_FILEINFO_ALL_INFORMATION;
1671 finfo.generic.in.file.handle = fh1;
1672 status = smb2_getinfo_file(tree1, mem_ctx, &finfo);
1673 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_getinfo_file");
1674 if (finfo.all_info.out.size != 0) {
1675 torture_result(tctx, TORTURE_FAIL,
1676 "(%s) Incorrect resource fork size\n",
1679 smb2_util_close(tree1, fh1);
1683 torture_comment(tctx, "(%s) open rfork, should still return ENOENT\n",
1686 ZERO_STRUCT(create);
1687 create.in.create_disposition = NTCREATEX_DISP_OPEN;
1688 create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
1689 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1690 create.in.fname = rfork;
1691 create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
1692 NTCREATEX_SHARE_ACCESS_READ |
1693 NTCREATEX_SHARE_ACCESS_WRITE;
1694 status = smb2_create(tree1, mem_ctx, &create);
1695 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done, "smb2_create");
1697 ZERO_STRUCT(create);
1698 create.in.fname = fname;
1699 create.in.create_disposition = NTCREATEX_DISP_OPEN;
1700 create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
1701 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1702 status = smb2_create(tree1, mem_ctx, &create);
1703 torture_assert_ntstatus_ok_goto(tctx, status, ret, done, "smb2_create");
1705 ret = check_stream_list(tree1, tctx, fname, 1, streams,
1706 create.out.file.handle);
1707 torture_assert_goto(tctx, ret == true, ret, done, "check_stream_list");
1708 smb2_util_close(tree1, create.out.file.handle);
1710 torture_comment(tctx, "(%s) close empty created rfork, open should return ENOENT\n",
1712 smb2_util_close(tree1, fh1);
1713 ZERO_STRUCT(create);
1714 create.in.create_disposition = NTCREATEX_DISP_OPEN;
1715 create.in.desired_access = SEC_STD_READ_CONTROL | SEC_FILE_ALL;
1716 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1717 create.in.fname = rfork;
1718 create.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE |
1719 NTCREATEX_SHARE_ACCESS_READ |
1720 NTCREATEX_SHARE_ACCESS_WRITE;
1721 status = smb2_create(tree1, mem_ctx, &create);
1722 torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done, "smb2_create");
1725 smb2_util_unlink(tree1, fname);
1726 smb2_deltree(tree1, BASEDIR);
1727 talloc_free(mem_ctx);
1731 static bool test_adouble_conversion(struct torture_context *tctx,
1732 struct smb2_tree *tree1)
1734 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1735 const char *fname = BASEDIR "\\test_adouble_conversion";
1736 const char *fname_local = BASEDIR "/test_adouble_conversion";
1737 const char *adname_local = BASEDIR "/._test_adouble_conversion";
1739 struct smb2_handle testdirh;
1741 const char *data = "This resource fork intentionally left blank";
1742 size_t datalen = strlen(data);
1744 smb2_util_unlink(tree1, fname);
1746 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1747 CHECK_STATUS(status, NT_STATUS_OK);
1748 smb2_util_close(tree1, testdirh);
1750 ret = torture_setup_local_file(tctx, "localdir", fname_local,
1756 ret = torture_setup_local_file(tctx, "localdir", adname_local,
1757 osx_adouble_w_xattr,
1758 sizeof(osx_adouble_w_xattr));
1763 torture_comment(tctx, "(%s) test OS X AppleDouble conversion\n",
1766 ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1767 fname, AFPRESOURCE_STREAM,
1768 16, datalen, 0, datalen, data);
1771 smb2_deltree(tree1, BASEDIR);
1772 talloc_free(mem_ctx);
1776 static bool test_aapl(struct torture_context *tctx,
1777 struct smb2_tree *tree1)
1779 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1780 const char *fname = BASEDIR "\\test_aapl";
1782 struct smb2_handle testdirh;
1784 struct smb2_create io;
1786 struct smb2_create_blob *aapl = NULL;
1788 const char *type_creator = "SMB,OLE!";
1789 char type_creator_buf[9];
1791 uint32_t aapl_reply_bitmap;
1792 uint32_t aapl_server_caps;
1793 uint32_t aapl_vol_caps;
1797 union smb_search_data *d;
1800 smb2_deltree(tree1, BASEDIR);
1802 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1803 CHECK_STATUS(status, NT_STATUS_OK);
1804 smb2_util_close(tree1, testdirh);
1807 io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
1808 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1809 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
1810 io.in.share_access = (NTCREATEX_SHARE_ACCESS_DELETE |
1811 NTCREATEX_SHARE_ACCESS_READ |
1812 NTCREATEX_SHARE_ACCESS_WRITE);
1813 io.in.fname = fname;
1816 * Issuing an SMB2/CREATE with a suitably formed AAPL context,
1817 * controls behaviour of Apple's SMB2 extensions for the whole
1821 data = data_blob_talloc(mem_ctx, NULL, 3 * sizeof(uint64_t));
1822 SBVAL(data.data, 0, SMB2_CRTCTX_AAPL_SERVER_QUERY);
1823 SBVAL(data.data, 8, (SMB2_CRTCTX_AAPL_SERVER_CAPS |
1824 SMB2_CRTCTX_AAPL_VOLUME_CAPS |
1825 SMB2_CRTCTX_AAPL_MODEL_INFO));
1826 SBVAL(data.data, 16, (SMB2_CRTCTX_AAPL_SUPPORTS_READ_DIR_ATTR |
1827 SMB2_CRTCTX_AAPL_UNIX_BASED |
1828 SMB2_CRTCTX_AAPL_SUPPORTS_NFS_ACE));
1830 torture_comment(tctx, "Testing SMB2 create context AAPL\n");
1831 status = smb2_create_blob_add(tctx, &io.in.blobs, "AAPL", data);
1832 CHECK_STATUS(status, NT_STATUS_OK);
1834 status = smb2_create(tree1, tctx, &io);
1835 CHECK_STATUS(status, NT_STATUS_OK);
1836 status = smb2_util_close(tree1, io.out.file.handle);
1837 CHECK_STATUS(status, NT_STATUS_OK);
1840 * Now check returned AAPL context
1842 torture_comment(tctx, "Comparing returned AAPL capabilities\n");
1844 aapl = smb2_create_blob_find(&io.out.blobs,
1845 SMB2_CREATE_TAG_AAPL);
1847 if (aapl->data.length != 50) {
1849 * uint32_t CommandCode = kAAPL_SERVER_QUERY
1850 * uint32_t Reserved = 0;
1851 * uint64_t ReplyBitmap = kAAPL_SERVER_CAPS |
1852 * kAAPL_VOLUME_CAPS |
1854 * uint64_t ServerCaps = kAAPL_SUPPORTS_READDIR_ATTR |
1855 * kAAPL_SUPPORTS_OSX_COPYFILE;
1856 * uint64_t VolumeCaps = kAAPL_SUPPORT_RESOLVE_ID |
1857 * kAAPL_CASE_SENSITIVE;
1858 * uint32_t Pad2 = 0;
1859 * uint32_t ModelStringLen = 10;
1860 * ucs2_t ModelString[5] = "Samba";
1866 aapl_cmd = IVAL(aapl->data.data, 0);
1867 if (aapl_cmd != SMB2_CRTCTX_AAPL_SERVER_QUERY) {
1868 torture_result(tctx, TORTURE_FAIL,
1869 "(%s) unexpected cmd: %d",
1870 __location__, (int)aapl_cmd);
1875 aapl_reply_bitmap = BVAL(aapl->data.data, 8);
1876 if (aapl_reply_bitmap != (SMB2_CRTCTX_AAPL_SERVER_CAPS |
1877 SMB2_CRTCTX_AAPL_VOLUME_CAPS |
1878 SMB2_CRTCTX_AAPL_MODEL_INFO)) {
1879 torture_result(tctx, TORTURE_FAIL,
1880 "(%s) unexpected reply_bitmap: %d",
1881 __location__, (int)aapl_reply_bitmap);
1886 aapl_server_caps = BVAL(aapl->data.data, 16);
1887 if (aapl_server_caps != (SMB2_CRTCTX_AAPL_UNIX_BASED |
1888 SMB2_CRTCTX_AAPL_SUPPORTS_READ_DIR_ATTR |
1889 SMB2_CRTCTX_AAPL_SUPPORTS_NFS_ACE |
1890 SMB2_CRTCTX_AAPL_SUPPORTS_OSX_COPYFILE)) {
1891 torture_result(tctx, TORTURE_FAIL,
1892 "(%s) unexpected server_caps: %d",
1893 __location__, (int)aapl_server_caps);
1898 aapl_vol_caps = BVAL(aapl->data.data, 24);
1899 if (aapl_vol_caps != SMB2_CRTCTX_AAPL_CASE_SENSITIVE) {
1900 /* this will fail on a case insensitive fs ... */
1901 torture_result(tctx, TORTURE_FAIL,
1902 "(%s) unexpected vol_caps: %d",
1903 __location__, (int)aapl_vol_caps);
1908 ret = convert_string_talloc(mem_ctx,
1909 CH_UTF16LE, CH_UNIX,
1910 aapl->data.data + 40, 10,
1913 torture_result(tctx, TORTURE_FAIL,
1914 "(%s) convert_string_talloc() failed",
1918 torture_comment(tctx, "Got server model: \"%s\"\n", model);
1921 * Now that Requested AAPL extensions are enabled, setup some
1922 * Mac files with metadata and resource fork
1924 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1926 torture_result(tctx, TORTURE_FAIL,
1927 "(%s) torture_setup_file() failed",
1932 info = torture_afpinfo_new(mem_ctx);
1934 torture_result(tctx, TORTURE_FAIL,
1935 "(%s) torture_afpinfo_new() failed",
1941 memcpy(info->afpi_FinderInfo, type_creator, 8);
1942 ret = torture_write_afpinfo(tree1, tctx, mem_ctx, fname, info);
1944 torture_result(tctx, TORTURE_FAIL,
1945 "(%s) torture_write_afpinfo() failed",
1950 ret = write_stream(tree1, __location__, tctx, mem_ctx,
1951 fname, AFPRESOURCE_STREAM,
1954 torture_result(tctx, TORTURE_FAIL,
1955 "(%s) write_stream() failed",
1961 * Ok, file is prepared, now call smb2/find
1965 io.in.desired_access = SEC_RIGHTS_DIR_ALL;
1966 io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
1967 io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
1968 io.in.share_access = (NTCREATEX_SHARE_ACCESS_READ |
1969 NTCREATEX_SHARE_ACCESS_WRITE |
1970 NTCREATEX_SHARE_ACCESS_DELETE);
1971 io.in.create_disposition = NTCREATEX_DISP_OPEN;
1972 io.in.fname = BASEDIR;
1973 status = smb2_create(tree1, tctx, &io);
1974 CHECK_STATUS(status, NT_STATUS_OK);
1977 f.in.file.handle = io.out.file.handle;
1978 f.in.pattern = "test_aapl";
1979 f.in.continue_flags = SMB2_CONTINUE_FLAG_SINGLE;
1980 f.in.max_response_size = 0x1000;
1981 f.in.level = SMB2_FIND_ID_BOTH_DIRECTORY_INFO;
1983 status = smb2_find_level(tree1, tree1, &f, &count, &d);
1984 CHECK_STATUS(status, NT_STATUS_OK);
1986 status = smb2_util_close(tree1, io.out.file.handle);
1987 CHECK_STATUS(status, NT_STATUS_OK);
1989 if (strcmp(d[0].id_both_directory_info.name.s, "test_aapl") != 0) {
1990 torture_result(tctx, TORTURE_FAIL,
1991 "(%s) write_stream() failed",
1997 if (d[0].id_both_directory_info.short_name.private_length != 24) {
1998 torture_result(tctx, TORTURE_FAIL,
1999 "(%s) bad short_name length %" PRIu32 ", expected 24",
2000 __location__, d[0].id_both_directory_info.short_name.private_length);
2005 torture_comment(tctx, "short_name buffer:\n");
2006 dump_data(0, d[0].id_both_directory_info.short_name_buf, 24);
2009 * Extract data as specified by the AAPL extension:
2010 * - ea_size contains max_access
2011 * - short_name contains resource fork length + FinderInfo
2012 * - reserved2 contains the unix mode
2014 torture_comment(tctx, "mac_access: %" PRIx32 "\n",
2015 d[0].id_both_directory_info.ea_size);
2017 rfork_len = BVAL(d[0].id_both_directory_info.short_name_buf, 0);
2018 if (rfork_len != 3) {
2019 torture_result(tctx, TORTURE_FAIL,
2020 "(%s) expected resource fork length 3, got: %" PRIu64,
2021 __location__, rfork_len);
2026 memcpy(type_creator_buf, d[0].id_both_directory_info.short_name_buf + 8, 8);
2027 type_creator_buf[8] = 0;
2028 if (strcmp(type_creator, type_creator_buf) != 0) {
2029 torture_result(tctx, TORTURE_FAIL,
2030 "(%s) expected type/creator \"%s\" , got: %s",
2031 __location__, type_creator, type_creator_buf);
2037 talloc_free(mem_ctx);
2041 static uint64_t patt_hash(uint64_t off)
2046 static bool write_pattern(struct torture_context *torture,
2047 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
2048 struct smb2_handle h, uint64_t off, uint64_t len,
2054 uint64_t io_sz = MIN(1024 * 64, len);
2060 torture_assert(torture, (len % 8) == 0, "invalid write len");
2062 buf = talloc_zero_size(mem_ctx, io_sz);
2063 torture_assert(torture, (buf != NULL), "no memory for file data buf");
2066 for (i = 0; i <= io_sz - 8; i += 8) {
2067 SBVAL(buf, i, patt_hash(patt_off));
2071 status = smb2_util_write(tree, h,
2073 torture_assert_ntstatus_ok(torture, status, "file write");
2084 static bool check_pattern(struct torture_context *torture,
2085 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
2086 struct smb2_handle h, uint64_t off, uint64_t len,
2093 torture_assert(torture, (len % 8) == 0, "invalid read len");
2099 uint64_t io_sz = MIN(1024 * 64, len);
2102 r.in.file.handle = h;
2103 r.in.length = io_sz;
2105 status = smb2_read(tree, mem_ctx, &r);
2106 torture_assert_ntstatus_ok(torture, status, "read");
2108 torture_assert_u64_equal(torture, r.out.data.length, io_sz,
2109 "read data len mismatch");
2111 for (i = 0; i <= io_sz - 8; i += 8, patt_off += 8) {
2112 uint64_t data = BVAL(r.out.data.data, i);
2113 torture_assert_u64_equal(torture, data, patt_hash(patt_off),
2114 talloc_asprintf(torture, "read data "
2115 "pattern bad at %llu\n",
2116 (unsigned long long)off + i));
2118 talloc_free(r.out.data.data);
2126 static bool test_setup_open(struct torture_context *torture,
2127 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
2129 struct smb2_handle *fh,
2130 uint32_t desired_access,
2131 uint32_t file_attributes)
2133 struct smb2_create io;
2137 io.in.desired_access = desired_access;
2138 io.in.file_attributes = file_attributes;
2139 io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
2140 io.in.share_access =
2141 NTCREATEX_SHARE_ACCESS_DELETE|
2142 NTCREATEX_SHARE_ACCESS_READ|
2143 NTCREATEX_SHARE_ACCESS_WRITE;
2144 if (file_attributes & FILE_ATTRIBUTE_DIRECTORY) {
2145 io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
2147 io.in.fname = fname;
2149 status = smb2_create(tree, mem_ctx, &io);
2150 torture_assert_ntstatus_ok(torture, status, "file create");
2152 *fh = io.out.file.handle;
2157 static bool test_setup_create_fill(struct torture_context *torture,
2158 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
2160 struct smb2_handle *fh,
2162 uint32_t desired_access,
2163 uint32_t file_attributes)
2167 ok = test_setup_open(torture, tree, mem_ctx,
2172 torture_assert(torture, ok, "file open");
2175 ok = write_pattern(torture, tree, mem_ctx, *fh, 0, size, 0);
2176 torture_assert(torture, ok, "write pattern");
2181 static bool test_setup_copy_chunk(struct torture_context *torture,
2182 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
2184 struct smb2_handle *src_h,
2186 uint32_t src_desired_access,
2187 struct smb2_handle *dest_h,
2189 uint32_t dest_desired_access,
2190 struct srv_copychunk_copy *cc_copy,
2191 union smb_ioctl *io)
2193 struct req_resume_key_rsp res_key;
2196 enum ndr_err_code ndr_ret;
2198 ok = test_setup_create_fill(torture, tree, mem_ctx, FNAME_CC_SRC,
2199 src_h, src_size, src_desired_access,
2200 FILE_ATTRIBUTE_NORMAL);
2201 torture_assert(torture, ok, "src file create fill");
2203 ok = test_setup_create_fill(torture, tree, mem_ctx, FNAME_CC_DST,
2204 dest_h, dest_size, dest_desired_access,
2205 FILE_ATTRIBUTE_NORMAL);
2206 torture_assert(torture, ok, "dest file create fill");
2209 io->smb2.level = RAW_IOCTL_SMB2;
2210 io->smb2.in.file.handle = *src_h;
2211 io->smb2.in.function = FSCTL_SRV_REQUEST_RESUME_KEY;
2212 /* Allow for Key + ContextLength + Context */
2213 io->smb2.in.max_response_size = 32;
2214 io->smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
2216 status = smb2_ioctl(tree, mem_ctx, &io->smb2);
2217 torture_assert_ntstatus_ok(torture, status,
2218 "FSCTL_SRV_REQUEST_RESUME_KEY");
2220 ndr_ret = ndr_pull_struct_blob(&io->smb2.out.out, mem_ctx, &res_key,
2221 (ndr_pull_flags_fn_t)ndr_pull_req_resume_key_rsp);
2223 torture_assert_ndr_success(torture, ndr_ret,
2224 "ndr_pull_req_resume_key_rsp");
2227 io->smb2.level = RAW_IOCTL_SMB2;
2228 io->smb2.in.file.handle = *dest_h;
2229 io->smb2.in.function = FSCTL_SRV_COPYCHUNK;
2230 io->smb2.in.max_response_size = sizeof(struct srv_copychunk_rsp);
2231 io->smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
2233 ZERO_STRUCTPN(cc_copy);
2234 memcpy(cc_copy->source_key, res_key.resume_key, ARRAY_SIZE(cc_copy->source_key));
2235 cc_copy->chunk_count = nchunks;
2236 cc_copy->chunks = talloc_zero_array(mem_ctx, struct srv_copychunk, nchunks);
2237 torture_assert(torture, (cc_copy->chunks != NULL), "no memory for chunks");
2243 static bool check_copy_chunk_rsp(struct torture_context *torture,
2244 struct srv_copychunk_rsp *cc_rsp,
2245 uint32_t ex_chunks_written,
2246 uint32_t ex_chunk_bytes_written,
2247 uint32_t ex_total_bytes_written)
2249 torture_assert_int_equal(torture, cc_rsp->chunks_written,
2250 ex_chunks_written, "num chunks");
2251 torture_assert_int_equal(torture, cc_rsp->chunk_bytes_written,
2252 ex_chunk_bytes_written, "chunk bytes written");
2253 torture_assert_int_equal(torture, cc_rsp->total_bytes_written,
2254 ex_total_bytes_written, "chunk total bytes");
2258 static bool neg_aapl_copyfile(struct torture_context *tctx,
2259 struct smb2_tree *tree,
2262 TALLOC_CTX *mem_ctx = talloc_new(tctx);
2263 const char *fname = "aapl";
2265 struct smb2_create io;
2267 struct smb2_create_blob *aapl = NULL;
2269 uint32_t aapl_reply_bitmap;
2270 uint32_t aapl_server_caps;
2274 io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
2275 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
2276 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
2277 io.in.share_access = (NTCREATEX_SHARE_ACCESS_DELETE |
2278 NTCREATEX_SHARE_ACCESS_READ |
2279 NTCREATEX_SHARE_ACCESS_WRITE);
2280 io.in.fname = fname;
2282 data = data_blob_talloc(mem_ctx, NULL, 3 * sizeof(uint64_t));
2283 SBVAL(data.data, 0, SMB2_CRTCTX_AAPL_SERVER_QUERY);
2284 SBVAL(data.data, 8, (SMB2_CRTCTX_AAPL_SERVER_CAPS));
2285 SBVAL(data.data, 16, flags);
2287 status = smb2_create_blob_add(tctx, &io.in.blobs, "AAPL", data);
2288 CHECK_STATUS(status, NT_STATUS_OK);
2290 status = smb2_create(tree, tctx, &io);
2291 CHECK_STATUS(status, NT_STATUS_OK);
2293 aapl = smb2_create_blob_find(&io.out.blobs,
2294 SMB2_CREATE_TAG_AAPL);
2300 if (aapl->data.length < 24) {
2305 aapl_cmd = IVAL(aapl->data.data, 0);
2306 if (aapl_cmd != SMB2_CRTCTX_AAPL_SERVER_QUERY) {
2307 torture_result(tctx, TORTURE_FAIL,
2308 "(%s) unexpected cmd: %d",
2309 __location__, (int)aapl_cmd);
2314 aapl_reply_bitmap = BVAL(aapl->data.data, 8);
2315 if (!(aapl_reply_bitmap & SMB2_CRTCTX_AAPL_SERVER_CAPS)) {
2316 torture_result(tctx, TORTURE_FAIL,
2317 "(%s) unexpected reply_bitmap: %d",
2318 __location__, (int)aapl_reply_bitmap);
2323 aapl_server_caps = BVAL(aapl->data.data, 16);
2324 if (!(aapl_server_caps & flags)) {
2325 torture_result(tctx, TORTURE_FAIL,
2326 "(%s) unexpected server_caps: %d",
2327 __location__, (int)aapl_server_caps);
2333 status = smb2_util_close(tree, io.out.file.handle);
2334 CHECK_STATUS(status, NT_STATUS_OK);
2336 smb2_util_unlink(tree, "aapl");
2337 talloc_free(mem_ctx);
2341 static bool test_copyfile(struct torture_context *torture,
2342 struct smb2_tree *tree)
2344 struct smb2_handle src_h;
2345 struct smb2_handle dest_h;
2348 TALLOC_CTX *tmp_ctx = talloc_new(tree);
2349 struct srv_copychunk_copy cc_copy;
2350 struct srv_copychunk_rsp cc_rsp;
2351 enum ndr_err_code ndr_ret;
2355 * First test a copy_chunk with a 0 chunk count without having
2356 * enabled this via AAPL. The request must not fail and the
2357 * copied length in the response must be 0. This is verified
2358 * against Windows 2008r2.
2361 ok = test_setup_copy_chunk(torture, tree, tmp_ctx,
2362 0, /* 0 chunks, copyfile semantics */
2363 &src_h, 4096, /* fill 4096 byte src file */
2364 SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA,
2365 &dest_h, 0, /* 0 byte dest file */
2366 SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA,
2370 torture_fail_goto(torture, done, "setup copy chunk error");
2373 ndr_ret = ndr_push_struct_blob(&io.smb2.in.out, tmp_ctx,
2375 (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy);
2376 torture_assert_ndr_success(torture, ndr_ret,
2377 "ndr_push_srv_copychunk_copy");
2379 status = smb2_ioctl(tree, tmp_ctx, &io.smb2);
2380 torture_assert_ntstatus_ok_goto(torture, status, ok, done, "FSCTL_SRV_COPYCHUNK");
2382 ndr_ret = ndr_pull_struct_blob(&io.smb2.out.out, tmp_ctx,
2384 (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp);
2385 torture_assert_ndr_success(torture, ndr_ret,
2386 "ndr_pull_srv_copychunk_rsp");
2388 ok = check_copy_chunk_rsp(torture, &cc_rsp,
2389 0, /* chunks written */
2390 0, /* chunk bytes unsuccessfully written */
2391 0); /* total bytes written */
2393 torture_fail_goto(torture, done, "bad copy chunk response data");
2397 * Now enable AAPL copyfile and test again, the file and the
2398 * stream must be copied by the server.
2400 ok = neg_aapl_copyfile(torture, tree,
2401 SMB2_CRTCTX_AAPL_SUPPORTS_OSX_COPYFILE);
2403 torture_skip_goto(torture, done, "missing AAPL copyfile");
2407 smb2_util_close(tree, src_h);
2408 smb2_util_close(tree, dest_h);
2409 smb2_util_unlink(tree, FNAME_CC_SRC);
2410 smb2_util_unlink(tree, FNAME_CC_DST);
2412 ok = torture_setup_file(tmp_ctx, tree, FNAME_CC_SRC, false);
2414 torture_fail(torture, "setup file error");
2416 ok = write_stream(tree, __location__, torture, tmp_ctx,
2417 FNAME_CC_SRC, AFPRESOURCE_STREAM,
2418 10, 10, "1234567890");
2420 torture_fail(torture, "setup stream error");
2423 ok = test_setup_copy_chunk(torture, tree, tmp_ctx,
2424 0, /* 0 chunks, copyfile semantics */
2425 &src_h, 4096, /* fill 4096 byte src file */
2426 SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA,
2427 &dest_h, 0, /* 0 byte dest file */
2428 SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA,
2432 torture_fail_goto(torture, done, "setup copy chunk error");
2435 ndr_ret = ndr_push_struct_blob(&io.smb2.in.out, tmp_ctx,
2437 (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy);
2438 torture_assert_ndr_success(torture, ndr_ret,
2439 "ndr_push_srv_copychunk_copy");
2441 status = smb2_ioctl(tree, tmp_ctx, &io.smb2);
2442 torture_assert_ntstatus_ok_goto(torture, status, ok, done, "FSCTL_SRV_COPYCHUNK");
2444 ndr_ret = ndr_pull_struct_blob(&io.smb2.out.out, tmp_ctx,
2446 (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp);
2447 torture_assert_ndr_success(torture, ndr_ret,
2448 "ndr_pull_srv_copychunk_rsp");
2450 ok = check_copy_chunk_rsp(torture, &cc_rsp,
2451 0, /* chunks written */
2452 0, /* chunk bytes unsuccessfully written */
2453 4096); /* total bytes written */
2455 torture_fail_goto(torture, done, "bad copy chunk response data");
2458 ok = test_setup_open(torture, tree, tmp_ctx, FNAME_CC_DST, &dest_h,
2459 SEC_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL);
2461 torture_fail_goto(torture, done,"open failed");
2463 ok = check_pattern(torture, tree, tmp_ctx, dest_h, 0, 4096, 0);
2465 torture_fail_goto(torture, done, "inconsistent file data");
2468 ok = check_stream(tree, __location__, torture, tmp_ctx,
2469 FNAME_CC_DST, AFPRESOURCE_STREAM,
2470 0, 20, 10, 10, "1234567890");
2472 torture_fail_goto(torture, done, "inconsistent stream data");
2476 smb2_util_close(tree, src_h);
2477 smb2_util_close(tree, dest_h);
2478 smb2_util_unlink(tree, FNAME_CC_SRC);
2479 smb2_util_unlink(tree, FNAME_CC_DST);
2480 talloc_free(tmp_ctx);
2484 static bool check_stream_list(struct smb2_tree *tree,
2485 struct torture_context *tctx,
2489 struct smb2_handle h)
2491 union smb_fileinfo finfo;
2494 TALLOC_CTX *tmp_ctx = talloc_new(tctx);
2496 struct stream_struct *stream_sort;
2498 finfo.generic.level = RAW_FILEINFO_STREAM_INFORMATION;
2499 finfo.generic.in.file.handle = h;
2501 status = smb2_getinfo_file(tree, tctx, &finfo);
2502 torture_assert_ntstatus_ok(tctx, status, "get stream info");
2504 torture_assert_int_equal(tctx, finfo.stream_info.out.num_streams, num_exp,
2508 TALLOC_FREE(tmp_ctx);
2512 exp_sort = talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp));
2513 torture_assert(tctx, exp_sort != NULL, __location__);
2515 TYPESAFE_QSORT(exp_sort, num_exp, qsort_string);
2517 stream_sort = talloc_memdup(tmp_ctx, finfo.stream_info.out.streams,
2518 finfo.stream_info.out.num_streams *
2519 sizeof(*stream_sort));
2520 torture_assert(tctx, stream_sort != NULL, __location__);
2522 TYPESAFE_QSORT(stream_sort, finfo.stream_info.out.num_streams, qsort_stream);
2524 for (i=0; i<num_exp; i++) {
2525 torture_comment(tctx, "i[%d] exp[%s] got[%s]\n",
2526 i, exp_sort[i], stream_sort[i].stream_name.s);
2527 torture_assert_str_equal(tctx, stream_sort[i].stream_name.s, exp_sort[i],
2531 TALLOC_FREE(tmp_ctx);
2538 static bool test_stream_names(struct torture_context *tctx,
2539 struct smb2_tree *tree)
2541 TALLOC_CTX *mem_ctx = talloc_new(tctx);
2543 struct smb2_create create;
2544 struct smb2_handle h;
2545 const char *fname = BASEDIR "\\stream_names.txt";
2548 /* UTF8 private use are starts at 0xef 0x80 0x80 (0xf000) */
2549 const char *streams[] = {
2550 ":foo" "\xef\x80\xa2" "bar:$DATA", /* "foo:bar:$DATA" */
2551 ":bar" "\xef\x80\xa2" "baz:$DATA", /* "bar:baz:$DATA" */
2555 sname1 = talloc_asprintf(mem_ctx, "%s%s", fname, streams[0]);
2557 /* clean slate ...*/
2558 smb2_util_unlink(tree, fname);
2559 smb2_deltree(tree, fname);
2560 smb2_deltree(tree, BASEDIR);
2562 status = torture_smb2_testdir(tree, BASEDIR, &h);
2563 CHECK_STATUS(status, NT_STATUS_OK);
2564 smb2_util_close(tree, h);
2566 torture_comment(tctx, "(%s) testing stream names\n", __location__);
2567 ZERO_STRUCT(create);
2568 create.in.desired_access = SEC_FILE_WRITE_DATA;
2569 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
2570 create.in.share_access =
2571 NTCREATEX_SHARE_ACCESS_DELETE|
2572 NTCREATEX_SHARE_ACCESS_READ|
2573 NTCREATEX_SHARE_ACCESS_WRITE;
2574 create.in.create_disposition = NTCREATEX_DISP_CREATE;
2575 create.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
2576 create.in.fname = sname1;
2578 status = smb2_create(tree, mem_ctx, &create);
2579 CHECK_STATUS(status, NT_STATUS_OK);
2580 smb2_util_close(tree, create.out.file.handle);
2582 ret = torture_setup_local_xattr(tctx, "localdir", BASEDIR "/stream_names.txt",
2583 "user.DosStream.bar:baz:$DATA",
2584 "data", strlen("data"));
2585 CHECK_VALUE(ret, true);
2587 ZERO_STRUCT(create);
2588 create.in.fname = fname;
2589 create.in.create_disposition = NTCREATEX_DISP_OPEN;
2590 create.in.desired_access = SEC_RIGHTS_FILE_ALL;
2591 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
2592 create.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
2593 status = smb2_create(tree, mem_ctx, &create);
2594 CHECK_STATUS(status, NT_STATUS_OK);
2596 ret = check_stream_list(tree, tctx, fname, 3, streams,
2597 create.out.file.handle);
2598 CHECK_VALUE(ret, true);
2600 smb2_util_close(tree, create.out.file.handle);
2603 status = smb2_util_unlink(tree, fname);
2604 smb2_deltree(tree, BASEDIR);
2605 talloc_free(mem_ctx);
2610 /* Renaming a directory with open file, should work for OS X AAPL clients */
2611 static bool test_rename_dir_openfile(struct torture_context *torture,
2612 struct smb2_tree *tree1)
2618 union smb_setfileinfo sinfo;
2619 struct smb2_handle d1, h1;
2620 const char *renamedir = BASEDIR "-new";
2622 smb2_deltree(tree1, BASEDIR);
2623 smb2_util_rmdir(tree1, BASEDIR);
2624 smb2_deltree(tree1, renamedir);
2626 ZERO_STRUCT(io.smb2);
2627 io.generic.level = RAW_OPEN_SMB2;
2628 io.smb2.in.create_flags = 0;
2629 io.smb2.in.desired_access = 0x0017019f;
2630 io.smb2.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
2631 io.smb2.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
2632 io.smb2.in.share_access = 0;
2633 io.smb2.in.alloc_size = 0;
2634 io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
2635 io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
2636 io.smb2.in.security_flags = 0;
2637 io.smb2.in.fname = BASEDIR;
2639 status = smb2_create(tree1, torture, &(io.smb2));
2640 torture_assert_ntstatus_ok(torture, status, "smb2_create dir");
2641 d1 = io.smb2.out.file.handle;
2643 ZERO_STRUCT(io.smb2);
2644 io.generic.level = RAW_OPEN_SMB2;
2645 io.smb2.in.create_flags = 0;
2646 io.smb2.in.desired_access = 0x0017019f;
2647 io.smb2.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
2648 io.smb2.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
2649 io.smb2.in.share_access = 0;
2650 io.smb2.in.alloc_size = 0;
2651 io.smb2.in.create_disposition = NTCREATEX_DISP_CREATE;
2652 io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
2653 io.smb2.in.security_flags = 0;
2654 io.smb2.in.fname = BASEDIR "\\file.txt";
2656 status = smb2_create(tree1, torture, &(io.smb2));
2657 torture_assert_ntstatus_ok(torture, status, "smb2_create file");
2658 h1 = io.smb2.out.file.handle;
2660 torture_comment(torture, "Renaming directory without AAPL, must fail\n");
2663 sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION;
2664 sinfo.rename_information.in.file.handle = d1;
2665 sinfo.rename_information.in.overwrite = 0;
2666 sinfo.rename_information.in.root_fid = 0;
2667 sinfo.rename_information.in.new_name = renamedir;
2668 status = smb2_setinfo_file(tree1, &sinfo);
2669 torture_assert_ntstatus_equal(torture, status, NT_STATUS_ACCESS_DENIED,
2670 "smb2_setinfo_file");
2672 ZERO_STRUCT(cl.smb2);
2673 cl.smb2.level = RAW_CLOSE_SMB2;
2674 cl.smb2.in.file.handle = d1;
2675 status = smb2_close(tree1, &(cl.smb2));
2676 torture_assert_ntstatus_ok(torture, status, "smb2_close");
2679 torture_comment(torture, "Enabling AAPL\n");
2681 ret = enable_aapl(torture, tree1);
2682 torture_assert(torture, ret == true, "enable_aapl failed");
2684 torture_comment(torture, "Renaming directory with AAPL\n");
2686 ZERO_STRUCT(io.smb2);
2687 io.generic.level = RAW_OPEN_SMB2;
2688 io.smb2.in.desired_access = 0x0017019f;
2689 io.smb2.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
2690 io.smb2.in.share_access = 0;
2691 io.smb2.in.alloc_size = 0;
2692 io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
2693 io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
2694 io.smb2.in.security_flags = 0;
2695 io.smb2.in.fname = BASEDIR;
2697 status = smb2_create(tree1, torture, &(io.smb2));
2698 torture_assert_ntstatus_ok(torture, status, "smb2_create dir");
2699 d1 = io.smb2.out.file.handle;
2701 ZERO_STRUCT(io.smb2);
2702 io.generic.level = RAW_OPEN_SMB2;
2703 io.smb2.in.desired_access = 0x0017019f;
2704 io.smb2.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
2705 io.smb2.in.share_access = 0;
2706 io.smb2.in.alloc_size = 0;
2707 io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
2708 io.smb2.in.impersonation_level = SMB2_IMPERSONATION_ANONYMOUS;
2709 io.smb2.in.security_flags = 0;
2710 io.smb2.in.fname = BASEDIR;
2711 sinfo.rename_information.in.file.handle = d1;
2713 status = smb2_setinfo_file(tree1, &sinfo);
2714 torture_assert_ntstatus_ok(torture, status, "smb2_setinfo_file");
2716 ZERO_STRUCT(cl.smb2);
2717 cl.smb2.level = RAW_CLOSE_SMB2;
2718 cl.smb2.in.file.handle = d1;
2719 status = smb2_close(tree1, &(cl.smb2));
2720 torture_assert_ntstatus_ok(torture, status, "smb2_close");
2723 cl.smb2.in.file.handle = h1;
2724 status = smb2_close(tree1, &(cl.smb2));
2725 torture_assert_ntstatus_ok(torture, status, "smb2_close");
2728 torture_comment(torture, "Cleaning up\n");
2731 ZERO_STRUCT(cl.smb2);
2732 cl.smb2.level = RAW_CLOSE_SMB2;
2733 cl.smb2.in.file.handle = h1;
2734 status = smb2_close(tree1, &(cl.smb2));
2737 smb2_deltree(tree1, BASEDIR);
2738 smb2_deltree(tree1, renamedir);
2743 * Note: This test depends on "vfs objects = catia fruit streams_xattr". For
2744 * some tests torture must be run on the host it tests and takes an additional
2745 * argument with the local path to the share:
2746 * "--option=torture:localdir=<SHAREPATH>".
2748 struct torture_suite *torture_vfs_fruit(void)
2750 struct torture_suite *suite = torture_suite_create(
2751 talloc_autofree_context(), "fruit");
2753 suite->description = talloc_strdup(suite, "vfs_fruit tests");
2755 torture_suite_add_1smb2_test(suite, "copyfile", test_copyfile);
2756 torture_suite_add_1smb2_test(suite, "read metadata", test_read_atalk_metadata);
2757 torture_suite_add_1smb2_test(suite, "write metadata", test_write_atalk_metadata);
2758 torture_suite_add_1smb2_test(suite, "resource fork IO", test_write_atalk_rfork_io);
2759 torture_suite_add_1smb2_test(suite, "OS X AppleDouble file conversion", test_adouble_conversion);
2760 torture_suite_add_1smb2_test(suite, "SMB2/CREATE context AAPL", test_aapl);
2761 torture_suite_add_1smb2_test(suite, "stream names", test_stream_names);
2762 torture_suite_add_1smb2_test(suite, "truncate resource fork to 0 bytes", test_rfork_truncate);
2763 torture_suite_add_1smb2_test(suite, "opening and creating resource fork", test_rfork_create);
2764 torture_suite_add_1smb2_test(suite, "rename_dir_openfile", test_rename_dir_openfile);