From 48c22170154e472fee7c13b1ffb03db141713fe7 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 5 Dec 2018 17:17:35 +0000 Subject: [PATCH] auto_id_prefix now defaults to 'auto-'. --- ChangeLog.txt | 1 + man/mosquitto.conf.5.xml | 2 +- mosquitto.conf | 3 ++- src/conf.c | 26 +++++++++++++++++++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index bb3fc58f..e2dd2e3a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,6 +4,7 @@ Broker features: - Improved general support for broker generated client ids. Removed libuuid dependency. +- auto_id_prefix now defaults to 'auto-'. Client library features: - Add mosquitto_subscribe_multiple() for sending subscriptions to multiple diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index fa9d1e86..ee240762 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -262,7 +262,7 @@ true, this option allows you to set a string that will be prefixed to the automatically generated client ids to aid visibility in - logs. Defaults to no prefix. + logs. Defaults to . Reloaded on reload signal. diff --git a/mosquitto.conf b/mosquitto.conf index fa332a24..d9456a68 100644 --- a/mosquitto.conf +++ b/mosquitto.conf @@ -89,7 +89,8 @@ # If allow_zero_length_clientid is true, this option allows you to set a prefix # to automatically generated client ids to aid visibility in logs. -#auto_id_prefix +# Defaults to 'auto-' +#auto_id_prefix auto- # This option allows persistent clients (those with clean session set to false) # to be removed if they do not reconnect within a certain time frame. diff --git a/src/conf.c b/src/conf.c index 00d30b2e..68da9929 100644 --- a/src/conf.c +++ b/src/conf.c @@ -2066,8 +2066,10 @@ static int config__check(struct mosquitto__config *config) { /* Checks that are easy to make after the config has been loaded. */ + int i; + #ifdef WITH_BRIDGE - int i, j; + int j; struct mosquitto__bridge *bridge1, *bridge2; char hostname[256]; int len; @@ -2115,6 +2117,28 @@ static int config__check(struct mosquitto__config *config) } } #endif + + /* Default to auto_id_prefix = 'auto-' if none set. */ + if(config->per_listener_settings){ + for(i=0; ilistener_count; i++){ + if(!config->listeners[i].security_options.auto_id_prefix){ + config->listeners[i].security_options.auto_id_prefix = mosquitto__strdup("auto-"); + if(!config->listeners[i].security_options.auto_id_prefix){ + return MOSQ_ERR_NOMEM; + } + config->listeners[i].security_options.auto_id_prefix_len = strlen("auto-"); + } + } + }else{ + if(!config->security_options.auto_id_prefix){ + config->security_options.auto_id_prefix = mosquitto__strdup("auto-"); + if(!config->security_options.auto_id_prefix){ + return MOSQ_ERR_NOMEM; + } + config->security_options.auto_id_prefix_len = strlen("auto-"); + } + } + return MOSQ_ERR_SUCCESS; }