summaryrefslogtreecommitdiff
path: root/source4/torture/raw/eas.c
blob: eace20ae83a367d7182fe95eacb61dcbf6dffbc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
/*
   Unix SMB/CIFS implementation.

   test DOS extended attributes

   Copyright (C) Andrew Tridgell 2004
   Copyright (C) Guenter Kukkukk 2005

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "includes.h"
#include "torture/torture.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
#include "torture/util.h"
#include "torture/raw/proto.h"

#define BASEDIR "\\testeas"

#define CHECK_STATUS(status, correct) do { \
	torture_assert_ntstatus_equal_goto(tctx, status, correct, ret, done, "Incorrect status"); \
	} while (0)

static	bool maxeadebug; /* need that here, to allow no file delete in debug case */

static bool check_ea(struct smbcli_state *cli,
		     const char *fname, const char *eaname, const char *value)
{
	NTSTATUS status = torture_check_ea(cli, fname, eaname, value);
	return NT_STATUS_IS_OK(status);
}

static char bad_ea_chars[] = "\"*+,/:;<=>?[\\]|";

static bool test_eas(struct smbcli_state *cli, struct torture_context *tctx)
{
	NTSTATUS status;
	union smb_setfileinfo setfile;
	union smb_open io;
	const char *fname = BASEDIR "\\ea.txt";
	bool ret = true;
	char bad_ea_name[7];
	int i;
	int fnum = -1;

	torture_comment(tctx, "TESTING SETFILEINFO EA_SET\n");

	io.generic.level = RAW_OPEN_NTCREATEX;
	io.ntcreatex.in.root_fid.fnum = 0;
	io.ntcreatex.in.flags = 0;
	io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
	io.ntcreatex.in.create_options = 0;
	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
	io.ntcreatex.in.share_access =
		NTCREATEX_SHARE_ACCESS_READ |
		NTCREATEX_SHARE_ACCESS_WRITE;
	io.ntcreatex.in.alloc_size = 0;
	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
	io.ntcreatex.in.security_flags = 0;
	io.ntcreatex.in.fname = fname;
	status = smb_raw_open(cli->tree, tctx, &io);
	CHECK_STATUS(status, NT_STATUS_OK);
	fnum = io.ntcreatex.out.file.fnum;

	ret &= check_ea(cli, fname, "EAONE", NULL);

	torture_comment(tctx, "Adding first two EAs\n");
	setfile.generic.level = RAW_SFILEINFO_EA_SET;
	setfile.generic.in.file.fnum = fnum;
	setfile.ea_set.in.num_eas = 2;
	setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 2);
	setfile.ea_set.in.eas[0].flags = 0;
	setfile.ea_set.in.eas[0].name.s = "EAONE";
	setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE1");
	setfile.ea_set.in.eas[1].flags = 0;
	setfile.ea_set.in.eas[1].name.s = "SECONDEA";
	setfile.ea_set.in.eas[1].value = data_blob_string_const("ValueTwo");

	status = smb_raw_setfileinfo(cli->tree, &setfile);
	CHECK_STATUS(status, NT_STATUS_OK);

	ret &= check_ea(cli, fname, "EAONE", "VALUE1");
	ret &= check_ea(cli, fname, "SECONDEA", "ValueTwo");

	torture_comment(tctx, "Modifying 2nd EA\n");
	setfile.ea_set.in.num_eas = 1;
	setfile.ea_set.in.eas[0].name.s = "SECONDEA";
	setfile.ea_set.in.eas[0].value = data_blob_string_const(" Changed Value");
	status = smb_raw_setfileinfo(cli->tree, &setfile);
	CHECK_STATUS(status, NT_STATUS_OK);

	ret &= check_ea(cli, fname, "EAONE", "VALUE1");
	ret &= check_ea(cli, fname, "SECONDEA", " Changed Value");

	torture_comment(tctx, "Setting a NULL EA\n");
	setfile.ea_set.in.eas[0].value = data_blob(NULL, 0);
	setfile.ea_set.in.eas[0].name.s = "NULLEA";
	status = smb_raw_setfileinfo(cli->tree, &setfile);
	CHECK_STATUS(status, NT_STATUS_OK);

	ret &= check_ea(cli, fname, "EAONE", "VALUE1");
	ret &= check_ea(cli, fname, "SECONDEA", " Changed Value");
	ret &= check_ea(cli, fname, "NULLEA", NULL);

	torture_comment(tctx, "Deleting first EA\n");
	setfile.ea_set.in.eas[0].flags = 0;
	setfile.ea_set.in.eas[0].name.s = "EAONE";
	setfile.ea_set.in.eas[0].value = data_blob(NULL, 0);
	status = smb_raw_setfileinfo(cli->tree, &setfile);
	CHECK_STATUS(status, NT_STATUS_OK);

	ret &= check_ea(cli, fname, "EAONE", NULL);
	ret &= check_ea(cli, fname, "SECONDEA", " Changed Value");

	torture_comment(tctx, "Deleting second EA\n");
	setfile.ea_set.in.eas[0].flags = 0;
	setfile.ea_set.in.eas[0].name.s = "SECONDEA";
	setfile.ea_set.in.eas[0].value = data_blob(NULL, 0);
	status = smb_raw_setfileinfo(cli->tree, &setfile);
	CHECK_STATUS(status, NT_STATUS_OK);

	ret &= check_ea(cli, fname, "EAONE", NULL);
	ret &= check_ea(cli, fname, "SECONDEA", NULL);

	/* Check EA name containing colon. All EA's set
	   must be ignored, not just the one with the bad
	   name. */

	torture_comment(tctx, "Adding bad EA name\n");
	setfile.generic.level = RAW_SFILEINFO_EA_SET;
	setfile.generic.in.file.fnum = fnum;
	setfile.ea_set.in.num_eas = 3;
	setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 3);
	setfile.ea_set.in.eas[0].flags = 0;
	setfile.ea_set.in.eas[0].name.s = "EAONE";
	setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE1");
	setfile.ea_set.in.eas[1].flags = 0;
	setfile.ea_set.in.eas[1].name.s = "SECOND:EA";
	setfile.ea_set.in.eas[1].value = data_blob_string_const("ValueTwo");
	setfile.ea_set.in.eas[2].flags = 0;
	setfile.ea_set.in.eas[2].name.s = "THIRDEA";
	setfile.ea_set.in.eas[2].value = data_blob_string_const("ValueThree");

	status = smb_raw_setfileinfo(cli->tree, &setfile);
	CHECK_STATUS(status, STATUS_INVALID_EA_NAME);

	ret &= check_ea(cli, fname, "EAONE", NULL);
	ret &= check_ea(cli, fname, "THIRDEA", NULL);

	setfile.generic.level = RAW_SFILEINFO_EA_SET;
	setfile.generic.in.file.fnum = fnum;
	setfile.ea_set.in.num_eas = 1;
	setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 1);
	setfile.ea_set.in.eas[0].flags = 0;
	strlcpy(bad_ea_name, "TEST_X", sizeof(bad_ea_name));
	setfile.ea_set.in.eas[0].name.s = bad_ea_name;

	torture_comment(tctx, "Testing bad EA name range.\n");

	for (i = 1; i < 256; i++) {
		setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE1");
		bad_ea_name[5] = (char)i;
		torture_comment(tctx, "Testing bad EA name %d.\n", i);
		status = smb_raw_setfileinfo(cli->tree, &setfile);
		if (i < 32 || strchr(bad_ea_chars, i)) {
			CHECK_STATUS(status, STATUS_INVALID_EA_NAME);
		} else {
			CHECK_STATUS(status, NT_STATUS_OK);

			/* Now delete the EA we just set to make
			   sure we don't run out of room. */
			setfile.ea_set.in.eas[0].value = data_blob(NULL, 0);
			status = smb_raw_setfileinfo(cli->tree, &setfile);
			CHECK_STATUS(status, NT_STATUS_OK);
		}
	}

done:
	smbcli_close(cli->tree, fnum);
	return ret;
}


/*
 * Helper function to retrieve the max. ea size for one ea name
 */
static int test_one_eamax(struct torture_context *tctx,
			  struct smbcli_state *cli, const int fnum,
			  const char *eaname, DATA_BLOB eablob,
			  const int eastart, const int eadebug)
{
	NTSTATUS status;
	struct ea_struct eastruct;
	union smb_setfileinfo setfile;
	int i, high, low, maxeasize;

	setfile.generic.level = RAW_SFILEINFO_EA_SET;
	setfile.generic.in.file.fnum = fnum;
	setfile.ea_set.in.num_eas = 1;
	setfile.ea_set.in.eas = &eastruct;
	setfile.ea_set.in.eas->flags = 0;
	setfile.ea_set.in.eas->name.s = eaname;
	setfile.ea_set.in.eas->value = eablob;

	maxeasize = eablob.length;
	i = eastart;
	low = 0;
	high = maxeasize;

	do {
		if (eadebug) {
			torture_comment(tctx, "Testing EA size: %d\n", i);
		}
		setfile.ea_set.in.eas->value.length = i;

		status = smb_raw_setfileinfo(cli->tree, &setfile);

		if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
			if (eadebug) {
				torture_comment(tctx, "[%s] EA size %d succeeded! "
					"(high=%d low=%d)\n",
					eaname, i, high, low);
			}
			low = i;
			if (low == maxeasize) {
				torture_comment(tctx, "Max. EA size for \"%s\"=%d "
					"[but could be possibly larger]\n",
					eaname, low);
				break;
			}
			if (high - low == 1 && high != maxeasize) {
				torture_comment(tctx, "Max. EA size for \"%s\"=%d\n",
					eaname, low);
				break;
			}
			i += (high - low + 1) / 2;
		} else {
			if (eadebug) {
				torture_comment(tctx, "[%s] EA size %d failed!    "
					"(high=%d low=%d) [%s]\n",
					eaname, i, high, low,
					nt_errstr(status));
			}
			high = i;
			if (high - low <= 1) {
				torture_comment(tctx, "Max. EA size for \"%s\"=%d\n",
					eaname, low);
				break;
			}
			i -= (high - low + 1) / 2;
		}
	} while (true);

	return low;
}

/*
 * Test for maximum ea size - more than one ea name is checked.
 *
 * Additional parameters can be passed, to allow further testing:
 *
 *             default
 * maxeasize    65536   limit the max. size for a single EA name
 * maxeanames     101   limit of the number of tested names
 * maxeastart       1   this EA size is used to test for the 1st EA (atm)
 * maxeadebug       0   if set true, further debug output is done - in addition
 *                      the testfile is not deleted for further inspection!
 *
 * Set some/all of these options on the cmdline with:
 * --option torture:maxeasize=1024 --option torture:maxeadebug=1 ...
 *
 */
static bool test_max_eas(struct smbcli_state *cli, struct torture_context *tctx)
{
	NTSTATUS status;
	union smb_open io;
	const char *fname = BASEDIR "\\ea_max.txt";
	int fnum = -1;
	bool ret = true;
	bool err = false;

	int       i, j, k, last, total;
	DATA_BLOB eablob;
	char      *eaname = NULL;
	int       maxeasize;
	int       maxeanames;
	int       maxeastart;

	torture_comment(tctx, "TESTING SETFILEINFO MAX. EA_SET\n");

	maxeasize  = torture_setting_int(tctx, "maxeasize", 65536);
	maxeanames = torture_setting_int(tctx, "maxeanames", 101);
	maxeastart = torture_setting_int(tctx, "maxeastart", 1);
	maxeadebug = torture_setting_bool(tctx, "maxeadebug", false);

	/* Do some sanity check on possibly passed parms */
	if (maxeasize <= 0) {
		torture_comment(tctx, "Invalid parameter 'maxeasize=%d'",maxeasize);
		err = true;
	}
	if (maxeanames <= 0) {
		torture_comment(tctx, "Invalid parameter 'maxeanames=%d'",maxeanames);
		err = true;
	}
	if (maxeastart <= 0) {
		torture_comment(tctx, "Invalid parameter 'maxeastart=%d'",maxeastart);
		err = true;
	}
	if (err) {
	  torture_comment(tctx, "\n\n");
	  goto done;
	}
	if (maxeastart > maxeasize) {
		maxeastart = maxeasize;
		torture_comment(tctx, "'maxeastart' outside range - corrected to %d\n",
			maxeastart);
	}
	torture_comment(tctx, "MAXEA parms: maxeasize=%d maxeanames=%d maxeastart=%d"
	       " maxeadebug=%d\n", maxeasize, maxeanames, maxeastart,
	       maxeadebug);

	io.generic.level = RAW_OPEN_NTCREATEX;
	io.ntcreatex.in.root_fid.fnum = 0;
	io.ntcreatex.in.flags = 0;
	io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
	io.ntcreatex.in.create_options = 0;
	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
	io.ntcreatex.in.share_access =
		NTCREATEX_SHARE_ACCESS_READ |
		NTCREATEX_SHARE_ACCESS_WRITE;
	io.ntcreatex.in.alloc_size = 0;
	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
	io.ntcreatex.in.security_flags = 0;
	io.ntcreatex.in.fname = fname;
	status = smb_raw_open(cli->tree, tctx, &io);
	CHECK_STATUS(status, NT_STATUS_OK);
	fnum = io.ntcreatex.out.file.fnum;

	eablob = data_blob_talloc(tctx, NULL, maxeasize);
	if (eablob.data == NULL) {
		goto done;
	}
	/*
	 * Fill in some EA data - the offset could be easily checked
	 * during a hexdump.
	 */
	for (i = 0, k = 0; i < eablob.length / 4; i++, k+=4) {
		eablob.data[k]   = k & 0xff;
		eablob.data[k+1] = (k >>  8) & 0xff;
		eablob.data[k+2] = (k >> 16) & 0xff;
		eablob.data[k+3] = (k >> 24) & 0xff;
	}

	i = eablob.length % 4;
	if (i-- > 0) {
		eablob.data[k] = k & 0xff;
		if (i-- > 0) {
			eablob.data[k+1] = (k >>  8) & 0xff;
			if (i-- > 0) {
				eablob.data[k+2] = (k >> 16) & 0xff;
			}
		}
	}
	/*
	 * Filesystems might allow max. EAs data for different EA names.
	 * So more than one EA name should be checked.
	 */
	total = 0;
	last  = maxeastart;

	for (i = 0; i < maxeanames; i++) {
		if (eaname != NULL) {
			talloc_free(eaname);
		}
		eaname = talloc_asprintf(tctx, "MAX%d", i);
		if(eaname == NULL) {
			goto done;
		}
		j = test_one_eamax(tctx, cli, fnum, eaname, eablob, last, maxeadebug);
		if (j <= 0) {
			break;
		}
		total += j;
		last = j;
	}

	torture_comment(tctx, "Total EA size:%d\n", total);
	if (i == maxeanames) {
		torture_comment(tctx, "NOTE: More EAs could be available!\n");
	}
	if (total == 0) {
		ret = false;
	}
done:
	smbcli_close(cli->tree, fnum);
	return ret;
}

/*
  test using NTTRANS CREATE to create a file with an initial EA set
*/
static bool test_nttrans_create(struct smbcli_state *cli, struct torture_context *tctx)
{
	NTSTATUS status;
	union smb_open io;
	const char *fname = BASEDIR "\\ea2.txt";
	const char *fname_bad = BASEDIR "\\ea2_bad.txt";
	bool ret = true;
	int fnum = -1;
	struct ea_struct eas[3];
	struct smb_ea_list ea_list;

	torture_comment(tctx, "TESTING NTTRANS CREATE WITH EAS\n");

	io.generic.level = RAW_OPEN_NTTRANS_CREATE;
	io.ntcreatex.in.root_fid.fnum = 0;
	io.ntcreatex.in.flags = 0;
	io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
	io.ntcreatex.in.create_options = 0;
	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
	io.ntcreatex.in.share_access =
		NTCREATEX_SHARE_ACCESS_READ |
		NTCREATEX_SHARE_ACCESS_WRITE;
	io.ntcreatex.in.alloc_size = 0;
	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
	io.ntcreatex.in.security_flags = 0;
	io.ntcreatex.in.fname = fname;

	ea_list.num_eas = 3;
	ea_list.eas = eas;

	eas[0].flags = 0;
	eas[0].name.s = "1st EA";
	eas[0].value = data_blob_string_const("Value One");

	eas[1].flags = 0;
	eas[1].name.s = "2nd EA";
	eas[1].value = data_blob_string_const("Second Value");

	eas[2].flags = 0;
	eas[2].name.s = "and 3rd";
	eas[2].value = data_blob_string_const("final value");

	io.ntcreatex.in.ea_list = &ea_list;
	io.ntcreatex.in.sec_desc = NULL;

	status = smb_raw_open(cli->tree, tctx, &io);
	CHECK_STATUS(status, NT_STATUS_OK);
	fnum = io.ntcreatex.out.file.fnum;

	ret &= check_ea(cli, fname, "EAONE", NULL);
	ret &= check_ea(cli, fname, "1st EA", "Value One");
	ret &= check_ea(cli, fname, "2nd EA", "Second Value");
	ret &= check_ea(cli, fname, "and 3rd", "final value");

	smbcli_close(cli->tree, fnum);

	torture_comment(tctx, "Trying to add EAs on non-create\n");
	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
	io.ntcreatex.in.fname = fname;

	ea_list.num_eas = 1;
	eas[0].flags = 0;
	eas[0].name.s = "Fourth EA";
	eas[0].value = data_blob_string_const("Value Four");

	status = smb_raw_open(cli->tree, tctx, &io);
	CHECK_STATUS(status, NT_STATUS_OK);
	fnum = io.ntcreatex.out.file.fnum;

	ret &= check_ea(cli, fname, "1st EA", "Value One");
	ret &= check_ea(cli, fname, "2nd EA", "Second Value");
	ret &= check_ea(cli, fname, "and 3rd", "final value");
	ret &= check_ea(cli, fname, "Fourth EA", NULL);

	torture_comment(tctx, "TESTING NTTRANS CREATE WITH BAD EA NAMES\n");

	io.generic.level = RAW_OPEN_NTTRANS_CREATE;
	io.ntcreatex.in.root_fid.fnum = 0;
	io.ntcreatex.in.flags = 0;
	io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
	io.ntcreatex.in.create_options = 0;
	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
	io.ntcreatex.in.share_access =
		NTCREATEX_SHARE_ACCESS_READ |
		NTCREATEX_SHARE_ACCESS_WRITE;
	io.ntcreatex.in.alloc_size = 0;
	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
	io.ntcreatex.in.security_flags = 0;
	io.ntcreatex.in.fname = fname_bad;

	ea_list.num_eas = 3;
	ea_list.eas = eas;

	eas[0].flags = 0;
	eas[0].name.s = "1st EA";
	eas[0].value = data_blob_string_const("Value One");

	eas[1].flags = 0;
	eas[1].name.s = "2nd:BAD:EA";
	eas[1].value = data_blob_string_const("Second Value");

	eas[2].flags = 0;
	eas[2].name.s = "and 3rd";
	eas[2].value = data_blob_string_const("final value");

	io.ntcreatex.in.ea_list = &ea_list;
	io.ntcreatex.in.sec_desc = NULL;

	status = smb_raw_open(cli->tree, tctx, &io);
	CHECK_STATUS(status, STATUS_INVALID_EA_NAME);

	/* File must not exist. */
	io.generic.level = RAW_OPEN_NTCREATEX;
	io.ntcreatex.in.root_fid.fnum = 0;
	io.ntcreatex.in.flags = 0;
	io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
	io.ntcreatex.in.create_options = 0;
	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
	io.ntcreatex.in.share_access =
		NTCREATEX_SHARE_ACCESS_READ |
		NTCREATEX_SHARE_ACCESS_WRITE;
	io.ntcreatex.in.alloc_size = 0;
	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
	io.ntcreatex.in.security_flags = 0;
	io.ntcreatex.in.fname = fname_bad;
	status = smb_raw_open(cli->tree, tctx, &io);
	CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);

done:
	smbcli_close(cli->tree, fnum);
	return ret;
}

/*
   basic testing of EA calls
*/
bool torture_raw_eas(struct torture_context *torture, struct smbcli_state *cli)
{
	bool ret = true;

	torture_assert(torture, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);

	ret &= test_eas(cli, torture);
	ret &= test_nttrans_create(cli, torture);

	smb_raw_exit(cli->session);

	return ret;
}

/*
   test max EA size
*/
bool torture_max_eas(struct torture_context *torture)
{
	struct smbcli_state *cli;
	bool ret = true;

	if (!torture_open_connection(&cli, torture, 0)) {
		return false;
	}

	torture_assert(torture, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);

	ret &= test_max_eas(cli, torture);

	smb_raw_exit(cli->session);
	if (!maxeadebug) {
		/* in no ea debug case, all files are gone now */
		smbcli_deltree(cli->tree, BASEDIR);
	}

	torture_close_connection(cli);
	return ret;
}