From: Ralph Boehme Date: Mon, 16 Sep 2024 19:29:10 +0000 (+0200) Subject: smbtorture: expand test test_lease_unlink() with set-delete-on-close X-Git-Tag: tdb-1.4.13~744 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaa9e60ddbcd7c905699739c9d70cb71bc2f74bc;p=thirdparty%2Fsamba.git smbtorture: expand test test_lease_unlink() with set-delete-on-close 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 Reviewed-by: Stefan Metzmacher --- diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c index b712b72f55e..736155440d4 100644 --- a/source4/torture/smb2/lease.c +++ b/source4/torture/smb2/lease.c @@ -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);