Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 :
4 : test DOS extended attributes
5 :
6 : Copyright (C) Andrew Tridgell 2004
7 : Copyright (C) Guenter Kukkukk 2005
8 :
9 : This program is free software; you can redistribute it and/or modify
10 : it under the terms of the GNU General Public License as published by
11 : the Free Software Foundation; either version 3 of the License, or
12 : (at your option) any later version.
13 :
14 : This program is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU General Public License for more details.
18 :
19 : You should have received a copy of the GNU General Public License
20 : along with this program. If not, see <http://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "includes.h"
24 : #include "torture/torture.h"
25 : #include "libcli/raw/libcliraw.h"
26 : #include "libcli/libcli.h"
27 : #include "torture/util.h"
28 : #include "torture/raw/proto.h"
29 :
30 : #define BASEDIR "\\testeas"
31 :
32 : #define CHECK_STATUS(status, correct) do { \
33 : torture_assert_ntstatus_equal_goto(tctx, status, correct, ret, done, "Incorrect status"); \
34 : } while (0)
35 :
36 : static bool maxeadebug; /* need that here, to allow no file delete in debug case */
37 :
38 110 : static bool check_ea(struct smbcli_state *cli,
39 : const char *fname, const char *eaname, const char *value)
40 : {
41 110 : NTSTATUS status = torture_check_ea(cli, fname, eaname, value);
42 110 : return NT_STATUS_IS_OK(status);
43 : }
44 :
45 : static char bad_ea_chars[] = "\"*+,/:;<=>?[\\]|";
46 :
47 5 : static bool test_eas(struct smbcli_state *cli, struct torture_context *tctx)
48 : {
49 1 : NTSTATUS status;
50 1 : union smb_setfileinfo setfile;
51 1 : union smb_open io;
52 5 : const char *fname = BASEDIR "\\ea.txt";
53 5 : bool ret = true;
54 1 : char bad_ea_name[7];
55 1 : int i;
56 5 : int fnum = -1;
57 :
58 5 : torture_comment(tctx, "TESTING SETFILEINFO EA_SET\n");
59 :
60 5 : io.generic.level = RAW_OPEN_NTCREATEX;
61 5 : io.ntcreatex.in.root_fid.fnum = 0;
62 5 : io.ntcreatex.in.flags = 0;
63 5 : io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
64 5 : io.ntcreatex.in.create_options = 0;
65 5 : io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
66 5 : io.ntcreatex.in.share_access =
67 : NTCREATEX_SHARE_ACCESS_READ |
68 : NTCREATEX_SHARE_ACCESS_WRITE;
69 5 : io.ntcreatex.in.alloc_size = 0;
70 5 : io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
71 5 : io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
72 5 : io.ntcreatex.in.security_flags = 0;
73 5 : io.ntcreatex.in.fname = fname;
74 5 : status = smb_raw_open(cli->tree, tctx, &io);
75 5 : CHECK_STATUS(status, NT_STATUS_OK);
76 5 : fnum = io.ntcreatex.out.file.fnum;
77 :
78 5 : ret &= check_ea(cli, fname, "EAONE", NULL);
79 :
80 5 : torture_comment(tctx, "Adding first two EAs\n");
81 5 : setfile.generic.level = RAW_SFILEINFO_EA_SET;
82 5 : setfile.generic.in.file.fnum = fnum;
83 5 : setfile.ea_set.in.num_eas = 2;
84 5 : setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 2);
85 5 : setfile.ea_set.in.eas[0].flags = 0;
86 5 : setfile.ea_set.in.eas[0].name.s = "EAONE";
87 5 : setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE1");
88 5 : setfile.ea_set.in.eas[1].flags = 0;
89 5 : setfile.ea_set.in.eas[1].name.s = "SECONDEA";
90 5 : setfile.ea_set.in.eas[1].value = data_blob_string_const("ValueTwo");
91 :
92 5 : status = smb_raw_setfileinfo(cli->tree, &setfile);
93 5 : CHECK_STATUS(status, NT_STATUS_OK);
94 :
95 5 : ret &= check_ea(cli, fname, "EAONE", "VALUE1");
96 5 : ret &= check_ea(cli, fname, "SECONDEA", "ValueTwo");
97 :
98 5 : torture_comment(tctx, "Modifying 2nd EA\n");
99 5 : setfile.ea_set.in.num_eas = 1;
100 5 : setfile.ea_set.in.eas[0].name.s = "SECONDEA";
101 5 : setfile.ea_set.in.eas[0].value = data_blob_string_const(" Changed Value");
102 5 : status = smb_raw_setfileinfo(cli->tree, &setfile);
103 5 : CHECK_STATUS(status, NT_STATUS_OK);
104 :
105 5 : ret &= check_ea(cli, fname, "EAONE", "VALUE1");
106 5 : ret &= check_ea(cli, fname, "SECONDEA", " Changed Value");
107 :
108 5 : torture_comment(tctx, "Setting a NULL EA\n");
109 5 : setfile.ea_set.in.eas[0].value = data_blob(NULL, 0);
110 5 : setfile.ea_set.in.eas[0].name.s = "NULLEA";
111 5 : status = smb_raw_setfileinfo(cli->tree, &setfile);
112 5 : CHECK_STATUS(status, NT_STATUS_OK);
113 :
114 5 : ret &= check_ea(cli, fname, "EAONE", "VALUE1");
115 5 : ret &= check_ea(cli, fname, "SECONDEA", " Changed Value");
116 5 : ret &= check_ea(cli, fname, "NULLEA", NULL);
117 :
118 5 : torture_comment(tctx, "Deleting first EA\n");
119 5 : setfile.ea_set.in.eas[0].flags = 0;
120 5 : setfile.ea_set.in.eas[0].name.s = "EAONE";
121 5 : setfile.ea_set.in.eas[0].value = data_blob(NULL, 0);
122 5 : status = smb_raw_setfileinfo(cli->tree, &setfile);
123 5 : CHECK_STATUS(status, NT_STATUS_OK);
124 :
125 5 : ret &= check_ea(cli, fname, "EAONE", NULL);
126 5 : ret &= check_ea(cli, fname, "SECONDEA", " Changed Value");
127 :
128 5 : torture_comment(tctx, "Deleting second EA\n");
129 5 : setfile.ea_set.in.eas[0].flags = 0;
130 5 : setfile.ea_set.in.eas[0].name.s = "SECONDEA";
131 5 : setfile.ea_set.in.eas[0].value = data_blob(NULL, 0);
132 5 : status = smb_raw_setfileinfo(cli->tree, &setfile);
133 5 : CHECK_STATUS(status, NT_STATUS_OK);
134 :
135 5 : ret &= check_ea(cli, fname, "EAONE", NULL);
136 5 : ret &= check_ea(cli, fname, "SECONDEA", NULL);
137 :
138 : /* Check EA name containing colon. All EA's set
139 : must be ignored, not just the one with the bad
140 : name. */
141 :
142 5 : torture_comment(tctx, "Adding bad EA name\n");
143 5 : setfile.generic.level = RAW_SFILEINFO_EA_SET;
144 5 : setfile.generic.in.file.fnum = fnum;
145 5 : setfile.ea_set.in.num_eas = 3;
146 5 : setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 3);
147 5 : setfile.ea_set.in.eas[0].flags = 0;
148 5 : setfile.ea_set.in.eas[0].name.s = "EAONE";
149 5 : setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE1");
150 5 : setfile.ea_set.in.eas[1].flags = 0;
151 5 : setfile.ea_set.in.eas[1].name.s = "SECOND:EA";
152 5 : setfile.ea_set.in.eas[1].value = data_blob_string_const("ValueTwo");
153 5 : setfile.ea_set.in.eas[2].flags = 0;
154 5 : setfile.ea_set.in.eas[2].name.s = "THIRDEA";
155 5 : setfile.ea_set.in.eas[2].value = data_blob_string_const("ValueThree");
156 :
157 5 : status = smb_raw_setfileinfo(cli->tree, &setfile);
158 5 : CHECK_STATUS(status, STATUS_INVALID_EA_NAME);
159 :
160 5 : ret &= check_ea(cli, fname, "EAONE", NULL);
161 5 : ret &= check_ea(cli, fname, "THIRDEA", NULL);
162 :
163 5 : setfile.generic.level = RAW_SFILEINFO_EA_SET;
164 5 : setfile.generic.in.file.fnum = fnum;
165 5 : setfile.ea_set.in.num_eas = 1;
166 5 : setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 1);
167 5 : setfile.ea_set.in.eas[0].flags = 0;
168 5 : strlcpy(bad_ea_name, "TEST_X", sizeof(bad_ea_name));
169 5 : setfile.ea_set.in.eas[0].name.s = bad_ea_name;
170 :
171 5 : torture_comment(tctx, "Testing bad EA name range.\n");
172 :
173 1281 : for (i = 1; i < 256; i++) {
174 1275 : setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE1");
175 1275 : bad_ea_name[5] = (char)i;
176 1275 : torture_comment(tctx, "Testing bad EA name %d.\n", i);
177 1275 : status = smb_raw_setfileinfo(cli->tree, &setfile);
178 1275 : if (i < 32 || strchr(bad_ea_chars, i)) {
179 230 : CHECK_STATUS(status, STATUS_INVALID_EA_NAME);
180 : } else {
181 1045 : CHECK_STATUS(status, NT_STATUS_OK);
182 :
183 : /* Now delete the EA we just set to make
184 : sure we don't run out of room. */
185 1045 : setfile.ea_set.in.eas[0].value = data_blob(NULL, 0);
186 1045 : status = smb_raw_setfileinfo(cli->tree, &setfile);
187 1091 : CHECK_STATUS(status, NT_STATUS_OK);
188 : }
189 : }
190 :
191 5 : done:
192 5 : smbcli_close(cli->tree, fnum);
193 5 : return ret;
194 : }
195 :
196 :
197 : /*
198 : * Helper function to retrieve the max. ea size for one ea name
199 : */
200 0 : static int test_one_eamax(struct torture_context *tctx,
201 : struct smbcli_state *cli, const int fnum,
202 : const char *eaname, DATA_BLOB eablob,
203 : const int eastart, const int eadebug)
204 : {
205 0 : NTSTATUS status;
206 0 : struct ea_struct eastruct;
207 0 : union smb_setfileinfo setfile;
208 0 : int i, high, low, maxeasize;
209 :
210 0 : setfile.generic.level = RAW_SFILEINFO_EA_SET;
211 0 : setfile.generic.in.file.fnum = fnum;
212 0 : setfile.ea_set.in.num_eas = 1;
213 0 : setfile.ea_set.in.eas = &eastruct;
214 0 : setfile.ea_set.in.eas->flags = 0;
215 0 : setfile.ea_set.in.eas->name.s = eaname;
216 0 : setfile.ea_set.in.eas->value = eablob;
217 :
218 0 : maxeasize = eablob.length;
219 0 : i = eastart;
220 0 : low = 0;
221 0 : high = maxeasize;
222 :
223 0 : do {
224 0 : if (eadebug) {
225 0 : torture_comment(tctx, "Testing EA size: %d\n", i);
226 : }
227 0 : setfile.ea_set.in.eas->value.length = i;
228 :
229 0 : status = smb_raw_setfileinfo(cli->tree, &setfile);
230 :
231 0 : if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
232 0 : if (eadebug) {
233 0 : torture_comment(tctx, "[%s] EA size %d succeeded! "
234 : "(high=%d low=%d)\n",
235 : eaname, i, high, low);
236 : }
237 0 : low = i;
238 0 : if (low == maxeasize) {
239 0 : torture_comment(tctx, "Max. EA size for \"%s\"=%d "
240 : "[but could be possibly larger]\n",
241 : eaname, low);
242 0 : break;
243 : }
244 0 : if (high - low == 1 && high != maxeasize) {
245 0 : torture_comment(tctx, "Max. EA size for \"%s\"=%d\n",
246 : eaname, low);
247 0 : break;
248 : }
249 0 : i += (high - low + 1) / 2;
250 : } else {
251 0 : if (eadebug) {
252 0 : torture_comment(tctx, "[%s] EA size %d failed! "
253 : "(high=%d low=%d) [%s]\n",
254 : eaname, i, high, low,
255 : nt_errstr(status));
256 : }
257 0 : high = i;
258 0 : if (high - low <= 1) {
259 0 : torture_comment(tctx, "Max. EA size for \"%s\"=%d\n",
260 : eaname, low);
261 0 : break;
262 : }
263 0 : i -= (high - low + 1) / 2;
264 : }
265 : } while (true);
266 :
267 0 : return low;
268 : }
269 :
270 : /*
271 : * Test for maximum ea size - more than one ea name is checked.
272 : *
273 : * Additional parameters can be passed, to allow further testing:
274 : *
275 : * default
276 : * maxeasize 65536 limit the max. size for a single EA name
277 : * maxeanames 101 limit of the number of tested names
278 : * maxeastart 1 this EA size is used to test for the 1st EA (atm)
279 : * maxeadebug 0 if set true, further debug output is done - in addition
280 : * the testfile is not deleted for further inspection!
281 : *
282 : * Set some/all of these options on the cmdline with:
283 : * --option torture:maxeasize=1024 --option torture:maxeadebug=1 ...
284 : *
285 : */
286 0 : static bool test_max_eas(struct smbcli_state *cli, struct torture_context *tctx)
287 : {
288 0 : NTSTATUS status;
289 0 : union smb_open io;
290 0 : const char *fname = BASEDIR "\\ea_max.txt";
291 0 : int fnum = -1;
292 0 : bool ret = true;
293 0 : bool err = false;
294 :
295 0 : int i, j, k, last;
296 0 : size_t total;
297 0 : DATA_BLOB eablob;
298 0 : char *eaname = NULL;
299 0 : int maxeasize;
300 0 : int maxeanames;
301 0 : int maxeastart;
302 :
303 0 : torture_comment(tctx, "TESTING SETFILEINFO MAX. EA_SET\n");
304 :
305 0 : maxeasize = torture_setting_int(tctx, "maxeasize", 65536);
306 0 : maxeanames = torture_setting_int(tctx, "maxeanames", 101);
307 0 : maxeastart = torture_setting_int(tctx, "maxeastart", 1);
308 0 : maxeadebug = torture_setting_bool(tctx, "maxeadebug", false);
309 :
310 : /* Do some sanity check on possibly passed parms */
311 0 : if (maxeasize <= 0) {
312 0 : torture_comment(tctx, "Invalid parameter 'maxeasize=%d'",maxeasize);
313 0 : err = true;
314 : }
315 0 : if (maxeanames <= 0) {
316 0 : torture_comment(tctx, "Invalid parameter 'maxeanames=%d'",maxeanames);
317 0 : err = true;
318 : }
319 0 : if (maxeastart <= 0) {
320 0 : torture_comment(tctx, "Invalid parameter 'maxeastart=%d'",maxeastart);
321 0 : err = true;
322 : }
323 0 : if (err) {
324 0 : torture_comment(tctx, "\n\n");
325 0 : goto done;
326 : }
327 0 : if (maxeastart > maxeasize) {
328 0 : maxeastart = maxeasize;
329 0 : torture_comment(tctx, "'maxeastart' outside range - corrected to %d\n",
330 : maxeastart);
331 : }
332 0 : torture_comment(tctx, "MAXEA parms: maxeasize=%d maxeanames=%d maxeastart=%d"
333 : " maxeadebug=%d\n", maxeasize, maxeanames, maxeastart,
334 : maxeadebug);
335 :
336 0 : io.generic.level = RAW_OPEN_NTCREATEX;
337 0 : io.ntcreatex.in.root_fid.fnum = 0;
338 0 : io.ntcreatex.in.flags = 0;
339 0 : io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
340 0 : io.ntcreatex.in.create_options = 0;
341 0 : io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
342 0 : io.ntcreatex.in.share_access =
343 : NTCREATEX_SHARE_ACCESS_READ |
344 : NTCREATEX_SHARE_ACCESS_WRITE;
345 0 : io.ntcreatex.in.alloc_size = 0;
346 0 : io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
347 0 : io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
348 0 : io.ntcreatex.in.security_flags = 0;
349 0 : io.ntcreatex.in.fname = fname;
350 0 : status = smb_raw_open(cli->tree, tctx, &io);
351 0 : CHECK_STATUS(status, NT_STATUS_OK);
352 0 : fnum = io.ntcreatex.out.file.fnum;
353 :
354 0 : eablob = data_blob_talloc(tctx, NULL, maxeasize);
355 0 : if (eablob.data == NULL) {
356 0 : goto done;
357 : }
358 : /*
359 : * Fill in some EA data - the offset could be easily checked
360 : * during a hexdump.
361 : */
362 0 : for (i = 0, k = 0; i < eablob.length / 4; i++, k+=4) {
363 0 : eablob.data[k] = k & 0xff;
364 0 : eablob.data[k+1] = (k >> 8) & 0xff;
365 0 : eablob.data[k+2] = (k >> 16) & 0xff;
366 0 : eablob.data[k+3] = (k >> 24) & 0xff;
367 : }
368 :
369 0 : i = eablob.length % 4;
370 0 : if (i-- > 0) {
371 0 : eablob.data[k] = k & 0xff;
372 0 : if (i-- > 0) {
373 0 : eablob.data[k+1] = (k >> 8) & 0xff;
374 0 : if (i-- > 0) {
375 0 : eablob.data[k+2] = (k >> 16) & 0xff;
376 : }
377 : }
378 : }
379 : /*
380 : * Filesystems might allow max. EAs data for different EA names.
381 : * So more than one EA name should be checked.
382 : */
383 0 : total = 0;
384 0 : last = maxeastart;
385 :
386 0 : for (i = 0; i < maxeanames; i++) {
387 0 : if (eaname != NULL) {
388 0 : talloc_free(eaname);
389 : }
390 0 : eaname = talloc_asprintf(tctx, "MAX%d", i);
391 0 : if(eaname == NULL) {
392 0 : goto done;
393 : }
394 0 : j = test_one_eamax(tctx, cli, fnum, eaname, eablob, last, maxeadebug);
395 0 : if (j <= 0) {
396 0 : break;
397 : }
398 0 : total += j;
399 0 : last = j;
400 : }
401 :
402 0 : torture_comment(tctx, "Total EA size:%zu\n", total);
403 0 : if (i == maxeanames) {
404 0 : torture_comment(tctx, "NOTE: More EAs could be available!\n");
405 : }
406 0 : if (total == 0) {
407 0 : ret = false;
408 : }
409 0 : done:
410 0 : smbcli_close(cli->tree, fnum);
411 0 : return ret;
412 : }
413 :
414 : /*
415 : test using NTTRANS CREATE to create a file with an initial EA set
416 : */
417 5 : static bool test_nttrans_create(struct smbcli_state *cli, struct torture_context *tctx)
418 : {
419 1 : NTSTATUS status;
420 1 : union smb_open io;
421 5 : const char *fname = BASEDIR "\\ea2.txt";
422 5 : const char *fname_bad = BASEDIR "\\ea2_bad.txt";
423 5 : bool ret = true;
424 5 : int fnum = -1;
425 1 : struct ea_struct eas[3];
426 1 : struct smb_ea_list ea_list;
427 :
428 5 : torture_comment(tctx, "TESTING NTTRANS CREATE WITH EAS\n");
429 :
430 5 : io.generic.level = RAW_OPEN_NTTRANS_CREATE;
431 5 : io.ntcreatex.in.root_fid.fnum = 0;
432 5 : io.ntcreatex.in.flags = 0;
433 5 : io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
434 5 : io.ntcreatex.in.create_options = 0;
435 5 : io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
436 5 : io.ntcreatex.in.share_access =
437 : NTCREATEX_SHARE_ACCESS_READ |
438 : NTCREATEX_SHARE_ACCESS_WRITE;
439 5 : io.ntcreatex.in.alloc_size = 0;
440 5 : io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
441 5 : io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
442 5 : io.ntcreatex.in.security_flags = 0;
443 5 : io.ntcreatex.in.fname = fname;
444 :
445 5 : ea_list.num_eas = 3;
446 5 : ea_list.eas = eas;
447 :
448 5 : eas[0].flags = 0;
449 5 : eas[0].name.s = "1st EA";
450 5 : eas[0].value = data_blob_string_const("Value One");
451 :
452 5 : eas[1].flags = 0;
453 5 : eas[1].name.s = "2nd EA";
454 5 : eas[1].value = data_blob_string_const("Second Value");
455 :
456 5 : eas[2].flags = 0;
457 5 : eas[2].name.s = "and 3rd";
458 5 : eas[2].value = data_blob_string_const("final value");
459 :
460 5 : io.ntcreatex.in.ea_list = &ea_list;
461 5 : io.ntcreatex.in.sec_desc = NULL;
462 :
463 5 : status = smb_raw_open(cli->tree, tctx, &io);
464 5 : CHECK_STATUS(status, NT_STATUS_OK);
465 5 : fnum = io.ntcreatex.out.file.fnum;
466 :
467 5 : ret &= check_ea(cli, fname, "EAONE", NULL);
468 5 : ret &= check_ea(cli, fname, "1st EA", "Value One");
469 5 : ret &= check_ea(cli, fname, "2nd EA", "Second Value");
470 5 : ret &= check_ea(cli, fname, "and 3rd", "final value");
471 :
472 5 : smbcli_close(cli->tree, fnum);
473 :
474 5 : torture_comment(tctx, "Trying to add EAs on non-create\n");
475 5 : io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
476 5 : io.ntcreatex.in.fname = fname;
477 :
478 5 : ea_list.num_eas = 1;
479 5 : eas[0].flags = 0;
480 5 : eas[0].name.s = "Fourth EA";
481 5 : eas[0].value = data_blob_string_const("Value Four");
482 :
483 5 : status = smb_raw_open(cli->tree, tctx, &io);
484 5 : CHECK_STATUS(status, NT_STATUS_OK);
485 5 : fnum = io.ntcreatex.out.file.fnum;
486 :
487 5 : ret &= check_ea(cli, fname, "1st EA", "Value One");
488 5 : ret &= check_ea(cli, fname, "2nd EA", "Second Value");
489 5 : ret &= check_ea(cli, fname, "and 3rd", "final value");
490 5 : ret &= check_ea(cli, fname, "Fourth EA", NULL);
491 :
492 5 : torture_comment(tctx, "TESTING NTTRANS CREATE WITH BAD EA NAMES\n");
493 :
494 5 : io.generic.level = RAW_OPEN_NTTRANS_CREATE;
495 5 : io.ntcreatex.in.root_fid.fnum = 0;
496 5 : io.ntcreatex.in.flags = 0;
497 5 : io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
498 5 : io.ntcreatex.in.create_options = 0;
499 5 : io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
500 5 : io.ntcreatex.in.share_access =
501 : NTCREATEX_SHARE_ACCESS_READ |
502 : NTCREATEX_SHARE_ACCESS_WRITE;
503 5 : io.ntcreatex.in.alloc_size = 0;
504 5 : io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
505 5 : io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
506 5 : io.ntcreatex.in.security_flags = 0;
507 5 : io.ntcreatex.in.fname = fname_bad;
508 :
509 5 : ea_list.num_eas = 3;
510 5 : ea_list.eas = eas;
511 :
512 5 : eas[0].flags = 0;
513 5 : eas[0].name.s = "1st EA";
514 5 : eas[0].value = data_blob_string_const("Value One");
515 :
516 5 : eas[1].flags = 0;
517 5 : eas[1].name.s = "2nd:BAD:EA";
518 5 : eas[1].value = data_blob_string_const("Second Value");
519 :
520 5 : eas[2].flags = 0;
521 5 : eas[2].name.s = "and 3rd";
522 5 : eas[2].value = data_blob_string_const("final value");
523 :
524 5 : io.ntcreatex.in.ea_list = &ea_list;
525 5 : io.ntcreatex.in.sec_desc = NULL;
526 :
527 5 : status = smb_raw_open(cli->tree, tctx, &io);
528 5 : CHECK_STATUS(status, STATUS_INVALID_EA_NAME);
529 :
530 : /* File must not exist. */
531 5 : io.generic.level = RAW_OPEN_NTCREATEX;
532 5 : io.ntcreatex.in.root_fid.fnum = 0;
533 5 : io.ntcreatex.in.flags = 0;
534 5 : io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
535 5 : io.ntcreatex.in.create_options = 0;
536 5 : io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
537 5 : io.ntcreatex.in.share_access =
538 : NTCREATEX_SHARE_ACCESS_READ |
539 : NTCREATEX_SHARE_ACCESS_WRITE;
540 5 : io.ntcreatex.in.alloc_size = 0;
541 5 : io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
542 5 : io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
543 5 : io.ntcreatex.in.security_flags = 0;
544 5 : io.ntcreatex.in.fname = fname_bad;
545 5 : status = smb_raw_open(cli->tree, tctx, &io);
546 5 : CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
547 :
548 5 : done:
549 5 : smbcli_close(cli->tree, fnum);
550 5 : return ret;
551 : }
552 :
553 : /*
554 : basic testing of EA calls
555 : */
556 5 : bool torture_raw_eas(struct torture_context *torture, struct smbcli_state *cli)
557 : {
558 5 : bool ret = true;
559 :
560 5 : torture_assert(torture, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
561 :
562 5 : ret &= test_eas(cli, torture);
563 5 : ret &= test_nttrans_create(cli, torture);
564 :
565 5 : smb_raw_exit(cli->session);
566 :
567 5 : return ret;
568 : }
569 :
570 : /*
571 : test max EA size
572 : */
573 0 : bool torture_max_eas(struct torture_context *torture)
574 : {
575 0 : struct smbcli_state *cli;
576 0 : bool ret = true;
577 :
578 0 : if (!torture_open_connection(&cli, torture, 0)) {
579 0 : return false;
580 : }
581 :
582 0 : torture_assert(torture, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
583 :
584 0 : ret &= test_max_eas(cli, torture);
585 :
586 0 : smb_raw_exit(cli->session);
587 0 : if (!maxeadebug) {
588 : /* in no ea debug case, all files are gone now */
589 0 : smbcli_deltree(cli->tree, BASEDIR);
590 : }
591 :
592 0 : torture_close_connection(cli);
593 0 : return ret;
594 : }
|