From f9fa19ce6a8f79d4d73c039a7e6aea5db05e6d83 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 10 Aug 2022 15:11:52 +0100 Subject: [PATCH] - Fix `-o` not working in `mosquitto_ctrl`, and typo in related documentation. Closes #2471. Thanks to Vitaljok and rillbert --- ChangeLog.txt | 5 +++++ apps/mosquitto_ctrl/options.c | 9 +++++---- www/pages/documentation/dynamic-security.md | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index f84d38c9b8..6e2376e0f5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -33,6 +33,11 @@ Clients: - Fix mosquitto_pub incorrectly reusing topic aliases when reconnecting. Closes #2494. +Apps: +- Fix `-o` not working in `mosquitto_ctrl`, and typo in related documentation. + Closes #2471. + + 2.0.14 - 2021-11-17 =================== diff --git a/apps/mosquitto_ctrl/options.c b/apps/mosquitto_ctrl/options.c index 5c36e5db6f..592d9e8c5f 100644 --- a/apps/mosquitto_ctrl/options.c +++ b/apps/mosquitto_ctrl/options.c @@ -89,13 +89,14 @@ int ctrl_config_parse(struct mosq_config *cfg, int *argc, char **argv[]) init_config(cfg); - rc = client_config_load(cfg); - if(rc) return rc; - /* Deal with real argc/argv */ rc = client_config_line_proc(cfg, argc, argv); if(rc) return rc; + /* Load options from config file - this must be after `-o` has been processed */ + rc = client_config_load(cfg); + if(rc) return rc; + #ifdef WITH_TLS if((cfg->certfile && !cfg->keyfile) || (cfg->keyfile && !cfg->certfile)){ fprintf(stderr, "Error: Both certfile and keyfile must be provided if one of them is set.\n"); @@ -531,7 +532,7 @@ int client_config_load(struct mosq_config *cfg) fclose(fptr); return 1; } - while(fgets(line, 1024, fptr)){ + while(fgets(line, sizeof(line), fptr)){ if(line[0] == '#') continue; /* Comments */ while(line[strlen(line)-1] == 10 || line[strlen(line)-1] == 13){ diff --git a/www/pages/documentation/dynamic-security.md b/www/pages/documentation/dynamic-security.md index a84f8589b1..b3550ac11a 100644 --- a/www/pages/documentation/dynamic-security.md +++ b/www/pages/documentation/dynamic-security.md @@ -389,9 +389,9 @@ admin username and any other options once and not have to add them to the command line every time. mosquitto_ctrl will try to load a configuration file from a default location. -For Windows this is at `%USER_PROFILE%\mosquitto_ctrl.conf`. For other systems, -it will try `$XDG_CONFIG_HOME/mosquitto_ctrl.conf` or -`$HOME/.config/mosquitto_ctrl.conf`. +For Windows this is at `%USER_PROFILE%\mosquitto_ctrl`. For other systems, +it will try `$XDG_CONFIG_HOME/mosquitto_ctrl` or +`$HOME/.config/mosquitto_ctrl`. You may override this behaviour by manually specifying an options file with `-o `.