2 Unix SMB/CIFS implementation.
4 test suite for SMB2 session setups
6 Copyright (C) Michael Adam 2012
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/>.
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"
28 #include "lib/cmdline/popt_common.h"
29 #include "auth/credentials/credentials.h"
30 #include "libcli/security/security.h"
33 #define CHECK_VAL(v, correct) do { \
34 if ((v) != (correct)) { \
35 torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
36 __location__, #v, (int)v, (int)correct); \
40 #define CHECK_STATUS(status, correct) do { \
41 if (!NT_STATUS_EQUAL(status, correct)) { \
42 torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
43 nt_errstr(status), nt_errstr(correct)); \
48 #define CHECK_CREATED(__io, __created, __attribute) \
50 CHECK_VAL((__io)->out.create_action, NTCREATEX_ACTION_ ## __created); \
51 CHECK_VAL((__io)->out.alloc_size, 0); \
52 CHECK_VAL((__io)->out.size, 0); \
53 CHECK_VAL((__io)->out.file_attr, (__attribute)); \
54 CHECK_VAL((__io)->out.reserved2, 0); \
59 * basic test for doing a session reconnect
61 bool test_session_reconnect1(struct torture_context
*tctx
, struct smb2_tree
*tree
)
64 TALLOC_CTX
*mem_ctx
= talloc_new(tctx
);
66 struct smb2_handle _h1
;
67 struct smb2_handle
*h1
= NULL
;
68 struct smb2_handle _h2
;
69 struct smb2_handle
*h2
= NULL
;
70 struct smb2_create io1
, io2
;
71 uint64_t previous_session_id
;
73 struct smb2_tree
*tree2
;
74 union smb_fileinfo qfinfo
;
76 /* Add some random component to the file name. */
77 snprintf(fname
, 256, "session_reconnect_%s.dat",
78 generate_random_str(tctx
, 8));
80 smb2_util_unlink(tree
, fname
);
82 smb2_oplock_create_share(&io1
, fname
,
83 smb2_util_share_access(""),
84 smb2_util_oplock_level("b"));
86 status
= smb2_create(tree
, mem_ctx
, &io1
);
87 CHECK_STATUS(status
, NT_STATUS_OK
);
88 _h1
= io1
.out
.file
.handle
;
90 CHECK_CREATED(&io1
, CREATED
, FILE_ATTRIBUTE_ARCHIVE
);
91 CHECK_VAL(io1
.out
.oplock_level
, smb2_util_oplock_level("b"));
93 /* disconnect, reconnect and then do durable reopen */
94 previous_session_id
= smb2cli_session_current_id(tree
->session
->smbXcli
);
96 if (!torture_smb2_connection_ext(tctx
, previous_session_id
, &tree2
)) {
97 torture_warning(tctx
, "session reconnect failed\n");
102 /* try to access the file via the old handle */
105 qfinfo
.generic
.level
= RAW_FILEINFO_POSITION_INFORMATION
;
106 qfinfo
.generic
.in
.file
.handle
= _h1
;
107 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
108 CHECK_STATUS(status
, NT_STATUS_USER_SESSION_DELETED
);
111 smb2_oplock_create_share(&io2
, fname
,
112 smb2_util_share_access(""),
113 smb2_util_oplock_level("b"));
115 status
= smb2_create(tree2
, mem_ctx
, &io2
);
116 CHECK_STATUS(status
, NT_STATUS_OK
);
117 CHECK_CREATED(&io2
, EXISTED
, FILE_ATTRIBUTE_ARCHIVE
);
118 CHECK_VAL(io2
.out
.oplock_level
, smb2_util_oplock_level("b"));
119 _h2
= io2
.out
.file
.handle
;
124 smb2_util_close(tree
, *h1
);
127 smb2_util_close(tree2
, *h2
);
130 smb2_util_unlink(tree2
, fname
);
135 talloc_free(mem_ctx
);
140 bool test_session_reauth1(struct torture_context
*tctx
, struct smb2_tree
*tree
)
143 TALLOC_CTX
*mem_ctx
= talloc_new(tctx
);
145 struct smb2_handle _h1
;
146 struct smb2_handle
*h1
= NULL
;
147 struct smb2_create io1
;
149 union smb_fileinfo qfinfo
;
151 /* Add some random component to the file name. */
152 snprintf(fname
, 256, "session_reauth1_%s.dat",
153 generate_random_str(tctx
, 8));
155 smb2_util_unlink(tree
, fname
);
157 smb2_oplock_create_share(&io1
, fname
,
158 smb2_util_share_access(""),
159 smb2_util_oplock_level("b"));
161 status
= smb2_create(tree
, mem_ctx
, &io1
);
162 CHECK_STATUS(status
, NT_STATUS_OK
);
163 _h1
= io1
.out
.file
.handle
;
165 CHECK_CREATED(&io1
, CREATED
, FILE_ATTRIBUTE_ARCHIVE
);
166 CHECK_VAL(io1
.out
.oplock_level
, smb2_util_oplock_level("b"));
168 status
= smb2_session_setup_spnego(tree
->session
,
170 0 /* previous_session_id */);
171 CHECK_STATUS(status
, NT_STATUS_OK
);
173 /* try to access the file via the old handle */
176 qfinfo
.generic
.level
= RAW_FILEINFO_POSITION_INFORMATION
;
177 qfinfo
.generic
.in
.file
.handle
= _h1
;
178 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
179 CHECK_STATUS(status
, NT_STATUS_OK
);
181 status
= smb2_session_setup_spnego(tree
->session
,
183 0 /* previous_session_id */);
184 CHECK_STATUS(status
, NT_STATUS_OK
);
186 /* try to access the file via the old handle */
189 qfinfo
.generic
.level
= RAW_FILEINFO_POSITION_INFORMATION
;
190 qfinfo
.generic
.in
.file
.handle
= _h1
;
191 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
192 CHECK_STATUS(status
, NT_STATUS_OK
);
196 smb2_util_close(tree
, *h1
);
199 smb2_util_unlink(tree
, fname
);
203 talloc_free(mem_ctx
);
208 bool test_session_reauth2(struct torture_context
*tctx
, struct smb2_tree
*tree
)
211 TALLOC_CTX
*mem_ctx
= talloc_new(tctx
);
213 struct smb2_handle _h1
;
214 struct smb2_handle
*h1
= NULL
;
215 struct smb2_create io1
;
217 union smb_fileinfo qfinfo
;
218 struct cli_credentials
*anon_creds
= NULL
;
220 /* Add some random component to the file name. */
221 snprintf(fname
, 256, "session_reauth2_%s.dat",
222 generate_random_str(tctx
, 8));
224 smb2_util_unlink(tree
, fname
);
226 smb2_oplock_create_share(&io1
, fname
,
227 smb2_util_share_access(""),
228 smb2_util_oplock_level("b"));
230 status
= smb2_create(tree
, mem_ctx
, &io1
);
231 CHECK_STATUS(status
, NT_STATUS_OK
);
232 _h1
= io1
.out
.file
.handle
;
234 CHECK_CREATED(&io1
, CREATED
, FILE_ATTRIBUTE_ARCHIVE
);
235 CHECK_VAL(io1
.out
.oplock_level
, smb2_util_oplock_level("b"));
237 /* re-authenticate as anonymous */
239 anon_creds
= cli_credentials_init_anon(mem_ctx
);
240 torture_assert(tctx
, (anon_creds
!= NULL
), "talloc error");
242 status
= smb2_session_setup_spnego(tree
->session
,
244 0 /* previous_session_id */);
245 CHECK_STATUS(status
, NT_STATUS_OK
);
247 /* try to access the file via the old handle */
250 qfinfo
.generic
.level
= RAW_FILEINFO_POSITION_INFORMATION
;
251 qfinfo
.generic
.in
.file
.handle
= _h1
;
252 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
253 CHECK_STATUS(status
, NT_STATUS_OK
);
255 /* re-authenticate as original user again */
257 status
= smb2_session_setup_spnego(tree
->session
,
259 0 /* previous_session_id */);
260 CHECK_STATUS(status
, NT_STATUS_OK
);
262 /* try to access the file via the old handle */
265 qfinfo
.generic
.level
= RAW_FILEINFO_POSITION_INFORMATION
;
266 qfinfo
.generic
.in
.file
.handle
= _h1
;
267 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
268 CHECK_STATUS(status
, NT_STATUS_OK
);
272 smb2_util_close(tree
, *h1
);
275 smb2_util_unlink(tree
, fname
);
279 talloc_free(mem_ctx
);
285 * test getting security descriptor after reauth
287 bool test_session_reauth3(struct torture_context
*tctx
, struct smb2_tree
*tree
)
290 TALLOC_CTX
*mem_ctx
= talloc_new(tctx
);
292 struct smb2_handle _h1
;
293 struct smb2_handle
*h1
= NULL
;
294 struct smb2_create io1
;
296 union smb_fileinfo qfinfo
;
297 struct cli_credentials
*anon_creds
= NULL
;
298 uint32_t secinfo_flags
= SECINFO_OWNER
301 | SECINFO_PROTECTED_DACL
302 | SECINFO_UNPROTECTED_DACL
;
304 /* Add some random component to the file name. */
305 snprintf(fname
, 256, "session_reauth3_%s.dat",
306 generate_random_str(tctx
, 8));
308 smb2_util_unlink(tree
, fname
);
310 smb2_oplock_create_share(&io1
, fname
,
311 smb2_util_share_access(""),
312 smb2_util_oplock_level("b"));
314 status
= smb2_create(tree
, mem_ctx
, &io1
);
315 CHECK_STATUS(status
, NT_STATUS_OK
);
316 _h1
= io1
.out
.file
.handle
;
318 CHECK_CREATED(&io1
, CREATED
, FILE_ATTRIBUTE_ARCHIVE
);
319 CHECK_VAL(io1
.out
.oplock_level
, smb2_util_oplock_level("b"));
321 /* get the security descriptor */
325 qfinfo
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
326 qfinfo
.query_secdesc
.in
.file
.handle
= _h1
;
327 qfinfo
.query_secdesc
.in
.secinfo_flags
= secinfo_flags
;
329 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
330 CHECK_STATUS(status
, NT_STATUS_OK
);
331 /* re-authenticate as anonymous */
333 anon_creds
= cli_credentials_init_anon(mem_ctx
);
334 torture_assert(tctx
, (anon_creds
!= NULL
), "talloc error");
336 status
= smb2_session_setup_spnego(tree
->session
,
338 0 /* previous_session_id */);
339 CHECK_STATUS(status
, NT_STATUS_OK
);
341 /* try to access the file via the old handle */
345 qfinfo
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
346 qfinfo
.query_secdesc
.in
.file
.handle
= _h1
;
347 qfinfo
.query_secdesc
.in
.secinfo_flags
= secinfo_flags
;
349 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
350 CHECK_STATUS(status
, NT_STATUS_OK
);
352 /* re-authenticate as original user again */
354 status
= smb2_session_setup_spnego(tree
->session
,
356 0 /* previous_session_id */);
357 CHECK_STATUS(status
, NT_STATUS_OK
);
359 /* try to access the file via the old handle */
363 qfinfo
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
364 qfinfo
.query_secdesc
.in
.file
.handle
= _h1
;
365 qfinfo
.query_secdesc
.in
.secinfo_flags
= secinfo_flags
;
367 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
368 CHECK_STATUS(status
, NT_STATUS_OK
);
372 smb2_util_close(tree
, *h1
);
375 smb2_util_unlink(tree
, fname
);
379 talloc_free(mem_ctx
);
385 * test setting security descriptor after reauth.
387 bool test_session_reauth4(struct torture_context
*tctx
, struct smb2_tree
*tree
)
390 TALLOC_CTX
*mem_ctx
= talloc_new(tctx
);
392 struct smb2_handle _h1
;
393 struct smb2_handle
*h1
= NULL
;
394 struct smb2_create io1
;
396 union smb_fileinfo qfinfo
;
397 union smb_setfileinfo sfinfo
;
398 struct cli_credentials
*anon_creds
= NULL
;
399 uint32_t secinfo_flags
= SECINFO_OWNER
402 | SECINFO_PROTECTED_DACL
403 | SECINFO_UNPROTECTED_DACL
;
404 struct security_descriptor
*sd1
;
405 struct security_ace ace
;
406 struct dom_sid
*extra_sid
;
408 /* Add some random component to the file name. */
409 snprintf(fname
, 256, "session_reauth4_%s.dat",
410 generate_random_str(tctx
, 8));
412 smb2_util_unlink(tree
, fname
);
414 smb2_oplock_create_share(&io1
, fname
,
415 smb2_util_share_access(""),
416 smb2_util_oplock_level("b"));
418 status
= smb2_create(tree
, mem_ctx
, &io1
);
419 CHECK_STATUS(status
, NT_STATUS_OK
);
420 _h1
= io1
.out
.file
.handle
;
422 CHECK_CREATED(&io1
, CREATED
, FILE_ATTRIBUTE_ARCHIVE
);
423 CHECK_VAL(io1
.out
.oplock_level
, smb2_util_oplock_level("b"));
425 /* get the security descriptor */
429 qfinfo
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
430 qfinfo
.query_secdesc
.in
.file
.handle
= _h1
;
431 qfinfo
.query_secdesc
.in
.secinfo_flags
= secinfo_flags
;
433 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
434 CHECK_STATUS(status
, NT_STATUS_OK
);
436 sd1
= qfinfo
.query_secdesc
.out
.sd
;
438 /* re-authenticate as anonymous */
440 anon_creds
= cli_credentials_init_anon(mem_ctx
);
441 torture_assert(tctx
, (anon_creds
!= NULL
), "talloc error");
443 status
= smb2_session_setup_spnego(tree
->session
,
445 0 /* previous_session_id */);
446 CHECK_STATUS(status
, NT_STATUS_OK
);
448 /* give full access on the file to anonymous */
450 extra_sid
= dom_sid_parse_talloc(tctx
, SID_NT_ANONYMOUS
);
453 ace
.type
= SEC_ACE_TYPE_ACCESS_ALLOWED
;
455 ace
.access_mask
= SEC_STD_ALL
| SEC_FILE_ALL
;
456 ace
.trustee
= *extra_sid
;
458 status
= security_descriptor_dacl_add(sd1
, &ace
);
459 CHECK_STATUS(status
, NT_STATUS_OK
);
462 sfinfo
.set_secdesc
.level
= RAW_SFILEINFO_SEC_DESC
;
463 sfinfo
.set_secdesc
.in
.file
.handle
= _h1
;
464 sfinfo
.set_secdesc
.in
.secinfo_flags
= SECINFO_DACL
;
465 sfinfo
.set_secdesc
.in
.sd
= sd1
;
467 status
= smb2_setinfo_file(tree
, &sfinfo
);
468 CHECK_STATUS(status
, NT_STATUS_OK
);
470 /* re-authenticate as original user again */
472 status
= smb2_session_setup_spnego(tree
->session
,
474 0 /* previous_session_id */);
475 CHECK_STATUS(status
, NT_STATUS_OK
);
477 /* re-get the security descriptor */
481 qfinfo
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
482 qfinfo
.query_secdesc
.in
.file
.handle
= _h1
;
483 qfinfo
.query_secdesc
.in
.secinfo_flags
= secinfo_flags
;
485 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
486 CHECK_STATUS(status
, NT_STATUS_OK
);
492 smb2_util_close(tree
, *h1
);
495 smb2_util_unlink(tree
, fname
);
499 talloc_free(mem_ctx
);
505 * test renaming after reauth.
506 * compare security descriptors before and after rename/reauth
508 bool test_session_reauth5(struct torture_context
*tctx
, struct smb2_tree
*tree
)
511 TALLOC_CTX
*mem_ctx
= talloc_new(tctx
);
514 struct smb2_handle _h1
;
515 struct smb2_handle
*h1
= NULL
;
516 struct smb2_create io1
;
518 union smb_fileinfo qfinfo
;
519 union smb_setfileinfo sfinfo
;
520 struct cli_credentials
*anon_creds
= NULL
;
521 uint32_t secinfo_flags
= SECINFO_OWNER
524 | SECINFO_PROTECTED_DACL
525 | SECINFO_UNPROTECTED_DACL
;
526 struct security_descriptor
*sd1
, *sd2
;
527 struct security_ace ace
;
528 struct dom_sid
*extra_sid
;
530 /* Add some random component to the file name. */
531 snprintf(fname
, 256, "session_reauth5_%s.dat",
532 generate_random_str(tctx
, 8));
534 smb2_util_unlink(tree
, fname
);
536 smb2_oplock_create_share(&io1
, fname
,
537 smb2_util_share_access(""),
538 smb2_util_oplock_level("b"));
540 status
= smb2_create(tree
, mem_ctx
, &io1
);
541 CHECK_STATUS(status
, NT_STATUS_OK
);
542 _h1
= io1
.out
.file
.handle
;
544 CHECK_CREATED(&io1
, CREATED
, FILE_ATTRIBUTE_ARCHIVE
);
545 CHECK_VAL(io1
.out
.oplock_level
, smb2_util_oplock_level("b"));
547 /* get the security descriptor */
551 qfinfo
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
552 qfinfo
.query_secdesc
.in
.file
.handle
= _h1
;
553 qfinfo
.query_secdesc
.in
.secinfo_flags
= secinfo_flags
;
555 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
556 CHECK_STATUS(status
, NT_STATUS_OK
);
558 sd1
= qfinfo
.query_secdesc
.out
.sd
;
560 /* re-authenticate as anonymous */
562 anon_creds
= cli_credentials_init_anon(mem_ctx
);
563 torture_assert(tctx
, (anon_creds
!= NULL
), "talloc error");
565 status
= smb2_session_setup_spnego(tree
->session
,
567 0 /* previous_session_id */);
568 CHECK_STATUS(status
, NT_STATUS_OK
);
570 /* try to rename the file: fails */
572 snprintf(fname2
, 256, "session_reauth5.2_%s.dat",
573 generate_random_str(tctx
, 8));
575 smb2_util_unlink(tree
, fname2
);
578 sfinfo
.rename_information
.level
= RAW_SFILEINFO_RENAME_INFORMATION
;
579 sfinfo
.rename_information
.in
.file
.handle
= _h1
;
580 sfinfo
.rename_information
.in
.overwrite
= true;
581 sfinfo
.rename_information
.in
.new_name
= fname2
;
583 status
= smb2_setinfo_file(tree
, &sfinfo
);
584 CHECK_STATUS(status
, NT_STATUS_ACCESS_DENIED
);
586 /* re-authenticate as original user again */
588 status
= smb2_session_setup_spnego(tree
->session
,
590 0 /* previous_session_id */);
591 CHECK_STATUS(status
, NT_STATUS_OK
);
593 /* give full access on the file to anonymous */
595 extra_sid
= dom_sid_parse_talloc(tctx
, SID_NT_ANONYMOUS
);
598 ace
.type
= SEC_ACE_TYPE_ACCESS_ALLOWED
;
600 ace
.access_mask
= SEC_STD_ALL
| SEC_FILE_ALL
;
601 ace
.trustee
= *extra_sid
;
603 status
= security_descriptor_dacl_add(sd1
, &ace
);
604 CHECK_STATUS(status
, NT_STATUS_OK
);
607 sfinfo
.set_secdesc
.level
= RAW_SFILEINFO_SEC_DESC
;
608 sfinfo
.set_secdesc
.in
.file
.handle
= _h1
;
609 sfinfo
.set_secdesc
.in
.secinfo_flags
= secinfo_flags
;
610 sfinfo
.set_secdesc
.in
.sd
= sd1
;
612 status
= smb2_setinfo_file(tree
, &sfinfo
);
613 CHECK_STATUS(status
, NT_STATUS_OK
);
615 /* re-get the security descriptor */
619 qfinfo
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
620 qfinfo
.query_secdesc
.in
.file
.handle
= _h1
;
621 qfinfo
.query_secdesc
.in
.secinfo_flags
= secinfo_flags
;
623 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
624 CHECK_STATUS(status
, NT_STATUS_OK
);
626 /* re-authenticate as anonymous - again */
628 anon_creds
= cli_credentials_init_anon(mem_ctx
);
629 torture_assert(tctx
, (anon_creds
!= NULL
), "talloc error");
631 status
= smb2_session_setup_spnego(tree
->session
,
633 0 /* previous_session_id */);
634 CHECK_STATUS(status
, NT_STATUS_OK
);
636 /* try to rename the file: fails */
638 snprintf(fname2
, 256, "session_reauth3.2_%s.dat",
639 generate_random_str(tctx
, 8));
641 smb2_util_unlink(tree
, fname2
);
644 sfinfo
.rename_information
.level
= RAW_SFILEINFO_RENAME_INFORMATION
;
645 sfinfo
.rename_information
.in
.file
.handle
= _h1
;
646 sfinfo
.rename_information
.in
.overwrite
= true;
647 sfinfo
.rename_information
.in
.new_name
= fname2
;
649 status
= smb2_setinfo_file(tree
, &sfinfo
);
650 CHECK_STATUS(status
, NT_STATUS_ACCESS_DENIED
);
652 /* re-authenticate as original user - again */
654 status
= smb2_session_setup_spnego(tree
->session
,
656 0 /* previous_session_id */);
657 CHECK_STATUS(status
, NT_STATUS_OK
);
659 /* rename the file - for verification that it works */
662 sfinfo
.rename_information
.level
= RAW_SFILEINFO_RENAME_INFORMATION
;
663 sfinfo
.rename_information
.in
.file
.handle
= _h1
;
664 sfinfo
.rename_information
.in
.overwrite
= true;
665 sfinfo
.rename_information
.in
.new_name
= fname2
;
667 status
= smb2_setinfo_file(tree
, &sfinfo
);
668 CHECK_STATUS(status
, NT_STATUS_OK
);
670 /* closs the file, check it is gone and reopen under the new name */
672 smb2_util_close(tree
, _h1
);
676 smb2_generic_create_share(&io1
,
677 NULL
/* lease */, false /* dir */,
680 smb2_util_share_access(""),
681 smb2_util_oplock_level("b"),
682 0 /* leasekey */, 0 /* leasestate */);
684 status
= smb2_create(tree
, mem_ctx
, &io1
);
685 CHECK_STATUS(status
, NT_STATUS_OBJECT_NAME_NOT_FOUND
);
689 smb2_generic_create_share(&io1
,
690 NULL
/* lease */, false /* dir */,
693 smb2_util_share_access(""),
694 smb2_util_oplock_level("b"),
695 0 /* leasekey */, 0 /* leasestate */);
697 status
= smb2_create(tree
, mem_ctx
, &io1
);
698 CHECK_STATUS(status
, NT_STATUS_OK
);
699 _h1
= io1
.out
.file
.handle
;
701 CHECK_CREATED(&io1
, EXISTED
, FILE_ATTRIBUTE_ARCHIVE
);
702 CHECK_VAL(io1
.out
.oplock_level
, smb2_util_oplock_level("b"));
704 /* try to access the file via the old handle */
708 qfinfo
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
709 qfinfo
.query_secdesc
.in
.file
.handle
= _h1
;
710 qfinfo
.query_secdesc
.in
.secinfo_flags
= secinfo_flags
;
712 status
= smb2_getinfo_file(tree
, mem_ctx
, &qfinfo
);
713 CHECK_STATUS(status
, NT_STATUS_OK
);
715 sd2
= qfinfo
.query_secdesc
.out
.sd
;
719 smb2_util_close(tree
, *h1
);
722 smb2_util_unlink(tree
, fname
);
726 talloc_free(mem_ctx
);
731 struct torture_suite
*torture_smb2_session_init(void)
733 struct torture_suite
*suite
=
734 torture_suite_create(talloc_autofree_context(), "session");
736 torture_suite_add_1smb2_test(suite
, "reconnect1", test_session_reconnect1
);
737 torture_suite_add_1smb2_test(suite
, "reauth1", test_session_reauth1
);
738 torture_suite_add_1smb2_test(suite
, "reauth2", test_session_reauth2
);
739 torture_suite_add_1smb2_test(suite
, "reauth3", test_session_reauth3
);
740 torture_suite_add_1smb2_test(suite
, "reauth4", test_session_reauth4
);
741 torture_suite_add_1smb2_test(suite
, "reauth5", test_session_reauth5
);
743 suite
->description
= talloc_strdup(suite
, "SMB2-SESSION tests");