From: Ralph Boehme Date: Fri, 23 May 2025 15:06:50 +0000 (+0200) Subject: smbd: add access_mask to delay_for_handle_lease_break_send() X-Git-Tag: samba-4.22.2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4874eb99e6e62b4289eece67db157b16196a32cb;p=thirdparty%2Fsamba.git smbd: add access_mask to delay_for_handle_lease_break_send() No change in behaviour, existing caller all pass SEC_RIGHTS_DIR_ALL. Prepares for selectively breaking only H-leases if the access_mask of the corresponding open contains DELETE_ACCESS. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15861 Signed-off-by: Ralph Boehme Reviewed-by: Bjoern Jacke (cherry picked from commit 5d4565c1f974b75a1c080f4503613201ecaf7001) --- diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 9c89bcc96f5..d227e639e1c 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1247,6 +1247,7 @@ struct tevent_req *delay_for_handle_lease_break_send( struct tevent_context *ev, struct timeval timeout, struct files_struct *fsp, + uint32_t access_mask, bool recursive, struct share_mode_lock **lck); diff --git a/source3/smbd/smb2_close.c b/source3/smbd/smb2_close.c index d68c0bd9e6c..4195adc3804 100644 --- a/source3/smbd/smb2_close.c +++ b/source3/smbd/smb2_close.c @@ -369,6 +369,7 @@ static struct tevent_req *smbd_smb2_close_send(TALLOC_CTX *mem_ctx, ev, timeout, in_fsp, + SEC_RIGHTS_DIR_ALL, false, &lck); if (tevent_req_nomem(subreq, req)) { diff --git a/source3/smbd/smb2_oplock.c b/source3/smbd/smb2_oplock.c index 16a4c70da2c..4b7a6c0363c 100644 --- a/source3/smbd/smb2_oplock.c +++ b/source3/smbd/smb2_oplock.c @@ -1516,6 +1516,7 @@ struct delay_for_handle_lease_break_state { TALLOC_CTX *mem_ctx; struct tevent_context *ev; struct timeval timeout; + uint32_t access_mask; bool recursive; bool recursive_h_leases_break; struct files_struct *fsp; @@ -1546,6 +1547,7 @@ struct tevent_req *delay_for_handle_lease_break_send( struct tevent_context *ev, struct timeval timeout, struct files_struct *fsp, + uint32_t access_mask, bool recursive, struct share_mode_lock **lck) { @@ -1564,6 +1566,7 @@ struct tevent_req *delay_for_handle_lease_break_send( .mem_ctx = mem_ctx, .ev = ev, .timeout = timeout, + .access_mask = access_mask, .recursive = recursive, .recursive_h_leases_break = recursive, .fsp = fsp, @@ -1604,6 +1607,10 @@ static bool delay_for_handle_lease_break_fn(struct share_mode_entry *e, } } + if ((state->access_mask & e->access_mask) == 0) { + return false; + } + lease_type = get_lease_type(e, fsp->file_id); if ((lease_type & SMB2_LEASE_HANDLE) == 0) { return false; diff --git a/source3/smbd/smb2_setinfo.c b/source3/smbd/smb2_setinfo.c index 91280a52c07..86cd0eac0ca 100644 --- a/source3/smbd/smb2_setinfo.c +++ b/source3/smbd/smb2_setinfo.c @@ -489,6 +489,7 @@ static void smbd_smb2_setinfo_lease_break_fsp_check(struct tevent_req *req) state->ev, timeout, fsp, + SEC_RIGHTS_DIR_ALL, rename, &state->lck); if (tevent_req_nomem(subreq, req)) { @@ -656,6 +657,7 @@ static void smbd_smb2_setinfo_rename_dst_check(struct tevent_req *req) state->ev, timeout, state->dstfsp, + SEC_RIGHTS_DIR_ALL, false, &state->lck); if (subreq == NULL) { diff --git a/source3/smbd/smbXsrv_session.c b/source3/smbd/smbXsrv_session.c index c074bb851de..3d4f0967570 100644 --- a/source3/smbd/smbXsrv_session.c +++ b/source3/smbd/smbXsrv_session.c @@ -2618,6 +2618,7 @@ static struct files_struct *smbXsrv_wait_for_handle_lease_break_fn( state->ev, timeout, fsp, + SEC_RIGHTS_DIR_ALL, false, &lck); if (tevent_req_nomem(subreq, state->req)) {