diff --git a/CMakeLists.txt b/CMakeLists.txt index 9167f9e5..187fd882 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.0) cmake_policy(SET CMP0042 NEW) project(mosquitto) -set (VERSION 2.0.3) +set (VERSION 2.0.4) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") diff --git a/ChangeLog.txt b/ChangeLog.txt index 1d6ae289..d65a9fa1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,21 @@ +2.0.4 - 2020-12-22 +================== + +Broker: +- Fix $SYS/broker/publish/messages/+ counters not being updated for QoS 1, 2 + messages. Closes #1968. +- mosquitto_connect_bind_async() and mosquitto_connect_bind_v5() should not + reset the bind address option if called with bind_address == NULL. +- Fix dynamic security configuration possibly not being reloaded on Windows + only. Closes #1962. +- Add more log messages for dynsec load/save error conditions. +- Fix websockets connections blocking non-websockets connections on Windows. + Closes #1934. + +Build: +- Fix man pages not being built when using CMake. Closes #1969. + + 2.0.3 - 2020-12-17 ================== diff --git a/config.mk b/config.mk index de328ea3..a807c606 100644 --- a/config.mk +++ b/config.mk @@ -125,7 +125,7 @@ WITH_XTREPORT=no # Also bump lib/mosquitto.h, CMakeLists.txt, # installer/mosquitto.nsi, installer/mosquitto64.nsi -VERSION=2.0.3 +VERSION=2.0.4 # Client library SO version. Bump if incompatible API/ABI changes are made. SOVERSION=1 diff --git a/include/mosquitto.h b/include/mosquitto.h index ef667693..b2c15cc6 100644 --- a/include/mosquitto.h +++ b/include/mosquitto.h @@ -19,6 +19,13 @@ Contributors: #ifndef MOSQUITTO_H #define MOSQUITTO_H +/* + * File: mosquitto.h + * + * This header contains functions and definitions for use with libmosquitto, the Mosquitto client library. + * + * The definitions are also used in Mosquitto broker plugins, and some functions are available to plugins. + */ #ifdef __cplusplus extern "C" { #endif @@ -59,7 +66,7 @@ extern "C" { #define LIBMOSQUITTO_MAJOR 2 #define LIBMOSQUITTO_MINOR 0 -#define LIBMOSQUITTO_REVISION 3 +#define LIBMOSQUITTO_REVISION 4 /* LIBMOSQUITTO_VERSION_NUMBER looks like 1002001 for e.g. version 1.2.1. */ #define LIBMOSQUITTO_VERSION_NUMBER (LIBMOSQUITTO_MAJOR*1000000+LIBMOSQUITTO_MINOR*1000+LIBMOSQUITTO_REVISION) @@ -3059,8 +3066,8 @@ libmosq_EXPORT void mosquitto_property_free_all(mosquitto_property **properties) * Function: mosquitto_property_copy_all * * Parameters: - * dest : pointer for new property list - * src : property list + * dest - pointer for new property list + * src - property list * * Returns: * MOSQ_ERR_SUCCESS - on successful copy diff --git a/include/mosquitto_broker.h b/include/mosquitto_broker.h index 6f23a71c..d1a26319 100644 --- a/include/mosquitto_broker.h +++ b/include/mosquitto_broker.h @@ -16,6 +16,11 @@ Contributors: Roger Light - initial implementation and documentation. */ +/* + * File: mosquitto_broker.h + * + * This header contains functions for use by plugins. + */ #ifndef MOSQUITTO_BROKER_H #define MOSQUITTO_BROKER_H @@ -44,7 +49,7 @@ enum mosquitto_protocol { /* ========================================================================= * - * Register callbacks. + * Section: Register callbacks. * * ========================================================================= */ @@ -172,6 +177,31 @@ typedef struct mosquitto_plugin_id_t mosquitto_plugin_id_t; /* * Function: mosquitto_callback_register + * + * Register a callback for an event. + * + * Parameters: + * identifier - the plugin identifier, as provided by . + * event - the event to register a callback for. Can be one of: + * * MOSQ_EVT_RELOAD + * * MOSQ_EVT_ACL_CHECK + * * MOSQ_EVT_BASIC_AUTH + * * MOSQ_EVT_EXT_AUTH_START + * * MOSQ_EVT_EXT_AUTH_CONTINUE + * * MOSQ_EVT_CONTROL + * * MOSQ_EVT_MESSAGE + * * MOSQ_EVT_PSK_KEY + * * MOSQ_EVT_TICK + * * MOSQ_EVT_DISCONNECT + * cb_func - the callback function + * event_data - event specific data + * + * Returns: + * MOSQ_ERR_SUCCESS - on success + * MOSQ_ERR_INVAL - if cb_func is NULL + * MOSQ_ERR_NOMEM - on out of memory + * MOSQ_ERR_ALREADY_EXISTS - if cb_func has already been registered for this event + * MOSQ_ERR_NOT_SUPPORTED - if the event is not supported */ mosq_EXPORT int mosquitto_callback_register( mosquitto_plugin_id_t *identifier, @@ -182,6 +212,30 @@ mosq_EXPORT int mosquitto_callback_register( /* * Function: mosquitto_callback_unregister + * + * Unregister a previously registered callback function. + * + * Parameters: + * identifier - the plugin identifier, as provided by . + * event - the event to register a callback for. Can be one of: + * * MOSQ_EVT_RELOAD + * * MOSQ_EVT_ACL_CHECK + * * MOSQ_EVT_BASIC_AUTH + * * MOSQ_EVT_EXT_AUTH_START + * * MOSQ_EVT_EXT_AUTH_CONTINUE + * * MOSQ_EVT_CONTROL + * * MOSQ_EVT_MESSAGE + * * MOSQ_EVT_PSK_KEY + * * MOSQ_EVT_TICK + * * MOSQ_EVT_DISCONNECT + * cb_func - the callback function + * event_data - event specific data + * + * Returns: + * MOSQ_ERR_SUCCESS - on success + * MOSQ_ERR_INVAL - if cb_func is NULL + * MOSQ_ERR_NOT_FOUND - if cb_func was not registered for this event + * MOSQ_ERR_NOT_SUPPORTED - if the event is not supported */ mosq_EXPORT int mosquitto_callback_unregister( mosquitto_plugin_id_t *identifier, @@ -192,21 +246,41 @@ mosq_EXPORT int mosquitto_callback_unregister( /* ========================================================================= * - * Memory allocation. + * Section: Memory allocation. * * Use these functions when allocating or freeing memory to have your memory * included in the memory tracking on the broker. * * ========================================================================= */ + +/* + * Function: mosquitto_calloc + */ mosq_EXPORT void *mosquitto_calloc(size_t nmemb, size_t size); + +/* + * Function: mosquitto_free + */ mosq_EXPORT void mosquitto_free(void *mem); + +/* + * Function: mosquitto_malloc + */ mosq_EXPORT void *mosquitto_malloc(size_t size); + +/* + * Function: mosquitto_realloc + */ mosq_EXPORT void *mosquitto_realloc(void *ptr, size_t size); + +/* + * Function: mosquitto_strdup + */ mosq_EXPORT char *mosquitto_strdup(const char *s); /* ========================================================================= * - * Utility Functions + * Section: Utility Functions * * Use these functions from within your plugin. * @@ -221,13 +295,13 @@ mosq_EXPORT char *mosquitto_strdup(const char *s); * Parameters: * level - Log message priority. Can currently be one of: * - * MOSQ_LOG_INFO - * MOSQ_LOG_NOTICE - * MOSQ_LOG_WARNING - * MOSQ_LOG_ERR - * MOSQ_LOG_DEBUG - * MOSQ_LOG_SUBSCRIBE (not recommended for use by plugins) - * MOSQ_LOG_UNSUBSCRIBE (not recommended for use by plugins) + * * MOSQ_LOG_INFO + * * MOSQ_LOG_NOTICE + * * MOSQ_LOG_WARNING + * * MOSQ_LOG_ERR + * * MOSQ_LOG_DEBUG + * * MOSQ_LOG_SUBSCRIBE (not recommended for use by plugins) + * * MOSQ_LOG_UNSUBSCRIBE (not recommended for use by plugins) * * These values are defined in mosquitto.h. * @@ -309,9 +383,10 @@ mosq_EXPORT int mosquitto_client_protocol(const struct mosquitto *client); * * Retrieve the MQTT protocol version with which the client has connected. Can be one of: * - * 3 - for MQTT v3 / v3.1 - * 4 - for MQTT v3.1.1 - * 5 - for MQTT v5 + * Returns: + * 3 - for MQTT v3 / v3.1 + * 4 - for MQTT v3.1.1 + * 5 - for MQTT v5 */ mosq_EXPORT int mosquitto_client_protocol_version(const struct mosquitto *client); @@ -354,7 +429,7 @@ mosq_EXPORT int mosquitto_set_username(struct mosquitto *client, const char *use /* ========================================================================= * - * Client control + * Section: Client control * * ========================================================================= */ @@ -388,7 +463,7 @@ mosq_EXPORT int mosquitto_kick_client_by_username(const char *username, bool wit /* ========================================================================= * - * Publishing functions + * Section: Publishing functions * * ========================================================================= */ diff --git a/include/mosquitto_plugin.h b/include/mosquitto_plugin.h index 360b889c..4199c7b3 100644 --- a/include/mosquitto_plugin.h +++ b/include/mosquitto_plugin.h @@ -19,6 +19,12 @@ Contributors: #ifndef MOSQUITTO_PLUGIN_H #define MOSQUITTO_PLUGIN_H +/* + * File: mosquitto_plugin.h + * + * This header contains function declarations for use when writing a Mosquitto plugin. + */ + #ifdef __cplusplus extern "C" { #endif @@ -108,7 +114,7 @@ struct mosquitto_acl_msg { /* ========================================================================= * - * Plugin Functions v5 + * Section: Plugin Functions v5 * * This is the plugin version 5 interface, which covers authentication, access * control, the $CONTROL topic space handling, and message inspection and @@ -138,7 +144,7 @@ struct mosquitto_acl_msg { mosq_plugin_EXPORT int mosquitto_plugin_version(int supported_version_count, const int *supported_versions); /* - * Function: mosquitto_auth_plugin_init + * Function: mosquitto_plugin_init * * Called after the plugin has been loaded and * has been called. This will only ever be called once and can be used to @@ -146,13 +152,13 @@ mosq_plugin_EXPORT int mosquitto_plugin_version(int supported_version_count, con * * Parameters: * - * identifier : This is a pointer to an opaque structure which you must + * identifier - This is a pointer to an opaque structure which you must * save and use when registering/unregistering callbacks. - * user_data : The pointer set here will be passed to the other plugin + * user_data - The pointer set here will be passed to the other plugin * functions. Use to hold connection information for example. - * opts : Pointer to an array of struct mosquitto_opt, which + * opts - Pointer to an array of struct mosquitto_opt, which * provides the plugin options defined in the configuration file. - * opt_count : The number of elements in the opts array. + * opt_count - The number of elements in the opts array. * * Return value: * Return 0 on success @@ -169,10 +175,10 @@ mosq_plugin_EXPORT int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, * * Parameters: * - * user_data : The pointer provided in . - * opts : Pointer to an array of struct mosquitto_opt, which + * user_data - The pointer provided in . + * opts - Pointer to an array of struct mosquitto_opt, which * provides the plugin options defined in the configuration file. - * opt_count : The number of elements in the opts array. + * opt_count - The number of elements in the opts array. * * Return value: * Return 0 on success @@ -184,7 +190,7 @@ mosq_plugin_EXPORT int mosquitto_plugin_cleanup(void *userdata, struct mosquitto /* ========================================================================= * - * Plugin Functions v4 + * Section: Plugin Functions v4 * * This is the plugin version 4 interface, which is exclusively for * authentication and access control, and which is still supported for existing @@ -213,11 +219,11 @@ mosq_plugin_EXPORT int mosquitto_auth_plugin_version(void); * * Parameters: * - * user_data : The pointer set here will be passed to the other plugin + * user_data - The pointer set here will be passed to the other plugin * functions. Use to hold connection information for example. - * opts : Pointer to an array of struct mosquitto_opt, which + * opts - Pointer to an array of struct mosquitto_opt, which * provides the plugin options defined in the configuration file. - * opt_count : The number of elements in the opts array. + * opt_count - The number of elements in the opts array. * * Return value: * Return 0 on success @@ -236,10 +242,10 @@ mosq_plugin_EXPORT int mosquitto_auth_plugin_init(void **user_data, struct mosqu * * Parameters: * - * user_data : The pointer provided in . - * opts : Pointer to an array of struct mosquitto_opt, which + * user_data - The pointer provided in . + * opts - Pointer to an array of struct mosquitto_opt, which * provides the plugin options defined in the configuration file. - * opt_count : The number of elements in the opts array. + * opt_count - The number of elements in the opts array. * * Return value: * Return 0 on success @@ -261,11 +267,11 @@ mosq_plugin_EXPORT int mosquitto_auth_plugin_cleanup(void *user_data, struct mos * * Parameters: * - * user_data : The pointer provided in . - * opts : Pointer to an array of struct mosquitto_opt, which + * user_data - The pointer provided in . + * opts - Pointer to an array of struct mosquitto_opt, which * provides the plugin options defined in the configuration file. - * opt_count : The number of elements in the opts array. - * reload : If set to false, this is the first time the function has + * opt_count - The number of elements in the opts array. + * reload - If set to false, this is the first time the function has * been called. If true, the broker has received a signal * asking to reload its configuration. * @@ -289,11 +295,11 @@ mosq_plugin_EXPORT int mosquitto_auth_security_init(void *user_data, struct mosq * * Parameters: * - * user_data : The pointer provided in . - * opts : Pointer to an array of struct mosquitto_opt, which + * user_data - The pointer provided in . + * opts - Pointer to an array of struct mosquitto_opt, which * provides the plugin options defined in the configuration file. - * opt_count : The number of elements in the opts array. - * reload : If set to false, this is the first time the function has + * opt_count - The number of elements in the opts array. + * reload - If set to false, this is the first time the function has * been called. If true, the broker has received a signal * asking to reload its configuration. * @@ -362,11 +368,11 @@ mosq_plugin_EXPORT int mosquitto_auth_unpwd_check(void *user_data, struct mosqui * hexadecimal string with no leading "0x") and copy this string into key. * * Parameters: - * user_data : the pointer provided in . - * hint : the psk_hint for the listener the client is connecting to. - * identity : the identity string provided by the client - * key : a string where the hex PSK should be copied - * max_key_len : the size of key + * user_data - the pointer provided in . + * hint - the psk_hint for the listener the client is connecting to. + * identity - the identity string provided by the client + * key - a string where the hex PSK should be copied + * max_key_len - the size of key * * Return value: * Return 0 on success. @@ -382,17 +388,17 @@ mosq_plugin_EXPORT int mosquitto_auth_psk_key_get(void *user_data, struct mosqui * are making extended authentication checks. * * Parameters: - * user_data : the pointer provided in . - * method : the authentication method - * reauth : this is set to false if this is the first authentication attempt + * user_data - the pointer provided in . + * method - the authentication method + * reauth - this is set to false if this is the first authentication attempt * on a connection, set to true if the client is attempting to * reauthenticate. - * data_in : pointer to authentication data, or NULL - * data_in_len : length of data_in, in bytes - * data_out : if your plugin wishes to send authentication data back to the + * data_in - pointer to authentication data, or NULL + * data_in_len - length of data_in, in bytes + * data_out - if your plugin wishes to send authentication data back to the * client, allocate some memory using malloc or friends and set * data_out. The broker will free the memory after use. - * data_out_len : Set the length of data_out in bytes. + * data_out_len - Set the length of data_out in bytes. * * Return value: * Return MOSQ_ERR_SUCCESS if authentication was successful. diff --git a/include/mqtt_protocol.h b/include/mqtt_protocol.h index a2a55e89..86d7dc99 100644 --- a/include/mqtt_protocol.h +++ b/include/mqtt_protocol.h @@ -19,6 +19,11 @@ Contributors: #ifndef MQTT_PROTOCOL_H #define MQTT_PROTOCOL_H +/* + * File: mqtt_protocol.h + * + * This header contains definitions of MQTT values as defined in the specifications. + */ #define PROTOCOL_NAME_v31 "MQIsdp" #define PROTOCOL_VERSION_v31 3 @@ -48,6 +53,18 @@ Contributors: /* Mosquitto only: for distinguishing CONNECT and WILL properties */ #define CMD_WILL 0x100 +/* Enum: mqtt311_connack_codes + * + * The CONNACK results for MQTT v3.1.1, and v3.1. + * + * Values: + * CONNACK_ACCEPTED - 0 + * CONNACK_REFUSED_PROTOCOL_VERSION - 1 + * CONNACK_REFUSED_IDENTIFIER_REJECTED - 2 + * CONNACK_REFUSED_SERVER_UNAVAILABLE - 3 + * CONNACK_REFUSED_BAD_USERNAME_PASSWORD - 4 + * CONNACK_REFUSED_NOT_AUTHORIZED - 5 + */ enum mqtt311_connack_codes { CONNACK_ACCEPTED = 0, CONNACK_REFUSED_PROTOCOL_VERSION = 1, @@ -57,7 +74,56 @@ enum mqtt311_connack_codes { CONNACK_REFUSED_NOT_AUTHORIZED = 5, }; - +/* Enum: mqtt5_return_codes + * The reason codes returned in various MQTT commands. + * + * Values: + * MQTT_RC_SUCCESS - 0 + * MQTT_RC_NORMAL_DISCONNECTION - 0 + * MQTT_RC_GRANTED_QOS0 - 0 + * MQTT_RC_GRANTED_QOS1 - 1 + * MQTT_RC_GRANTED_QOS2 - 2 + * MQTT_RC_DISCONNECT_WITH_WILL_MSG - 4 + * MQTT_RC_NO_MATCHING_SUBSCRIBERS - 16 + * MQTT_RC_NO_SUBSCRIPTION_EXISTED - 17 + * MQTT_RC_CONTINUE_AUTHENTICATION - 24 + * MQTT_RC_REAUTHENTICATE - 25 + * MQTT_RC_UNSPECIFIED - 128 + * MQTT_RC_MALFORMED_PACKET - 129 + * MQTT_RC_PROTOCOL_ERROR - 130 + * MQTT_RC_IMPLEMENTATION_SPECIFIC - 131 + * MQTT_RC_UNSUPPORTED_PROTOCOL_VERSION - 132 + * MQTT_RC_CLIENTID_NOT_VALID - 133 + * MQTT_RC_BAD_USERNAME_OR_PASSWORD - 134 + * MQTT_RC_NOT_AUTHORIZED - 135 + * MQTT_RC_SERVER_UNAVAILABLE - 136 + * MQTT_RC_SERVER_BUSY - 137 + * MQTT_RC_BANNED - 138 + * MQTT_RC_SERVER_SHUTTING_DOWN - 139 + * MQTT_RC_BAD_AUTHENTICATION_METHOD - 140 + * MQTT_RC_KEEP_ALIVE_TIMEOUT - 141 + * MQTT_RC_SESSION_TAKEN_OVER - 142 + * MQTT_RC_TOPIC_FILTER_INVALID - 143 + * MQTT_RC_TOPIC_NAME_INVALID - 144 + * MQTT_RC_PACKET_ID_IN_USE - 145 + * MQTT_RC_PACKET_ID_NOT_FOUND - 146 + * MQTT_RC_RECEIVE_MAXIMUM_EXCEEDED - 147 + * MQTT_RC_TOPIC_ALIAS_INVALID - 148 + * MQTT_RC_PACKET_TOO_LARGE - 149 + * MQTT_RC_MESSAGE_RATE_TOO_HIGH - 150 + * MQTT_RC_QUOTA_EXCEEDED - 151 + * MQTT_RC_ADMINISTRATIVE_ACTION - 152 + * MQTT_RC_PAYLOAD_FORMAT_INVALID - 153 + * MQTT_RC_RETAIN_NOT_SUPPORTED - 154 + * MQTT_RC_QOS_NOT_SUPPORTED - 155 + * MQTT_RC_USE_ANOTHER_SERVER - 156 + * MQTT_RC_SERVER_MOVED - 157 + * MQTT_RC_SHARED_SUBS_NOT_SUPPORTED - 158 + * MQTT_RC_CONNECTION_RATE_EXCEEDED - 159 + * MQTT_RC_MAXIMUM_CONNECT_TIME - 160 + * MQTT_RC_SUBSCRIPTION_IDS_NOT_SUPPORTED - 161 + * MQTT_RC_WILDCARD_SUBS_NOT_SUPPORTED - 162 + */ enum mqtt5_return_codes { MQTT_RC_SUCCESS = 0, /* CONNACK, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK, AUTH */ MQTT_RC_NORMAL_DISCONNECTION = 0, /* DISCONNECT */ diff --git a/installer/mosquitto.nsi b/installer/mosquitto.nsi index 702a0a98..2498c845 100644 --- a/installer/mosquitto.nsi +++ b/installer/mosquitto.nsi @@ -9,7 +9,7 @@ !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' Name "Eclipse Mosquitto" -!define VERSION 2.0.3 +!define VERSION 2.0.4 OutFile "mosquitto-${VERSION}-install-windows-x86.exe" InstallDir "$PROGRAMFILES\mosquitto" diff --git a/installer/mosquitto64.nsi b/installer/mosquitto64.nsi index b40ef29e..783c2e66 100644 --- a/installer/mosquitto64.nsi +++ b/installer/mosquitto64.nsi @@ -9,7 +9,7 @@ !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' Name "Eclipse Mosquitto" -!define VERSION 2.0.3 +!define VERSION 2.0.4 OutFile "mosquitto-${VERSION}-install-windows-x64.exe" !include "x64.nsh" diff --git a/lib/connect.c b/lib/connect.c index 4a0d1eec..f5669924 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -96,8 +96,10 @@ int mosquitto_connect_bind_v5(struct mosquitto *mosq, const char *host, int port { int rc; - rc = mosquitto_string_option(mosq, MOSQ_OPT_BIND_ADDRESS, bind_address); - if(rc) return rc; + if(bind_address){ + rc = mosquitto_string_option(mosq, MOSQ_OPT_BIND_ADDRESS, bind_address); + if(rc) return rc; + } mosquitto_property_free_all(&mosq->connect_properties); if(properties){ @@ -128,8 +130,10 @@ int mosquitto_connect_bind_async(struct mosquitto *mosq, const char *host, int p { int rc; - rc = mosquitto_string_option(mosq, MOSQ_OPT_BIND_ADDRESS, bind_address); - if(rc) return rc; + if(bind_address){ + rc = mosquitto_string_option(mosq, MOSQ_OPT_BIND_ADDRESS, bind_address); + if(rc) return rc; + } rc = mosquitto__connect_init(mosq, host, port, keepalive); if(rc) return rc; diff --git a/lib/packet_mosq.c b/lib/packet_mosq.c index 23a29688..5cf78fa9 100644 --- a/lib/packet_mosq.c +++ b/lib/packet_mosq.c @@ -294,6 +294,8 @@ int packet__write(struct mosquitto *mosq) mosquitto__free(packet); return MOSQ_ERR_SUCCESS; #endif + }else if(((packet->command)&0xF0) == CMD_PUBLISH){ + G_PUB_MSGS_SENT_INC(1); } /* Free data and reset values */ diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index d68753d3..4390c1ef 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -1,3 +1,24 @@ +if(NOT WIN32) + function(compile_manpage page) + add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/man/${page} + COMMAND xsltproc ${CMAKE_SOURCE_DIR}/man/${page}.xml -o ${CMAKE_SOURCE_DIR}/man/ + MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/man/${page}.xml) + add_custom_target(${page} ALL DEPENDS ${CMAKE_SOURCE_DIR}/man/${page}) + endfunction() + + compile_manpage("mosquitto_ctrl.1") + compile_manpage("mosquitto_ctrl_dynsec.1") + compile_manpage("mosquitto_passwd.1") + compile_manpage("mosquitto_pub.1") + compile_manpage("mosquitto_sub.1") + compile_manpage("mosquitto_rr.1") + compile_manpage("libmosquitto.3") + compile_manpage("mosquitto.conf.5") + compile_manpage("mosquitto-tls.7") + compile_manpage("mqtt.7") + compile_manpage("mosquitto.8") +endif() + install(FILES mosquitto_ctrl.1 mosquitto_ctrl_dynsec.1 mosquitto_passwd.1 mosquitto_pub.1 mosquitto_sub.1 mosquitto_rr.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) install(FILES libmosquitto.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) install(FILES mosquitto.conf.5 DESTINATION ${CMAKE_INSTALL_MANDIR}/man5) diff --git a/plugins/dynamic-security/plugin.c b/plugins/dynamic-security/plugin.c index c41e498c..dd76a9da 100644 --- a/plugins/dynamic-security/plugin.c +++ b/plugins/dynamic-security/plugin.c @@ -346,16 +346,17 @@ static int dynsec__config_load(void) char *json_str; cJSON *tree; - /* Save to file */ - fptr = fopen(config_file, "rt"); + /* Load from file */ + fptr = fopen(config_file, "rb"); if(fptr == NULL){ + mosquitto_log_printf(MOSQ_LOG_ERR, "Error loading Dynamic security plugin config: File is not readable - check permissions.\n"); return 1; } fseek(fptr, 0, SEEK_END); flen_l = ftell(fptr); if(flen_l < 0){ - mosquitto_log_printf(MOSQ_LOG_WARNING, "Error loading Dynamic security plugin config: %s\n", strerror(errno)); + mosquitto_log_printf(MOSQ_LOG_ERR, "Error loading Dynamic security plugin config: %s\n", strerror(errno)); fclose(fptr); return 1; }else if(flen_l == 0){ @@ -366,10 +367,12 @@ static int dynsec__config_load(void) fseek(fptr, 0, SEEK_SET); json_str = mosquitto_calloc(flen+1, sizeof(char)); if(json_str == NULL){ + mosquitto_log_printf(MOSQ_LOG_ERR, "Error: Out of memory."); fclose(fptr); return 1; } if(fread(json_str, 1, flen, fptr) != flen){ + mosquitto_log_printf(MOSQ_LOG_WARNING, "Error loading Dynamic security plugin config: Unable to read file contents.\n"); mosquitto_free(json_str); fclose(fptr); return 1; @@ -379,6 +382,7 @@ static int dynsec__config_load(void) tree = cJSON_Parse(json_str); mosquitto_free(json_str); if(tree == NULL){ + mosquitto_log_printf(MOSQ_LOG_ERR, "Error loading Dynamic security plugin config: File is not valid JSON.\n"); return 1; } @@ -422,6 +426,7 @@ void dynsec__config_save(void) json_str = cJSON_Print(tree); if(json_str == NULL){ cJSON_Delete(tree); + mosquitto_log_printf(MOSQ_LOG_ERR, "Error saving Dynamic security plugin config: Out of memory.\n"); return; } cJSON_Delete(tree); @@ -432,6 +437,7 @@ void dynsec__config_save(void) file_path = mosquitto_malloc(file_path_len); if(file_path == NULL){ mosquitto_free(json_str); + mosquitto_log_printf(MOSQ_LOG_ERR, "Error saving Dynamic security plugin config: Out of memory.\n"); return; } snprintf(file_path, file_path_len, "%s.new", config_file); @@ -440,6 +446,7 @@ void dynsec__config_save(void) if(fptr == NULL){ mosquitto_free(json_str); mosquitto_free(file_path); + mosquitto_log_printf(MOSQ_LOG_ERR, "Error saving Dynamic security plugin config: File is not writable - check permissions.\n"); return; } fwrite(json_str, 1, json_str_len, fptr); diff --git a/set-version.sh b/set-version.sh index 11de2bda..a062b1ad 100755 --- a/set-version.sh +++ b/set-version.sh @@ -2,7 +2,7 @@ MAJOR=2 MINOR=0 -REVISION=3 +REVISION=4 sed -i "s/^VERSION=.*/VERSION=${MAJOR}.${MINOR}.${REVISION}/" config.mk diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 4f3add82..0e485bdf 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: mosquitto -version: 2.0.3 +version: 2.0.4 summary: Eclipse Mosquitto MQTT broker description: This is a message broker that supports version 5.0, 3.1.1, and 3.1 of the MQTT protocol. diff --git a/src/mux_poll.c b/src/mux_poll.c index 79926641..947a512e 100644 --- a/src/mux_poll.c +++ b/src/mux_poll.c @@ -84,7 +84,7 @@ int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_c pollfd_max = (size_t)sysconf(_SC_OPEN_MAX); #endif - pollfds = mosquitto__malloc(sizeof(struct pollfd)*pollfd_max); + pollfds = mosquitto__calloc(pollfd_max, sizeof(struct pollfd)); if(!pollfds){ log__printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory."); return MOSQ_ERR_NOMEM; @@ -145,7 +145,7 @@ int mux_poll__add_in(struct mosquitto *context) if(context->pollfd_index != -1){ pollfds[context->pollfd_index].fd = context->sock; - pollfds[context->pollfd_index].events = POLLIN | POLLPRI; + pollfds[context->pollfd_index].events = POLLIN; pollfds[context->pollfd_index].revents = 0; }else{ for(i=0; iws_context){ /* Nothing needs to happen here, because we always call lws_service in the loop. diff --git a/src/plugin.c b/src/plugin.c index 899cf5db..34fddf26 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -313,7 +313,7 @@ int mosquitto_callback_unregister( cb_base = &security_options->plugin_callbacks.disconnect; break; default: - return MOSQ_ERR_INVAL; + return MOSQ_ERR_NOT_SUPPORTED; break; } diff --git a/src/websockets.c b/src/websockets.c index 6a9c1bee..4b9d4222 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -188,9 +188,6 @@ static int callback_mqtt( if(mosq->sock != INVALID_SOCKET){ HASH_DELETE(hh_sock, db.contexts_by_sock, mosq); mosq->sock = INVALID_SOCKET; -#ifndef WITH_EPOLL - mosq->pollfd_index = -1; -#endif mux__delete(mosq); } mosq->wsi = NULL; diff --git a/www/pages/download.md b/www/pages/download.md index 7436afda..fb141c5d 100644 --- a/www/pages/download.md +++ b/www/pages/download.md @@ -1,7 +1,7 @@ + +Version 2.0.4 of Mosquitto has been released. This is a bugfix release. + +# Broker +- Fix $SYS/broker/publish/messages/+ counters not being updated for QoS 1, 2 + messages. Closes #1968. +- `mosquitto_connect_bind_async()` and `mosquitto_connect_bind_v5()` should not + reset the bind address option if called with `bind_address == NULL`. +- Fix dynamic security configuration possibly not being reloaded on Windows + only. Closes #1962. +- Add more log messages for dynsec load/save error conditions. +- Fix websockets connections blocking non-websockets connections on Windows. + Closes #1934. + +# Build +- Fix man pages not being built when using CMake. Closes #1969. + +[#1934]: https://github.com/eclipse/mosquitto/issues/1934 +[#1962]: https://github.com/eclipse/mosquitto/issues/1962 +[#1968]: https://github.com/eclipse/mosquitto/issues/1968 +[#1969]: https://github.com/eclipse/mosquitto/issues/1969