From: Ralph Boehme Date: Tue, 17 Jun 2025 14:59:07 +0000 (+0200) Subject: smbd: also delete replay cache record in smbXsrv_open_cleanup() X-Git-Tag: tdb-1.4.14~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26ee66860795d2a9bdf0763517b84fba0bbe8c30;p=thirdparty%2Fsamba.git smbd: also delete replay cache record in smbXsrv_open_cleanup() Add and use smbXsrv_replay_cleanup() to delete replay cache records. Another external caller comes later, hence adding this as a public function. Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/source3/smbd/smbXsrv_open.c b/source3/smbd/smbXsrv_open.c index 275b332d005..79b7fc17772 100644 --- a/source3/smbd/smbXsrv_open.c +++ b/source3/smbd/smbXsrv_open.c @@ -1510,6 +1510,8 @@ NTSTATUS smbXsrv_open_global_traverse( struct smbXsrv_open_cleanup_state { uint32_t global_id; + struct GUID client_guid; + struct GUID create_guid; NTSTATUS status; }; @@ -1594,6 +1596,8 @@ do_delete: state->global_id, dbwrap_name(dbwrap_record_get_db(rec))); state->status = NT_STATUS_OK; + state->client_guid = global->client_guid; + state->create_guid = global->create_guid; } NTSTATUS smbXsrv_open_cleanup(uint64_t persistent_id) @@ -1618,5 +1622,40 @@ NTSTATUS smbXsrv_open_cleanup(uint64_t persistent_id) return status; } - return state.status; + if (!NT_STATUS_IS_OK(state.status)) { + return state.status; + } + + if (GUID_all_zero(&state.create_guid)) { + return NT_STATUS_OK; + } + status = smbXsrv_replay_cleanup(&state.client_guid, &state.create_guid); + if (!NT_STATUS_IS_OK(status)) { + DBG_DEBUG("Failed to remove replay record\n"); + return status; + } + + return NT_STATUS_OK; +} + +NTSTATUS smbXsrv_replay_cleanup(const struct GUID *client_guid, + const struct GUID *create_guid) +{ + struct smbXsrv_open_replay_cache_key_buf rc_key_buf; + TDB_DATA key; + NTSTATUS status; + + key = smbXsrv_open_replay_cache_key(client_guid, + create_guid, + &rc_key_buf); + + status = dbwrap_purge(smbXsrv_open_global_db_ctx, key); + if (!NT_STATUS_IS_OK(status)) { + struct GUID_txt_buf create_guid_buf; + DBG_ERR("create_guid [%s] purge replay-cache " + "record failed: %s\n", + GUID_buf_string(create_guid, &create_guid_buf), + nt_errstr(status)); + } + return status; } diff --git a/source3/smbd/smbXsrv_open.h b/source3/smbd/smbXsrv_open.h index c09aa0d9b96..f5dc1804d3a 100644 --- a/source3/smbd/smbXsrv_open.h +++ b/source3/smbd/smbXsrv_open.h @@ -76,5 +76,7 @@ NTSTATUS smbXsrv_open_global_traverse( void *private_data); NTSTATUS smbXsrv_open_cleanup(uint64_t persistent_id); +NTSTATUS smbXsrv_replay_cleanup(const struct GUID *client_guid, + const struct GUID *create_guid); #endif