From 03c46342e2a65e6d81bd581471310c0ec2cbbdfb Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 22 May 2025 16:57:49 +0200 Subject: [PATCH] smbd: support breaking leases on an object where we don't have an own internal open So far, when dealing with the rename destination, we had an internal open on that which ensured get_existing_share_mode_lock() would always return a lock. Subsequently I'll want delay_for_handle_lease_break_send() to be callable on an object that doesn't have a full internal open including locking.tdb entry, but merely an open handle from filename_convert_dirfsp(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15861 Signed-off-by: Ralph Boehme Reviewed-by: Bjoern Jacke --- source3/smbd/smb2_oplock.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/source3/smbd/smb2_oplock.c b/source3/smbd/smb2_oplock.c index d1f3e85d3ed..4e877c147ca 100644 --- a/source3/smbd/smb2_oplock.c +++ b/source3/smbd/smb2_oplock.c @@ -1639,6 +1639,12 @@ static void delay_for_handle_lease_break_fsp_check(struct tevent_req *req) DBG_DEBUG("fsp [%s]\n", fsp_str_dbg(state->fsp)); + if (state->lck == NULL) { + DBG_DEBUG("fsp [%s] all opens are gone\n", + fsp_str_dbg(state->fsp)); + return; + } + ok = share_mode_forall_leases(state->lck, delay_for_handle_lease_break_fn, state); @@ -1696,11 +1702,6 @@ static void delay_for_handle_lease_break_fsp_done(struct tevent_req *subreq) } state->lck = get_existing_share_mode_lock(state, state->fsp->file_id); - if (state->lck == NULL) { - tevent_req_nterror(req, NT_STATUS_UNSUCCESSFUL); - return; - } - /* * This could potentially end up looping for some if a client * aggressively reaquires H-leases on the file, but we have a @@ -1964,11 +1965,6 @@ static void delay_for_handle_lease_break_below_done(struct tevent_req *subreq) state->recursive_h_leases_break = false; state->lck = get_existing_share_mode_lock(state, state->fsp->file_id); - if (state->lck == NULL) { - tevent_req_nterror(req, NT_STATUS_UNSUCCESSFUL); - return; - } - delay_for_handle_lease_break_check(req); } -- 2.47.2