2 Unix SMB/CIFS implementation.
4 helper functions for SMB2 test suite
6 Copyright (C) Andrew Tridgell 2005
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/security/security_descriptor.h"
24 #include "libcli/smb2/smb2.h"
25 #include "libcli/smb2/smb2_calls.h"
26 #include "../libcli/smb/smbXcli_base.h"
27 #include "lib/cmdline/popt_common.h"
28 #include "system/time.h"
29 #include "librpc/gen_ndr/ndr_security.h"
30 #include "param/param.h"
31 #include "libcli/resolve/resolve.h"
33 #include "torture/torture.h"
34 #include "torture/smb2/proto.h"
38 write to a file on SMB2
40 NTSTATUS
smb2_util_write(struct smb2_tree
*tree
,
41 struct smb2_handle handle
,
42 const void *buf
, off_t offset
, size_t size
)
47 w
.in
.file
.handle
= handle
;
49 w
.in
.data
= data_blob_const(buf
, size
);
51 return smb2_write(tree
, &w
);
55 create a complex file/dir using the SMB2 protocol
57 static NTSTATUS
smb2_create_complex(struct smb2_tree
*tree
, const char *fname
,
58 struct smb2_handle
*handle
, bool dir
)
60 TALLOC_CTX
*tmp_ctx
= talloc_new(tree
);
62 struct smb2_create io
;
63 union smb_setfileinfo setfile
;
64 union smb_fileinfo fileinfo
;
65 time_t t
= (time(NULL
) & ~1);
68 smb2_util_unlink(tree
, fname
);
70 io
.in
.desired_access
= SEC_FLAG_MAXIMUM_ALLOWED
;
71 io
.in
.file_attributes
= FILE_ATTRIBUTE_NORMAL
;
72 io
.in
.create_disposition
= NTCREATEX_DISP_OVERWRITE_IF
;
74 NTCREATEX_SHARE_ACCESS_DELETE
|
75 NTCREATEX_SHARE_ACCESS_READ
|
76 NTCREATEX_SHARE_ACCESS_WRITE
;
77 io
.in
.create_options
= 0;
80 io
.in
.create_options
= NTCREATEX_OPTIONS_DIRECTORY
;
81 io
.in
.share_access
&= ~NTCREATEX_SHARE_ACCESS_DELETE
;
82 io
.in
.file_attributes
= FILE_ATTRIBUTE_DIRECTORY
;
83 io
.in
.create_disposition
= NTCREATEX_DISP_CREATE
;
86 /* it seems vista is now fussier about alignment? */
87 if (strchr(fname
, ':') == NULL
) {
89 io
.in
.eas
.num_eas
= 2;
90 io
.in
.eas
.eas
= talloc_array(tmp_ctx
, struct ea_struct
, 2);
91 io
.in
.eas
.eas
[0].flags
= 0;
92 io
.in
.eas
.eas
[0].name
.s
= "EAONE";
93 io
.in
.eas
.eas
[0].value
= data_blob_talloc(tmp_ctx
, "VALUE1", 6);
94 io
.in
.eas
.eas
[1].flags
= 0;
95 io
.in
.eas
.eas
[1].name
.s
= "SECONDEA";
96 io
.in
.eas
.eas
[1].value
= data_blob_talloc(tmp_ctx
, "ValueTwo", 8);
99 status
= smb2_create(tree
, tmp_ctx
, &io
);
100 talloc_free(tmp_ctx
);
101 NT_STATUS_NOT_OK_RETURN(status
);
103 *handle
= io
.out
.file
.handle
;
106 status
= smb2_util_write(tree
, *handle
, buf
, 0, sizeof(buf
));
107 NT_STATUS_NOT_OK_RETURN(status
);
110 /* make sure all the timestamps aren't the same, and are also
111 in different DST zones*/
112 setfile
.generic
.level
= RAW_SFILEINFO_BASIC_INFORMATION
;
113 setfile
.generic
.in
.file
.handle
= *handle
;
115 unix_to_nt_time(&setfile
.basic_info
.in
.create_time
, t
+ 9*30*24*60*60);
116 unix_to_nt_time(&setfile
.basic_info
.in
.access_time
, t
+ 6*30*24*60*60);
117 unix_to_nt_time(&setfile
.basic_info
.in
.write_time
, t
+ 3*30*24*60*60);
118 unix_to_nt_time(&setfile
.basic_info
.in
.change_time
, t
+ 1*30*24*60*60);
119 setfile
.basic_info
.in
.attrib
= FILE_ATTRIBUTE_NORMAL
;
121 status
= smb2_setinfo_file(tree
, &setfile
);
122 if (!NT_STATUS_IS_OK(status
)) {
123 printf("Failed to setup file times - %s\n", nt_errstr(status
));
127 /* make sure all the timestamps aren't the same */
128 fileinfo
.generic
.level
= RAW_FILEINFO_SMB2_ALL_INFORMATION
;
129 fileinfo
.generic
.in
.file
.handle
= *handle
;
131 status
= smb2_getinfo_file(tree
, tree
, &fileinfo
);
132 if (!NT_STATUS_IS_OK(status
)) {
133 printf("Failed to query file times - %s\n", nt_errstr(status
));
138 #define CHECK_TIME(field) do {\
139 if (setfile.basic_info.in.field != fileinfo.all_info2.out.field) { \
140 printf("(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \
142 nt_time_string(tree, setfile.basic_info.in.field), \
143 (unsigned long long)setfile.basic_info.in.field, \
144 nt_time_string(tree, fileinfo.basic_info.out.field), \
145 (unsigned long long)fileinfo.basic_info.out.field); \
146 status = NT_STATUS_INVALID_PARAMETER; \
150 CHECK_TIME(create_time
);
151 CHECK_TIME(access_time
);
152 CHECK_TIME(write_time
);
153 CHECK_TIME(change_time
);
159 create a complex file using the SMB2 protocol
161 NTSTATUS
smb2_create_complex_file(struct smb2_tree
*tree
, const char *fname
,
162 struct smb2_handle
*handle
)
164 return smb2_create_complex(tree
, fname
, handle
, false);
168 create a complex dir using the SMB2 protocol
170 NTSTATUS
smb2_create_complex_dir(struct smb2_tree
*tree
, const char *fname
,
171 struct smb2_handle
*handle
)
173 return smb2_create_complex(tree
, fname
, handle
, true);
177 show lots of information about a file
179 void torture_smb2_all_info(struct smb2_tree
*tree
, struct smb2_handle handle
)
182 TALLOC_CTX
*tmp_ctx
= talloc_new(tree
);
183 union smb_fileinfo io
;
185 io
.generic
.level
= RAW_FILEINFO_SMB2_ALL_INFORMATION
;
186 io
.generic
.in
.file
.handle
= handle
;
188 status
= smb2_getinfo_file(tree
, tmp_ctx
, &io
);
189 if (!NT_STATUS_IS_OK(status
)) {
190 DEBUG(0,("getinfo failed - %s\n", nt_errstr(status
)));
191 talloc_free(tmp_ctx
);
195 d_printf("all_info for '%s'\n", io
.all_info2
.out
.fname
.s
);
196 d_printf("\tcreate_time: %s\n", nt_time_string(tmp_ctx
, io
.all_info2
.out
.create_time
));
197 d_printf("\taccess_time: %s\n", nt_time_string(tmp_ctx
, io
.all_info2
.out
.access_time
));
198 d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx
, io
.all_info2
.out
.write_time
));
199 d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx
, io
.all_info2
.out
.change_time
));
200 d_printf("\tattrib: 0x%x\n", io
.all_info2
.out
.attrib
);
201 d_printf("\tunknown1: 0x%x\n", io
.all_info2
.out
.unknown1
);
202 d_printf("\talloc_size: %llu\n", (long long)io
.all_info2
.out
.alloc_size
);
203 d_printf("\tsize: %llu\n", (long long)io
.all_info2
.out
.size
);
204 d_printf("\tnlink: %u\n", io
.all_info2
.out
.nlink
);
205 d_printf("\tdelete_pending: %u\n", io
.all_info2
.out
.delete_pending
);
206 d_printf("\tdirectory: %u\n", io
.all_info2
.out
.directory
);
207 d_printf("\tfile_id: %llu\n", (long long)io
.all_info2
.out
.file_id
);
208 d_printf("\tea_size: %u\n", io
.all_info2
.out
.ea_size
);
209 d_printf("\taccess_mask: 0x%08x\n", io
.all_info2
.out
.access_mask
);
210 d_printf("\tposition: 0x%llx\n", (long long)io
.all_info2
.out
.position
);
211 d_printf("\tmode: 0x%llx\n", (long long)io
.all_info2
.out
.mode
);
213 /* short name, if any */
214 io
.generic
.level
= RAW_FILEINFO_ALT_NAME_INFORMATION
;
215 status
= smb2_getinfo_file(tree
, tmp_ctx
, &io
);
216 if (NT_STATUS_IS_OK(status
)) {
217 d_printf("\tshort name: '%s'\n", io
.alt_name_info
.out
.fname
.s
);
220 /* the EAs, if any */
221 io
.generic
.level
= RAW_FILEINFO_SMB2_ALL_EAS
;
222 status
= smb2_getinfo_file(tree
, tmp_ctx
, &io
);
223 if (NT_STATUS_IS_OK(status
)) {
225 for (i
=0;i
<io
.all_eas
.out
.num_eas
;i
++) {
226 d_printf("\tEA[%d] flags=%d len=%d '%s'\n", i
,
227 io
.all_eas
.out
.eas
[i
].flags
,
228 (int)io
.all_eas
.out
.eas
[i
].value
.length
,
229 io
.all_eas
.out
.eas
[i
].name
.s
);
233 /* streams, if available */
234 io
.generic
.level
= RAW_FILEINFO_STREAM_INFORMATION
;
235 status
= smb2_getinfo_file(tree
, tmp_ctx
, &io
);
236 if (NT_STATUS_IS_OK(status
)) {
238 for (i
=0;i
<io
.stream_info
.out
.num_streams
;i
++) {
239 d_printf("\tstream %d:\n", i
);
240 d_printf("\t\tsize %ld\n",
241 (long)io
.stream_info
.out
.streams
[i
].size
);
242 d_printf("\t\talloc size %ld\n",
243 (long)io
.stream_info
.out
.streams
[i
].alloc_size
);
244 d_printf("\t\tname %s\n", io
.stream_info
.out
.streams
[i
].stream_name
.s
);
249 /* the security descriptor */
250 io
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
251 io
.query_secdesc
.in
.secinfo_flags
=
252 SECINFO_OWNER
|SECINFO_GROUP
|
254 status
= smb2_getinfo_file(tree
, tmp_ctx
, &io
);
255 if (NT_STATUS_IS_OK(status
)) {
256 NDR_PRINT_DEBUG(security_descriptor
, io
.query_secdesc
.out
.sd
);
260 talloc_free(tmp_ctx
);
264 * open a smb2 tree connect
266 bool torture_smb2_tree_connect(struct torture_context
*tctx
,
267 struct smb2_session
*session
,
269 struct smb2_tree
**_tree
)
272 const char *host
= torture_setting_string(tctx
, "host", NULL
);
273 const char *share
= torture_setting_string(tctx
, "share", NULL
);
274 struct smb2_tree_connect tcon
;
275 struct smb2_tree
*tree
;
278 tcon
.in
.reserved
= 0;
279 tcon
.in
.path
= talloc_asprintf(tctx
, "\\\\%s\\%s", host
, share
);
280 if (tcon
.in
.path
== NULL
) {
281 printf("talloc failed\n");
285 status
= smb2_tree_connect(session
, &tcon
);
286 if (!NT_STATUS_IS_OK(status
)) {
287 printf("Failed to tree_connect to SMB2 share \\\\%s\\%s - %s\n",
288 host
, share
, nt_errstr(status
));
292 tree
= smb2_tree_init(session
, mem_ctx
, true);
294 printf("talloc failed\n");
298 smb2cli_tcon_set_values(tree
->smbXcli
,
299 tree
->session
->smbXcli
,
303 tcon
.out
.capabilities
,
304 tcon
.out
.access_mask
);
312 * do a smb2 session setup (without a tree connect)
314 bool torture_smb2_session_setup(struct torture_context
*tctx
,
315 struct smb2_transport
*transport
,
316 uint64_t previous_session_id
,
318 struct smb2_session
**_session
)
321 struct smb2_session
*session
;
322 struct cli_credentials
*credentials
= cmdline_credentials
;
324 session
= smb2_session_init(transport
,
325 lpcfg_gensec_settings(tctx
, tctx
->lp_ctx
),
328 if (session
== NULL
) {
332 status
= smb2_session_setup_spnego(session
, credentials
,
333 previous_session_id
);
334 if (!NT_STATUS_IS_OK(status
)) {
335 printf("session setup failed: %s\n", nt_errstr(status
));
336 talloc_free(session
);
346 open a smb2 connection
348 bool torture_smb2_connection_ext(struct torture_context
*tctx
,
349 uint64_t previous_session_id
,
350 const struct smbcli_options
*options
,
351 struct smb2_tree
**tree
)
354 const char *host
= torture_setting_string(tctx
, "host", NULL
);
355 const char *share
= torture_setting_string(tctx
, "share", NULL
);
356 struct cli_credentials
*credentials
= cmdline_credentials
;
358 status
= smb2_connect_ext(tctx
,
360 lpcfg_smb_ports(tctx
->lp_ctx
),
362 lpcfg_resolve_context(tctx
->lp_ctx
),
368 lpcfg_socket_options(tctx
->lp_ctx
),
369 lpcfg_gensec_settings(tctx
, tctx
->lp_ctx
)
371 if (!NT_STATUS_IS_OK(status
)) {
372 printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
373 host
, share
, nt_errstr(status
));
379 bool torture_smb2_connection(struct torture_context
*tctx
, struct smb2_tree
**tree
)
382 struct smbcli_options options
;
384 lpcfg_smbcli_options(tctx
->lp_ctx
, &options
);
386 ret
= torture_smb2_connection_ext(tctx
, 0, &options
, tree
);
393 create and return a handle to a test file
395 NTSTATUS
torture_smb2_testfile(struct smb2_tree
*tree
, const char *fname
,
396 struct smb2_handle
*handle
)
398 struct smb2_create io
;
402 io
.in
.oplock_level
= 0;
403 io
.in
.desired_access
= SEC_RIGHTS_FILE_ALL
;
404 io
.in
.file_attributes
= FILE_ATTRIBUTE_NORMAL
;
405 io
.in
.create_disposition
= NTCREATEX_DISP_OPEN_IF
;
407 NTCREATEX_SHARE_ACCESS_DELETE
|
408 NTCREATEX_SHARE_ACCESS_READ
|
409 NTCREATEX_SHARE_ACCESS_WRITE
;
410 io
.in
.create_options
= 0;
413 status
= smb2_create(tree
, tree
, &io
);
414 NT_STATUS_NOT_OK_RETURN(status
);
416 *handle
= io
.out
.file
.handle
;
422 create and return a handle to a test directory
424 NTSTATUS
torture_smb2_testdir(struct smb2_tree
*tree
, const char *fname
,
425 struct smb2_handle
*handle
)
427 struct smb2_create io
;
431 io
.in
.oplock_level
= 0;
432 io
.in
.desired_access
= SEC_RIGHTS_DIR_ALL
;
433 io
.in
.file_attributes
= FILE_ATTRIBUTE_DIRECTORY
;
434 io
.in
.create_disposition
= NTCREATEX_DISP_OPEN_IF
;
435 io
.in
.share_access
= NTCREATEX_SHARE_ACCESS_READ
|NTCREATEX_SHARE_ACCESS_WRITE
|NTCREATEX_SHARE_ACCESS_DELETE
;
436 io
.in
.create_options
= NTCREATEX_OPTIONS_DIRECTORY
;
439 status
= smb2_create(tree
, tree
, &io
);
440 NT_STATUS_NOT_OK_RETURN(status
);
442 *handle
= io
.out
.file
.handle
;
449 create a complex file using SMB2, to make it easier to
450 find fields in SMB2 getinfo levels
452 NTSTATUS
torture_setup_complex_file(struct smb2_tree
*tree
, const char *fname
)
454 struct smb2_handle handle
;
455 NTSTATUS status
= smb2_create_complex_file(tree
, fname
, &handle
);
456 NT_STATUS_NOT_OK_RETURN(status
);
457 return smb2_util_close(tree
, handle
);
462 create a complex dir using SMB2, to make it easier to
463 find fields in SMB2 getinfo levels
465 NTSTATUS
torture_setup_complex_dir(struct smb2_tree
*tree
, const char *fname
)
467 struct smb2_handle handle
;
468 NTSTATUS status
= smb2_create_complex_dir(tree
, fname
, &handle
);
469 NT_STATUS_NOT_OK_RETURN(status
);
470 return smb2_util_close(tree
, handle
);
475 return a handle to the root of the share
477 NTSTATUS
smb2_util_roothandle(struct smb2_tree
*tree
, struct smb2_handle
*handle
)
479 struct smb2_create io
;
483 io
.in
.oplock_level
= 0;
484 io
.in
.desired_access
= SEC_STD_SYNCHRONIZE
| SEC_DIR_READ_ATTRIBUTE
| SEC_DIR_LIST
;
485 io
.in
.file_attributes
= 0;
486 io
.in
.create_disposition
= NTCREATEX_DISP_OPEN
;
487 io
.in
.share_access
= NTCREATEX_SHARE_ACCESS_READ
|NTCREATEX_SHARE_ACCESS_DELETE
;
488 io
.in
.create_options
= NTCREATEX_OPTIONS_ASYNC_ALERT
;
491 status
= smb2_create(tree
, tree
, &io
);
492 NT_STATUS_NOT_OK_RETURN(status
);
494 *handle
= io
.out
.file
.handle
;
499 /* Comparable to torture_setup_dir, but for SMB2. */
500 bool smb2_util_setup_dir(struct torture_context
*tctx
, struct smb2_tree
*tree
,
505 /* XXX: smb_raw_exit equivalent?
506 smb_raw_exit(cli->session); */
507 if (smb2_deltree(tree
, dname
) == -1) {
508 torture_result(tctx
, TORTURE_ERROR
, "Unable to deltree when setting up %s.\n", dname
);
512 status
= smb2_util_mkdir(tree
, dname
);
513 if (NT_STATUS_IS_ERR(status
)) {
514 torture_result(tctx
, TORTURE_ERROR
, "Unable to mkdir when setting up %s - %s\n", dname
,
522 #define CHECK_STATUS(status, correct) do { \
523 if (!NT_STATUS_EQUAL(status, correct)) { \
524 torture_result(tctx, TORTURE_FAIL, "(%s) Incorrect status %s - should be %s\n", \
525 __location__, nt_errstr(status), nt_errstr(correct)); \
531 * Helper function to verify a security descriptor, by querying
532 * and comparing against the passed in sd.
534 bool smb2_util_verify_sd(TALLOC_CTX
*tctx
, struct smb2_tree
*tree
,
535 struct smb2_handle handle
, struct security_descriptor
*sd
)
539 union smb_fileinfo q
= {};
541 q
.query_secdesc
.level
= RAW_FILEINFO_SEC_DESC
;
542 q
.query_secdesc
.in
.file
.handle
= handle
;
543 q
.query_secdesc
.in
.secinfo_flags
=
547 status
= smb2_getinfo_file(tree
, tctx
, &q
);
548 CHECK_STATUS(status
, NT_STATUS_OK
);
550 if (!security_acl_equal(
551 q
.query_secdesc
.out
.sd
->dacl
, sd
->dacl
)) {
552 torture_warning(tctx
, "%s: security descriptors don't match!\n",
554 torture_warning(tctx
, "got:\n");
555 NDR_PRINT_DEBUG(security_descriptor
,
556 q
.query_secdesc
.out
.sd
);
557 torture_warning(tctx
, "expected:\n");
558 NDR_PRINT_DEBUG(security_descriptor
, sd
);
567 * Helper function to verify attributes, by querying
568 * and comparing against the passed in attrib.
570 bool smb2_util_verify_attrib(TALLOC_CTX
*tctx
, struct smb2_tree
*tree
,
571 struct smb2_handle handle
, uint32_t attrib
)
575 union smb_fileinfo q
= {};
577 q
.standard
.level
= RAW_FILEINFO_SMB2_ALL_INFORMATION
;
578 q
.standard
.in
.file
.handle
= handle
;
579 status
= smb2_getinfo_file(tree
, tctx
, &q
);
580 CHECK_STATUS(status
, NT_STATUS_OK
);
582 q
.all_info2
.out
.attrib
&= ~(FILE_ATTRIBUTE_ARCHIVE
| FILE_ATTRIBUTE_NONINDEXED
);
584 if (q
.all_info2
.out
.attrib
!= attrib
) {
585 torture_warning(tctx
, "%s: attributes don't match! "
586 "got %x, expected %x\n", __location__
,
587 (uint32_t)q
.standard
.out
.attrib
,
597 uint32_t smb2_util_lease_state(const char *ls
)
602 for (i
= 0; i
< strlen(ls
); i
++) {
605 val
|= SMB2_LEASE_READ
;
608 val
|= SMB2_LEASE_HANDLE
;
611 val
|= SMB2_LEASE_WRITE
;
620 uint32_t smb2_util_share_access(const char *sharemode
)
622 uint32_t val
= NTCREATEX_SHARE_ACCESS_NONE
; /* 0 */
625 for (i
= 0; i
< strlen(sharemode
); i
++) {
626 switch(sharemode
[i
]) {
628 val
|= NTCREATEX_SHARE_ACCESS_READ
;
631 val
|= NTCREATEX_SHARE_ACCESS_WRITE
;
634 val
|= NTCREATEX_SHARE_ACCESS_DELETE
;
642 uint8_t smb2_util_oplock_level(const char *op
)
644 uint8_t val
= SMB2_OPLOCK_LEVEL_NONE
;
647 for (i
= 0; i
< strlen(op
); i
++) {
650 return SMB2_OPLOCK_LEVEL_II
;
652 return SMB2_OPLOCK_LEVEL_EXCLUSIVE
;
654 return SMB2_OPLOCK_LEVEL_BATCH
;
664 * Helper functions to fill a smb2_create struct for several
667 void smb2_generic_create_share(struct smb2_create
*io
, struct smb2_lease
*ls
,
668 bool dir
, const char *name
, uint32_t disposition
,
669 uint32_t share_access
,
670 uint8_t oplock
, uint64_t leasekey
,
674 io
->in
.security_flags
= 0x00;
675 io
->in
.oplock_level
= oplock
;
676 io
->in
.impersonation_level
= NTCREATEX_IMPERSONATION_IMPERSONATION
;
677 io
->in
.create_flags
= 0x00000000;
678 io
->in
.reserved
= 0x00000000;
679 io
->in
.desired_access
= SEC_RIGHTS_FILE_ALL
;
680 io
->in
.file_attributes
= FILE_ATTRIBUTE_NORMAL
;
681 io
->in
.share_access
= share_access
;
682 io
->in
.create_disposition
= disposition
;
683 io
->in
.create_options
= NTCREATEX_OPTIONS_SEQUENTIAL_ONLY
|
684 NTCREATEX_OPTIONS_ASYNC_ALERT
|
685 NTCREATEX_OPTIONS_NON_DIRECTORY_FILE
|
690 io
->in
.create_options
= NTCREATEX_OPTIONS_DIRECTORY
;
691 io
->in
.file_attributes
= FILE_ATTRIBUTE_DIRECTORY
;
692 io
->in
.create_disposition
= NTCREATEX_DISP_CREATE
;
697 ls
->lease_key
.data
[0] = leasekey
;
698 ls
->lease_key
.data
[1] = ~leasekey
;
699 ls
->lease_state
= leasestate
;
700 io
->in
.lease_request
= ls
;
704 void smb2_generic_create(struct smb2_create
*io
, struct smb2_lease
*ls
,
705 bool dir
, const char *name
, uint32_t disposition
,
706 uint8_t oplock
, uint64_t leasekey
,
709 smb2_generic_create_share(io
, ls
, dir
, name
, disposition
,
710 smb2_util_share_access("RWD"),
712 leasekey
, leasestate
);
715 void smb2_lease_create_share(struct smb2_create
*io
, struct smb2_lease
*ls
,
716 bool dir
, const char *name
, uint32_t share_access
,
717 uint64_t leasekey
, uint32_t leasestate
)
719 smb2_generic_create_share(io
, ls
, dir
, name
, NTCREATEX_DISP_OPEN_IF
,
720 share_access
, SMB2_OPLOCK_LEVEL_LEASE
,
721 leasekey
, leasestate
);
724 void smb2_lease_create(struct smb2_create
*io
, struct smb2_lease
*ls
,
725 bool dir
, const char *name
, uint64_t leasekey
,
728 smb2_lease_create_share(io
, ls
, dir
, name
,
729 smb2_util_share_access("RWD"),
730 leasekey
, leasestate
);
733 void smb2_lease_v2_create_share(struct smb2_create
*io
,
734 struct smb2_lease
*ls
,
737 uint32_t share_access
,
739 const uint64_t *parentleasekey
,
741 uint16_t lease_epoch
)
743 smb2_generic_create_share(io
, NULL
, dir
, name
, NTCREATEX_DISP_OPEN_IF
,
744 share_access
, SMB2_OPLOCK_LEVEL_LEASE
, 0, 0);
748 ls
->lease_key
.data
[0] = leasekey
;
749 ls
->lease_key
.data
[1] = ~leasekey
;
750 ls
->lease_state
= leasestate
;
751 if (parentleasekey
!= NULL
) {
752 ls
->lease_flags
|= SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET
;
753 ls
->parent_lease_key
.data
[0] = *parentleasekey
;
754 ls
->parent_lease_key
.data
[1] = ~(*parentleasekey
);
756 ls
->lease_epoch
= lease_epoch
;
757 io
->in
.lease_request_v2
= ls
;
761 void smb2_oplock_create_share(struct smb2_create
*io
, const char *name
,
762 uint32_t share_access
, uint8_t oplock
)
764 smb2_generic_create_share(io
, NULL
, false, name
, NTCREATEX_DISP_OPEN_IF
,
765 share_access
, oplock
, 0, 0);
767 void smb2_oplock_create(struct smb2_create
*io
, const char *name
, uint8_t oplock
)
769 smb2_oplock_create_share(io
, name
, smb2_util_share_access("RWD"),