s4:torture/smb2: create temporary smbXcli_tcon/session structures instead of changing...
[Samba/gebeck_regimport.git] / source4 / torture / smb2 / compound.c
blobda4de3a73993bc07176b26da2c56f198a26c840a
1 /*
2 Unix SMB/CIFS implementation.
4 test suite for SMB2 compounded requests
6 Copyright (C) Stefan Metzmacher 2009
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "libcli/smb2/smb2.h"
24 #include "libcli/smb2/smb2_calls.h"
25 #include "torture/torture.h"
26 #include "torture/smb2/proto.h"
27 #include "../libcli/smb/smbXcli_base.h"
29 #define CHECK_STATUS(status, correct) do { \
30 if (!NT_STATUS_EQUAL(status, correct)) { \
31 torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
32 nt_errstr(status), nt_errstr(correct)); \
33 ret = false; \
34 goto done; \
35 }} while (0)
37 #define TARGET_IS_W2K8(_tctx) (torture_setting_bool(_tctx, "w2k8", false))
38 #define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false))
40 static bool test_compound_related1(struct torture_context *tctx,
41 struct smb2_tree *tree)
43 struct smb2_handle hd;
44 struct smb2_create cr;
45 NTSTATUS status;
46 const char *fname = "compound_related1.dat";
47 struct smb2_close cl;
48 bool ret = true;
49 struct smb2_request *req[2];
50 struct smbXcli_tcon *saved_tcon = tree->smbXcli;
51 struct smbXcli_session *saved_session = tree->session->smbXcli;
53 smb2_transport_credits_ask_num(tree->session->transport, 2);
55 smb2_util_unlink(tree, fname);
57 smb2_transport_credits_ask_num(tree->session->transport, 1);
59 ZERO_STRUCT(cr);
60 cr.in.security_flags = 0x00;
61 cr.in.oplock_level = 0;
62 cr.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
63 cr.in.create_flags = 0x00000000;
64 cr.in.reserved = 0x00000000;
65 cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
66 cr.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
67 cr.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
68 NTCREATEX_SHARE_ACCESS_WRITE |
69 NTCREATEX_SHARE_ACCESS_DELETE;
70 cr.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
71 cr.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
72 NTCREATEX_OPTIONS_ASYNC_ALERT |
73 NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
74 0x00200000;
75 cr.in.fname = fname;
77 smb2_transport_compound_start(tree->session->transport, 2);
79 req[0] = smb2_create_send(tree, &cr);
81 smb2_transport_compound_set_related(tree->session->transport, true);
83 hd.data[0] = UINT64_MAX;
84 hd.data[1] = UINT64_MAX;
86 ZERO_STRUCT(cl);
87 cl.in.file.handle = hd;
89 tree->smbXcli = smbXcli_tcon_create(tree);
90 smb2cli_tcon_set_values(tree->smbXcli,
91 0xFFFFFFFF, /* tcon_id */
92 0, /* type */
93 0, /* flags */
94 0, /* capabilities */
95 0 /* maximal_access */);
97 tree->session->smbXcli = smbXcli_session_create(tree->session,
98 tree->session->transport->conn);
99 smb2cli_session_set_id_and_flags(tree->session->smbXcli, UINT64_MAX, 0);
101 req[1] = smb2_close_send(tree, &cl);
103 status = smb2_create_recv(req[0], tree, &cr);
104 CHECK_STATUS(status, NT_STATUS_OK);
105 status = smb2_close_recv(req[1], &cl);
106 CHECK_STATUS(status, NT_STATUS_OK);
108 TALLOC_FREE(tree->smbXcli);
109 tree->smbXcli = saved_tcon;
110 TALLOC_FREE(tree->session->smbXcli);
111 tree->session->smbXcli = saved_session;
113 smb2_util_unlink(tree, fname);
114 done:
115 return ret;
118 static bool test_compound_related2(struct torture_context *tctx,
119 struct smb2_tree *tree)
121 struct smb2_handle hd;
122 struct smb2_create cr;
123 NTSTATUS status;
124 const char *fname = "compound_related2.dat";
125 struct smb2_close cl;
126 bool ret = true;
127 struct smb2_request *req[5];
128 struct smbXcli_tcon *saved_tcon = tree->smbXcli;
129 struct smbXcli_session *saved_session = tree->session->smbXcli;
131 smb2_transport_credits_ask_num(tree->session->transport, 5);
133 smb2_util_unlink(tree, fname);
135 smb2_transport_credits_ask_num(tree->session->transport, 1);
137 ZERO_STRUCT(cr);
138 cr.in.security_flags = 0x00;
139 cr.in.oplock_level = 0;
140 cr.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
141 cr.in.create_flags = 0x00000000;
142 cr.in.reserved = 0x00000000;
143 cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
144 cr.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
145 cr.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
146 NTCREATEX_SHARE_ACCESS_WRITE |
147 NTCREATEX_SHARE_ACCESS_DELETE;
148 cr.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
149 cr.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
150 NTCREATEX_OPTIONS_ASYNC_ALERT |
151 NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
152 0x00200000;
153 cr.in.fname = fname;
155 smb2_transport_compound_start(tree->session->transport, 5);
157 req[0] = smb2_create_send(tree, &cr);
159 hd.data[0] = UINT64_MAX;
160 hd.data[1] = UINT64_MAX;
162 smb2_transport_compound_set_related(tree->session->transport, true);
164 ZERO_STRUCT(cl);
165 cl.in.file.handle = hd;
167 tree->smbXcli = smbXcli_tcon_create(tree);
168 smb2cli_tcon_set_values(tree->smbXcli,
169 0xFFFFFFFF, /* tcon_id */
170 0, /* type */
171 0, /* flags */
172 0, /* capabilities */
173 0 /* maximal_access */);
175 tree->session->smbXcli = smbXcli_session_create(tree->session,
176 tree->session->transport->conn);
177 smb2cli_session_set_id_and_flags(tree->session->smbXcli, UINT64_MAX, 0);
179 req[1] = smb2_close_send(tree, &cl);
180 req[2] = smb2_close_send(tree, &cl);
181 req[3] = smb2_close_send(tree, &cl);
182 req[4] = smb2_close_send(tree, &cl);
184 status = smb2_create_recv(req[0], tree, &cr);
185 CHECK_STATUS(status, NT_STATUS_OK);
186 status = smb2_close_recv(req[1], &cl);
187 CHECK_STATUS(status, NT_STATUS_OK);
188 status = smb2_close_recv(req[2], &cl);
189 CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
190 status = smb2_close_recv(req[3], &cl);
191 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
192 status = smb2_close_recv(req[4], &cl);
193 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
195 TALLOC_FREE(tree->smbXcli);
196 tree->smbXcli = saved_tcon;
197 TALLOC_FREE(tree->session->smbXcli);
198 tree->session->smbXcli = saved_session;
200 smb2_util_unlink(tree, fname);
201 done:
202 return ret;
205 static bool test_compound_unrelated1(struct torture_context *tctx,
206 struct smb2_tree *tree)
208 struct smb2_handle hd;
209 struct smb2_create cr;
210 NTSTATUS status;
211 const char *fname = "compound_unrelated1.dat";
212 struct smb2_close cl;
213 bool ret = true;
214 struct smb2_request *req[5];
216 smb2_transport_credits_ask_num(tree->session->transport, 5);
218 smb2_util_unlink(tree, fname);
220 smb2_transport_credits_ask_num(tree->session->transport, 1);
222 ZERO_STRUCT(cr);
223 cr.in.security_flags = 0x00;
224 cr.in.oplock_level = 0;
225 cr.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
226 cr.in.create_flags = 0x00000000;
227 cr.in.reserved = 0x00000000;
228 cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
229 cr.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
230 cr.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
231 NTCREATEX_SHARE_ACCESS_WRITE |
232 NTCREATEX_SHARE_ACCESS_DELETE;
233 cr.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
234 cr.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
235 NTCREATEX_OPTIONS_ASYNC_ALERT |
236 NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
237 0x00200000;
238 cr.in.fname = fname;
240 smb2_transport_compound_start(tree->session->transport, 5);
242 req[0] = smb2_create_send(tree, &cr);
244 hd.data[0] = UINT64_MAX;
245 hd.data[1] = UINT64_MAX;
247 ZERO_STRUCT(cl);
248 cl.in.file.handle = hd;
249 req[1] = smb2_close_send(tree, &cl);
250 req[2] = smb2_close_send(tree, &cl);
251 req[3] = smb2_close_send(tree, &cl);
252 req[4] = smb2_close_send(tree, &cl);
254 status = smb2_create_recv(req[0], tree, &cr);
255 CHECK_STATUS(status, NT_STATUS_OK);
256 status = smb2_close_recv(req[1], &cl);
257 CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
258 status = smb2_close_recv(req[2], &cl);
259 CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
260 status = smb2_close_recv(req[3], &cl);
261 CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
262 status = smb2_close_recv(req[4], &cl);
263 CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
265 smb2_util_unlink(tree, fname);
266 done:
267 return ret;
270 static bool test_compound_invalid1(struct torture_context *tctx,
271 struct smb2_tree *tree)
273 struct smb2_handle hd;
274 struct smb2_create cr;
275 NTSTATUS status;
276 const char *fname = "compound_invalid1.dat";
277 struct smb2_close cl;
278 bool ret = true;
279 struct smb2_request *req[2];
281 smb2_transport_credits_ask_num(tree->session->transport, 2);
283 smb2_util_unlink(tree, fname);
285 smb2_transport_credits_ask_num(tree->session->transport, 1);
287 ZERO_STRUCT(cr);
288 cr.in.security_flags = 0x00;
289 cr.in.oplock_level = 0;
290 cr.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
291 cr.in.create_flags = 0x00000000;
292 cr.in.reserved = 0x00000000;
293 cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
294 cr.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
295 cr.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
296 NTCREATEX_SHARE_ACCESS_WRITE |
297 NTCREATEX_SHARE_ACCESS_DELETE;
298 cr.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
299 cr.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
300 NTCREATEX_OPTIONS_ASYNC_ALERT |
301 NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
302 0x00200000;
303 cr.in.fname = fname;
305 smb2_transport_compound_start(tree->session->transport, 2);
307 /* passing the first request with the related flag is invalid */
308 smb2_transport_compound_set_related(tree->session->transport, true);
310 req[0] = smb2_create_send(tree, &cr);
312 hd.data[0] = UINT64_MAX;
313 hd.data[1] = UINT64_MAX;
315 ZERO_STRUCT(cl);
316 cl.in.file.handle = hd;
317 req[1] = smb2_close_send(tree, &cl);
319 status = smb2_create_recv(req[0], tree, &cr);
320 /* TODO: check why this fails with --signing=required */
321 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
322 status = smb2_close_recv(req[1], &cl);
323 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
325 smb2_util_unlink(tree, fname);
326 done:
327 return ret;
330 static bool test_compound_invalid2(struct torture_context *tctx,
331 struct smb2_tree *tree)
333 struct smb2_handle hd;
334 struct smb2_create cr;
335 NTSTATUS status;
336 const char *fname = "compound_invalid2.dat";
337 struct smb2_close cl;
338 bool ret = true;
339 struct smb2_request *req[5];
340 struct smbXcli_tcon *saved_tcon = tree->smbXcli;
341 struct smbXcli_session *saved_session = tree->session->smbXcli;
343 smb2_transport_credits_ask_num(tree->session->transport, 5);
345 smb2_util_unlink(tree, fname);
347 smb2_transport_credits_ask_num(tree->session->transport, 1);
349 ZERO_STRUCT(cr);
350 cr.in.security_flags = 0x00;
351 cr.in.oplock_level = 0;
352 cr.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
353 cr.in.create_flags = 0x00000000;
354 cr.in.reserved = 0x00000000;
355 cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
356 cr.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
357 cr.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
358 NTCREATEX_SHARE_ACCESS_WRITE |
359 NTCREATEX_SHARE_ACCESS_DELETE;
360 cr.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
361 cr.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
362 NTCREATEX_OPTIONS_ASYNC_ALERT |
363 NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
364 0x00200000;
365 cr.in.fname = fname;
367 smb2_transport_compound_start(tree->session->transport, 5);
369 req[0] = smb2_create_send(tree, &cr);
371 hd.data[0] = UINT64_MAX;
372 hd.data[1] = UINT64_MAX;
374 smb2_transport_compound_set_related(tree->session->transport, true);
376 ZERO_STRUCT(cl);
377 cl.in.file.handle = hd;
379 tree->smbXcli = smbXcli_tcon_create(tree);
380 smb2cli_tcon_set_values(tree->smbXcli,
381 0xFFFFFFFF, /* tcon_id */
382 0, /* type */
383 0, /* flags */
384 0, /* capabilities */
385 0 /* maximal_access */);
387 tree->session->smbXcli = smbXcli_session_create(tree->session,
388 tree->session->transport->conn);
389 smb2cli_session_set_id_and_flags(tree->session->smbXcli, UINT64_MAX, 0);
391 req[1] = smb2_close_send(tree, &cl);
392 /* strange that this is not generating invalid parameter */
393 smb2_transport_compound_set_related(tree->session->transport, false);
394 req[2] = smb2_close_send(tree, &cl);
395 req[3] = smb2_close_send(tree, &cl);
396 smb2_transport_compound_set_related(tree->session->transport, true);
397 req[4] = smb2_close_send(tree, &cl);
399 status = smb2_create_recv(req[0], tree, &cr);
400 CHECK_STATUS(status, NT_STATUS_OK);
401 status = smb2_close_recv(req[1], &cl);
402 CHECK_STATUS(status, NT_STATUS_OK);
403 status = smb2_close_recv(req[2], &cl);
404 CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED);
405 status = smb2_close_recv(req[3], &cl);
406 CHECK_STATUS(status, NT_STATUS_USER_SESSION_DELETED);
407 status = smb2_close_recv(req[4], &cl);
408 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
410 TALLOC_FREE(tree->smbXcli);
411 tree->smbXcli = saved_tcon;
412 TALLOC_FREE(tree->session->smbXcli);
413 tree->session->smbXcli = saved_session;
415 smb2_util_unlink(tree, fname);
416 done:
417 return ret;
420 static bool test_compound_invalid3(struct torture_context *tctx,
421 struct smb2_tree *tree)
423 struct smb2_handle hd;
424 struct smb2_create cr;
425 NTSTATUS status;
426 const char *fname = "compound_invalid3.dat";
427 struct smb2_close cl;
428 bool ret = true;
429 struct smb2_request *req[5];
431 smb2_transport_credits_ask_num(tree->session->transport, 5);
433 smb2_util_unlink(tree, fname);
435 smb2_transport_credits_ask_num(tree->session->transport, 1);
437 ZERO_STRUCT(cr);
438 cr.in.security_flags = 0x00;
439 cr.in.oplock_level = 0;
440 cr.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
441 cr.in.create_flags = 0x00000000;
442 cr.in.reserved = 0x00000000;
443 cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
444 cr.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
445 cr.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
446 NTCREATEX_SHARE_ACCESS_WRITE |
447 NTCREATEX_SHARE_ACCESS_DELETE;
448 cr.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
449 cr.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
450 NTCREATEX_OPTIONS_ASYNC_ALERT |
451 NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
452 0x00200000;
453 cr.in.fname = fname;
455 smb2_transport_compound_start(tree->session->transport, 5);
457 req[0] = smb2_create_send(tree, &cr);
459 hd.data[0] = UINT64_MAX;
460 hd.data[1] = UINT64_MAX;
462 ZERO_STRUCT(cl);
463 cl.in.file.handle = hd;
464 req[1] = smb2_close_send(tree, &cl);
465 req[2] = smb2_close_send(tree, &cl);
466 /* flipping the related flag is invalid */
467 smb2_transport_compound_set_related(tree->session->transport, true);
468 req[3] = smb2_close_send(tree, &cl);
469 req[4] = smb2_close_send(tree, &cl);
471 status = smb2_create_recv(req[0], tree, &cr);
472 CHECK_STATUS(status, NT_STATUS_OK);
473 status = smb2_close_recv(req[1], &cl);
474 CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
475 status = smb2_close_recv(req[2], &cl);
476 CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
477 status = smb2_close_recv(req[3], &cl);
478 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
479 status = smb2_close_recv(req[4], &cl);
480 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
482 smb2_util_unlink(tree, fname);
483 done:
484 return ret;
487 /* Send a compound request where we expect the last request (Create, Notify)
488 * to go asynchronous. This works against a Win7 server and the reply is
489 * sent in two different packets. */
490 static bool test_compound_interim1(struct torture_context *tctx,
491 struct smb2_tree *tree)
493 struct smb2_handle hd;
494 struct smb2_create cr;
495 NTSTATUS status = NT_STATUS_OK;
496 const char *dname = "compound_interim_dir";
497 struct smb2_notify nt;
498 bool ret = true;
499 struct smb2_request *req[2];
501 /* Win7 compound request implementation deviates substantially from the
502 * SMB2 spec as noted in MS-SMB2 <159>, <162>. This, test currently
503 * verifies the Windows behavior, not the general spec behavior. */
504 if (!TARGET_IS_WIN7(tctx) && !TARGET_IS_W2K8(tctx)) {
505 torture_skip(tctx, "Interim test is specific to Windows server "
506 "behavior.\n");
509 smb2_transport_credits_ask_num(tree->session->transport, 5);
511 smb2_deltree(tree, dname);
513 smb2_transport_credits_ask_num(tree->session->transport, 1);
515 ZERO_STRUCT(cr);
516 cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
517 cr.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
518 cr.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
519 cr.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
520 NTCREATEX_SHARE_ACCESS_WRITE |
521 NTCREATEX_SHARE_ACCESS_DELETE;
522 cr.in.create_disposition = NTCREATEX_DISP_CREATE;
523 cr.in.fname = dname;
525 smb2_transport_compound_start(tree->session->transport, 2);
527 req[0] = smb2_create_send(tree, &cr);
529 smb2_transport_compound_set_related(tree->session->transport, true);
531 hd.data[0] = UINT64_MAX;
532 hd.data[1] = UINT64_MAX;
534 ZERO_STRUCT(nt);
535 nt.in.recursive = true;
536 nt.in.buffer_size = 0x1000;
537 nt.in.file.handle = hd;
538 nt.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
539 nt.in.unknown = 0x00000000;
541 req[1] = smb2_notify_send(tree, &nt);
543 status = smb2_create_recv(req[0], tree, &cr);
544 CHECK_STATUS(status, NT_STATUS_OK);
546 smb2_cancel(req[1]);
547 status = smb2_notify_recv(req[1], tree, &nt);
548 CHECK_STATUS(status, NT_STATUS_CANCELLED);
550 smb2_util_close(tree, cr.out.file.handle);
552 smb2_deltree(tree, dname);
553 done:
554 return ret;
557 /* Send a compound request where we expect the middle request (Create, Notify,
558 * GetInfo) to go asynchronous. Against Win7 the sync request succeed while
559 * the async fails. All are returned in the same compound response. */
560 static bool test_compound_interim2(struct torture_context *tctx,
561 struct smb2_tree *tree)
563 struct smb2_handle hd;
564 struct smb2_create cr;
565 NTSTATUS status = NT_STATUS_OK;
566 const char *dname = "compound_interim_dir";
567 struct smb2_getinfo gf;
568 struct smb2_notify nt;
569 bool ret = true;
570 struct smb2_request *req[3];
572 /* Win7 compound request implementation deviates substantially from the
573 * SMB2 spec as noted in MS-SMB2 <159>, <162>. This, test currently
574 * verifies the Windows behavior, not the general spec behavior. */
575 if (!TARGET_IS_WIN7(tctx) && !TARGET_IS_W2K8(tctx)) {
576 torture_skip(tctx, "Interim test is specific to Windows server "
577 "behavior.\n");
580 smb2_transport_credits_ask_num(tree->session->transport, 5);
582 smb2_deltree(tree, dname);
584 smb2_transport_credits_ask_num(tree->session->transport, 1);
586 ZERO_STRUCT(cr);
587 cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
588 cr.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
589 cr.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
590 cr.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
591 NTCREATEX_SHARE_ACCESS_WRITE |
592 NTCREATEX_SHARE_ACCESS_DELETE;
593 cr.in.create_disposition = NTCREATEX_DISP_CREATE;
594 cr.in.fname = dname;
596 smb2_transport_compound_start(tree->session->transport, 3);
598 req[0] = smb2_create_send(tree, &cr);
600 smb2_transport_compound_set_related(tree->session->transport, true);
602 hd.data[0] = UINT64_MAX;
603 hd.data[1] = UINT64_MAX;
605 ZERO_STRUCT(nt);
606 nt.in.recursive = true;
607 nt.in.buffer_size = 0x1000;
608 nt.in.file.handle = hd;
609 nt.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
610 nt.in.unknown = 0x00000000;
612 req[1] = smb2_notify_send(tree, &nt);
614 ZERO_STRUCT(gf);
615 gf.in.file.handle = hd;
616 gf.in.info_type = SMB2_GETINFO_FILE;
617 gf.in.info_class = 0x04; /* FILE_BASIC_INFORMATION */
618 gf.in.output_buffer_length = 0x1000;
619 gf.in.input_buffer_length = 0;
621 req[2] = smb2_getinfo_send(tree, &gf);
623 status = smb2_create_recv(req[0], tree, &cr);
624 CHECK_STATUS(status, NT_STATUS_OK);
626 status = smb2_notify_recv(req[1], tree, &nt);
627 CHECK_STATUS(status, NT_STATUS_INTERNAL_ERROR);
629 status = smb2_getinfo_recv(req[2], tree, &gf);
630 CHECK_STATUS(status, NT_STATUS_OK);
632 smb2_util_close(tree, cr.out.file.handle);
634 smb2_deltree(tree, dname);
635 done:
636 return ret;
639 struct torture_suite *torture_smb2_compound_init(void)
641 struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "compound");
643 torture_suite_add_1smb2_test(suite, "related1", test_compound_related1);
644 torture_suite_add_1smb2_test(suite, "related2", test_compound_related2);
645 torture_suite_add_1smb2_test(suite, "unrelated1", test_compound_unrelated1);
646 torture_suite_add_1smb2_test(suite, "invalid1", test_compound_invalid1);
647 torture_suite_add_1smb2_test(suite, "invalid2", test_compound_invalid2);
648 torture_suite_add_1smb2_test(suite, "invalid3", test_compound_invalid3);
649 torture_suite_add_1smb2_test(suite, "interim1", test_compound_interim1);
650 torture_suite_add_1smb2_test(suite, "interim2", test_compound_interim2);
652 suite->description = talloc_strdup(suite, "SMB2-COMPOUND tests");
654 return suite;