]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbtorture: check parent leasekey is ignored unless SMB2_LEASE_FLAG_PARENT_LEASE_KEY_...
authorRalph Boehme <slow@samba.org>
Thu, 24 Oct 2024 10:00:40 +0000 (12:00 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Nov 2024 14:39:31 +0000 (14:39 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
selftest/knownfail.d/samba3.smb2.lease [new file with mode: 0644]
source4/torture/smb2/lease.c

diff --git a/selftest/knownfail.d/samba3.smb2.lease b/selftest/knownfail.d/samba3.smb2.lease
new file mode 100644 (file)
index 0000000..c3084dc
--- /dev/null
@@ -0,0 +1 @@
+^samba3.smb2.lease.v2_flags_parentkey\(fileserver\)
index dfac95b7506f85e00a1bff63987fdcae878d7b43..9a841ecacfdfa7876d18968c5457a346dddcbc02 100644 (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);