From 03721ccd93f1394f2be56adeabd1461427ed24d9 Mon Sep 17 00:00:00 2001 From: Gavin Sherry Date: Tue, 14 Mar 2017 10:58:07 -0700 Subject: [PATCH 01/28] Fix typo Signed-off-by: Gavin Sherry --- mosquitto.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mosquitto.conf b/mosquitto.conf index f0e14023..e8a19bb3 100644 --- a/mosquitto.conf +++ b/mosquitto.conf @@ -220,7 +220,7 @@ #crlfile # If you wish to control which encryption ciphers are used, use the ciphers -# option. The list of available ciphers can be optained using the "openssl +# option. The list of available ciphers can be obtained using the "openssl # ciphers" command and should be provided in the same format as the output of # that command. # If unset defaults to DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH @@ -253,7 +253,7 @@ # When using PSK, the encryption ciphers used will be chosen from the list of # available PSK ciphers. If you want to control which ciphers are available, -# use the "ciphers" option. The list of available ciphers can be optained +# use the "ciphers" option. The list of available ciphers can be obtained # using the "openssl ciphers" command and should be provided in the same format # as the output of that command. #ciphers From 58757639d21217f6fce5860fbe0d1383fcbb90a2 Mon Sep 17 00:00:00 2001 From: Srikanth Anantharam Date: Wed, 19 Jul 2017 04:35:08 +0530 Subject: [PATCH 02/28] added missing information to the mosquitto-tls manpage (#479) Signed-off-by: Srikanth Anantharam --- man/mosquitto-tls.7.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/man/mosquitto-tls.7.xml b/man/mosquitto-tls.7.xml index 1fa40f7f..ab0124f5 100644 --- a/man/mosquitto-tls.7.xml +++ b/man/mosquitto-tls.7.xml @@ -50,6 +50,7 @@ openssl req -out server.csr -key server.key -new + When prompted for the CN (Common Name), please enter either your server (or broker) hostname or domain name. Send the CSR to the CA, or sign it with your CA key: From 88f72f3f14127124c9e80c9bb9830f5154a8782f Mon Sep 17 00:00:00 2001 From: Srikanth Anantharam Date: Wed, 19 Jul 2017 04:35:48 +0530 Subject: [PATCH 03/28] fixed a typo in the manpage (#476) Signed-off-by: Srikanth Anantharam --- man/mosquitto_passwd.1.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/mosquitto_passwd.1.xml b/man/mosquitto_passwd.1.xml index 95b3c130..5f144bf9 100644 --- a/man/mosquitto_passwd.1.xml +++ b/man/mosquitto_passwd.1.xml @@ -41,7 +41,7 @@ Description mosquitto_passwd is a tool for managing - password files the mosquitto MQTT broker. + password files for the mosquitto MQTT broker. Usernames must not contain ":". Passwords are stored in a similar format to crypt3. From 53c71b2a77af0f34c756e101a681efc27ad80732 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 26 Jul 2017 23:25:49 +0100 Subject: [PATCH 04/28] Fix memory leak related to use_identity_as_username. --- ChangeLog.txt | 2 ++ src/read_handle_server.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9f471d92..8f56cd4f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,8 @@ Broker: - Use constant time memcmp for password comparisons. - Fix incorrect PSK key being used if it had leading zeroes. +- Fix memory leak if a client provided a username/password for a listener with + use_identity_as_username configured. Client library: - Fix incorrect PSK key being used if it had leading zeroes. diff --git a/src/read_handle_server.c b/src/read_handle_server.c index 6be6a250..a16f2057 100644 --- a/src/read_handle_server.c +++ b/src/read_handle_server.c @@ -336,6 +336,12 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context) #ifdef WITH_TLS if(context->listener && context->listener->ssl_ctx && context->listener->use_identity_as_username){ + /* Don't need the username or password if provided */ + _mosquitto_free(username); + username = NULL; + _mosquitto_free(password); + password = NULL; + if(!context->ssl){ _mosquitto_send_connack(context, 0, CONNACK_REFUSED_BAD_USERNAME_PASSWORD); rc = 1; From 7943072b1f3bf68e820655408ec4ecb73fd8a3d9 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 26 Jul 2017 23:27:04 +0100 Subject: [PATCH 05/28] Fix use_identity_as_username not working on websockets clients. Thanks to achest. --- ChangeLog.txt | 1 + src/conf.c | 7 +++++-- src/websockets.c | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 8f56cd4f..0110aede 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,6 +3,7 @@ Broker: - Fix incorrect PSK key being used if it had leading zeroes. - Fix memory leak if a client provided a username/password for a listener with use_identity_as_username configured. +- Fix use_identity_as_username not working on websockets clients. Client library: - Fix incorrect PSK key being used if it had leading zeroes. diff --git a/src/conf.c b/src/conf.c index a3e233de..9affc29d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -240,10 +240,13 @@ void mqtt3_config_cleanup(struct mqtt3_config *config) if(config->listeners[i].psk_hint) _mosquitto_free(config->listeners[i].psk_hint); if(config->listeners[i].crlfile) _mosquitto_free(config->listeners[i].crlfile); if(config->listeners[i].tls_version) _mosquitto_free(config->listeners[i].tls_version); - if(config->listeners[i].ssl_ctx) SSL_CTX_free(config->listeners[i].ssl_ctx); -#endif #ifdef WITH_WEBSOCKETS if(config->listeners[i].http_dir) _mosquitto_free(config->listeners[i].http_dir); + if(!config->listeners[i].ws_context) /* libwebsockets frees its own SSL_CTX */ +#endif + { + SSL_CTX_free(config->listeners[i].ssl_ctx); + } #endif } _mosquitto_free(config->listeners); diff --git a/src/websockets.c b/src/websockets.c index dde0c9cc..5fdf12b3 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -201,6 +201,12 @@ static int callback_mqtt(struct libwebsocket_context *context, mosq->ws_context = context; #endif mosq->wsi = wsi; + if(in){ + mosq->ssl = (SSL *)in; + if(!mosq->listener->ssl_ctx){ + mosq->listener->ssl_ctx = SSL_get_SSL_CTX(mosq->ssl); + } + } u->mosq = mosq; }else{ return -1; @@ -234,6 +240,7 @@ static int callback_mqtt(struct libwebsocket_context *context, mosq->pollfd_index = -1; } mosq->wsi = NULL; + mosq->ssl = NULL; do_disconnect(db, mosq); } break; From 22063013be1ef96756c3d55f3f48706ff05be826 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 27 Jul 2017 00:12:32 +0100 Subject: [PATCH 06/28] [490] Fix auth plugin+WS client+MOSQ_ERR_AUTH related crash. Thanks to "hasunperera". Bug: https://github.com/eclipse/mosquitto/issues/490 --- ChangeLog.txt | 2 ++ lib/net_mosq.c | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0110aede..152e634f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,6 +4,8 @@ Broker: - Fix memory leak if a client provided a username/password for a listener with use_identity_as_username configured. - Fix use_identity_as_username not working on websockets clients. +- Don't crash if an auth plugin returns MOSQ_ERR_AUTH for a username check on + a websockets client. Closes #490. Client library: - Fix incorrect PSK key being used if it had leading zeroes. diff --git a/lib/net_mosq.c b/lib/net_mosq.c index 063c4a22..c51749c3 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -214,14 +214,19 @@ int _mosquitto_socket_close(struct mosquitto *mosq) assert(mosq); #ifdef WITH_TLS - if(mosq->ssl){ - SSL_shutdown(mosq->ssl); - SSL_free(mosq->ssl); - mosq->ssl = NULL; - } - if(mosq->ssl_ctx){ - SSL_CTX_free(mosq->ssl_ctx); - mosq->ssl_ctx = NULL; +#ifdef WITH_WEBSOCKETS + if(!mosq->wsi) +#endif + { + if(mosq->ssl){ + SSL_shutdown(mosq->ssl); + SSL_free(mosq->ssl); + mosq->ssl = NULL; + } + if(mosq->ssl_ctx){ + SSL_CTX_free(mosq->ssl_ctx); + mosq->ssl_ctx = NULL; + } } #endif From 124ee1af914c8d8f7f5b28863d0fd6908247c7f5 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 27 Jul 2017 14:56:10 +0100 Subject: [PATCH 07/28] [490] Further fix for auth related crashes. Bug: https://github.com/eclipse/mosquitto/issues/490 --- lib/net_mosq.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/net_mosq.c b/lib/net_mosq.c index c51749c3..9684b224 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -230,22 +230,23 @@ int _mosquitto_socket_close(struct mosquitto *mosq) } #endif - if((int)mosq->sock >= 0){ -#ifdef WITH_BROKER - HASH_DELETE(hh_sock, db->contexts_by_sock, mosq); -#endif - rc = COMPAT_CLOSE(mosq->sock); - mosq->sock = INVALID_SOCKET; #ifdef WITH_WEBSOCKETS - }else if(mosq->sock == WEBSOCKET_CLIENT){ + if(mosq->wsi) + { if(mosq->state != mosq_cs_disconnecting){ mosq->state = mosq_cs_disconnect_ws; } - if(mosq->wsi){ - libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi); - } - mosq->sock = INVALID_SOCKET; + libwebsocket_callback_on_writable(mosq->ws_context, mosq->wsi); + }else #endif + { + if((int)mosq->sock >= 0){ +#ifdef WITH_BROKER + HASH_DELETE(hh_sock, db->contexts_by_sock, mosq); +#endif + rc = COMPAT_CLOSE(mosq->sock); + mosq->sock = INVALID_SOCKET; + } } #ifdef WITH_BROKER From a480a9daf90cffe2b7c92c6b62ded579e96971a0 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 30 Jul 2017 11:35:45 +0100 Subject: [PATCH 08/28] Fix 08-ssl-bridge.py test when using async dns lookups. Thanks to Tatsuzo Osawa. Bug: https://github.com/eclipse/mosquitto/issues/507 --- ChangeLog.txt | 1 + test/broker/08-ssl-bridge.conf | 1 + 2 files changed, 2 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 152e634f..741b53e8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -6,6 +6,7 @@ Broker: - Fix use_identity_as_username not working on websockets clients. - Don't crash if an auth plugin returns MOSQ_ERR_AUTH for a username check on a websockets client. Closes #490. +- Fix 08-ssl-bridge.py test when using async dns lookups. Closes #507. Client library: - Fix incorrect PSK key being used if it had leading zeroes. diff --git a/test/broker/08-ssl-bridge.conf b/test/broker/08-ssl-bridge.conf index fc2c17b5..ec057b66 100644 --- a/test/broker/08-ssl-bridge.conf +++ b/test/broker/08-ssl-bridge.conf @@ -4,6 +4,7 @@ connection bridge_test address localhost:1888 topic bridge/# both 0 notifications false +restart_timeout 2 #bridge_cafile ../ssl/test-root-ca.crt bridge_cafile ../ssl/all-ca.crt From 355bb37ab9a86e1b600b89a8d4cd67a68ddbfbe3 Mon Sep 17 00:00:00 2001 From: Tatsuzo Osawa Date: Fri, 4 Aug 2017 00:11:15 +0000 Subject: [PATCH 09/28] Fix 08-ssl-bridge.conf to dial localhost by ipv4. Signed-off-by: Tatsuzo Osawa --- test/broker/08-ssl-bridge.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/broker/08-ssl-bridge.conf b/test/broker/08-ssl-bridge.conf index ec057b66..763546e1 100644 --- a/test/broker/08-ssl-bridge.conf +++ b/test/broker/08-ssl-bridge.conf @@ -1,7 +1,7 @@ port 1889 connection bridge_test -address localhost:1888 +address 127.0.0.1:1888 topic bridge/# both 0 notifications false restart_timeout 2 From d2118aeb17309efa3d5f2bec12b0c845e5b15a94 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 3 Dec 2017 21:20:40 +0000 Subject: [PATCH 10/28] [636] Don't run TLS-PSK tests when disabled at compile time. Thanks to 'TBK'. Bug: https://github.com/eclipse/mosquitto/issues/636 --- ChangeLog.txt | 3 +++ test/broker/Makefile | 2 ++ 2 files changed, 5 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 741b53e8..7072ae3a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -11,6 +11,9 @@ Broker: Client library: - Fix incorrect PSK key being used if it had leading zeroes. +Build: +- Don't run TLS-PSK tests if TLS-PSK disabled at compile time. Closes #636. + 1.4.14 - 20170710 ================= diff --git a/test/broker/Makefile b/test/broker/Makefile index 45f08b2e..a8a63a53 100644 --- a/test/broker/Makefile +++ b/test/broker/Makefile @@ -89,9 +89,11 @@ ifeq ($(WITH_TLS),yes) ./08-ssl-connect-identity.py ./08-ssl-connect-no-identity.py ./08-ssl-bridge.py +ifeq ($(WITH_TLS_PSK),yes) ./08-tls-psk-pub.py ./08-tls-psk-bridge.py endif +endif 09 : ./09-plugin-auth-unpwd-success.py From 7f82cdc753483eb053e595f84de3975e3b42deac Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 20 Dec 2017 11:00:16 +0000 Subject: [PATCH 11/28] [652] Don't limit config file lines to 1024 chars. Bug: https://github.com/eclipse/mosquitto/issues/652 --- ChangeLog.txt | 2 ++ src/conf.c | 56 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7072ae3a..d356c85e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,8 @@ Broker: - Don't crash if an auth plugin returns MOSQ_ERR_AUTH for a username check on a websockets client. Closes #490. - Fix 08-ssl-bridge.py test when using async dns lookups. Closes #507. +- Lines in the config file are no longer limited to 1024 characters long. + Closes #652. Client library: - Fix incorrect PSK key being used if it had leading zeroes. diff --git a/src/conf.c b/src/conf.c index 9affc29d..274140a3 100644 --- a/src/conf.c +++ b/src/conf.c @@ -64,6 +64,35 @@ static int _conf_parse_int(char **token, const char *name, int *value, char *sav static int _conf_parse_string(char **token, const char *name, char **value, char *saveptr); static int _config_read_file(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *config_tmp, int level, int *lineno); +static char *fgets_extending(char **buf, int *buflen, FILE *stream) +{ + char *rc; + char endchar; + int offset = 0; + char *newbuf; + + do{ + rc = fgets(&((*buf)[offset]), *buflen-offset, stream); + if(feof(stream)){ + return rc; + } + + endchar = (*buf)[strlen(*buf)-1]; + if(endchar == '\n'){ + return rc; + } + /* No EOL char found, so extend buffer */ + offset = *buflen-1; + *buflen += 1000; + newbuf = realloc(*buf, *buflen); + if(!newbuf){ + return NULL; + } + *buf = newbuf; + }while(1); +} + + static int _conf_attempt_resolve(const char *host, const char *text, int log, const char *msg) { struct addrinfo gai_hints; @@ -540,10 +569,9 @@ int mqtt3_config_read(struct mqtt3_config *config, bool reload) return MOSQ_ERR_SUCCESS; } -int _config_read_file_core(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno, FILE *fptr) +int _config_read_file_core(struct mqtt3_config *config, bool reload, const char *file, struct config_recurse *cr, int level, int *lineno, FILE *fptr, char **buf, int *buflen) { int rc; - char buf[1024]; char *token; int tmp_int; char *saveptr = NULL; @@ -572,13 +600,13 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char *lineno = 0; - while(fgets(buf, 1024, fptr)){ + while(fgets_extending(buf, buflen, fptr)){ (*lineno)++; - if(buf[0] != '#' && buf[0] != 10 && buf[0] != 13){ - while(buf[strlen(buf)-1] == 10 || buf[strlen(buf)-1] == 13){ - buf[strlen(buf)-1] = 0; + if((*buf)[0] != '#' && (*buf)[0] != 10 && (*buf)[0] != 13){ + while((*buf)[strlen((*buf))-1] == 10 || (*buf)[strlen((*buf))-1] == 13){ + (*buf)[strlen((*buf))-1] = 0; } - token = strtok_r(buf, " ", &saveptr); + token = strtok_r((*buf), " ", &saveptr); if(token){ if(!strcmp(token, "acl_file")){ if(reload){ @@ -1016,7 +1044,7 @@ int _config_read_file_core(struct mqtt3_config *config, bool reload, const char snprintf(conf_file, len, "%s\\%s", token, find_data.cFileName); conf_file[len] = '\0'; - rc = _config_read_file(config, reload, conf_file, cr, level+1, &lineno_ext); + rc = _config_read_file(config, reload, conf_file, cr, level+1, &lineno_ext, buf, buflen); if(rc){ FindClose(fh); _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error found at %s:%d.", conf_file, lineno_ext); @@ -1768,6 +1796,8 @@ int _config_read_file(struct mqtt3_config *config, bool reload, const char *file { int rc; FILE *fptr = NULL; + char *buf; + int buflen; fptr = _mosquitto_fopen(file, "rt", false); if(!fptr){ @@ -1775,7 +1805,15 @@ int _config_read_file(struct mqtt3_config *config, bool reload, const char *file return 1; } - rc = _config_read_file_core(config, reload, file, cr, level, lineno, fptr); + buflen = 1000; + buf = _mosquitto_malloc(buflen); + if(!buf){ + _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory."); + return MOSQ_ERR_NOMEM; + } + + rc = _config_read_file_core(config, reload, file, cr, level, lineno, fptr, &buf, &buflen); + _mosquitto_free(buf); fclose(fptr); return rc; From ae666b07ce38d3dea536b12bcfc001fd4250d86b Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 21 Dec 2017 08:36:58 +0000 Subject: [PATCH 12/28] [654] Initialise "result" in mosquitto_topic_matches_sub. Thanks to markhermelinggt. Bug: https://github.com/eclipse/mosquitto/issues/654 --- ChangeLog.txt | 2 ++ lib/util_mosq.c | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index d356c85e..d77a54fc 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -12,6 +12,8 @@ Broker: Client library: - Fix incorrect PSK key being used if it had leading zeroes. +- Initialise "result" variable as soon as possible in + mosquitto_topic_matches_sub. Closes #654. Build: - Don't run TLS-PSK tests if TLS-PSK disabled at compile time. Closes #636. diff --git a/lib/util_mosq.c b/lib/util_mosq.c index 55e65e9e..6469dfad 100644 --- a/lib/util_mosq.c +++ b/lib/util_mosq.c @@ -228,13 +228,17 @@ int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result int spos, tpos; bool multilevel_wildcard = false; - if(!sub || !topic || !result) return MOSQ_ERR_INVAL; + if(!result) return MOSQ_ERR_INVAL; + *result = false; + + if(!sub || !topic){ + return MOSQ_ERR_INVAL; + } slen = strlen(sub); tlen = strlen(topic); if(!slen || !tlen){ - *result = false; return MOSQ_ERR_INVAL; } @@ -242,7 +246,6 @@ int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result if((sub[0] == '$' && topic[0] != '$') || (topic[0] == '$' && sub[0] != '$')){ - *result = false; return MOSQ_ERR_SUCCESS; } } @@ -269,7 +272,6 @@ int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result return MOSQ_ERR_SUCCESS; }else if(tpos == tlen && spos == slen-1 && sub[spos] == '+'){ if(spos > 0 && sub[spos-1] != '/'){ - *result = false; return MOSQ_ERR_INVAL; } spos++; @@ -280,12 +282,10 @@ int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result if(sub[spos] == '+'){ /* Check for bad "+foo" or "a/+foo" subscription */ if(spos > 0 && sub[spos-1] != '/'){ - *result = false; return MOSQ_ERR_INVAL; } /* Check for bad "foo+" or "foo+/a" subscription */ if(spos < slen-1 && sub[spos+1] != '/'){ - *result = false; return MOSQ_ERR_INVAL; } spos++; @@ -298,19 +298,16 @@ int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result } }else if(sub[spos] == '#'){ if(spos > 0 && sub[spos-1] != '/'){ - *result = false; return MOSQ_ERR_INVAL; } multilevel_wildcard = true; if(spos+1 != slen){ - *result = false; return MOSQ_ERR_INVAL; }else{ *result = true; return MOSQ_ERR_SUCCESS; } }else{ - *result = false; return MOSQ_ERR_SUCCESS; } } From b193918ca076b0615cb0d49ecee069cd732f7026 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 21 Dec 2017 21:56:01 +0000 Subject: [PATCH 13/28] [649] Don't close socket again if nonblock fails. Thanks to Edwin van den Oetelaar. Bug: https://github.com/eclipse/mosquitto/issues/649 --- ChangeLog.txt | 1 + lib/net_mosq.c | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index d77a54fc..7c7ff363 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -14,6 +14,7 @@ Client library: - Fix incorrect PSK key being used if it had leading zeroes. - Initialise "result" variable as soon as possible in mosquitto_topic_matches_sub. Closes #654. +- No need to close socket again if setting non-blocking failed. Closes #649. Build: - Don't run TLS-PSK tests if TLS-PSK disabled at compile time. Closes #636. diff --git a/lib/net_mosq.c b/lib/net_mosq.c index 9684b224..e8097b6d 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -329,7 +329,6 @@ int _mosquitto_try_connect_step2(struct mosquitto *mosq, uint16_t port, mosq_soc /* Set non-blocking */ if(_mosquitto_socket_nonblock(*sock)){ - COMPAT_CLOSE(*sock); continue; } @@ -344,7 +343,6 @@ int _mosquitto_try_connect_step2(struct mosquitto *mosq, uint16_t port, mosq_soc /* Set non-blocking */ if(_mosquitto_socket_nonblock(*sock)){ - COMPAT_CLOSE(*sock); continue; } break; @@ -429,7 +427,6 @@ int _mosquitto_try_connect(struct mosquitto *mosq, const char *host, uint16_t po if(!blocking){ /* Set non-blocking */ if(_mosquitto_socket_nonblock(*sock)){ - COMPAT_CLOSE(*sock); continue; } } @@ -446,7 +443,6 @@ int _mosquitto_try_connect(struct mosquitto *mosq, const char *host, uint16_t po if(blocking){ /* Set non-blocking */ if(_mosquitto_socket_nonblock(*sock)){ - COMPAT_CLOSE(*sock); continue; } } @@ -1250,7 +1246,6 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW) continue; } if(_mosquitto_socket_nonblock(spR)){ - COMPAT_CLOSE(spR); COMPAT_CLOSE(listensock); continue; } @@ -1278,7 +1273,6 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW) if(_mosquitto_socket_nonblock(spW)){ COMPAT_CLOSE(spR); - COMPAT_CLOSE(spW); COMPAT_CLOSE(listensock); continue; } @@ -1296,13 +1290,11 @@ int _mosquitto_socketpair(mosq_sock_t *pairR, mosq_sock_t *pairW) return MOSQ_ERR_ERRNO; } if(_mosquitto_socket_nonblock(sv[0])){ - COMPAT_CLOSE(sv[0]); COMPAT_CLOSE(sv[1]); return MOSQ_ERR_ERRNO; } if(_mosquitto_socket_nonblock(sv[1])){ COMPAT_CLOSE(sv[0]); - COMPAT_CLOSE(sv[1]); return MOSQ_ERR_ERRNO; } *pairR = sv[0]; From 71a748e1c4430e98c377997397a9df18cc188e53 Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Fri, 29 Dec 2017 13:50:05 +0100 Subject: [PATCH 14/28] Remove duplicated bridge_attempt_unsubscribe option Signed-off-by: Pierre Fersing --- man/mosquitto.conf.5.xml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index 37614dd4..077a4d69 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -1295,21 +1295,6 @@ topic clients/total in 0 test/mosquitto/org $SYS/broker/ The following options are available for all bridges to configure SSL/TLS support. - - [ true | false ] - - If a bridge has topics that have "out" direction, - the default behaviour is to send an unsubscribe - request to the remote broker on that topic. This - means that changing a topic direction from "in" to - "out" will not keep receiving incoming messages. - Sending these unsubscribe requests is not always - desirable, setting - to - false will disable - sending the unsubscribe request. - - file path From 94ae09589592f06664d96aef4359c0ef9821eb9d Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Fri, 29 Dec 2017 13:54:08 +0100 Subject: [PATCH 15/28] Update man page for "remote_clientid" Fix occurent of old "clientid" option which was renamed in "remote_clientid". Signed-off-by: Pierre Fersing --- man/mosquitto.conf.5.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index 077a4d69..b291184c 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -1031,9 +1031,9 @@ Set the clientid to use on the local broker. If not defined, this defaults to - . If you are + . If you are bridging a broker to itself, it is important that - local_clientid and clientid do not match. + local_clientid and remote_clientid do not match. @@ -1059,7 +1059,7 @@ notification messages to the local and remote brokers giving information about the state of the bridge connection. Retained messages are published to the - topic $SYS/broker/connection/<clientid>/state + topic $SYS/broker/connection/<remote_clientid>/state unless otherwise set with s. If the message is 1 then the connection is active, or 0 if the @@ -1073,7 +1073,7 @@ Choose the topic on which notifications will be published for this bridge. If not set the messages will be sent on the topic - $SYS/broker/connection/<clientid>/state. + $SYS/broker/connection/<remote_clientid>/state. From 60cb8bedb02d75d17f317a7d2f48c6c4c22fad53 Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Fri, 29 Dec 2017 13:57:10 +0100 Subject: [PATCH 16/28] Fix