From: Ralph Boehme Date: Tue, 30 Sep 2025 15:12:49 +0000 (+0200) Subject: smbd: make grant_new_fsp_lease() public and add bump_epoch X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eeffe90f4a8b9eb7b6a511f80210aa019c002217;p=thirdparty%2Fsamba.git smbd: make grant_new_fsp_lease() public and add bump_epoch Current caller passed true which results in unchanged behaviour. However, we will call this from durable.c when reconnecting Persistent Handle where we need control over the exact lease version. Signed-off-by: Ralph Boehme Reviewed-by: Anoop C S --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 1a90d6e633b..bdf243dcaf4 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -2161,11 +2161,12 @@ static NTSTATUS try_lease_upgrade(struct files_struct *fsp, return NT_STATUS_OK; } -static NTSTATUS grant_new_fsp_lease(struct files_struct *fsp, - struct share_mode_lock *lck, - const struct GUID *client_guid, - const struct smb2_lease *lease, - uint32_t granted) +NTSTATUS grant_new_fsp_lease(struct files_struct *fsp, + struct share_mode_lock *lck, + const struct GUID *client_guid, + const struct smb2_lease *lease, + uint32_t granted, + bool bump_epoch) { NTSTATUS status; @@ -2181,7 +2182,7 @@ static NTSTATUS grant_new_fsp_lease(struct files_struct *fsp, fsp->lease->lease.lease_flags = lease->lease_flags; fsp->lease->lease.lease_state = granted; fsp->lease->lease.lease_epoch = lease->lease_epoch; - if (granted != 0) { + if (granted != 0 && bump_epoch) { fsp->lease->lease.lease_epoch++; } @@ -2232,7 +2233,7 @@ static NTSTATUS grant_fsp_lease(struct files_struct *fsp, if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { status = grant_new_fsp_lease( - fsp, lck, client_guid, lease, granted); + fsp, lck, client_guid, lease, granted, true); } return status; diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 08772a91acb..3bb309e463b 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -699,6 +699,13 @@ NTSTATUS create_file_default(connection_struct *conn, const struct smb2_create_blobs *in_context_blobs, struct smb2_create_blobs *out_context_blobs); +NTSTATUS grant_new_fsp_lease(struct files_struct *fsp, + struct share_mode_lock *lck, + const struct GUID *client_guid, + const struct smb2_lease *lease, + uint32_t granted, + bool bump_epoch); + /* The following definitions come from smbd/oplock.c */ uint32_t get_lease_type(struct share_mode_entry *e, struct file_id id);