1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

smbtorture: check parent leasekey is ignored unless SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET is set

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Ralph Boehme 2024-10-24 12:00:40 +02:00
parent 52d8af2f42
commit dde84e5fd3
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1 @@
^samba3.smb2.lease.v2_flags_parentkey\(fileserver\)

View File

@ -93,6 +93,9 @@
if (__flags & SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET) { \
CHECK_VAL((__io)->out.lease_response_v2.parent_lease_key.data[0], (__parent)); \
CHECK_VAL((__io)->out.lease_response_v2.parent_lease_key.data[1], ~(__parent)); \
} else { \
CHECK_VAL((__io)->out.lease_response_v2.parent_lease_key.data[0], 0); \
CHECK_VAL((__io)->out.lease_response_v2.parent_lease_key.data[1], 0); \
} \
CHECK_VAL((__io)->out.lease_response_v2.lease_duration, 0); \
CHECK_VAL((__io)->out.lease_response_v2.lease_epoch, (__epoch)); \
@ -1981,6 +1984,52 @@ done:
return ret;
}
/*
* Verify server ignores the parent leasekey if
* SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET is not set in the request.
*/
static bool test_lease_v2_flags_parentkey(struct torture_context *tctx,
struct smb2_tree *tree)
{
struct smb2_create c = {};
struct smb2_lease ls = {};
struct smb2_handle h = {};
const char *fname = "lease_v2_epoch1.dat";
enum protocol_types protocol;
uint32_t caps;
NTSTATUS status;
bool ret = true;
caps = smb2cli_conn_server_capabilities(tree->session->transport->conn);
torture_assert_goto(tctx, caps & SMB2_CAP_LEASING, ret, done, "leases are not supported");
protocol = smbXcli_conn_protocol(tree->session->transport->conn);
if (protocol < PROTOCOL_SMB3_00) {
torture_skip(tctx, "v2 leases are not supported");
}
smb2_util_unlink(tree, fname);
smb2_lease_v2_create_share(&c, &ls, false, fname,
smb2_util_share_access("RWD"),
LEASE1, &LEASE1,
smb2_util_lease_state("RHW"),
0x4711);
ls.lease_flags = 0;
status = smb2_create(tree, tree, &c);
CHECK_STATUS(status, NT_STATUS_OK);
h = c.out.file.handle;
CHECK_CREATED(&c, CREATED, FILE_ATTRIBUTE_ARCHIVE);
CHECK_LEASE_V2(&c, "RHW", true, LEASE1, 0, 0, ls.lease_epoch + 1);
done:
smb2_util_close(tree, h);
smb2_util_unlink(tree, fname);
return ret;
}
static bool test_lease_v2_epoch1(struct torture_context *tctx,
struct smb2_tree *tree)
{
@ -5759,6 +5808,7 @@ struct torture_suite *torture_smb2_lease_init(TALLOC_CTX *ctx)
torture_suite_add_2smb2_test(suite, "lock1", test_lease_lock1);
torture_suite_add_1smb2_test(suite, "complex1", test_lease_complex1);
torture_suite_add_1smb2_test(suite, "v2_flags_breaking", test_lease_v2_flags_breaking);
torture_suite_add_1smb2_test(suite, "v2_flags_parentkey", test_lease_v2_flags_parentkey);
torture_suite_add_1smb2_test(suite, "v2_epoch1", test_lease_v2_epoch1);
torture_suite_add_1smb2_test(suite, "v2_epoch2", test_lease_v2_epoch2);
torture_suite_add_1smb2_test(suite, "v2_epoch3", test_lease_v2_epoch3);