From: Ralph Boehme Date: Thu, 22 May 2025 14:57:49 +0000 (+0200) Subject: smbd: support breaking leases on an object where we don't have an own internal open X-Git-Tag: samba-4.22.2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b171beb860c6c70e009a6f0b402b34ca601935ae;p=thirdparty%2Fsamba.git 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 (cherry picked from commit 03c46342e2a65e6d81bd581471310c0ec2cbbdfb) --- diff --git a/source3/smbd/smb2_oplock.c b/source3/smbd/smb2_oplock.c index 4e900647ef5..16a4c70da2c 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); }