]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: make grant_new_fsp_lease() public and add bump_epoch
authorRalph Boehme <slow@samba.org>
Tue, 30 Sep 2025 15:12:49 +0000 (17:12 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 10:18:36 +0000 (10:18 +0000)
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 <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/smbd/open.c
source3/smbd/proto.h

index 1a90d6e633bdce7cee37669d3a8d492c9bf3f476..bdf243dcaf4dcd551e4aec65f63097d3de502c4b 100644 (file)
@@ -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;
index 08772a91acbd2ecb3c91590acf607a4595ecbffc..3bb309e463b1daafbce8263f77c4a7a1ef64c161 100644 (file)
@@ -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);