From 68fbb7b5bb6d21d8784d58372137205b3240e981 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 25 Nov 2021 10:32:02 +0000 Subject: [PATCH] auth method needs persisting. --- include/mosquitto_broker.h | 2 ++ src/plugin_persist.c | 2 ++ src/plugin_public.c | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/include/mosquitto_broker.h b/include/mosquitto_broker.h index 310f0e16..6c6352b4 100644 --- a/include/mosquitto_broker.h +++ b/include/mosquitto_broker.h @@ -215,9 +215,11 @@ struct mosquitto_evt_persist_restore { struct mosquitto_evt_persist_client { const char *client_id; const char *username; + const char *auth_method; const struct mosquitto_message_v5 *will; char *plugin_client_id; char *plugin_username; + char *plugin_auth_method; struct mosquitto_message_v5 *plugin_will; time_t will_delay_time; /* update */ time_t session_expiry_time; /* update */ diff --git a/src/plugin_persist.c b/src/plugin_persist.c index 5a587f49..e3b8e608 100644 --- a/src/plugin_persist.c +++ b/src/plugin_persist.c @@ -57,6 +57,7 @@ void plugin_persist__handle_client_add(struct mosquitto *context) memset(&event_data, 0, sizeof(event_data)); event_data.client_id = context->id; event_data.username = context->username; + event_data.auth_method = context->auth_method; event_data.will_delay_time = context->will_delay_time; event_data.session_expiry_time = context->session_expiry_time; event_data.will_delay_interval = context->will_delay_interval; @@ -88,6 +89,7 @@ void plugin_persist__handle_client_update(struct mosquitto *context) memset(&event_data, 0, sizeof(event_data)); event_data.client_id = context->id; event_data.username = context->username; + event_data.auth_method = context->auth_method; event_data.will_delay_time = context->will_delay_time; event_data.session_expiry_time = context->session_expiry_time; event_data.will_delay_interval = context->will_delay_interval; diff --git a/src/plugin_public.c b/src/plugin_public.c index 67e0fac1..0f6004d1 100644 --- a/src/plugin_public.c +++ b/src/plugin_public.c @@ -413,6 +413,17 @@ int mosquitto_persist_client_add(const struct mosquitto_evt_persist_client *clie }else{ context->username = NULL; } + if(client->auth_method){ + context->auth_method = mosquitto__strdup(client->plugin_auth_method); + if(!context->auth_method){ + mosquitto__free(context->username); + mosquitto__free(context->id); + mosquitto__free(context); + return MOSQ_ERR_NOMEM; + } + }else{ + context->auth_method = NULL; + } context->clean_start = false; context->will_delay_time = client->will_delay_time; context->session_expiry_time = client->session_expiry_time;