From 692fa5537d4a57f70e243fd0758a9d3276a8ec65 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 30 Nov 2020 10:32:09 +0000 Subject: [PATCH] dynsec: Reply with error on add role fail. --- plugins/dynamic-security/clients.c | 5 ++++- plugins/dynamic-security/groups.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/dynamic-security/clients.c b/plugins/dynamic-security/clients.c index d74aea44..3708af2a 100644 --- a/plugins/dynamic-security/clients.c +++ b/plugins/dynamic-security/clients.c @@ -1058,7 +1058,10 @@ int dynsec_clients__process_add_role(cJSON *j_responses, struct mosquitto *conte return MOSQ_ERR_SUCCESS; } - dynsec_rolelist__client_add(client, role, priority); + if(dynsec_rolelist__client_add(client, role, priority) != MOSQ_ERR_SUCCESS){ + dynsec__command_reply(j_responses, context, "addClientRole", "Internal error", correlation_data); + return MOSQ_ERR_UNKNOWN; + } dynsec__config_save(); dynsec__command_reply(j_responses, context, "addClientRole", NULL, correlation_data); diff --git a/plugins/dynamic-security/groups.c b/plugins/dynamic-security/groups.c index c6d6a129..c4fa70b1 100644 --- a/plugins/dynamic-security/groups.c +++ b/plugins/dynamic-security/groups.c @@ -151,7 +151,10 @@ int dynsec_groups__process_add_role(cJSON *j_responses, struct mosquitto *contex mosquitto_log_printf(MOSQ_LOG_INFO, "dynsec: %s/%s | addGroupRole | groupname=%s | rolename=%s | priority=%d", admin_clientid, admin_username, groupname, rolename, priority); - dynsec_rolelist__group_add(group, role, priority); + if(dynsec_rolelist__group_add(group, role, priority) != MOSQ_ERR_SUCCESS){ + dynsec__command_reply(j_responses, context, "addGroupRole", "Internal error", correlation_data); + return MOSQ_ERR_UNKNOWN; + } dynsec__config_save(); dynsec__command_reply(j_responses, context, "addGroupRole", NULL, correlation_data);