2 Unix SMB/CIFS implementation.
3 RAW_OPEN_* individual test suite
4 Copyright (C) Andrew Tridgell 2003
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "torture/torture.h"
22 #include "libcli/raw/libcliraw.h"
23 #include "libcli/raw/raw_proto.h"
24 #include "system/time.h"
25 #include "system/filesys.h"
26 #include "librpc/gen_ndr/security.h"
27 #include "lib/events/events.h"
28 #include "libcli/libcli.h"
29 #include "torture/util.h"
30 #include "auth/credentials/credentials.h"
31 #include "lib/cmdline/popt_common.h"
32 #include "param/param.h"
34 /* enum for whether reads/writes are possible on a file */
35 enum rdwr_mode {RDWR_NONE, RDWR_RDONLY, RDWR_WRONLY, RDWR_RDWR};
37 #define BASEDIR "\\rawopen"
40 check if a open file can be read/written
42 static enum rdwr_mode check_rdwr(struct smbcli_tree *tree, int fnum)
45 bool can_read = (smbcli_read(tree, fnum, &c, 0, 1) == 1);
46 bool can_write = (smbcli_write(tree, fnum, 0, &c, 0, 1) == 1);
47 if ( can_read && can_write) return RDWR_RDWR;
48 if ( can_read && !can_write) return RDWR_RDONLY;
49 if (!can_read && can_write) return RDWR_WRONLY;
54 describe a RDWR mode as a string
56 static const char *rdwr_string(enum rdwr_mode m)
59 case RDWR_NONE: return "NONE";
60 case RDWR_RDONLY: return "RDONLY";
61 case RDWR_WRONLY: return "WRONLY";
62 case RDWR_RDWR: return "RDWR";
67 #define CHECK_STATUS(status, correct) do { \
68 if (!NT_STATUS_EQUAL(status, correct)) { \
69 printf("(%s) Incorrect status %s - should be %s\n", \
70 __location__, nt_errstr(status), nt_errstr(correct)); \
75 #define CREATE_FILE do { \
76 fnum = create_complex_file(cli, tctx, fname); \
78 printf("(%s) Failed to create %s - %s\n", __location__, fname, smbcli_errstr(cli->tree)); \
83 #define CHECK_RDWR(fnum, correct) do { \
84 enum rdwr_mode m = check_rdwr(cli->tree, fnum); \
86 printf("(%s) Incorrect readwrite mode %s - expected %s\n", \
87 __location__, rdwr_string(m), rdwr_string(correct)); \
91 #define CHECK_TIME(t, field) do { \
93 finfo.all_info.level = RAW_FILEINFO_ALL_INFO; \
94 finfo.all_info.in.file.path = fname; \
95 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \
96 CHECK_STATUS(status, NT_STATUS_OK); \
98 t2 = nt_time_to_unix(finfo.all_info.out.field) & ~1; \
99 if (abs(t1-t2) > 2) { \
100 printf("(%s) wrong time for field %s %s - %s\n", \
101 __location__, #field, \
102 timestring(tctx, t1), \
103 timestring(tctx, t2)); \
104 dump_all_info(tctx, &finfo); \
108 #define CHECK_NTTIME(t, field) do { \
110 finfo.all_info.level = RAW_FILEINFO_ALL_INFO; \
111 finfo.all_info.in.file.path = fname; \
112 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \
113 CHECK_STATUS(status, NT_STATUS_OK); \
114 t2 = finfo.all_info.out.field; \
116 printf("(%s) wrong time for field %s %s - %s\n", \
117 __location__, #field, \
118 nt_time_string(tctx, t), \
119 nt_time_string(tctx, t2)); \
120 dump_all_info(tctx, &finfo); \
124 #define CHECK_ALL_INFO(v, field) do { \
125 finfo.all_info.level = RAW_FILEINFO_ALL_INFO; \
126 finfo.all_info.in.file.path = fname; \
127 status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \
128 CHECK_STATUS(status, NT_STATUS_OK); \
129 if ((v) != (finfo.all_info.out.field)) { \
130 printf("(%s) wrong value for field %s 0x%x - 0x%x\n", \
131 __location__, #field, (int)v, (int)(finfo.all_info.out.field)); \
132 dump_all_info(tctx, &finfo); \
136 #define CHECK_VAL(v, correct) do { \
137 if ((v) != (correct)) { \
138 printf("(%s) wrong value for %s 0x%x - should be 0x%x\n", \
139 __location__, #v, (int)(v), (int)correct); \
143 #define SET_ATTRIB(sattrib) do { \
144 union smb_setfileinfo sfinfo; \
145 ZERO_STRUCT(sfinfo.basic_info.in); \
146 sfinfo.basic_info.level = RAW_SFILEINFO_BASIC_INFORMATION; \
147 sfinfo.basic_info.in.file.path = fname; \
148 sfinfo.basic_info.in.attrib = sattrib; \
149 status = smb_raw_setpathinfo(cli->tree, &sfinfo); \
150 if (!NT_STATUS_IS_OK(status)) { \
151 printf("(%s) Failed to set attrib 0x%x on %s\n", \
152 __location__, sattrib, fname); \
158 static bool test_open(struct smbcli_state *cli, struct torture_context *tctx)
161 union smb_fileinfo finfo;
162 const char *fname = BASEDIR "\\torture_open.txt";
164 int fnum = -1, fnum2;
167 printf("Checking RAW_OPEN_OPEN\n");
169 io.openold.level = RAW_OPEN_OPEN;
170 io.openold.in.fname = fname;
171 io.openold.in.open_mode = OPEN_FLAGS_FCB;
172 io.openold.in.search_attrs = 0;
173 status = smb_raw_open(cli->tree, tctx, &io);
174 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
175 fnum = io.openold.out.file.fnum;
177 smbcli_unlink(cli->tree, fname);
179 smbcli_close(cli->tree, fnum);
181 status = smb_raw_open(cli->tree, tctx, &io);
182 CHECK_STATUS(status, NT_STATUS_OK);
183 fnum = io.openold.out.file.fnum;
184 CHECK_RDWR(fnum, RDWR_RDWR);
186 status = smb_raw_open(cli->tree, tctx, &io);
187 CHECK_STATUS(status, NT_STATUS_OK);
188 fnum2 = io.openold.out.file.fnum;
189 CHECK_RDWR(fnum2, RDWR_RDWR);
190 smbcli_close(cli->tree, fnum2);
191 smbcli_close(cli->tree, fnum);
193 /* check the read/write modes */
194 io.openold.level = RAW_OPEN_OPEN;
195 io.openold.in.fname = fname;
196 io.openold.in.search_attrs = 0;
198 io.openold.in.open_mode = OPEN_FLAGS_OPEN_READ;
199 status = smb_raw_open(cli->tree, tctx, &io);
200 CHECK_STATUS(status, NT_STATUS_OK);
201 fnum = io.openold.out.file.fnum;
202 CHECK_RDWR(fnum, RDWR_RDONLY);
203 smbcli_close(cli->tree, fnum);
205 io.openold.in.open_mode = OPEN_FLAGS_OPEN_WRITE;
206 status = smb_raw_open(cli->tree, tctx, &io);
207 CHECK_STATUS(status, NT_STATUS_OK);
208 fnum = io.openold.out.file.fnum;
209 CHECK_RDWR(fnum, RDWR_WRONLY);
210 smbcli_close(cli->tree, fnum);
212 io.openold.in.open_mode = OPEN_FLAGS_OPEN_RDWR;
213 status = smb_raw_open(cli->tree, tctx, &io);
214 CHECK_STATUS(status, NT_STATUS_OK);
215 fnum = io.openold.out.file.fnum;
216 CHECK_RDWR(fnum, RDWR_RDWR);
217 smbcli_close(cli->tree, fnum);
219 /* check the share modes roughly - not a complete matrix */
220 io.openold.in.open_mode = OPEN_FLAGS_OPEN_RDWR | OPEN_FLAGS_DENY_WRITE;
221 status = smb_raw_open(cli->tree, tctx, &io);
222 CHECK_STATUS(status, NT_STATUS_OK);
223 fnum = io.openold.out.file.fnum;
224 CHECK_RDWR(fnum, RDWR_RDWR);
226 if (io.openold.in.open_mode != io.openold.out.rmode) {
227 printf("(%s) rmode should equal open_mode - 0x%x 0x%x\n",
228 __location__, io.openold.out.rmode, io.openold.in.open_mode);
231 io.openold.in.open_mode = OPEN_FLAGS_OPEN_RDWR | OPEN_FLAGS_DENY_NONE;
232 status = smb_raw_open(cli->tree, tctx, &io);
233 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
235 io.openold.in.open_mode = OPEN_FLAGS_OPEN_READ | OPEN_FLAGS_DENY_NONE;
236 status = smb_raw_open(cli->tree, tctx, &io);
237 CHECK_STATUS(status, NT_STATUS_OK);
238 fnum2 = io.openold.out.file.fnum;
239 CHECK_RDWR(fnum2, RDWR_RDONLY);
240 smbcli_close(cli->tree, fnum);
241 smbcli_close(cli->tree, fnum2);
244 /* check the returned write time */
245 io.openold.level = RAW_OPEN_OPEN;
246 io.openold.in.fname = fname;
247 io.openold.in.search_attrs = 0;
248 io.openold.in.open_mode = OPEN_FLAGS_OPEN_READ;
249 status = smb_raw_open(cli->tree, tctx, &io);
250 CHECK_STATUS(status, NT_STATUS_OK);
251 fnum = io.openold.out.file.fnum;
253 /* check other reply fields */
254 CHECK_TIME(io.openold.out.write_time, write_time);
255 CHECK_ALL_INFO(io.openold.out.size, size);
256 CHECK_ALL_INFO(io.openold.out.attrib, attrib & ~FILE_ATTRIBUTE_NONINDEXED);
259 smbcli_close(cli->tree, fnum);
260 smbcli_unlink(cli->tree, fname);
269 static bool test_openx(struct smbcli_state *cli, struct torture_context *tctx)
272 union smb_fileinfo finfo;
273 const char *fname = BASEDIR "\\torture_openx.txt";
274 const char *fname_exe = BASEDIR "\\torture_openx.exe";
276 int fnum = -1, fnum2;
283 NTSTATUS correct_status;
285 { OPENX_OPEN_FUNC_OPEN, true, NT_STATUS_OK },
286 { OPENX_OPEN_FUNC_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
287 { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK },
288 { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
289 { OPENX_OPEN_FUNC_FAIL, true, NT_STATUS_DOS(ERRDOS, ERRbadaccess) },
290 { OPENX_OPEN_FUNC_FAIL, false, NT_STATUS_DOS(ERRDOS, ERRbadaccess) },
291 { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION },
292 { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
293 { OPENX_OPEN_FUNC_TRUNC, true, NT_STATUS_OK },
294 { OPENX_OPEN_FUNC_TRUNC, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
295 { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK },
296 { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
299 printf("Checking RAW_OPEN_OPENX\n");
300 smbcli_unlink(cli->tree, fname);
302 io.openx.level = RAW_OPEN_OPENX;
303 io.openx.in.fname = fname;
304 io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO;
305 io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR;
306 io.openx.in.search_attrs = 0;
307 io.openx.in.file_attrs = 0;
308 io.openx.in.write_time = 0;
309 io.openx.in.size = 1024*1024;
310 io.openx.in.timeout = 0;
312 /* check all combinations of open_func */
313 for (i=0; i<ARRAY_SIZE(open_funcs); i++) {
314 if (open_funcs[i].with_file) {
315 fnum = create_complex_file(cli, tctx, fname);
317 d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
321 smbcli_close(cli->tree, fnum);
323 io.openx.in.open_func = open_funcs[i].open_func;
324 status = smb_raw_open(cli->tree, tctx, &io);
325 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) {
326 printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n",
327 __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
328 i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_func);
331 if (NT_STATUS_IS_OK(status)) {
332 smbcli_close(cli->tree, io.openx.out.file.fnum);
334 if (open_funcs[i].with_file) {
335 smbcli_unlink(cli->tree, fname);
339 smbcli_unlink(cli->tree, fname);
341 /* check the basic return fields */
342 io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
343 status = smb_raw_open(cli->tree, tctx, &io);
344 CHECK_STATUS(status, NT_STATUS_OK);
345 fnum = io.openx.out.file.fnum;
347 CHECK_ALL_INFO(io.openx.out.size, size);
348 CHECK_TIME(io.openx.out.write_time, write_time);
349 CHECK_ALL_INFO(io.openx.out.attrib, attrib & ~FILE_ATTRIBUTE_NONINDEXED);
350 CHECK_VAL(io.openx.out.access, OPENX_MODE_ACCESS_RDWR);
351 CHECK_VAL(io.openx.out.ftype, 0);
352 CHECK_VAL(io.openx.out.devstate, 0);
353 CHECK_VAL(io.openx.out.action, OPENX_ACTION_CREATED);
354 CHECK_VAL(io.openx.out.size, 1024*1024);
355 CHECK_ALL_INFO(io.openx.in.size, size);
356 smbcli_close(cli->tree, fnum);
357 smbcli_unlink(cli->tree, fname);
359 /* check the fields when the file already existed */
360 fnum2 = create_complex_file(cli, tctx, fname);
365 smbcli_close(cli->tree, fnum2);
367 io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN;
368 status = smb_raw_open(cli->tree, tctx, &io);
369 CHECK_STATUS(status, NT_STATUS_OK);
370 fnum = io.openx.out.file.fnum;
372 CHECK_ALL_INFO(io.openx.out.size, size);
373 CHECK_TIME(io.openx.out.write_time, write_time);
374 CHECK_VAL(io.openx.out.action, OPENX_ACTION_EXISTED);
375 CHECK_VAL(io.openx.out.unknown, 0);
376 CHECK_ALL_INFO(io.openx.out.attrib, attrib & ~FILE_ATTRIBUTE_NONINDEXED);
377 smbcli_close(cli->tree, fnum);
379 /* now check the search attrib for hidden files - win2003 ignores this? */
380 SET_ATTRIB(FILE_ATTRIBUTE_HIDDEN);
381 CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN, attrib);
383 io.openx.in.search_attrs = FILE_ATTRIBUTE_HIDDEN;
384 status = smb_raw_open(cli->tree, tctx, &io);
385 CHECK_STATUS(status, NT_STATUS_OK);
386 smbcli_close(cli->tree, io.openx.out.file.fnum);
388 io.openx.in.search_attrs = 0;
389 status = smb_raw_open(cli->tree, tctx, &io);
390 CHECK_STATUS(status, NT_STATUS_OK);
391 smbcli_close(cli->tree, io.openx.out.file.fnum);
393 SET_ATTRIB(FILE_ATTRIBUTE_NORMAL);
394 smbcli_unlink(cli->tree, fname);
396 /* and check attrib on create */
397 io.openx.in.open_func = OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE;
398 io.openx.in.search_attrs = 0;
399 io.openx.in.file_attrs = FILE_ATTRIBUTE_SYSTEM;
400 status = smb_raw_open(cli->tree, tctx, &io);
401 CHECK_STATUS(status, NT_STATUS_OK);
402 if (torture_setting_bool(tctx, "samba3", false)) {
403 CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE,
404 attrib & ~(FILE_ATTRIBUTE_NONINDEXED|
405 FILE_ATTRIBUTE_SPARSE));
408 CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE,
409 attrib & ~(FILE_ATTRIBUTE_NONINDEXED));
411 smbcli_close(cli->tree, io.openx.out.file.fnum);
412 smbcli_unlink(cli->tree, fname);
414 /* check timeout on create - win2003 ignores the timeout! */
415 io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
416 io.openx.in.file_attrs = 0;
417 io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPENX_MODE_DENY_ALL;
418 status = smb_raw_open(cli->tree, tctx, &io);
419 CHECK_STATUS(status, NT_STATUS_OK);
420 fnum = io.openx.out.file.fnum;
422 io.openx.in.timeout = 20000;
423 tv = timeval_current();
424 io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPENX_MODE_DENY_NONE;
425 status = smb_raw_open(cli->tree, tctx, &io);
426 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
427 if (timeval_elapsed(&tv) > 3.0) {
428 printf("(%s) Incorrect timing in openx with timeout - waited %.2f seconds\n",
429 __location__, timeval_elapsed(&tv));
432 smbcli_close(cli->tree, fnum);
433 smbcli_unlink(cli->tree, fname);
435 /* now this is a really weird one - open for execute implies create?! */
436 io.openx.in.fname = fname;
437 io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO;
438 io.openx.in.open_mode = OPENX_MODE_ACCESS_EXEC | OPENX_MODE_DENY_NONE;
439 io.openx.in.search_attrs = 0;
440 io.openx.in.open_func = OPENX_OPEN_FUNC_FAIL;
441 io.openx.in.file_attrs = 0;
442 io.openx.in.write_time = 0;
443 io.openx.in.size = 0;
444 io.openx.in.timeout = 0;
445 status = smb_raw_open(cli->tree, tctx, &io);
446 CHECK_STATUS(status, NT_STATUS_OK);
447 smbcli_close(cli->tree, io.openx.out.file.fnum);
449 /* check the extended return flag */
450 io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO | OPENX_FLAGS_EXTENDED_RETURN;
451 io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN;
452 status = smb_raw_open(cli->tree, tctx, &io);
453 CHECK_STATUS(status, NT_STATUS_OK);
454 CHECK_VAL(io.openx.out.access_mask, SEC_STD_ALL);
455 smbcli_close(cli->tree, io.openx.out.file.fnum);
457 io.openx.in.fname = "\\A.+,;=[].B";
458 status = smb_raw_open(cli->tree, tctx, &io);
459 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
461 /* Check the mapping for open exec. */
463 /* First create an .exe file. */
464 smbcli_unlink(cli->tree, fname_exe);
465 fnum = create_complex_file(cli, tctx, fname_exe);
466 smbcli_close(cli->tree, fnum);
468 io.openx.level = RAW_OPEN_OPENX;
469 io.openx.in.fname = fname_exe;
470 io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO;
471 io.openx.in.open_mode = OPENX_MODE_ACCESS_EXEC | OPENX_MODE_DENY_NONE;
472 io.openx.in.search_attrs = 0;
473 io.openx.in.file_attrs = 0;
474 io.openx.in.write_time = 0;
475 io.openx.in.size = 0;
476 io.openx.in.timeout = 0;
477 status = smb_raw_open(cli->tree, tctx, &io);
478 CHECK_STATUS(status, NT_STATUS_OK);
480 /* Can we read and write ? */
481 CHECK_RDWR(io.openx.out.file.fnum, RDWR_RDONLY);
482 smbcli_close(cli->tree, io.openx.out.file.fnum);
483 smbcli_unlink(cli->tree, fname);
486 smbcli_close(cli->tree, fnum);
487 smbcli_unlink(cli->tree, fname_exe);
488 smbcli_unlink(cli->tree, fname);
497 many thanks to kukks for a sniff showing how this works with os2->w2k
499 static bool test_t2open(struct smbcli_state *cli, struct torture_context *tctx)
502 union smb_fileinfo finfo;
503 const char *fname1 = BASEDIR "\\torture_t2open_yes.txt";
504 const char *fname2 = BASEDIR "\\torture_t2open_no.txt";
505 const char *fname = BASEDIR "\\torture_t2open_3.txt";
513 NTSTATUS correct_status;
515 { OPENX_OPEN_FUNC_OPEN, true, NT_STATUS_OK },
516 { OPENX_OPEN_FUNC_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
517 { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK },
518 { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
519 { OPENX_OPEN_FUNC_FAIL, true, NT_STATUS_OBJECT_NAME_COLLISION },
520 { OPENX_OPEN_FUNC_FAIL, false, NT_STATUS_OBJECT_NAME_COLLISION },
521 { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION },
522 { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OBJECT_NAME_COLLISION },
523 { OPENX_OPEN_FUNC_TRUNC, true, NT_STATUS_OK },
524 { OPENX_OPEN_FUNC_TRUNC, false, NT_STATUS_OK },
525 { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK },
526 { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK },
529 fnum = create_complex_file(cli, tctx, fname1);
531 d_printf("Failed to create file %s - %s\n", fname1, smbcli_errstr(cli->tree));
535 smbcli_close(cli->tree, fnum);
537 printf("Checking RAW_OPEN_T2OPEN\n");
539 io.t2open.level = RAW_OPEN_T2OPEN;
540 io.t2open.in.flags = OPENX_FLAGS_ADDITIONAL_INFO;
541 io.t2open.in.open_mode = OPENX_MODE_DENY_NONE | OPENX_MODE_ACCESS_RDWR;
542 io.t2open.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
543 io.t2open.in.search_attrs = 0;
544 io.t2open.in.file_attrs = 0;
545 io.t2open.in.write_time = 0;
546 io.t2open.in.size = 0;
547 io.t2open.in.timeout = 0;
549 io.t2open.in.num_eas = 3;
550 io.t2open.in.eas = talloc_array(tctx, struct ea_struct, io.t2open.in.num_eas);
551 io.t2open.in.eas[0].flags = 0;
552 io.t2open.in.eas[0].name.s = ".CLASSINFO";
553 io.t2open.in.eas[0].value = data_blob_talloc(tctx, "first value", 11);
554 io.t2open.in.eas[1].flags = 0;
555 io.t2open.in.eas[1].name.s = "EA TWO";
556 io.t2open.in.eas[1].value = data_blob_talloc(tctx, "foo", 3);
557 io.t2open.in.eas[2].flags = 0;
558 io.t2open.in.eas[2].name.s = "X THIRD";
559 io.t2open.in.eas[2].value = data_blob_talloc(tctx, "xy", 2);
561 /* check all combinations of open_func */
562 for (i=0; i<ARRAY_SIZE(open_funcs); i++) {
564 if (open_funcs[i].with_file) {
565 io.t2open.in.fname = fname1;
567 io.t2open.in.fname = fname2;
569 io.t2open.in.open_func = open_funcs[i].open_func;
570 status = smb_raw_open(cli->tree, tctx, &io);
571 if ((io.t2open.in.num_eas != 0)
572 && NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED)
573 && torture_setting_bool(tctx, "samba3", false)) {
574 printf("(%s) EAs not supported, not treating as fatal "
575 "in Samba3 test\n", __location__);
576 io.t2open.in.num_eas = 0;
580 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) {
581 printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n",
582 __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
583 i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_func);
586 if (NT_STATUS_IS_OK(status)) {
587 smbcli_close(cli->tree, io.t2open.out.file.fnum);
591 smbcli_unlink(cli->tree, fname1);
592 smbcli_unlink(cli->tree, fname2);
594 /* check the basic return fields */
595 io.t2open.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
596 io.t2open.in.write_time = 0;
597 io.t2open.in.fname = fname;
598 status = smb_raw_open(cli->tree, tctx, &io);
599 CHECK_STATUS(status, NT_STATUS_OK);
600 fnum = io.t2open.out.file.fnum;
602 CHECK_ALL_INFO(io.t2open.out.size, size);
604 /* windows appears to leak uninitialised memory here */
605 CHECK_VAL(io.t2open.out.write_time, 0);
607 CHECK_ALL_INFO(io.t2open.out.attrib, attrib & ~FILE_ATTRIBUTE_NONINDEXED);
608 CHECK_VAL(io.t2open.out.access, OPENX_MODE_DENY_NONE | OPENX_MODE_ACCESS_RDWR);
609 CHECK_VAL(io.t2open.out.ftype, 0);
610 CHECK_VAL(io.t2open.out.devstate, 0);
611 CHECK_VAL(io.t2open.out.action, OPENX_ACTION_CREATED);
612 smbcli_close(cli->tree, fnum);
614 status = torture_check_ea(cli, fname, ".CLASSINFO", "first value");
615 CHECK_STATUS(status, io.t2open.in.num_eas
616 ? NT_STATUS_OK : NT_STATUS_EAS_NOT_SUPPORTED);
617 status = torture_check_ea(cli, fname, "EA TWO", "foo");
618 CHECK_STATUS(status, io.t2open.in.num_eas
619 ? NT_STATUS_OK : NT_STATUS_EAS_NOT_SUPPORTED);
620 status = torture_check_ea(cli, fname, "X THIRD", "xy");
621 CHECK_STATUS(status, io.t2open.in.num_eas
622 ? NT_STATUS_OK : NT_STATUS_EAS_NOT_SUPPORTED);
624 /* now check the search attrib for hidden files - win2003 ignores this? */
625 SET_ATTRIB(FILE_ATTRIBUTE_HIDDEN);
626 CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN, attrib);
628 status = smb_raw_open(cli->tree, tctx, &io);
629 CHECK_STATUS(status, NT_STATUS_OK);
630 smbcli_close(cli->tree, io.t2open.out.file.fnum);
632 status = smb_raw_open(cli->tree, tctx, &io);
633 CHECK_STATUS(status, NT_STATUS_OK);
634 smbcli_close(cli->tree, io.t2open.out.file.fnum);
636 SET_ATTRIB(FILE_ATTRIBUTE_NORMAL);
637 smbcli_unlink(cli->tree, fname);
639 /* and check attrib on create */
640 io.t2open.in.open_func = OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE;
641 io.t2open.in.file_attrs = FILE_ATTRIBUTE_SYSTEM;
642 status = smb_raw_open(cli->tree, tctx, &io);
643 CHECK_STATUS(status, NT_STATUS_OK);
645 /* check timeout on create - win2003 ignores the timeout! */
646 io.t2open.in.open_func = OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE;
647 io.t2open.in.file_attrs = 0;
648 io.t2open.in.timeout = 20000;
649 io.t2open.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPENX_MODE_DENY_ALL;
650 status = smb_raw_open(cli->tree, tctx, &io);
651 CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
654 smbcli_close(cli->tree, fnum);
655 smbcli_unlink(cli->tree, fname);
662 test RAW_OPEN_NTCREATEX
664 static bool test_ntcreatex(struct smbcli_state *cli, struct torture_context *tctx)
667 union smb_fileinfo finfo;
668 const char *fname = BASEDIR "\\torture_ntcreatex.txt";
669 const char *dname = BASEDIR "\\torture_ntcreatex.dir";
677 NTSTATUS correct_status;
679 { NTCREATEX_DISP_SUPERSEDE, true, NT_STATUS_OK },
680 { NTCREATEX_DISP_SUPERSEDE, false, NT_STATUS_OK },
681 { NTCREATEX_DISP_OPEN, true, NT_STATUS_OK },
682 { NTCREATEX_DISP_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
683 { NTCREATEX_DISP_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION },
684 { NTCREATEX_DISP_CREATE, false, NT_STATUS_OK },
685 { NTCREATEX_DISP_OPEN_IF, true, NT_STATUS_OK },
686 { NTCREATEX_DISP_OPEN_IF, false, NT_STATUS_OK },
687 { NTCREATEX_DISP_OVERWRITE, true, NT_STATUS_OK },
688 { NTCREATEX_DISP_OVERWRITE, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
689 { NTCREATEX_DISP_OVERWRITE_IF, true, NT_STATUS_OK },
690 { NTCREATEX_DISP_OVERWRITE_IF, false, NT_STATUS_OK },
691 { 6, true, NT_STATUS_INVALID_PARAMETER },
692 { 6, false, NT_STATUS_INVALID_PARAMETER },
695 printf("Checking RAW_OPEN_NTCREATEX\n");
697 /* reasonable default parameters */
698 io.generic.level = RAW_OPEN_NTCREATEX;
699 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
700 io.ntcreatex.in.root_fid = 0;
701 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
702 io.ntcreatex.in.alloc_size = 1024*1024;
703 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
704 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
705 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
706 io.ntcreatex.in.create_options = 0;
707 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
708 io.ntcreatex.in.security_flags = 0;
709 io.ntcreatex.in.fname = fname;
711 /* test the open disposition */
712 for (i=0; i<ARRAY_SIZE(open_funcs); i++) {
713 if (open_funcs[i].with_file) {
714 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE);
716 d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
720 smbcli_close(cli->tree, fnum);
722 io.ntcreatex.in.open_disposition = open_funcs[i].open_disp;
723 status = smb_raw_open(cli->tree, tctx, &io);
724 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) {
725 printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n",
726 __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
727 i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_disp);
730 if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) {
731 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
732 smbcli_unlink(cli->tree, fname);
736 /* basic field testing */
737 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
739 status = smb_raw_open(cli->tree, tctx, &io);
740 CHECK_STATUS(status, NT_STATUS_OK);
741 fnum = io.ntcreatex.out.file.fnum;
743 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
744 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_CREATED);
745 CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
746 CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
747 CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
748 CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
749 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
750 CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
751 CHECK_ALL_INFO(io.ntcreatex.out.size, size);
752 CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
753 CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
755 /* check fields when the file already existed */
756 smbcli_close(cli->tree, fnum);
757 smbcli_unlink(cli->tree, fname);
758 fnum = create_complex_file(cli, tctx, fname);
763 smbcli_close(cli->tree, fnum);
765 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
766 status = smb_raw_open(cli->tree, tctx, &io);
767 CHECK_STATUS(status, NT_STATUS_OK);
768 fnum = io.ntcreatex.out.file.fnum;
770 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
771 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_EXISTED);
772 CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
773 CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
774 CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
775 CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
776 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
777 CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
778 CHECK_ALL_INFO(io.ntcreatex.out.size, size);
779 CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
780 CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
781 smbcli_close(cli->tree, fnum);
782 smbcli_unlink(cli->tree, fname);
785 /* create a directory */
786 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
787 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
788 io.ntcreatex.in.alloc_size = 0;
789 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
790 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
791 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
792 io.ntcreatex.in.create_options = 0;
793 io.ntcreatex.in.fname = dname;
796 smbcli_rmdir(cli->tree, fname);
797 smbcli_unlink(cli->tree, fname);
799 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
800 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
801 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
802 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
803 status = smb_raw_open(cli->tree, tctx, &io);
804 CHECK_STATUS(status, NT_STATUS_OK);
805 fnum = io.ntcreatex.out.file.fnum;
807 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
808 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_CREATED);
809 CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
810 CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
811 CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
812 CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
813 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
814 CHECK_VAL(io.ntcreatex.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED,
815 FILE_ATTRIBUTE_DIRECTORY);
816 CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
817 CHECK_ALL_INFO(io.ntcreatex.out.size, size);
818 CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
819 CHECK_VAL(io.ntcreatex.out.is_directory, 1);
820 CHECK_VAL(io.ntcreatex.out.size, 0);
821 CHECK_VAL(io.ntcreatex.out.alloc_size, 0);
822 CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
823 smbcli_unlink(cli->tree, fname);
827 smbcli_close(cli->tree, fnum);
828 smbcli_unlink(cli->tree, fname);
835 test RAW_OPEN_NTTRANS_CREATE
837 static bool test_nttrans_create(struct smbcli_state *cli, struct torture_context *tctx)
840 union smb_fileinfo finfo;
841 const char *fname = BASEDIR "\\torture_ntcreatex.txt";
842 const char *dname = BASEDIR "\\torture_ntcreatex.dir";
847 uint32_t ok_mask, not_supported_mask, invalid_parameter_mask;
848 uint32_t not_a_directory_mask, unexpected_mask;
852 NTSTATUS correct_status;
854 { NTCREATEX_DISP_SUPERSEDE, true, NT_STATUS_OK },
855 { NTCREATEX_DISP_SUPERSEDE, false, NT_STATUS_OK },
856 { NTCREATEX_DISP_OPEN, true, NT_STATUS_OK },
857 { NTCREATEX_DISP_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
858 { NTCREATEX_DISP_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION },
859 { NTCREATEX_DISP_CREATE, false, NT_STATUS_OK },
860 { NTCREATEX_DISP_OPEN_IF, true, NT_STATUS_OK },
861 { NTCREATEX_DISP_OPEN_IF, false, NT_STATUS_OK },
862 { NTCREATEX_DISP_OVERWRITE, true, NT_STATUS_OK },
863 { NTCREATEX_DISP_OVERWRITE, false, NT_STATUS_OBJECT_NAME_NOT_FOUND },
864 { NTCREATEX_DISP_OVERWRITE_IF, true, NT_STATUS_OK },
865 { NTCREATEX_DISP_OVERWRITE_IF, false, NT_STATUS_OK },
866 { 6, true, NT_STATUS_INVALID_PARAMETER },
867 { 6, false, NT_STATUS_INVALID_PARAMETER },
870 printf("Checking RAW_OPEN_NTTRANS_CREATE\n");
872 /* reasonable default parameters */
873 io.generic.level = RAW_OPEN_NTTRANS_CREATE;
874 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
875 io.ntcreatex.in.root_fid = 0;
876 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
877 io.ntcreatex.in.alloc_size = 1024*1024;
878 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
879 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
880 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
881 io.ntcreatex.in.create_options = 0;
882 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
883 io.ntcreatex.in.security_flags = 0;
884 io.ntcreatex.in.fname = fname;
885 io.ntcreatex.in.sec_desc = NULL;
886 io.ntcreatex.in.ea_list = NULL;
888 /* test the open disposition */
889 for (i=0; i<ARRAY_SIZE(open_funcs); i++) {
890 if (open_funcs[i].with_file) {
891 fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE);
893 d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree));
897 smbcli_close(cli->tree, fnum);
899 io.ntcreatex.in.open_disposition = open_funcs[i].open_disp;
900 status = smb_raw_open(cli->tree, tctx, &io);
901 if (!NT_STATUS_EQUAL(status, open_funcs[i].correct_status)) {
902 printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n",
903 __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status),
904 i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_disp);
907 if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) {
908 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
909 smbcli_unlink(cli->tree, fname);
913 /* basic field testing */
914 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
916 status = smb_raw_open(cli->tree, tctx, &io);
917 CHECK_STATUS(status, NT_STATUS_OK);
918 fnum = io.ntcreatex.out.file.fnum;
920 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
921 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_CREATED);
922 CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
923 CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
924 CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
925 CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
926 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
927 CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
928 CHECK_ALL_INFO(io.ntcreatex.out.size, size);
929 CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
930 CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
932 /* check fields when the file already existed */
933 smbcli_close(cli->tree, fnum);
934 smbcli_unlink(cli->tree, fname);
935 fnum = create_complex_file(cli, tctx, fname);
940 smbcli_close(cli->tree, fnum);
942 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
943 status = smb_raw_open(cli->tree, tctx, &io);
944 CHECK_STATUS(status, NT_STATUS_OK);
945 fnum = io.ntcreatex.out.file.fnum;
947 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
948 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_EXISTED);
949 CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
950 CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
951 CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
952 CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
953 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
954 CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
955 CHECK_ALL_INFO(io.ntcreatex.out.size, size);
956 CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
957 CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
958 smbcli_close(cli->tree, fnum);
960 /* check no-recall - don't pull a file from tape on a HSM */
961 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_NO_RECALL;
962 status = smb_raw_open(cli->tree, tctx, &io);
963 CHECK_STATUS(status, NT_STATUS_OK);
964 fnum = io.ntcreatex.out.file.fnum;
966 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
967 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_EXISTED);
968 CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
969 CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
970 CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
971 CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
972 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
973 CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
974 CHECK_ALL_INFO(io.ntcreatex.out.size, size);
975 CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
976 CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
977 smbcli_close(cli->tree, fnum);
979 /* Check some create options (these all should be ignored) */
980 for (i=0; i < 32; i++) {
981 uint32_t create_option = (1 << i) & NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
982 if (create_option == 0) {
985 io.ntcreatex.in.create_options = create_option;
986 status = smb_raw_open(cli->tree, tctx, &io);
987 if (!NT_STATUS_IS_OK(status)) {
988 printf("ntcreatex create option 0x%08x gave %s - should give NT_STATUS_OK\n",
989 create_option, nt_errstr(status));
991 CHECK_STATUS(status, NT_STATUS_OK);
992 fnum = io.ntcreatex.out.file.fnum;
994 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
995 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_EXISTED);
996 CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
997 CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
998 CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
999 CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
1000 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
1001 CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
1002 CHECK_ALL_INFO(io.ntcreatex.out.size, size);
1003 CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
1004 CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
1005 smbcli_close(cli->tree, fnum);
1008 io.ntcreatex.in.file_attr = 0;
1009 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
1010 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1012 /* Check for options that should return NOT_SUPPORTED, OK or INVALID_PARAMETER */
1014 not_supported_mask = 0;
1015 invalid_parameter_mask = 0;
1016 not_a_directory_mask = 0;
1017 unexpected_mask = 0;
1018 for (i=0; i < 32; i++) {
1019 uint32_t create_option = 1<<i;
1020 if (create_option & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) {
1023 io.ntcreatex.in.create_options = create_option;
1024 status = smb_raw_open(cli->tree, tctx, &io);
1025 if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
1026 not_supported_mask |= create_option;
1027 } else if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
1028 ok_mask |= create_option;
1029 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
1030 } else if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
1031 invalid_parameter_mask |= create_option;
1032 } else if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_A_DIRECTORY)) {
1033 not_a_directory_mask |= 1<<i;
1035 unexpected_mask |= 1<<i;
1036 printf("create option 0x%08x returned %s\n", create_option, nt_errstr(status));
1040 CHECK_VAL(ok_mask, 0x00efcfce);
1041 CHECK_VAL(not_a_directory_mask, 0x00000001);
1042 CHECK_VAL(not_supported_mask, 0x00002000);
1043 CHECK_VAL(invalid_parameter_mask, 0xff100030);
1044 CHECK_VAL(unexpected_mask, 0x00000000);
1046 smbcli_unlink(cli->tree, fname);
1049 /* create a directory */
1050 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
1051 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
1052 io.ntcreatex.in.alloc_size = 0;
1053 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
1054 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
1055 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
1056 io.ntcreatex.in.create_options = 0;
1057 io.ntcreatex.in.fname = dname;
1060 smbcli_rmdir(cli->tree, fname);
1061 smbcli_unlink(cli->tree, fname);
1063 io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1064 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
1065 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
1066 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
1067 status = smb_raw_open(cli->tree, tctx, &io);
1068 CHECK_STATUS(status, NT_STATUS_OK);
1069 fnum = io.ntcreatex.out.file.fnum;
1071 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
1072 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_CREATED);
1073 CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
1074 CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
1075 CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
1076 CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
1077 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
1078 CHECK_VAL(io.ntcreatex.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED,
1079 FILE_ATTRIBUTE_DIRECTORY);
1080 CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
1081 CHECK_ALL_INFO(io.ntcreatex.out.size, size);
1082 CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
1083 CHECK_VAL(io.ntcreatex.out.is_directory, 1);
1084 CHECK_VAL(io.ntcreatex.out.size, 0);
1085 CHECK_VAL(io.ntcreatex.out.alloc_size, 0);
1086 CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
1087 smbcli_unlink(cli->tree, fname);
1091 smbcli_close(cli->tree, fnum);
1092 smbcli_unlink(cli->tree, fname);
1098 test RAW_OPEN_NTCREATEX with an already opened and byte range locked file
1100 I've got an application that does a similar sequence of ntcreate&x,
1101 locking&x and another ntcreate&x with
1102 open_disposition==NTCREATEX_DISP_OVERWRITE_IF. Windows 2003 allows the
1105 static bool test_ntcreatex_brlocked(struct smbcli_state *cli, struct torture_context *tctx)
1107 union smb_open io, io1;
1109 struct smb_lock_entry lock[1];
1110 const char *fname = BASEDIR "\\torture_ntcreatex.txt";
1114 printf("Testing ntcreatex with a byte range locked file\n");
1116 io.generic.level = RAW_OPEN_NTCREATEX;
1117 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
1118 io.ntcreatex.in.root_fid = 0;
1119 io.ntcreatex.in.access_mask = 0x2019f;
1120 io.ntcreatex.in.alloc_size = 0;
1121 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
1122 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
1123 NTCREATEX_SHARE_ACCESS_WRITE;
1124 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
1125 io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
1126 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION;
1127 io.ntcreatex.in.security_flags = NTCREATEX_SECURITY_DYNAMIC |
1128 NTCREATEX_SECURITY_ALL;
1129 io.ntcreatex.in.fname = fname;
1131 status = smb_raw_open(cli->tree, tctx, &io);
1132 CHECK_STATUS(status, NT_STATUS_OK);
1134 io2.lockx.level = RAW_LOCK_LOCKX;
1135 io2.lockx.in.file.fnum = io.ntcreatex.out.file.fnum;
1136 io2.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
1137 io2.lockx.in.timeout = 0;
1138 io2.lockx.in.ulock_cnt = 0;
1139 io2.lockx.in.lock_cnt = 1;
1140 lock[0].pid = cli->session->pid;
1142 lock[0].count = 0x1;
1143 io2.lockx.in.locks = &lock[0];
1144 status = smb_raw_lock(cli->tree, &io2);
1145 CHECK_STATUS(status, NT_STATUS_OK);
1147 io1.generic.level = RAW_OPEN_NTCREATEX;
1148 io1.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
1149 io1.ntcreatex.in.root_fid = 0;
1150 io1.ntcreatex.in.access_mask = 0x20196;
1151 io1.ntcreatex.in.alloc_size = 0;
1152 io1.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
1153 io1.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
1154 NTCREATEX_SHARE_ACCESS_WRITE;
1155 io1.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF;
1156 io1.ntcreatex.in.create_options = 0;
1157 io1.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION;
1158 io1.ntcreatex.in.security_flags = NTCREATEX_SECURITY_DYNAMIC |
1159 NTCREATEX_SECURITY_ALL;
1160 io1.ntcreatex.in.fname = fname;
1162 status = smb_raw_open(cli->tree, tctx, &io1);
1163 CHECK_STATUS(status, NT_STATUS_OK);
1166 smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
1167 smbcli_close(cli->tree, io1.ntcreatex.out.file.fnum);
1168 smbcli_unlink(cli->tree, fname);
1175 static bool test_mknew(struct smbcli_state *cli, struct torture_context *tctx)
1178 const char *fname = BASEDIR "\\torture_mknew.txt";
1182 time_t basetime = (time(NULL) + 3600*24*3) & ~1;
1183 union smb_fileinfo finfo;
1185 printf("Checking RAW_OPEN_MKNEW\n");
1187 io.mknew.level = RAW_OPEN_MKNEW;
1188 io.mknew.in.attrib = 0;
1189 io.mknew.in.write_time = 0;
1190 io.mknew.in.fname = fname;
1191 status = smb_raw_open(cli->tree, tctx, &io);
1192 CHECK_STATUS(status, NT_STATUS_OK);
1193 fnum = io.mknew.out.file.fnum;
1195 status = smb_raw_open(cli->tree, tctx, &io);
1196 CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION);
1198 smbcli_close(cli->tree, fnum);
1199 smbcli_unlink(cli->tree, fname);
1201 /* make sure write_time works */
1202 io.mknew.in.write_time = basetime;
1203 status = smb_raw_open(cli->tree, tctx, &io);
1204 CHECK_STATUS(status, NT_STATUS_OK);
1205 fnum = io.mknew.out.file.fnum;
1206 CHECK_TIME(basetime, write_time);
1208 smbcli_close(cli->tree, fnum);
1209 smbcli_unlink(cli->tree, fname);
1211 /* make sure file_attrs works */
1212 io.mknew.in.attrib = FILE_ATTRIBUTE_HIDDEN;
1213 status = smb_raw_open(cli->tree, tctx, &io);
1214 CHECK_STATUS(status, NT_STATUS_OK);
1215 fnum = io.mknew.out.file.fnum;
1216 CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE,
1217 attrib & ~FILE_ATTRIBUTE_NONINDEXED);
1220 smbcli_close(cli->tree, fnum);
1221 smbcli_unlink(cli->tree, fname);
1228 test RAW_OPEN_CREATE
1230 static bool test_create(struct smbcli_state *cli, struct torture_context *tctx)
1233 const char *fname = BASEDIR "\\torture_create.txt";
1237 time_t basetime = (time(NULL) + 3600*24*3) & ~1;
1238 union smb_fileinfo finfo;
1240 printf("Checking RAW_OPEN_CREATE\n");
1242 io.create.level = RAW_OPEN_CREATE;
1243 io.create.in.attrib = 0;
1244 io.create.in.write_time = 0;
1245 io.create.in.fname = fname;
1246 status = smb_raw_open(cli->tree, tctx, &io);
1247 CHECK_STATUS(status, NT_STATUS_OK);
1248 fnum = io.create.out.file.fnum;
1250 status = smb_raw_open(cli->tree, tctx, &io);
1251 CHECK_STATUS(status, NT_STATUS_OK);
1253 smbcli_close(cli->tree, io.create.out.file.fnum);
1254 smbcli_close(cli->tree, fnum);
1255 smbcli_unlink(cli->tree, fname);
1257 /* make sure write_time works */
1258 io.create.in.write_time = basetime;
1259 status = smb_raw_open(cli->tree, tctx, &io);
1260 CHECK_STATUS(status, NT_STATUS_OK);
1261 fnum = io.create.out.file.fnum;
1262 CHECK_TIME(basetime, write_time);
1264 smbcli_close(cli->tree, fnum);
1265 smbcli_unlink(cli->tree, fname);
1267 /* make sure file_attrs works */
1268 io.create.in.attrib = FILE_ATTRIBUTE_HIDDEN;
1269 status = smb_raw_open(cli->tree, tctx, &io);
1270 CHECK_STATUS(status, NT_STATUS_OK);
1271 fnum = io.create.out.file.fnum;
1272 CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE,
1273 attrib & ~FILE_ATTRIBUTE_NONINDEXED);
1276 smbcli_close(cli->tree, fnum);
1277 smbcli_unlink(cli->tree, fname);
1286 static bool test_ctemp(struct smbcli_state *cli, TALLOC_CTX *tctx)
1292 time_t basetime = (time(NULL) + 3600*24*3) & ~1;
1293 union smb_fileinfo finfo;
1294 const char *name, *fname = NULL;
1296 printf("Checking RAW_OPEN_CTEMP\n");
1298 io.ctemp.level = RAW_OPEN_CTEMP;
1299 io.ctemp.in.attrib = FILE_ATTRIBUTE_HIDDEN;
1300 io.ctemp.in.write_time = basetime;
1301 io.ctemp.in.directory = BASEDIR;
1302 status = smb_raw_open(cli->tree, tctx, &io);
1303 CHECK_STATUS(status, NT_STATUS_OK);
1304 fnum = io.ctemp.out.file.fnum;
1306 name = io.ctemp.out.name;
1308 finfo.generic.level = RAW_FILEINFO_NAME_INFO;
1309 finfo.generic.in.file.fnum = fnum;
1310 status = smb_raw_fileinfo(cli->tree, tctx, &finfo);
1311 CHECK_STATUS(status, NT_STATUS_OK);
1313 fname = finfo.name_info.out.fname.s;
1314 d_printf("ctemp name=%s real name=%s\n", name, fname);
1317 smbcli_close(cli->tree, fnum);
1319 smbcli_unlink(cli->tree, fname);
1327 test chained RAW_OPEN_OPENX_READX
1329 static bool test_chained(struct smbcli_state *cli, TALLOC_CTX *tctx)
1332 const char *fname = BASEDIR "\\torture_chained.txt";
1336 const char *buf = "test";
1339 printf("Checking RAW_OPEN_OPENX chained with READX\n");
1340 smbcli_unlink(cli->tree, fname);
1342 fnum = create_complex_file(cli, tctx, fname);
1344 smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
1346 smbcli_close(cli->tree, fnum);
1348 io.openxreadx.level = RAW_OPEN_OPENX_READX;
1349 io.openxreadx.in.fname = fname;
1350 io.openxreadx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO;
1351 io.openxreadx.in.open_mode = OPENX_MODE_ACCESS_RDWR;
1352 io.openxreadx.in.open_func = OPENX_OPEN_FUNC_OPEN;
1353 io.openxreadx.in.search_attrs = 0;
1354 io.openxreadx.in.file_attrs = 0;
1355 io.openxreadx.in.write_time = 0;
1356 io.openxreadx.in.size = 1024*1024;
1357 io.openxreadx.in.timeout = 0;
1359 io.openxreadx.in.offset = 0;
1360 io.openxreadx.in.mincnt = sizeof(buf);
1361 io.openxreadx.in.maxcnt = sizeof(buf);
1362 io.openxreadx.in.remaining = 0;
1363 io.openxreadx.out.data = (uint8_t *)buf2;
1365 status = smb_raw_open(cli->tree, tctx, &io);
1366 CHECK_STATUS(status, NT_STATUS_OK);
1367 fnum = io.openxreadx.out.file.fnum;
1369 if (memcmp(buf, buf2, sizeof(buf)) != 0) {
1370 d_printf("wrong data in reply buffer\n");
1375 smbcli_close(cli->tree, fnum);
1376 smbcli_unlink(cli->tree, fname);
1382 test RAW_OPEN_OPENX without a leading slash on the path.
1383 NetApp filers are known to fail on this.
1386 static bool test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *tctx)
1389 const char *fname = BASEDIR "\\torture_no_leading_slash.txt";
1393 const char *buf = "test";
1395 printf("Checking RAW_OPEN_OPENX without leading slash on path\n");
1396 smbcli_unlink(cli->tree, fname);
1398 /* Create the file */
1399 fnum = create_complex_file(cli, tctx, fname);
1400 smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
1401 smbcli_close(cli->tree, fnum);
1403 /* Prepare to open the file using path without leading slash */
1404 io.openx.level = RAW_OPEN_OPENX;
1405 io.openx.in.fname = fname + 1;
1406 io.openx.in.flags = OPENX_FLAGS_ADDITIONAL_INFO;
1407 io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR;
1408 io.openx.in.open_func = OPENX_OPEN_FUNC_OPEN;
1409 io.openx.in.search_attrs = 0;
1410 io.openx.in.file_attrs = 0;
1411 io.openx.in.write_time = 0;
1412 io.openx.in.size = 1024*1024;
1413 io.openx.in.timeout = 0;
1415 status = smb_raw_open(cli->tree, tctx, &io);
1416 CHECK_STATUS(status, NT_STATUS_OK);
1417 fnum = io.openx.out.file.fnum;
1420 smbcli_close(cli->tree, fnum);
1421 smbcli_unlink(cli->tree, fname);
1426 /* A little torture test to expose a race condition in Samba 3.0.20 ... :-) */
1428 static bool test_raw_open_multi(struct torture_context *tctx)
1430 struct smbcli_state *cli;
1431 TALLOC_CTX *mem_ctx = talloc_init("torture_test_oplock_multi");
1432 const char *fname = "\\test_oplock.dat";
1436 struct smbcli_state **clients;
1437 struct smbcli_request **requests;
1438 union smb_open *ios;
1439 const char *host = torture_setting_string(tctx, "host", NULL);
1440 const char *share = torture_setting_string(tctx, "share", NULL);
1441 int i, num_files = 3;
1443 int num_collision = 0;
1445 clients = talloc_array(mem_ctx, struct smbcli_state *, num_files);
1446 requests = talloc_array(mem_ctx, struct smbcli_request *, num_files);
1447 ios = talloc_array(mem_ctx, union smb_open, num_files);
1448 if ((tctx->ev == NULL) || (clients == NULL) || (requests == NULL) ||
1450 DEBUG(0, ("talloc failed\n"));
1454 if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, tctx->ev)) {
1458 cli->tree->session->transport->options.request_timeout = 60;
1460 for (i=0; i<num_files; i++) {
1461 if (!torture_open_connection_share(mem_ctx, &(clients[i]),
1462 tctx, host, share, tctx->ev)) {
1463 DEBUG(0, ("Could not open %d'th connection\n", i));
1466 clients[i]->tree->session->transport->options.request_timeout = 60;
1470 smbcli_unlink(cli->tree, fname);
1473 base ntcreatex parms
1475 io.generic.level = RAW_OPEN_NTCREATEX;
1476 io.ntcreatex.in.root_fid = 0;
1477 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
1478 io.ntcreatex.in.alloc_size = 0;
1479 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
1480 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
1481 NTCREATEX_SHARE_ACCESS_WRITE|
1482 NTCREATEX_SHARE_ACCESS_DELETE;
1483 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
1484 io.ntcreatex.in.create_options = 0;
1485 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
1486 io.ntcreatex.in.security_flags = 0;
1487 io.ntcreatex.in.fname = fname;
1488 io.ntcreatex.in.flags = 0;
1490 for (i=0; i<num_files; i++) {
1492 requests[i] = smb_raw_open_send(clients[i]->tree, &ios[i]);
1493 if (requests[i] == NULL) {
1494 DEBUG(0, ("could not send %d'th request\n", i));
1499 DEBUG(10, ("waiting for replies\n"));
1501 bool unreplied = false;
1502 for (i=0; i<num_files; i++) {
1503 if (requests[i] == NULL) {
1506 if (requests[i]->state < SMBCLI_REQUEST_DONE) {
1510 status = smb_raw_open_recv(requests[i], mem_ctx,
1513 DEBUG(0, ("File %d returned status %s\n", i,
1514 nt_errstr(status)));
1516 if (NT_STATUS_IS_OK(status)) {
1520 if (NT_STATUS_EQUAL(status,
1521 NT_STATUS_OBJECT_NAME_COLLISION)) {
1531 if (event_loop_once(tctx->ev) != 0) {
1532 DEBUG(0, ("event_loop_once failed\n"));
1537 if ((num_ok != 1) || (num_ok + num_collision != num_files)) {
1541 for (i=0; i<num_files; i++) {
1542 torture_close_connection(clients[i]);
1544 talloc_free(mem_ctx);
1549 test opening for delete on a read-only attribute file.
1551 static bool test_open_for_delete(struct smbcli_state *cli, struct torture_context *tctx)
1554 union smb_fileinfo finfo;
1555 const char *fname = BASEDIR "\\torture_open_for_delete.txt";
1560 printf("Checking RAW_NTCREATEX for delete on a readonly file.\n");
1562 /* reasonable default parameters */
1563 io.generic.level = RAW_OPEN_NTCREATEX;
1564 io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
1565 io.ntcreatex.in.root_fid = 0;
1566 io.ntcreatex.in.alloc_size = 0;
1567 io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
1568 io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_READONLY;
1569 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
1570 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
1571 io.ntcreatex.in.create_options = 0;
1572 io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
1573 io.ntcreatex.in.security_flags = 0;
1574 io.ntcreatex.in.fname = fname;
1576 /* Create the readonly file. */
1578 status = smb_raw_open(cli->tree, tctx, &io);
1579 CHECK_STATUS(status, NT_STATUS_OK);
1580 fnum = io.ntcreatex.out.file.fnum;
1582 CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
1583 io.ntcreatex.in.create_options = 0;
1584 CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_CREATED);
1585 CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
1586 smbcli_close(cli->tree, fnum);
1588 /* Now try and open for delete only - should succeed. */
1589 io.ntcreatex.in.access_mask = SEC_STD_DELETE;
1590 io.ntcreatex.in.file_attr = 0;
1591 io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE;
1592 io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
1593 status = smb_raw_open(cli->tree, tctx, &io);
1594 CHECK_STATUS(status, NT_STATUS_OK);
1596 smbcli_unlink(cli->tree, fname);
1599 smbcli_close(cli->tree, fnum);
1600 smbcli_unlink(cli->tree, fname);
1606 /* basic testing of all RAW_OPEN_* calls
1608 bool torture_raw_open(struct torture_context *torture, struct smbcli_state *cli)
1612 if (!torture_setup_dir(cli, BASEDIR)) {
1616 ret &= test_ntcreatex_brlocked(cli, torture);
1617 ret &= test_open(cli, torture);
1618 ret &= test_raw_open_multi(torture);
1619 ret &= test_openx(cli, torture);
1620 ret &= test_ntcreatex(cli, torture);
1621 ret &= test_nttrans_create(cli, torture);
1622 ret &= test_t2open(cli, torture);
1623 ret &= test_mknew(cli, torture);
1624 ret &= test_create(cli, torture);
1625 ret &= test_ctemp(cli, torture);
1626 ret &= test_chained(cli, torture);
1627 ret &= test_no_leading_slash(cli, torture);
1628 ret &= test_open_for_delete(cli, torture);
1630 smb_raw_exit(cli->session);
1631 smbcli_deltree(cli->tree, BASEDIR);