From 77af2ecefe7aca8df89bd1515fc847a3c0fa106a Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 30 Aug 2021 22:28:51 +0100 Subject: [PATCH] Fix `mosquitto_ctrl dynsec setDefaultACLAccess` command not working. --- ChangeLog.txt | 3 +++ apps/mosquitto_ctrl/dynsec.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 8ec8b65b..6e2484c3 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -51,6 +51,9 @@ Client library: - Threaded mode is deconfigured when the mosquitto_loop_start() thread ends, which allows mosquitto_loop_start() to be called again. Closes #2242. +Apps: +- Fix `mosquitto_ctrl dynsec setDefaultACLAccess` command not working. + Clients: - mosquitto_sub and mosquitto_rr now open stdout in binary mode on Windows so binary payloads are not modified when printing. diff --git a/apps/mosquitto_ctrl/dynsec.c b/apps/mosquitto_ctrl/dynsec.c index a8a6a9d1..052597e2 100644 --- a/apps/mosquitto_ctrl/dynsec.c +++ b/apps/mosquitto_ctrl/dynsec.c @@ -455,6 +455,7 @@ static void dynsec__payload_callback(struct mosq_ctrl *ctrl, long payloadlen, co static int dynsec__set_default_acl_access(int argc, char *argv[], cJSON *j_command) { char *acltype, *access; + bool b_access; cJSON *j_acls, *j_acl; if(argc == 2){ @@ -472,7 +473,11 @@ static int dynsec__set_default_acl_access(int argc, char *argv[], cJSON *j_comma return MOSQ_ERR_INVAL; } - if(strcasecmp(access, "allow") && strcasecmp(access, "deny")){ + if(!strcasecmp(access, "allow")){ + b_access = true; + }else if(!strcasecmp(access, "deny")){ + b_access = false; + }else{ fprintf(stderr, "Error: access must be \"allow\" or \"deny\".\n"); return MOSQ_ERR_INVAL; } @@ -490,7 +495,7 @@ static int dynsec__set_default_acl_access(int argc, char *argv[], cJSON *j_comma } cJSON_AddItemToArray(j_acls, j_acl); if(cJSON_AddStringToObject(j_acl, "acltype", acltype) == NULL - || cJSON_AddStringToObject(j_acl, "access", access) == NULL + || cJSON_AddBoolToObject(j_acl, "allow", b_access) == NULL ){ return MOSQ_ERR_NOMEM;