]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: add and fill CreateGuid in struct smbd_smb2_request
authorRalph Boehme <slow@samba.org>
Mon, 19 May 2025 10:59:24 +0000 (12:59 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 10:18:36 +0000 (10:18 +0000)
This will get stored in the share_mode_entry and is used as part of Persistent
Handle reconnect.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/locking/share_mode_lock.c
source3/locking/share_mode_lock.h
source3/smbd/globals.h
source3/smbd/open.c
source3/smbd/smb2_create.c

index 7047fdf97bfab136cccd2bbc84c6f21823613dce..70400f9e98b5bcd57dc4df45a10aac4968a3c008 100644 (file)
@@ -2075,6 +2075,7 @@ bool set_share_mode(struct share_mode_lock *lck,
                    uint64_t mid,
                    uint16_t op_type,
                    const struct smb2_lease_key *lease_key,
+                   const struct GUID *create_guid,
                    uint32_t share_access,
                    uint32_t access_mask)
 {
@@ -2136,6 +2137,8 @@ bool set_share_mode(struct share_mode_lock *lck,
        if (e.flags & SHARE_ENTRY_FLAG_PERSISTENT_OPEN) {
                d->num_persistent++;
                d->modified = true;
+               SMB_ASSERT(create_guid != NULL);
+               e.create_guid = *create_guid;
        }
 
        ok = share_mode_entry_put(&e, &e_buf);
index b4f2848d81b66d945caba08db7db77d20ef21a5e..a3c66d74f317631ea23af42bc2b778cbe3d78701 100644 (file)
@@ -49,6 +49,7 @@ bool remove_share_oplock(struct share_mode_lock *lck,
                         struct files_struct *fsp);
 bool file_has_read_lease(struct files_struct *fsp);
 
+struct GUID;
 bool set_share_mode(
        struct share_mode_lock *lck,
        struct files_struct *fsp,
@@ -56,6 +57,7 @@ bool set_share_mode(
        uint64_t mid,
        uint16_t op_type,
        const struct smb2_lease_key *lease_key,
+       const struct GUID *create_guid,
        uint32_t share_access,
        uint32_t access_mask);
 bool reset_share_mode_entry(
index c7d67e2ed9d609b1988c50046ce6f479cfae6c86..ff4ea7161281d362a1ff60d7648a33d958a13c97 100644 (file)
@@ -666,6 +666,13 @@ struct smbd_smb2_request {
        bool request_counters_updated;
        uint64_t channel_generation;
 
+       /*
+        * The client provided CreateGuid from a
+        * SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 if any.
+        */
+       struct GUID _create_guid;
+       struct GUID *create_guid;
+
        /*
         * The sub request for async backend calls.
         * This is used for SMB2 Cancel.
index bdf243dcaf4dcd551e4aec65f63097d3de502c4b..c4b7daf787ec42e17496f58e77fba128d94f01c0 100644 (file)
@@ -3224,6 +3224,7 @@ static NTSTATUS check_and_store_share_mode(
        uint32_t granted_lease = 0;
        const struct smb2_lease_key *lease_key = NULL;
        struct blocker_debug_state *blocker_debug_state = NULL;
+       const struct GUID *create_guid = NULL;
        bool delete_on_close;
        bool ok;
 
@@ -3263,12 +3264,17 @@ static NTSTATUS check_and_store_share_mode(
 
        share_mode_flags_restrict(lck, access_mask, share_access, 0);
 
+       if (req != NULL && req->smb2req != NULL) {
+               create_guid = req->smb2req->create_guid;
+       }
+
        ok = set_share_mode(lck,
                            fsp,
                            get_current_uid(fsp->conn),
                            req ? req->mid : 0,
                            oplock_type,
                            lease_key,
+                           create_guid,
                            share_access,
                            access_mask);
        if (!ok) {
index a3a1edb00bacea6cef2813657f16af2147934ec4..c79c8970e1ee8aa7532a19f82da97afb47a68443 100644 (file)
@@ -1412,6 +1412,13 @@ static void smbd_smb2_cc_before_exec_dhc2q(struct tevent_req *req)
                return;
        }
        state->create_guid = &state->_create_guid;
+       /*
+        * Make the CreateGuid available to the FSA and VFS layers via
+        * the "req" argument to SMB_VFS_CREATE_FILE():
+        * req->smb2req->create_guid.
+        */
+       smb2req->_create_guid = state->_create_guid;
+       smb2req->create_guid = &smb2req->_create_guid;
 
        /*
         * we need to store the create_guid later