s4:torture:vfs_fruit: check offset and length when reading AFP_AfpInfo stream
[Samba.git] / source4 / torture / vfs / fruit.c
blob4de21b27da3e0c5b8b6ccdd45edb464a50f58f3a
1 /*
2 Unix SMB/CIFS implementation.
4 vfs_fruit tests
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/>.
22 #include "includes.h"
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"
33 #include "torture/torture.h"
34 #include "torture/util.h"
35 #include "torture/smb2/proto.h"
36 #include "torture/vfs/proto.h"
37 #include "librpc/gen_ndr/ndr_ioctl.h"
39 #define BASEDIR "vfs_fruit_dir"
40 #define FNAME_CC_SRC "testfsctl.dat"
41 #define FNAME_CC_DST "testfsctl2.dat"
43 #define CHECK_STATUS(status, correct) do { \
44 if (!NT_STATUS_EQUAL(status, correct)) { \
45 torture_result(tctx, TORTURE_FAIL, \
46 "(%s) Incorrect status %s - should be %s\n", \
47 __location__, nt_errstr(status), nt_errstr(correct)); \
48 ret = false; \
49 goto done; \
50 }} while (0)
52 #define CHECK_VALUE(v, correct) do { \
53 if ((v) != (correct)) { \
54 torture_result(tctx, TORTURE_FAIL, \
55 "(%s) Incorrect value %s=%u - should be %u\n", \
56 __location__, #v, (unsigned)v, (unsigned)correct); \
57 ret = false; \
58 goto done; \
59 }} while (0)
62 * REVIEW:
63 * This is hokey, but what else can we do?
65 #if defined(HAVE_ATTROPEN) || defined(FREEBSD)
66 #define AFPINFO_EA_NETATALK "org.netatalk.Metadata"
67 #define AFPRESOURCE_EA_NETATALK "org.netatalk.ResourceFork"
68 #else
69 #define AFPINFO_EA_NETATALK "user.org.netatalk.Metadata"
70 #define AFPRESOURCE_EA_NETATALK "user.org.netatalk.ResourceFork"
71 #endif
74 The metadata xattr char buf below contains the following attributes:
76 -------------------------------------------------------------------------------
77 Entry ID : 00000008 : File Dates Info
78 Offset : 00000162 : 354
79 Length : 00000010 : 16
81 -DATE------: : (GMT) : (Local)
82 create : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
83 modify : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
84 backup : 80000000 : Unknown or Initial
85 access : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
87 -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
88 00000000 : 1B 44 21 69 1B 44 21 69 80 00 00 00 1B 44 21 69 : .D!i.D!i.....D!i
90 -------------------------------------------------------------------------------
91 Entry ID : 00000009 : Finder Info
92 Offset : 0000007A : 122
93 Length : 00000020 : 32
95 -FInfo-----:
96 Type : 42415252 : BARR
97 Creator : 464F4F4F : FOOO
98 isAlias : 0
99 Invisible : 1
100 hasBundle : 0
101 nameLocked : 0
102 Stationery : 0
103 CustomIcon : 0
104 Reserved : 0
105 Inited : 0
106 NoINITS : 0
107 Shared : 0
108 SwitchLaunc: 0
109 Hidden Ext : 0
110 color : 000 : none
111 isOnDesk : 0
112 Location v : 0000 : 0
113 Location h : 0000 : 0
114 Fldr : 0000 : ..
116 -FXInfo----:
117 Rsvd|IconID: 0000 : 0
118 Rsvd : 0000 : ..
119 Rsvd : 0000 : ..
120 Rsvd : 0000 : ..
121 AreInvalid : 0
122 unknown bit: 0
123 unknown bit: 0
124 unknown bit: 0
125 unknown bit: 0
126 unknown bit: 0
127 unknown bit: 0
128 CustomBadge: 0
129 ObjctIsBusy: 0
130 unknown bit: 0
131 unknown bit: 0
132 unknown bit: 0
133 unknown bit: 0
134 RoutingInfo: 0
135 unknown bit: 0
136 unknown bit: 0
137 Rsvd|commnt: 0000 : 0
138 PutAway : 00000000 : 0
140 -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
141 00000000 : 42 41 52 52 46 4F 4F 4F 40 00 00 00 00 00 00 00 : BARRFOOO@.......
142 00000010 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
144 -------------------------------------------------------------------------------
145 Entry ID : 0000000E : AFP File Info
146 Offset : 00000172 : 370
147 Length : 00000004 : 4
149 -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
150 00000000 : 00 00 01 A1 : ....
153 char metadata_xattr[] = {
154 0x00, 0x05, 0x16, 0x07, 0x00, 0x02, 0x00, 0x00,
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
158 0x00, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
159 0x00, 0x08, 0x00, 0x00, 0x01, 0x62, 0x00, 0x00,
160 0x00, 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
161 0x00, 0x7a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
162 0x00, 0x0e, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00,
163 0x00, 0x04, 0x80, 0x44, 0x45, 0x56, 0x00, 0x00,
164 0x01, 0x76, 0x00, 0x00, 0x00, 0x08, 0x80, 0x49,
165 0x4e, 0x4f, 0x00, 0x00, 0x01, 0x7e, 0x00, 0x00,
166 0x00, 0x08, 0x80, 0x53, 0x59, 0x4e, 0x00, 0x00,
167 0x01, 0x86, 0x00, 0x00, 0x00, 0x08, 0x80, 0x53,
168 0x56, 0x7e, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00,
169 0x00, 0x04, 0x42, 0x41, 0x52, 0x52, 0x46, 0x4f,
170 0x4f, 0x4f, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
183 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
184 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
188 0x00, 0x00, 0x00, 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, 0x1b, 0x44, 0x21, 0x69, 0x1b, 0x44,
199 0x21, 0x69, 0x80, 0x00, 0x00, 0x00, 0x1b, 0x44,
200 0x21, 0x69, 0x00, 0x00, 0x01, 0xa1, 0x00, 0xfd,
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x20,
202 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0xe3,
203 0x86, 0x53, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x01,
204 0x00, 0x00
208 The buf below contains the following AppleDouble encoded data:
210 -------------------------------------------------------------------------------
211 MagicNumber: 00051607 : AppleDouble
212 Version : 00020000 : Version 2
213 Filler : 4D 61 63 20 4F 53 20 58 20 20 20 20 20 20 20 20 : Mac OS X
214 Num. of ent: 0002 : 2
216 -------------------------------------------------------------------------------
217 Entry ID : 00000009 : Finder Info
218 Offset : 00000032 : 50
219 Length : 00000EB0 : 3760
221 -FInfo-----:
222 Type : 54455854 : TEXT
223 Creator : 21526368 : !Rch
226 -EA--------:
227 pad : 0000 : ..
228 magic : 41545452 : ATTR
229 debug_tag : 0007F98E : 522638
230 total_size : 00000EE2 : 3810
231 data_start : 00000078 : 120
232 data_length: 00000000 : 0
233 reserved[0]: 00000000 : ....
234 reserved[1]: 00000000 : ....
235 reserved[2]: 00000000 : ....
236 flags : 0000 : ..
237 num_attrs : 0000 : 0
239 -------------------------------------------------------------------------------
240 Entry ID : 00000002 : Resource Fork
241 Offset : 00000EE2 : 3810
242 Length : 0000011E : 286
244 -RAW DUMP--: 0 1 2 3 4 5 6 7 8 9 A B C D E F : (ASCII)
245 00000000 : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
246 00000010 : 54 68 69 73 20 72 65 73 6F 75 72 63 65 20 66 6F : This resource fo
247 00000020 : 72 6B 20 69 6E 74 65 6E 74 69 6F 6E 61 6C 6C 79 : rk intentionally
248 00000030 : 20 6C 65 66 74 20 62 6C 61 6E 6B 20 20 20 00 00 : left blank ..
250 00000110 : 00 00 00 00 00 00 00 00 00 1C 00 1E FF FF : ..............
252 static char osx_adouble_w_xattr[] = {
253 0x00, 0x05, 0x16, 0x07, 0x00, 0x02, 0x00, 0x00,
254 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x58,
255 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
256 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
257 0x00, 0x32, 0x00, 0x00, 0x0e, 0xb0, 0x00, 0x00,
258 0x00, 0x02, 0x00, 0x00, 0x0e, 0xe2, 0x00, 0x00,
259 0x01, 0x1e, 0x54, 0x45, 0x58, 0x54, 0x21, 0x52,
260 0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
263 0x00, 0x00, 0x00, 0x00, 0x41, 0x54, 0x54, 0x52,
264 0x00, 0x07, 0xf9, 0x8e, 0x00, 0x00, 0x0e, 0xe2,
265 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
273 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
275 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00,
282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
283 0x00, 0x00, 0x00, 0x00, 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, 0x01, 0x00, 0x00, 0x00,
730 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
731 0x00, 0x1e, 0x54, 0x68, 0x69, 0x73, 0x20, 0x72,
732 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20,
733 0x66, 0x6f, 0x72, 0x6b, 0x20, 0x69, 0x6e, 0x74,
734 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
735 0x6c, 0x79, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x20,
736 0x62, 0x6c, 0x61, 0x6e, 0x6b, 0x20, 0x20, 0x20,
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, 0x00, 0x00, 0x00, 0x00,
748 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
749 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
750 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
751 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
752 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
753 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
754 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
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, 0x01, 0x00, 0x00, 0x00,
762 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
763 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
764 0x00, 0x00, 0x00, 0x1c, 0x00, 0x1e, 0xff, 0xff
768 * talloc and intialize an AfpInfo
770 static AfpInfo *torture_afpinfo_new(TALLOC_CTX *mem_ctx)
772 AfpInfo *info;
774 info = talloc_zero(mem_ctx, AfpInfo);
775 if (info == NULL) {
776 return NULL;
779 info->afpi_Signature = AFP_Signature;
780 info->afpi_Version = AFP_Version;
781 info->afpi_BackupTime = AFP_BackupTime;
783 return info;
787 * Pack AfpInfo into a talloced buffer
789 static char *torture_afpinfo_pack(TALLOC_CTX *mem_ctx,
790 AfpInfo *info)
792 char *buf;
794 buf = talloc_array(mem_ctx, char, AFP_INFO_SIZE);
795 if (buf == NULL) {
796 return NULL;
799 RSIVAL(buf, 0, info->afpi_Signature);
800 RSIVAL(buf, 4, info->afpi_Version);
801 RSIVAL(buf, 12, info->afpi_BackupTime);
802 memcpy(buf + 16, info->afpi_FinderInfo, sizeof(info->afpi_FinderInfo));
804 return buf;
808 * Unpack AfpInfo
810 #if 0
811 static void torture_afpinfo_unpack(AfpInfo *info, char *data)
813 info->afpi_Signature = RIVAL(data, 0);
814 info->afpi_Version = RIVAL(data, 4);
815 info->afpi_BackupTime = RIVAL(data, 12);
816 memcpy(info->afpi_FinderInfo, (const char *)data + 16,
817 sizeof(info->afpi_FinderInfo));
819 #endif
821 static bool torture_write_afpinfo(struct smb2_tree *tree,
822 struct torture_context *tctx,
823 TALLOC_CTX *mem_ctx,
824 const char *fname,
825 AfpInfo *info)
827 struct smb2_handle handle;
828 struct smb2_create io;
829 NTSTATUS status;
830 const char *full_name;
831 char *infobuf;
832 bool ret = true;
834 full_name = talloc_asprintf(mem_ctx, "%s%s", fname, AFPINFO_STREAM);
835 if (full_name == NULL) {
836 torture_comment(tctx, "talloc_asprintf error\n");
837 return false;
839 ZERO_STRUCT(io);
840 io.in.desired_access = SEC_FILE_WRITE_DATA;
841 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
842 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
843 io.in.create_options = 0;
844 io.in.fname = full_name;
846 status = smb2_create(tree, mem_ctx, &io);
847 CHECK_STATUS(status, NT_STATUS_OK);
849 handle = io.out.file.handle;
851 infobuf = torture_afpinfo_pack(mem_ctx, info);
852 if (infobuf == NULL) {
853 return false;
856 status = smb2_util_write(tree, handle, infobuf, 0, AFP_INFO_SIZE);
857 CHECK_STATUS(status, NT_STATUS_OK);
859 smb2_util_close(tree, handle);
861 done:
862 return ret;
866 * Read 'count' bytes at 'offset' from stream 'fname:sname' and
867 * compare against buffer 'value'
869 static bool check_stream(struct smb2_tree *tree,
870 const char *location,
871 struct torture_context *tctx,
872 TALLOC_CTX *mem_ctx,
873 const char *fname,
874 const char *sname,
875 off_t read_offset,
876 size_t read_count,
877 off_t comp_offset,
878 size_t comp_count,
879 const char *value)
881 struct smb2_handle handle;
882 struct smb2_create create;
883 struct smb2_read r;
884 NTSTATUS status;
885 const char *full_name;
887 full_name = talloc_asprintf(mem_ctx, "%s%s", fname, sname);
888 if (full_name == NULL) {
889 torture_comment(tctx, "talloc_asprintf error\n");
890 return false;
892 ZERO_STRUCT(create);
893 create.in.desired_access = SEC_FILE_READ_DATA;
894 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
895 create.in.create_disposition = NTCREATEX_DISP_OPEN;
896 create.in.fname = full_name;
898 torture_comment(tctx, "Open stream %s\n", full_name);
900 status = smb2_create(tree, mem_ctx, &create);
901 if (!NT_STATUS_IS_OK(status)) {
902 if (value == NULL) {
903 return true;
904 } else {
905 torture_comment(tctx, "Unable to open stream %s\n",
906 full_name);
907 sleep(10000000);
908 return false;
912 handle = create.out.file.handle;
913 if (value == NULL) {
914 return true;
918 ZERO_STRUCT(r);
919 r.in.file.handle = handle;
920 r.in.length = read_count;
921 r.in.offset = read_offset;
923 status = smb2_read(tree, tree, &r);
925 if (!NT_STATUS_IS_OK(status)) {
926 torture_comment(tctx, "(%s) Failed to read %lu bytes from "
927 "stream '%s'\n", location, (long)strlen(value), full_name);
928 return false;
931 if (memcmp(r.out.data.data + comp_offset, value, comp_count) != 0) {
932 torture_comment(tctx, "(%s) Bad data in stream\n", location);
933 return false;
936 smb2_util_close(tree, handle);
937 return true;
941 * Read 'count' bytes at 'offset' from stream 'fname:sname' and
942 * compare against buffer 'value'
944 static ssize_t read_stream(struct smb2_tree *tree,
945 const char *location,
946 struct torture_context *tctx,
947 TALLOC_CTX *mem_ctx,
948 const char *fname,
949 const char *sname,
950 off_t read_offset,
951 size_t read_count)
953 struct smb2_handle handle;
954 struct smb2_create create;
955 struct smb2_read r;
956 NTSTATUS status;
957 const char *full_name;
958 bool ret = true;
960 full_name = talloc_asprintf(mem_ctx, "%s%s", fname, sname);
961 if (full_name == NULL) {
962 torture_comment(tctx, "talloc_asprintf error\n");
963 return -1;
965 ZERO_STRUCT(create);
966 create.in.desired_access = SEC_FILE_READ_DATA;
967 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
968 create.in.create_disposition = NTCREATEX_DISP_OPEN;
969 create.in.fname = full_name;
971 torture_comment(tctx, "Open stream %s\n", full_name);
973 status = smb2_create(tree, mem_ctx, &create);
974 if (!NT_STATUS_IS_OK(status)) {
975 torture_comment(tctx, "Unable to open stream %s\n",
976 full_name);
977 return -1;
980 handle = create.out.file.handle;
982 ZERO_STRUCT(r);
983 r.in.file.handle = handle;
984 r.in.length = read_count;
985 r.in.offset = read_offset;
987 status = smb2_read(tree, tree, &r);
988 if (!NT_STATUS_IS_OK(status)) {
989 CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
992 smb2_util_close(tree, handle);
994 done:
995 if (ret == false) {
996 return -1;
998 return r.out.data.length;
1002 * Read 'count' bytes at 'offset' from stream 'fname:sname' and
1003 * compare against buffer 'value'
1005 static bool write_stream(struct smb2_tree *tree,
1006 const char *location,
1007 struct torture_context *tctx,
1008 TALLOC_CTX *mem_ctx,
1009 const char *fname,
1010 const char *sname,
1011 off_t offset,
1012 size_t size,
1013 const char *value)
1015 struct smb2_handle handle;
1016 struct smb2_create create;
1017 NTSTATUS status;
1018 const char *full_name;
1020 full_name = talloc_asprintf(mem_ctx, "%s%s", fname, sname);
1021 if (full_name == NULL) {
1022 torture_comment(tctx, "talloc_asprintf error\n");
1023 return false;
1025 ZERO_STRUCT(create);
1026 create.in.desired_access = SEC_FILE_WRITE_DATA;
1027 create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1028 create.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
1029 create.in.fname = full_name;
1031 status = smb2_create(tree, mem_ctx, &create);
1032 if (!NT_STATUS_IS_OK(status)) {
1033 if (value == NULL) {
1034 return true;
1035 } else {
1036 torture_comment(tctx, "Unable to open stream %s\n",
1037 full_name);
1038 sleep(10000000);
1039 return false;
1043 handle = create.out.file.handle;
1044 if (value == NULL) {
1045 return true;
1048 status = smb2_util_write(tree, handle, value, offset, size);
1050 if (!NT_STATUS_IS_OK(status)) {
1051 torture_comment(tctx, "(%s) Failed to write %lu bytes to "
1052 "stream '%s'\n", location, (long)size, full_name);
1053 return false;
1056 smb2_util_close(tree, handle);
1057 return true;
1060 static bool torture_setup_local_xattr(struct torture_context *tctx,
1061 const char *path_option,
1062 const char *name,
1063 const char *metadata,
1064 size_t size)
1066 int ret = true;
1067 int result;
1068 const char *spath;
1069 char *path;
1071 spath = torture_setting_string(tctx, path_option, NULL);
1072 if (spath == NULL) {
1073 printf("No sharepath for option %s\n", path_option);
1074 return false;
1077 path = talloc_asprintf(tctx, "%s/%s", spath, name);
1079 result = setxattr(path, AFPINFO_EA_NETATALK, metadata, size, 0);
1080 if (result != 0) {
1081 ret = false;
1084 TALLOC_FREE(path);
1086 return ret;
1089 static bool torture_setup_local_file(struct torture_context *tctx,
1090 const char *path_option,
1091 const char *name,
1092 const char *buf,
1093 size_t size)
1095 int fd;
1096 const char *spath;
1097 char *path;
1098 ssize_t rsize;
1100 spath = torture_setting_string(tctx, path_option, NULL);
1101 if (spath == NULL) {
1102 printf("No sharepath for option %s\n", path_option);
1103 return false;
1106 path = talloc_asprintf(tctx, "%s/%s", spath, name);
1107 if (path == NULL) {
1108 return false;
1111 fd = creat(path, S_IRWXU);
1112 TALLOC_FREE(path);
1113 if (fd == -1) {
1114 return false;
1117 if ((buf == NULL) || (size == 0)) {
1118 close(fd);
1119 return true;
1122 rsize = write(fd, buf, size);
1123 if (rsize != size) {
1124 return false;
1127 close(fd);
1129 return true;
1133 * Create a file or directory
1135 static bool torture_setup_file(TALLOC_CTX *mem_ctx, struct smb2_tree *tree,
1136 const char *name, bool dir)
1138 struct smb2_create io;
1139 NTSTATUS status;
1141 smb2_util_unlink(tree, name);
1142 ZERO_STRUCT(io);
1143 io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
1144 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1145 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
1146 io.in.share_access =
1147 NTCREATEX_SHARE_ACCESS_DELETE|
1148 NTCREATEX_SHARE_ACCESS_READ|
1149 NTCREATEX_SHARE_ACCESS_WRITE;
1150 io.in.create_options = 0;
1151 io.in.fname = name;
1152 if (dir) {
1153 io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
1154 io.in.share_access &= ~NTCREATEX_SHARE_ACCESS_DELETE;
1155 io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
1156 io.in.create_disposition = NTCREATEX_DISP_CREATE;
1159 status = smb2_create(tree, mem_ctx, &io);
1160 if (!NT_STATUS_IS_OK(status)) {
1161 return false;
1164 status = smb2_util_close(tree, io.out.file.handle);
1165 if (!NT_STATUS_IS_OK(status)) {
1166 return false;
1169 return true;
1172 static bool test_read_atalk_metadata(struct torture_context *tctx,
1173 struct smb2_tree *tree1,
1174 struct smb2_tree *tree2)
1176 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1177 const char *fname = BASEDIR "\\torture_read_metadata";
1178 NTSTATUS status;
1179 struct smb2_handle testdirh;
1180 bool ret = true;
1181 ssize_t len;
1183 torture_comment(tctx, "Checking metadata access\n");
1185 smb2_util_unlink(tree1, fname);
1187 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1188 CHECK_STATUS(status, NT_STATUS_OK);
1189 smb2_util_close(tree1, testdirh);
1191 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1192 if (ret == false) {
1193 goto done;
1196 ret = torture_setup_local_xattr(tctx, "localdir",
1197 BASEDIR "/torture_read_metadata",
1198 metadata_xattr, sizeof(metadata_xattr));
1199 if (ret == false) {
1200 goto done;
1203 ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1204 0, 60, 0, 4, "AFP");
1206 ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1207 0, 60, 16, 8, "BARRFOOO");
1209 ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1210 16, 8, 0, 8, "BARRFOOO");
1212 /* Check reading offset and read size > sizeof(AFPINFO_STREAM) */
1214 len = read_stream(tree1, __location__, tctx, mem_ctx, fname,
1215 AFPINFO_STREAM, 0, 61);
1216 CHECK_VALUE(len, 60);
1218 len = read_stream(tree1, __location__, tctx, mem_ctx, fname,
1219 AFPINFO_STREAM, 59, 2);
1220 CHECK_VALUE(len, 1);
1222 len = read_stream(tree1, __location__, tctx, mem_ctx, fname,
1223 AFPINFO_STREAM, 60, 1);
1224 CHECK_VALUE(len, 0);
1226 len = read_stream(tree1, __location__, tctx, mem_ctx, fname,
1227 AFPINFO_STREAM, 61, 1);
1228 CHECK_VALUE(len, 0);
1230 done:
1231 smb2_deltree(tree1, BASEDIR);
1232 talloc_free(mem_ctx);
1233 return ret;
1236 static bool test_write_atalk_metadata(struct torture_context *tctx,
1237 struct smb2_tree *tree1,
1238 struct smb2_tree *tree2)
1240 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1241 const char *fname = BASEDIR "\\torture_write_metadata";
1242 const char *type_creator = "SMB,OLE!";
1243 NTSTATUS status;
1244 struct smb2_handle testdirh;
1245 bool ret = true;
1246 AfpInfo *info;
1248 smb2_util_unlink(tree1, fname);
1250 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1251 CHECK_STATUS(status, NT_STATUS_OK);
1252 smb2_util_close(tree1, testdirh);
1254 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1255 if (ret == false) {
1256 goto done;
1259 info = torture_afpinfo_new(mem_ctx);
1260 if (info == NULL) {
1261 goto done;
1264 memcpy(info->afpi_FinderInfo, type_creator, 8);
1265 ret = torture_write_afpinfo(tree1, tctx, mem_ctx, fname, info);
1266 ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1267 0, 60, 16, 8, type_creator);
1269 done:
1270 smb2_deltree(tree1, BASEDIR);
1271 talloc_free(mem_ctx);
1272 return ret;
1275 static bool test_write_atalk_rfork_io(struct torture_context *tctx,
1276 struct smb2_tree *tree1,
1277 struct smb2_tree *tree2)
1279 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1280 const char *fname = BASEDIR "\\torture_write_rfork_io";
1281 const char *rfork = BASEDIR "\\torture_write_rfork_io" AFPRESOURCE_STREAM;
1282 const char *rfork_content = "1234567890";
1283 NTSTATUS status;
1284 struct smb2_handle testdirh;
1285 bool ret = true;
1287 union smb_open io;
1288 struct smb2_handle filehandle;
1289 union smb_fileinfo finfo;
1290 union smb_setfileinfo sinfo;
1292 smb2_util_unlink(tree1, fname);
1294 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1295 CHECK_STATUS(status, NT_STATUS_OK);
1296 smb2_util_close(tree1, testdirh);
1298 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1299 if (ret == false) {
1300 goto done;
1303 torture_comment(tctx, "(%s) writing to resource fork\n",
1304 __location__);
1306 ret &= write_stream(tree1, __location__, tctx, mem_ctx,
1307 fname, AFPRESOURCE_STREAM,
1308 10, 10, rfork_content);
1310 ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1311 fname, AFPRESOURCE_STREAM,
1312 0, 20, 10, 10, rfork_content);
1314 /* Check size after write */
1316 ZERO_STRUCT(io);
1317 io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1318 io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1319 SEC_FILE_WRITE_ATTRIBUTE;
1320 io.smb2.in.fname = rfork;
1321 status = smb2_create(tree1, mem_ctx, &(io.smb2));
1322 CHECK_STATUS(status, NT_STATUS_OK);
1323 filehandle = io.smb2.out.file.handle;
1325 torture_comment(tctx, "(%s) check resource fork size after write\n",
1326 __location__);
1328 ZERO_STRUCT(finfo);
1329 finfo.generic.level = RAW_FILEINFO_ALL_INFORMATION;
1330 finfo.generic.in.file.handle = filehandle;
1331 status = smb2_getinfo_file(tree1, mem_ctx, &finfo);
1332 CHECK_STATUS(status, NT_STATUS_OK);
1333 if (finfo.all_info.out.size != 20) {
1334 torture_result(tctx, TORTURE_FAIL,
1335 "(%s) Incorrect resource fork size\n",
1336 __location__);
1337 ret = false;
1338 smb2_util_close(tree1, filehandle);
1339 goto done;
1341 smb2_util_close(tree1, filehandle);
1343 /* Write at large offset */
1345 torture_comment(tctx, "(%s) writing to resource fork at large offset\n",
1346 __location__);
1348 ret &= write_stream(tree1, __location__, tctx, mem_ctx,
1349 fname, AFPRESOURCE_STREAM,
1350 (off_t)1<<32, 10, rfork_content);
1352 ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1353 fname, AFPRESOURCE_STREAM,
1354 (off_t)1<<32, 10, 0, 10, rfork_content);
1356 /* Truncate back to size of 1 byte */
1358 torture_comment(tctx, "(%s) truncate resource fork and check size\n",
1359 __location__);
1361 ZERO_STRUCT(io);
1362 io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1363 io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1364 SEC_FILE_WRITE_ATTRIBUTE;
1365 io.smb2.in.fname = rfork;
1366 status = smb2_create(tree1, mem_ctx, &(io.smb2));
1367 CHECK_STATUS(status, NT_STATUS_OK);
1368 filehandle = io.smb2.out.file.handle;
1370 ZERO_STRUCT(sinfo);
1371 sinfo.end_of_file_info.level =
1372 RAW_SFILEINFO_END_OF_FILE_INFORMATION;
1373 sinfo.end_of_file_info.in.file.handle = filehandle;
1374 sinfo.end_of_file_info.in.size = 1;
1375 status = smb2_setinfo_file(tree1, &sinfo);
1376 CHECK_STATUS(status, NT_STATUS_OK);
1378 smb2_util_close(tree1, filehandle);
1380 /* Now check size */
1381 ZERO_STRUCT(io);
1382 io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1383 io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1384 SEC_FILE_WRITE_ATTRIBUTE;
1385 io.smb2.in.fname = rfork;
1386 status = smb2_create(tree1, mem_ctx, &(io.smb2));
1387 CHECK_STATUS(status, NT_STATUS_OK);
1388 filehandle = io.smb2.out.file.handle;
1390 ZERO_STRUCT(finfo);
1391 finfo.generic.level = RAW_FILEINFO_ALL_INFORMATION;
1392 finfo.generic.in.file.handle = filehandle;
1393 status = smb2_getinfo_file(tree1, mem_ctx, &finfo);
1394 CHECK_STATUS(status, NT_STATUS_OK);
1395 if (finfo.all_info.out.size != 1) {
1396 torture_result(tctx, TORTURE_FAIL,
1397 "(%s) Incorrect resource fork size\n",
1398 __location__);
1399 ret = false;
1400 smb2_util_close(tree1, filehandle);
1401 goto done;
1403 smb2_util_close(tree1, filehandle);
1405 done:
1406 smb2_deltree(tree1, BASEDIR);
1407 talloc_free(mem_ctx);
1408 return ret;
1411 static bool test_adouble_conversion(struct torture_context *tctx,
1412 struct smb2_tree *tree1,
1413 struct smb2_tree *tree2)
1415 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1416 const char *fname = BASEDIR "\\test_adouble_conversion";
1417 const char *fname_local = BASEDIR "/test_adouble_conversion";
1418 const char *adname_local = BASEDIR "/._test_adouble_conversion";
1419 NTSTATUS status;
1420 struct smb2_handle testdirh;
1421 bool ret = true;
1422 const char *data = "This resource fork intentionally left blank";
1423 size_t datalen = strlen(data);
1425 smb2_util_unlink(tree1, fname);
1427 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1428 CHECK_STATUS(status, NT_STATUS_OK);
1429 smb2_util_close(tree1, testdirh);
1431 ret = torture_setup_local_file(tctx, "localdir", fname_local,
1432 NULL, 0);
1433 if (ret == false) {
1434 goto done;
1437 ret = torture_setup_local_file(tctx, "localdir", adname_local,
1438 osx_adouble_w_xattr,
1439 sizeof(osx_adouble_w_xattr));
1440 if (ret == false) {
1441 goto done;
1444 torture_comment(tctx, "(%s) test OS X AppleDouble conversion\n",
1445 __location__);
1447 ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1448 fname, AFPRESOURCE_STREAM,
1449 16, datalen, 0, datalen, data);
1451 done:
1452 smb2_deltree(tree1, BASEDIR);
1453 talloc_free(mem_ctx);
1454 return ret;
1457 static bool test_aapl(struct torture_context *tctx,
1458 struct smb2_tree *tree1,
1459 struct smb2_tree *tree2)
1461 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1462 const char *fname = BASEDIR "\\test_aapl";
1463 NTSTATUS status;
1464 struct smb2_handle testdirh;
1465 bool ret = true;
1466 struct smb2_create io;
1467 DATA_BLOB data;
1468 struct smb2_create_blob *aapl = NULL;
1469 AfpInfo *info;
1470 const char *type_creator = "SMB,OLE!";
1471 char type_creator_buf[9];
1472 uint32_t aapl_cmd;
1473 uint32_t aapl_reply_bitmap;
1474 uint32_t aapl_server_caps;
1475 uint32_t aapl_vol_caps;
1476 char *model;
1477 struct smb2_find f;
1478 unsigned int count;
1479 union smb_search_data *d;
1480 uint64_t rfork_len;
1482 smb2_deltree(tree1, BASEDIR);
1484 status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1485 CHECK_STATUS(status, NT_STATUS_OK);
1486 smb2_util_close(tree1, testdirh);
1488 ZERO_STRUCT(io);
1489 io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
1490 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1491 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
1492 io.in.share_access = (NTCREATEX_SHARE_ACCESS_DELETE |
1493 NTCREATEX_SHARE_ACCESS_READ |
1494 NTCREATEX_SHARE_ACCESS_WRITE);
1495 io.in.fname = fname;
1498 * Issuing an SMB2/CREATE with a suitably formed AAPL context,
1499 * controls behaviour of Apple's SMB2 extensions for the whole
1500 * session!
1503 data = data_blob_talloc(mem_ctx, NULL, 3 * sizeof(uint64_t));
1504 SBVAL(data.data, 0, SMB2_CRTCTX_AAPL_SERVER_QUERY);
1505 SBVAL(data.data, 8, (SMB2_CRTCTX_AAPL_SERVER_CAPS |
1506 SMB2_CRTCTX_AAPL_VOLUME_CAPS |
1507 SMB2_CRTCTX_AAPL_MODEL_INFO));
1508 SBVAL(data.data, 16, (SMB2_CRTCTX_AAPL_SUPPORTS_READ_DIR_ATTR |
1509 SMB2_CRTCTX_AAPL_UNIX_BASED |
1510 SMB2_CRTCTX_AAPL_SUPPORTS_NFS_ACE));
1512 torture_comment(tctx, "Testing SMB2 create context AAPL\n");
1513 status = smb2_create_blob_add(tctx, &io.in.blobs, "AAPL", data);
1514 CHECK_STATUS(status, NT_STATUS_OK);
1516 status = smb2_create(tree1, tctx, &io);
1517 CHECK_STATUS(status, NT_STATUS_OK);
1518 status = smb2_util_close(tree1, io.out.file.handle);
1519 CHECK_STATUS(status, NT_STATUS_OK);
1522 * Now check returned AAPL context
1524 torture_comment(tctx, "Comparing returned AAPL capabilites\n");
1526 aapl = smb2_create_blob_find(&io.out.blobs,
1527 SMB2_CREATE_TAG_AAPL);
1529 if (aapl->data.length != 50) {
1531 * uint32_t CommandCode = kAAPL_SERVER_QUERY
1532 * uint32_t Reserved = 0;
1533 * uint64_t ReplyBitmap = kAAPL_SERVER_CAPS |
1534 * kAAPL_VOLUME_CAPS |
1535 * kAAPL_MODEL_INFO;
1536 * uint64_t ServerCaps = kAAPL_SUPPORTS_READDIR_ATTR |
1537 * kAAPL_SUPPORTS_OSX_COPYFILE;
1538 * uint64_t VolumeCaps = kAAPL_SUPPORT_RESOLVE_ID |
1539 * kAAPL_CASE_SENSITIVE;
1540 * uint32_t Pad2 = 0;
1541 * uint32_t ModelStringLen = 10;
1542 * ucs2_t ModelString[5] = "Samba";
1544 ret = false;
1545 goto done;
1548 aapl_cmd = IVAL(aapl->data.data, 0);
1549 if (aapl_cmd != SMB2_CRTCTX_AAPL_SERVER_QUERY) {
1550 torture_result(tctx, TORTURE_FAIL,
1551 "(%s) unexpected cmd: %d",
1552 __location__, (int)aapl_cmd);
1553 ret = false;
1554 goto done;
1557 aapl_reply_bitmap = BVAL(aapl->data.data, 8);
1558 if (aapl_reply_bitmap != (SMB2_CRTCTX_AAPL_SERVER_CAPS |
1559 SMB2_CRTCTX_AAPL_VOLUME_CAPS |
1560 SMB2_CRTCTX_AAPL_MODEL_INFO)) {
1561 torture_result(tctx, TORTURE_FAIL,
1562 "(%s) unexpected reply_bitmap: %d",
1563 __location__, (int)aapl_reply_bitmap);
1564 ret = false;
1565 goto done;
1568 aapl_server_caps = BVAL(aapl->data.data, 16);
1569 if (aapl_server_caps != (SMB2_CRTCTX_AAPL_UNIX_BASED |
1570 SMB2_CRTCTX_AAPL_SUPPORTS_READ_DIR_ATTR |
1571 SMB2_CRTCTX_AAPL_SUPPORTS_NFS_ACE |
1572 SMB2_CRTCTX_AAPL_SUPPORTS_OSX_COPYFILE)) {
1573 torture_result(tctx, TORTURE_FAIL,
1574 "(%s) unexpected server_caps: %d",
1575 __location__, (int)aapl_server_caps);
1576 ret = false;
1577 goto done;
1580 aapl_vol_caps = BVAL(aapl->data.data, 24);
1581 if (aapl_vol_caps != SMB2_CRTCTX_AAPL_CASE_SENSITIVE) {
1582 /* this will fail on a case insensitive fs ... */
1583 torture_result(tctx, TORTURE_FAIL,
1584 "(%s) unexpected vol_caps: %d",
1585 __location__, (int)aapl_vol_caps);
1586 ret = false;
1587 goto done;
1590 ret = convert_string_talloc(mem_ctx,
1591 CH_UTF16LE, CH_UNIX,
1592 aapl->data.data + 40, 10,
1593 &model, NULL);
1594 if (ret == false) {
1595 torture_result(tctx, TORTURE_FAIL,
1596 "(%s) convert_string_talloc() failed",
1597 __location__);
1598 goto done;
1600 torture_comment(tctx, "Got server model: \"%s\"\n", model);
1603 * Now that Requested AAPL extensions are enabled, setup some
1604 * Mac files with metadata and resource fork
1606 ret = torture_setup_file(mem_ctx, tree1, fname, false);
1607 if (ret == false) {
1608 torture_result(tctx, TORTURE_FAIL,
1609 "(%s) torture_setup_file() failed",
1610 __location__);
1611 goto done;
1614 info = torture_afpinfo_new(mem_ctx);
1615 if (info == NULL) {
1616 torture_result(tctx, TORTURE_FAIL,
1617 "(%s) torture_afpinfo_new() failed",
1618 __location__);
1619 ret = false;
1620 goto done;
1623 memcpy(info->afpi_FinderInfo, type_creator, 8);
1624 ret = torture_write_afpinfo(tree1, tctx, mem_ctx, fname, info);
1625 if (ret == false) {
1626 torture_result(tctx, TORTURE_FAIL,
1627 "(%s) torture_write_afpinfo() failed",
1628 __location__);
1629 goto done;
1632 ret = write_stream(tree1, __location__, tctx, mem_ctx,
1633 fname, AFPRESOURCE_STREAM,
1634 0, 3, "foo");
1635 if (ret == false) {
1636 torture_result(tctx, TORTURE_FAIL,
1637 "(%s) write_stream() failed",
1638 __location__);
1639 goto done;
1643 * Ok, file is prepared, now call smb2/find
1646 ZERO_STRUCT(io);
1647 io.in.desired_access = SEC_RIGHTS_DIR_ALL;
1648 io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
1649 io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
1650 io.in.share_access = (NTCREATEX_SHARE_ACCESS_READ |
1651 NTCREATEX_SHARE_ACCESS_WRITE |
1652 NTCREATEX_SHARE_ACCESS_DELETE);
1653 io.in.create_disposition = NTCREATEX_DISP_OPEN;
1654 io.in.fname = BASEDIR;
1655 status = smb2_create(tree1, tctx, &io);
1656 CHECK_STATUS(status, NT_STATUS_OK);
1658 ZERO_STRUCT(f);
1659 f.in.file.handle = io.out.file.handle;
1660 f.in.pattern = "test_aapl";
1661 f.in.continue_flags = SMB2_CONTINUE_FLAG_SINGLE;
1662 f.in.max_response_size = 0x1000;
1663 f.in.level = SMB2_FIND_ID_BOTH_DIRECTORY_INFO;
1665 status = smb2_find_level(tree1, tree1, &f, &count, &d);
1666 CHECK_STATUS(status, NT_STATUS_OK);
1668 status = smb2_util_close(tree1, io.out.file.handle);
1669 CHECK_STATUS(status, NT_STATUS_OK);
1671 if (strcmp(d[0].id_both_directory_info.name.s, "test_aapl") != 0) {
1672 torture_result(tctx, TORTURE_FAIL,
1673 "(%s) write_stream() failed",
1674 __location__);
1675 ret = false;
1676 goto done;
1679 if (d[0].id_both_directory_info.short_name.private_length != 24) {
1680 torture_result(tctx, TORTURE_FAIL,
1681 "(%s) bad short_name length %" PRIu32 ", expected 24",
1682 __location__, d[0].id_both_directory_info.short_name.private_length);
1683 ret = false;
1684 goto done;
1687 torture_comment(tctx, "short_name buffer:\n");
1688 dump_data(0, d[0].id_both_directory_info.short_name_buf, 24);
1691 * Extract data as specified by the AAPL extension:
1692 * - ea_size contains max_access
1693 * - short_name contains resource fork length + FinderInfo
1694 * - reserved2 contains the unix mode
1696 torture_comment(tctx, "mac_access: %" PRIx32 "\n",
1697 d[0].id_both_directory_info.ea_size);
1699 rfork_len = BVAL(d[0].id_both_directory_info.short_name_buf, 0);
1700 if (rfork_len != 3) {
1701 torture_result(tctx, TORTURE_FAIL,
1702 "(%s) expected resource fork length 3, got: %" PRIu64,
1703 __location__, rfork_len);
1704 ret = false;
1705 goto done;
1708 memcpy(type_creator_buf, d[0].id_both_directory_info.short_name_buf + 8, 8);
1709 type_creator_buf[8] = 0;
1710 if (strcmp(type_creator, type_creator_buf) != 0) {
1711 torture_result(tctx, TORTURE_FAIL,
1712 "(%s) expected type/creator \"%s\" , got: %s",
1713 __location__, type_creator, type_creator_buf);
1714 ret = false;
1715 goto done;
1718 done:
1719 talloc_free(mem_ctx);
1720 return ret;
1723 static uint64_t patt_hash(uint64_t off)
1725 return off;
1728 static bool write_pattern(struct torture_context *torture,
1729 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
1730 struct smb2_handle h, uint64_t off, uint64_t len,
1731 uint64_t patt_off)
1733 NTSTATUS status;
1734 uint64_t i;
1735 uint8_t *buf;
1736 uint64_t io_sz = MIN(1024 * 64, len);
1738 if (len == 0) {
1739 return true;
1742 torture_assert(torture, (len % 8) == 0, "invalid write len");
1744 buf = talloc_zero_size(mem_ctx, io_sz);
1745 torture_assert(torture, (buf != NULL), "no memory for file data buf");
1747 while (len > 0) {
1748 for (i = 0; i <= io_sz - 8; i += 8) {
1749 SBVAL(buf, i, patt_hash(patt_off));
1750 patt_off += 8;
1753 status = smb2_util_write(tree, h,
1754 buf, off, io_sz);
1755 torture_assert_ntstatus_ok(torture, status, "file write");
1757 len -= io_sz;
1758 off += io_sz;
1761 talloc_free(buf);
1763 return true;
1766 static bool check_pattern(struct torture_context *torture,
1767 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
1768 struct smb2_handle h, uint64_t off, uint64_t len,
1769 uint64_t patt_off)
1771 if (len == 0) {
1772 return true;
1775 torture_assert(torture, (len % 8) == 0, "invalid read len");
1777 while (len > 0) {
1778 uint64_t i;
1779 struct smb2_read r;
1780 NTSTATUS status;
1781 uint64_t io_sz = MIN(1024 * 64, len);
1783 ZERO_STRUCT(r);
1784 r.in.file.handle = h;
1785 r.in.length = io_sz;
1786 r.in.offset = off;
1787 status = smb2_read(tree, mem_ctx, &r);
1788 torture_assert_ntstatus_ok(torture, status, "read");
1790 torture_assert_u64_equal(torture, r.out.data.length, io_sz,
1791 "read data len mismatch");
1793 for (i = 0; i <= io_sz - 8; i += 8, patt_off += 8) {
1794 uint64_t data = BVAL(r.out.data.data, i);
1795 torture_assert_u64_equal(torture, data, patt_hash(patt_off),
1796 talloc_asprintf(torture, "read data "
1797 "pattern bad at %llu\n",
1798 (unsigned long long)off + i));
1800 talloc_free(r.out.data.data);
1801 len -= io_sz;
1802 off += io_sz;
1805 return true;
1808 static bool test_setup_open(struct torture_context *torture,
1809 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
1810 const char *fname,
1811 struct smb2_handle *fh,
1812 uint32_t desired_access,
1813 uint32_t file_attributes)
1815 struct smb2_create io;
1816 NTSTATUS status;
1818 ZERO_STRUCT(io);
1819 io.in.desired_access = desired_access;
1820 io.in.file_attributes = file_attributes;
1821 io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
1822 io.in.share_access =
1823 NTCREATEX_SHARE_ACCESS_DELETE|
1824 NTCREATEX_SHARE_ACCESS_READ|
1825 NTCREATEX_SHARE_ACCESS_WRITE;
1826 if (file_attributes & FILE_ATTRIBUTE_DIRECTORY) {
1827 io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
1829 io.in.fname = fname;
1831 status = smb2_create(tree, mem_ctx, &io);
1832 torture_assert_ntstatus_ok(torture, status, "file create");
1834 *fh = io.out.file.handle;
1836 return true;
1839 static bool test_setup_create_fill(struct torture_context *torture,
1840 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
1841 const char *fname,
1842 struct smb2_handle *fh,
1843 uint64_t size,
1844 uint32_t desired_access,
1845 uint32_t file_attributes)
1847 bool ok;
1849 ok = test_setup_open(torture, tree, mem_ctx,
1850 fname,
1852 desired_access,
1853 file_attributes);
1854 torture_assert(torture, ok, "file open");
1856 if (size > 0) {
1857 ok = write_pattern(torture, tree, mem_ctx, *fh, 0, size, 0);
1858 torture_assert(torture, ok, "write pattern");
1860 return true;
1863 static bool test_setup_copy_chunk(struct torture_context *torture,
1864 struct smb2_tree *tree, TALLOC_CTX *mem_ctx,
1865 uint32_t nchunks,
1866 struct smb2_handle *src_h,
1867 uint64_t src_size,
1868 uint32_t src_desired_access,
1869 struct smb2_handle *dest_h,
1870 uint64_t dest_size,
1871 uint32_t dest_desired_access,
1872 struct srv_copychunk_copy *cc_copy,
1873 union smb_ioctl *io)
1875 struct req_resume_key_rsp res_key;
1876 bool ok;
1877 NTSTATUS status;
1878 enum ndr_err_code ndr_ret;
1880 ok = test_setup_create_fill(torture, tree, mem_ctx, FNAME_CC_SRC,
1881 src_h, src_size, src_desired_access,
1882 FILE_ATTRIBUTE_NORMAL);
1883 torture_assert(torture, ok, "src file create fill");
1885 ok = test_setup_create_fill(torture, tree, mem_ctx, FNAME_CC_DST,
1886 dest_h, dest_size, dest_desired_access,
1887 FILE_ATTRIBUTE_NORMAL);
1888 torture_assert(torture, ok, "dest file create fill");
1890 ZERO_STRUCTPN(io);
1891 io->smb2.level = RAW_IOCTL_SMB2;
1892 io->smb2.in.file.handle = *src_h;
1893 io->smb2.in.function = FSCTL_SRV_REQUEST_RESUME_KEY;
1894 /* Allow for Key + ContextLength + Context */
1895 io->smb2.in.max_response_size = 32;
1896 io->smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
1898 status = smb2_ioctl(tree, mem_ctx, &io->smb2);
1899 torture_assert_ntstatus_ok(torture, status,
1900 "FSCTL_SRV_REQUEST_RESUME_KEY");
1902 ndr_ret = ndr_pull_struct_blob(&io->smb2.out.out, mem_ctx, &res_key,
1903 (ndr_pull_flags_fn_t)ndr_pull_req_resume_key_rsp);
1905 torture_assert_ndr_success(torture, ndr_ret,
1906 "ndr_pull_req_resume_key_rsp");
1908 ZERO_STRUCTPN(io);
1909 io->smb2.level = RAW_IOCTL_SMB2;
1910 io->smb2.in.file.handle = *dest_h;
1911 io->smb2.in.function = FSCTL_SRV_COPYCHUNK;
1912 io->smb2.in.max_response_size = sizeof(struct srv_copychunk_rsp);
1913 io->smb2.in.flags = SMB2_IOCTL_FLAG_IS_FSCTL;
1915 ZERO_STRUCTPN(cc_copy);
1916 memcpy(cc_copy->source_key, res_key.resume_key, ARRAY_SIZE(cc_copy->source_key));
1917 cc_copy->chunk_count = nchunks;
1918 cc_copy->chunks = talloc_zero_array(mem_ctx, struct srv_copychunk, nchunks);
1919 torture_assert(torture, (cc_copy->chunks != NULL), "no memory for chunks");
1921 return true;
1925 static bool check_copy_chunk_rsp(struct torture_context *torture,
1926 struct srv_copychunk_rsp *cc_rsp,
1927 uint32_t ex_chunks_written,
1928 uint32_t ex_chunk_bytes_written,
1929 uint32_t ex_total_bytes_written)
1931 torture_assert_int_equal(torture, cc_rsp->chunks_written,
1932 ex_chunks_written, "num chunks");
1933 torture_assert_int_equal(torture, cc_rsp->chunk_bytes_written,
1934 ex_chunk_bytes_written, "chunk bytes written");
1935 torture_assert_int_equal(torture, cc_rsp->total_bytes_written,
1936 ex_total_bytes_written, "chunk total bytes");
1937 return true;
1940 static bool neg_aapl_copyfile(struct torture_context *tctx,
1941 struct smb2_tree *tree,
1942 uint64_t flags)
1944 TALLOC_CTX *mem_ctx = talloc_new(tctx);
1945 const char *fname = "aapl";
1946 NTSTATUS status;
1947 struct smb2_create io;
1948 DATA_BLOB data;
1949 struct smb2_create_blob *aapl = NULL;
1950 uint32_t aapl_cmd;
1951 uint32_t aapl_reply_bitmap;
1952 uint32_t aapl_server_caps;
1953 bool ret = true;
1955 ZERO_STRUCT(io);
1956 io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
1957 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
1958 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
1959 io.in.share_access = (NTCREATEX_SHARE_ACCESS_DELETE |
1960 NTCREATEX_SHARE_ACCESS_READ |
1961 NTCREATEX_SHARE_ACCESS_WRITE);
1962 io.in.fname = fname;
1964 data = data_blob_talloc(mem_ctx, NULL, 3 * sizeof(uint64_t));
1965 SBVAL(data.data, 0, SMB2_CRTCTX_AAPL_SERVER_QUERY);
1966 SBVAL(data.data, 8, (SMB2_CRTCTX_AAPL_SERVER_CAPS));
1967 SBVAL(data.data, 16, flags);
1969 status = smb2_create_blob_add(tctx, &io.in.blobs, "AAPL", data);
1970 CHECK_STATUS(status, NT_STATUS_OK);
1972 status = smb2_create(tree, tctx, &io);
1973 CHECK_STATUS(status, NT_STATUS_OK);
1975 aapl = smb2_create_blob_find(&io.out.blobs,
1976 SMB2_CREATE_TAG_AAPL);
1977 if (aapl == NULL) {
1978 ret = false;
1979 goto done;
1982 if (aapl->data.length < 24) {
1983 ret = false;
1984 goto done;
1987 aapl_cmd = IVAL(aapl->data.data, 0);
1988 if (aapl_cmd != SMB2_CRTCTX_AAPL_SERVER_QUERY) {
1989 torture_result(tctx, TORTURE_FAIL,
1990 "(%s) unexpected cmd: %d",
1991 __location__, (int)aapl_cmd);
1992 ret = false;
1993 goto done;
1996 aapl_reply_bitmap = BVAL(aapl->data.data, 8);
1997 if (!(aapl_reply_bitmap & SMB2_CRTCTX_AAPL_SERVER_CAPS)) {
1998 torture_result(tctx, TORTURE_FAIL,
1999 "(%s) unexpected reply_bitmap: %d",
2000 __location__, (int)aapl_reply_bitmap);
2001 ret = false;
2002 goto done;
2005 aapl_server_caps = BVAL(aapl->data.data, 16);
2006 if (!(aapl_server_caps & flags)) {
2007 torture_result(tctx, TORTURE_FAIL,
2008 "(%s) unexpected server_caps: %d",
2009 __location__, (int)aapl_server_caps);
2010 ret = false;
2011 goto done;
2014 done:
2015 status = smb2_util_close(tree, io.out.file.handle);
2016 CHECK_STATUS(status, NT_STATUS_OK);
2018 smb2_util_unlink(tree, "aapl");
2019 talloc_free(mem_ctx);
2020 return ret;
2023 static bool test_copyfile(struct torture_context *torture,
2024 struct smb2_tree *tree)
2026 struct smb2_handle src_h;
2027 struct smb2_handle dest_h;
2028 NTSTATUS status;
2029 union smb_ioctl io;
2030 TALLOC_CTX *tmp_ctx = talloc_new(tree);
2031 struct srv_copychunk_copy cc_copy;
2032 struct srv_copychunk_rsp cc_rsp;
2033 enum ndr_err_code ndr_ret;
2034 bool ok;
2037 * First test a copy_chunk with a 0 chunk count without having
2038 * enabled this via AAPL. The request must not fail and the
2039 * copied length in the response must be 0. This is verified
2040 * against Windows 2008r2.
2043 ok = test_setup_copy_chunk(torture, tree, tmp_ctx,
2044 0, /* 0 chunks, copyfile semantics */
2045 &src_h, 4096, /* fill 4096 byte src file */
2046 SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA,
2047 &dest_h, 0, /* 0 byte dest file */
2048 SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA,
2049 &cc_copy,
2050 &io);
2051 if (!ok) {
2052 torture_fail_goto(torture, done, "setup copy chunk error");
2055 ndr_ret = ndr_push_struct_blob(&io.smb2.in.out, tmp_ctx,
2056 &cc_copy,
2057 (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy);
2058 torture_assert_ndr_success(torture, ndr_ret,
2059 "ndr_push_srv_copychunk_copy");
2061 status = smb2_ioctl(tree, tmp_ctx, &io.smb2);
2062 torture_assert_ntstatus_ok_goto(torture, status, ok, done, "FSCTL_SRV_COPYCHUNK");
2064 ndr_ret = ndr_pull_struct_blob(&io.smb2.out.out, tmp_ctx,
2065 &cc_rsp,
2066 (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp);
2067 torture_assert_ndr_success(torture, ndr_ret,
2068 "ndr_pull_srv_copychunk_rsp");
2070 ok = check_copy_chunk_rsp(torture, &cc_rsp,
2071 0, /* chunks written */
2072 0, /* chunk bytes unsuccessfully written */
2073 0); /* total bytes written */
2074 if (!ok) {
2075 torture_fail_goto(torture, done, "bad copy chunk response data");
2079 * Now enable AAPL copyfile and test again, the file and the
2080 * stream must be copied by the server.
2082 ok = neg_aapl_copyfile(torture, tree,
2083 SMB2_CRTCTX_AAPL_SUPPORTS_OSX_COPYFILE);
2084 if (!ok) {
2085 torture_skip_goto(torture, done, "missing AAPL copyfile");
2086 goto done;
2089 smb2_util_close(tree, src_h);
2090 smb2_util_close(tree, dest_h);
2091 smb2_util_unlink(tree, FNAME_CC_SRC);
2092 smb2_util_unlink(tree, FNAME_CC_DST);
2094 ok = torture_setup_file(tmp_ctx, tree, FNAME_CC_SRC, false);
2095 if (!ok) {
2096 torture_fail(torture, "setup file error");
2098 ok = write_stream(tree, __location__, torture, tmp_ctx,
2099 FNAME_CC_SRC, AFPRESOURCE_STREAM,
2100 10, 10, "1234567890");
2101 if (!ok) {
2102 torture_fail(torture, "setup stream error");
2105 ok = test_setup_copy_chunk(torture, tree, tmp_ctx,
2106 0, /* 0 chunks, copyfile semantics */
2107 &src_h, 4096, /* fill 4096 byte src file */
2108 SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA,
2109 &dest_h, 0, /* 0 byte dest file */
2110 SEC_FILE_READ_DATA | SEC_FILE_WRITE_DATA,
2111 &cc_copy,
2112 &io);
2113 if (!ok) {
2114 torture_fail_goto(torture, done, "setup copy chunk error");
2117 ndr_ret = ndr_push_struct_blob(&io.smb2.in.out, tmp_ctx,
2118 &cc_copy,
2119 (ndr_push_flags_fn_t)ndr_push_srv_copychunk_copy);
2120 torture_assert_ndr_success(torture, ndr_ret,
2121 "ndr_push_srv_copychunk_copy");
2123 status = smb2_ioctl(tree, tmp_ctx, &io.smb2);
2124 torture_assert_ntstatus_ok_goto(torture, status, ok, done, "FSCTL_SRV_COPYCHUNK");
2126 ndr_ret = ndr_pull_struct_blob(&io.smb2.out.out, tmp_ctx,
2127 &cc_rsp,
2128 (ndr_pull_flags_fn_t)ndr_pull_srv_copychunk_rsp);
2129 torture_assert_ndr_success(torture, ndr_ret,
2130 "ndr_pull_srv_copychunk_rsp");
2132 ok = check_copy_chunk_rsp(torture, &cc_rsp,
2133 0, /* chunks written */
2134 0, /* chunk bytes unsuccessfully written */
2135 4096); /* total bytes written */
2136 if (!ok) {
2137 torture_fail_goto(torture, done, "bad copy chunk response data");
2140 ok = test_setup_open(torture, tree, tmp_ctx, FNAME_CC_DST, &dest_h,
2141 SEC_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL);
2142 if (!ok) {
2143 torture_fail_goto(torture, done,"open failed");
2145 ok = check_pattern(torture, tree, tmp_ctx, dest_h, 0, 4096, 0);
2146 if (!ok) {
2147 torture_fail_goto(torture, done, "inconsistent file data");
2150 ok = check_stream(tree, __location__, torture, tmp_ctx,
2151 FNAME_CC_DST, AFPRESOURCE_STREAM,
2152 0, 20, 10, 10, "1234567890");
2153 if (!ok) {
2154 torture_fail_goto(torture, done, "inconsistent stream data");
2157 done:
2158 smb2_util_close(tree, src_h);
2159 smb2_util_close(tree, dest_h);
2160 smb2_util_unlink(tree, FNAME_CC_SRC);
2161 smb2_util_unlink(tree, FNAME_CC_DST);
2162 talloc_free(tmp_ctx);
2163 return true;
2167 * Note: This test depends on "vfs objects = catia fruit
2168 * streams_xattr". Note: To run this test, use
2169 * "--option=torture:share1=<SHARENAME1>
2170 * --option=torture:share2=<SHARENAME2>
2171 * --option=torture:localdir=<SHAREPATH>"
2173 struct torture_suite *torture_vfs_fruit(void)
2175 struct torture_suite *suite = torture_suite_create(
2176 talloc_autofree_context(), "fruit");
2178 suite->description = talloc_strdup(suite, "vfs_fruit tests");
2180 torture_suite_add_1smb2_test(suite, "copyfile", test_copyfile);
2181 torture_suite_add_2ns_smb2_test(suite, "read metadata", test_read_atalk_metadata);
2182 torture_suite_add_2ns_smb2_test(suite, "write metadata", test_write_atalk_metadata);
2183 torture_suite_add_2ns_smb2_test(suite, "resource fork IO", test_write_atalk_rfork_io);
2184 torture_suite_add_2ns_smb2_test(suite, "OS X AppleDouble file conversion", test_adouble_conversion);
2185 torture_suite_add_2ns_smb2_test(suite, "SMB2/CREATE context AAPL", test_aapl);
2187 return suite;