From: Ralph Boehme Date: Tue, 2 Dec 2025 18:49:01 +0000 (+0100) Subject: vfs_default: adapt share_mode_entry_durable_reconnect_fn() for Persistent Handles X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ddc16c2763e1afc583f4588dc8ef3e10293140f;p=thirdparty%2Fsamba.git vfs_default: adapt share_mode_entry_durable_reconnect_fn() for Persistent Handles Additionally check the create_guid. We could also do this for Durable Handles v2 if we wanted to. Signed-off-by: Ralph Boehme Reviewed-by: Anoop C S --- diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index cbc39bc05ac..5d153babf2c 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -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 */ }