From a611e6d4027b261e666e03532089de7af10c9cf5 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 14 Oct 2024 17:20:16 +0200 Subject: [PATCH] smbtorture: expand test test_lease_v2_rename_target_overwrite() BUG: https://bugzilla.samba.org/show_bug.cgi?id=15608 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- source4/torture/smb2/lease.c | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c index 76a946c87de..9cf3adcf0b3 100644 --- a/source4/torture/smb2/lease.c +++ b/source4/torture/smb2/lease.c @@ -3962,6 +3962,7 @@ static bool test_lease_v2_rename_target_overwrite(struct torture_context *tctx, NTSTATUS status; uint32_t caps; enum protocol_types protocol; + struct smb2_request *rename_req = NULL; caps = smb2cli_conn_server_capabilities(tree->session->transport->conn); torture_assert_goto(tctx, caps & SMB2_CAP_LEASING, ret, done, "leases are not supported"); @@ -4023,6 +4024,65 @@ static bool test_lease_v2_rename_target_overwrite(struct torture_context *tctx, CHECK_BREAK_INFO_V2(tree->session->transport, "RWH", "RW", LEASE2, ls_dst.lease_epoch + 1); + torture_reset_lease_break_info(tctx, &lease_break_info); + lease_break_info.lease_skip_ack = true; + + /* + * Do the rename again, this time there's no h-lease on the dst anymore, + * so we should get no break and the rename should still fail. + */ + + torture_reset_lease_break_info(tctx, &lease_break_info); + + status = smb2_setinfo_file(tree, &sinfo); + CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); + + CHECK_NO_BREAK(tctx); + + /* + * Do the rename again, but this time close the handle on the + * destination when receiving the h-lease break. + */ + + torture_reset_lease_break_info(tctx, &lease_break_info); + lease_break_info.lease_skip_ack = true; + + status = smb2_util_close(tree, h_dst); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "smb2_util_close failed\n"); + ZERO_STRUCT(h_dst); + + status = smb2_create(tree, mem_ctx, &io_dst); + CHECK_STATUS(status, NT_STATUS_OK); + h_dst = io_dst.out.file.handle; + ls_dst.lease_epoch += 1; + + ZERO_STRUCT(sinfo); + sinfo.rename_information.level = RAW_SFILEINFO_RENAME_INFORMATION; + sinfo.rename_information.in.file.handle = h; + sinfo.rename_information.in.overwrite = true; + sinfo.rename_information.in.new_name = fname_dst; + rename_req = smb2_setinfo_file_send(tree, &sinfo); + + torture_assert(tctx, + rename_req != NULL, + "smb2_setinfo_file_send"); + torture_assert(tctx, + rename_req->state == SMB2_REQUEST_RECV, + "rename pending"); + + CHECK_BREAK_INFO_V2(tree->session->transport, + "RWH", "RW", LEASE2, ls_dst.lease_epoch + 1); + + status = smb2_util_close(tree, h_dst); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "smb2_util_close failed\n"); + ZERO_STRUCT(h_dst); + + /* Get the rename reply. */ + status = smb2_setinfo_recv(rename_req); + CHECK_STATUS(status, NT_STATUS_OK); + done: smb2_util_close(tree, h); -- 2.47.3