diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index 2bcd5c17..07e3c39a 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -902,15 +902,6 @@ normal. - - id - - Set the client id for this bridge connection. If not - defined, this defaults to 'name.hostname', where name - is the connection name and hostname is the hostname of - this computer. - - name @@ -988,13 +979,41 @@ - value + id + + Set the client id for this bridge connection. If not + defined, this defaults to 'name.hostname', where name + is the connection name and hostname is the hostname of + this computer. + This replaces the old "clientid" option to avoid + confusion with local/remote sides of the bridge. + "clientid" remains valid for the time being. + + + + value Configure a password for the bridge. This is used for authentication purposes when connecting to a broker - that support MQTT v3.1 and requires a username and/or - password to connect. This option is only valid if a - username is also supplied. + that supports MQTT v3.1 and up and requires a username + and/or password to connect. This option is only valid + if a remote_username is also supplied. + This replaces the old "password" option to avoid + confusion with local/remote sides of the bridge. + "password" remains valid for the time being. + + + + name + + Configure a username for the bridge. This is used for + authentication purposes when connecting to a broker + that supports MQTT v3.1 and up and requires a username + and/or password to connect. See also the + option. + This replaces the old "username" option to avoid + confusion with local/remote sides of the bridge. + "username" remains valid for the time being. @@ -1172,16 +1191,6 @@ topic clients/total in 0 test/mosquitto/org $SYS/broker/ Defaults to true. - - name - - Configure a for the bridge. - This is used for authentication purposes when - connecting to a broker that support MQTT v3.1 and - requires a username and/or password to connect. See - also the option. - - SSL/TLS Support diff --git a/mosquitto.conf b/mosquitto.conf index c5c1c3cd..72b59458 100644 --- a/mosquitto.conf +++ b/mosquitto.conf @@ -626,7 +626,9 @@ # Set the client id to use on the remote end of this bridge connection. If not # defined, this defaults to 'name.hostname' where name is the connection name # and hostname is the hostname of this computer. -#clientid +# This replaces the old "clientid" option to avoid confusion. "clientid" +# remains valid for the time being. +#remote_clientid # Set the clientid to use on the local broker. If not defined, this defaults to # 'local.'. If you are bridging a broker to itself, it is important @@ -699,14 +701,17 @@ # properly. #try_private true -# Set the username to use when connecting to an MQTT v3.1 broker -# that requires authentication. -#username - -# Set the password to use when connecting to an MQTT v3.1 broker -# that requires authentication. This option is only used if -# username is also set. -#password +# Set the username to use when connecting to a broker that requires +# authentication. +# This replaces the old "username" option to avoid confusion. "username" +# remains valid for the time being. +#remote_username + +# Set the password to use when connecting to a broker that requires +# authentication. This option is only used if remote_username is also set. +# This replaces the old "password" option to avoid confusion. "password" +# remains valid for the time being. +#remote_password # Set the username to use on the local broker. #local_username diff --git a/src/bridge.c b/src/bridge.c index 6f277cf5..83bb438e 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -52,7 +52,7 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge) assert(db); assert(bridge); - if(!bridge->clientid){ + if(!bridge->remote_clientid){ if(!gethostname(hostname, 256)){ len = strlen(hostname) + strlen(bridge->name) + 2; id = _mosquitto_malloc(len); @@ -63,7 +63,7 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge) }else{ return 1; } - bridge->clientid = id; + bridge->remote_clientid = id; } if(bridge->local_clientid){ local_id = _mosquitto_strdup(bridge->local_clientid); @@ -71,12 +71,12 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge) return MOSQ_ERR_NOMEM; } }else{ - len = strlen(bridge->clientid) + strlen("local.") + 2; + len = strlen(bridge->remote_clientid) + strlen("local.") + 2; local_id = _mosquitto_malloc(len); if(!local_id){ return MOSQ_ERR_NOMEM; } - snprintf(local_id, len, "local.%s", bridge->clientid); + snprintf(local_id, len, "local.%s", bridge->remote_clientid); bridge->local_clientid = _mosquitto_strdup(local_id); if(!bridge->local_clientid){ _mosquitto_free(local_id); @@ -100,8 +100,8 @@ int mqtt3_bridge_new(struct mosquitto_db *db, struct _mqtt3_bridge *bridge) new_context->bridge = bridge; new_context->is_bridge = true; - new_context->username = new_context->bridge->username; - new_context->password = new_context->bridge->password; + new_context->username = new_context->bridge->remote_username; + new_context->password = new_context->bridge->remote_password; #ifdef WITH_TLS new_context->tls_cafile = new_context->bridge->tls_cafile; diff --git a/src/conf.c b/src/conf.c index 3203ba5f..7d121e1d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -249,9 +249,9 @@ void mqtt3_config_cleanup(struct mqtt3_config *config) } _mosquitto_free(config->bridges[i].addresses); } - if(config->bridges[i].clientid) _mosquitto_free(config->bridges[i].clientid); - if(config->bridges[i].username) _mosquitto_free(config->bridges[i].username); - if(config->bridges[i].password) _mosquitto_free(config->bridges[i].password); + if(config->bridges[i].remote_clientid) _mosquitto_free(config->bridges[i].remote_clientid); + if(config->bridges[i].remote_username) _mosquitto_free(config->bridges[i].remote_username); + if(config->bridges[i].remote_password) _mosquitto_free(config->bridges[i].remote_password); if(config->bridges[i].local_clientid) _mosquitto_free(config->bridges[i].local_clientid); if(config->bridges[i].local_username) _mosquitto_free(config->bridges[i].local_username); if(config->bridges[i].local_password) _mosquitto_free(config->bridges[i].local_password); @@ -931,7 +931,7 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char #else _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: TLS support not available."); #endif - }else if(!strcmp(token, "clientid")){ + }else if(!strcmp(token, "clientid") || !strcmp(token, "remote_clientid")){ #ifdef WITH_BRIDGE if(reload) continue; // FIXME if(!cur_bridge){ @@ -940,12 +940,12 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char } token = strtok_r(NULL, " ", &saveptr); if(token){ - if(cur_bridge->clientid){ + if(cur_bridge->remote_clientid){ _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate clientid value in bridge configuration."); return MOSQ_ERR_INVAL; } - cur_bridge->clientid = _mosquitto_strdup(token); - if(!cur_bridge->clientid){ + cur_bridge->remote_clientid = _mosquitto_strdup(token); + if(!cur_bridge->remote_clientid){ _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory"); return MOSQ_ERR_NOMEM; } @@ -1373,7 +1373,7 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char #else _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available."); #endif - }else if(!strcmp(token, "password")){ + }else if(!strcmp(token, "password") || !strcmp(token, "remote_password")){ #ifdef WITH_BRIDGE if(reload) continue; // FIXME if(!cur_bridge){ @@ -1382,12 +1382,12 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char } token = strtok_r(NULL, " ", &saveptr); if(token){ - if(cur_bridge->password){ + if(cur_bridge->remote_password){ _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate password value in bridge configuration."); return MOSQ_ERR_INVAL; } - cur_bridge->password = _mosquitto_strdup(token); - if(!cur_bridge->password){ + cur_bridge->remote_password = _mosquitto_strdup(token); + if(!cur_bridge->remote_password){ _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory"); return MOSQ_ERR_NOMEM; } @@ -1775,7 +1775,7 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char }else if(!strcmp(token, "user")){ if(reload) continue; // Drop privileges user not valid for reloading. if(_conf_parse_string(&token, "user", &config->user, saveptr)) return MOSQ_ERR_INVAL; - }else if(!strcmp(token, "username")){ + }else if(!strcmp(token, "username") || !strcmp(token, "remote_username")){ #ifdef WITH_BRIDGE if(reload) continue; // FIXME if(!cur_bridge){ @@ -1784,12 +1784,12 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char } token = strtok_r(NULL, " ", &saveptr); if(token){ - if(cur_bridge->username){ + if(cur_bridge->remote_username){ _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate username value in bridge configuration."); return MOSQ_ERR_INVAL; } - cur_bridge->username = _mosquitto_strdup(token); - if(!cur_bridge->username){ + cur_bridge->remote_username = _mosquitto_strdup(token); + if(!cur_bridge->remote_username){ _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory"); return MOSQ_ERR_NOMEM; } diff --git a/src/context.c b/src/context.c index 66c0d919..38365918 100644 --- a/src/context.c +++ b/src/context.c @@ -114,11 +114,11 @@ void mqtt3_context_cleanup(struct mosquitto_db *db, struct mosquitto *context, b _mosquitto_free(context->bridge->local_clientid); context->bridge->local_clientid = NULL; } - if(context->bridge->username){ - context->bridge->username = NULL; + if(context->bridge->remote_username){ + context->bridge->remote_username = NULL; } - if(context->bridge->password){ - context->bridge->password = NULL; + if(context->bridge->remote_password){ + context->bridge->remote_password = NULL; } if(context->bridge->local_username){ context->bridge->local_username = NULL; diff --git a/src/mosquitto_broker.h b/src/mosquitto_broker.h index b54868b9..10cf8288 100644 --- a/src/mosquitto_broker.h +++ b/src/mosquitto_broker.h @@ -260,15 +260,15 @@ struct _mqtt3_bridge{ int address_count; time_t primary_retry; bool round_robin; - char *clientid; int keepalive; bool clean_session; struct _mqtt3_bridge_topic *topics; int topic_count; bool topic_remapping; time_t restart_t; - char *username; - char *password; + char *remote_clientid; + char *remote_username; + char *remote_password; char *local_clientid; char *local_username; char *local_password;