]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_default: adapt share_mode_entry_durable_reconnect_fn() for Persistent Handles
authorRalph Boehme <slow@samba.org>
Tue, 2 Dec 2025 18:49:01 +0000 (19:49 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 10:18:36 +0000 (10:18 +0000)
Additionally check the create_guid. We could also do this for Durable Handles
v2 if we wanted to.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/smbd/durable.c

index cbc39bc05ac0439469bf3e0e10f28d399db5239e..5d153babf2cb310364ecc4ff9b460bc8702a14d1 100644 (file)
@@ -545,21 +545,45 @@ static bool share_mode_entry_durable_reconnect_cb(
        void *private_data)
 {
        struct durable_reconnect_state *state = private_data;
-       uint64_t id = state->op->global->open_persistent_id;
+       struct smbXsrv_open_global0 *global = state->op->global;
+       uint64_t id = global->open_persistent_id;
 
        if (e->share_file_id != id) {
                return false; /* Look at potential other entries */
        }
-
-       if (!server_id_is_disconnected(&e->pid)) {
-               return false; /* Look at potential other entries */
-       }
-
        if (state->e->share_file_id == id) {
                DBG_INFO("Found more than one entry, invalidating previous\n");
                *state->e = (struct share_mode_entry) { .pid = { .pid = 0, }};
                return true;    /* end the loop through share mode entries */
        }
+
+       if (global->persistent) {
+               if (!(e->flags & SHARE_ENTRY_FLAG_PERSISTENT_OPEN)) {
+                       DBG_WARNING("Persistent not set on sharemode entry\n");
+                       return false;
+               }
+               if (serverid_exists(&e->pid)) {
+                       return false; /* Look at potential other entries */
+               }
+               if (!GUID_equal(&e->create_guid, &global->create_guid)) {
+                       return false; /* Look at potential other entries */
+               }
+               if (GUID_equal(&state->e->create_guid, &global->create_guid)) {
+                       DBG_INFO("Found more than one entry, "
+                                "invalidating previous\n");
+                       *state->e = (struct share_mode_entry) {
+                               .pid = { .pid = 0, },
+                       };
+                       return true; /* end the loop */
+               }
+               *state->e = *e;
+               return false; /* Look at potential other entries */
+       }
+
+       if (!server_id_is_disconnected(&e->pid)) {
+               return false; /* Look at potential other entries */
+       }
+
        *state->e = *e;
        return false;           /* Look at potential other entries */
 }