]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbtorture: expand test test_lease_unlink() with set-delete-on-close
authorRalph Boehme <slow@samba.org>
Mon, 16 Sep 2024 19:29:10 +0000 (21:29 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Nov 2024 14:39:30 +0000 (14:39 +0000)
Currently the test only uses initial-delete-on-close. Expand the test to also
use set-delete-on-close.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13458
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15608

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/torture/smb2/lease.c

index b712b72f55e18c3c16e70c8af770f821806c2027..736155440d472134ce885336c2509a8a6658e8d5 100644 (file)
@@ -4260,6 +4260,7 @@ static bool test_lease_unlink(struct torture_context *tctx,
        struct smb2_create io2;
        struct smb2_lease ls1;
        struct smb2_lease ls2;
+       union smb_setfileinfo sfinfo = {};
 
        caps = smb2cli_conn_server_capabilities(
                        tree1->session->transport->conn);
@@ -4315,6 +4316,56 @@ static bool test_lease_unlink(struct torture_context *tctx,
        CHECK_VAL(lease_break_info.count, 1);
        CHECK_BREAK_INFO("RH", "R", LEASE1);
 
+       smb2_util_close(tree1, h1);
+
+       torture_comment(tctx, "Client 1 recreates file with RH lease\n");
+
+       torture_reset_lease_break_info(tctx, &lease_break_info);
+
+       smb2_lease_create(&io1, &ls1, false, fname, LEASE1,
+                               smb2_util_lease_state("RH"));
+
+       status = smb2_create(tree1, mem_ctx, &io1);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "create failed\n");
+       h1 = io1.out.file.handle;
+       CHECK_CREATED(&io1, CREATED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_LEASE(&io1, "RH", true, LEASE1, 0);
+       CHECK_VAL(lease_break_info.count, 0);
+
+       torture_comment(tctx, "Client 2 opens with RH lease\n");
+
+       smb2_lease_create(&io2, &ls2, false, fname, LEASE2,
+                               smb2_util_lease_state("RH"));
+       status = smb2_create(tree2, mem_ctx, &io2);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "create failed\n");
+
+       h2 = io2.out.file.handle;
+       CHECK_CREATED(&io2, EXISTED, FILE_ATTRIBUTE_ARCHIVE);
+       CHECK_LEASE(&io2, "RH", true, LEASE2, 0);
+       CHECK_VAL(lease_break_info.count, 0);
+
+       torture_comment(tctx, "Client 2 sets delete on close, "
+                       "triggering lease break\n");
+
+       sfinfo.disposition_info.in.delete_on_close = 1;
+       sfinfo.generic.level = RAW_SFILEINFO_DISPOSITION_INFORMATION;
+       sfinfo.generic.in.file.handle = h2;
+
+       status = smb2_setinfo_file(tree2, &sfinfo);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                     "Set DELETE_ON_CLOSE disposition "
+                                     "returned un expected status.\n");
+
+       CHECK_LEASE(&io1, "RH", true, LEASE1, 0);
+       CHECK_VAL(lease_break_info.count, 1);
+
+       status = smb2_util_close(tree2, h2);
+       torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+                                       "smb2_util_close failed\n");
+       ZERO_STRUCT(h2);
+
 done:
        smb2_util_close(tree1, h1);
        smb2_util_close(tree2, h2);