Merge branch 'fixes'

pull/1964/head v2.0.3
Roger A. Light 5 years ago
commit 2cc12adcab

@ -4,16 +4,13 @@
# To configure the build options either use the CMake gui, or run the command # To configure the build options either use the CMake gui, or run the command
# line utility including the "-i" option. # line utility including the "-i" option.
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
project(mosquitto)
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0042 NEW) cmake_policy(SET CMP0042 NEW)
set (VERSION 2.0.2) project(mosquitto)
set (VERSION 2.0.3)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
add_definitions (-DCMAKE -DVERSION=\"${VERSION}\") add_definitions (-DCMAKE -DVERSION=\"${VERSION}\")

@ -1,3 +1,37 @@
2.0.3 - 2020-12-17
==================
Security:
- Running mosquitto_passwd with the following arguments only
`mosquitto_passwd -b password_file username password` would cause the
username to be used as the password.
Broker:
- Fix excessive CPU use on non-Linux systems when the open file limit is set
high. Closes #1947.
- Fix LWT not being sent on client takeover when the existing session wasn't
being continued. Closes #1946.
- Fix bridges possibly not completing connections when WITH_ADNS is in use.
Closes #1960.
- Fix QoS 0 messages not being delivered if max_queued_messages was set to 0.
Closes #1956.
- Fix local bridges being disconnected on SIGHUP. Closes #1942.
- Fix slow initial bridge connections for WITH_ADNS=no.
- Fix persistence_location not appending a '/'.
Clients:
- Fix mosquitto_sub being unable to terminate with Ctrl-C if a successful
connection is not made. Closes #1957.
Apps:
- Fix `mosquitto_passwd -b` using username as password (not if `-c` is also
used). Closes #1949.
Build:
- Fix `install` target when using WITH_CJSON=no. Closes #1938.
- Fix `generic` docker build. Closes #1945.
2.0.2 - 2020-12-10 2.0.2 - 2020-12-10
================== ==================
@ -101,8 +135,8 @@ Broker features:
to a v3.x only broker. to a v3.x only broker.
- DLT logging is now configurable at runtime with `log_dest dlt`. - DLT logging is now configurable at runtime with `log_dest dlt`.
Closes #1735. Closes #1735.
- Add `mosquitto_plugin_publish()` function, which can be used by plugins to - Add `mosquitto_broker_publish()` and `mosquitto_broker_publish_copy()`
publish messages. functions, which can be used by plugins to publish messages.
- Add `mosquitto_client_protocol_version()` function which can be used by - Add `mosquitto_client_protocol_version()` function which can be used by
plugins to determine which version of MQTT a client has connected with. plugins to determine which version of MQTT a client has connected with.
- Add `mosquitto_kick_client_by_clientid()` and `mosquitto_kick_client_by_username()` - Add `mosquitto_kick_client_by_clientid()` and `mosquitto_kick_client_by_username()`

@ -36,9 +36,9 @@ else
TARGET:= TARGET:=
endif endif
all : $(TARGET) all : ${TARGET}
mosquitto_ctrl : ${OBJS} mosquitto_ctrl : ${OBJS} ${LIBMOSQ}
${CROSS_COMPILE}${CC} ${APP_LDFLAGS} $^ -o $@ $(PASSWD_LDADD) $(LOCAL_LDFLAGS) $(LIBMOSQ) -lcjson -ldl ${CROSS_COMPILE}${CC} ${APP_LDFLAGS} $^ -o $@ $(PASSWD_LDADD) $(LOCAL_LDFLAGS) $(LIBMOSQ) -lcjson -ldl
mosquitto_ctrl_example.so : ${EXAMPLE_OBJS} mosquitto_ctrl_example.so : ${EXAMPLE_OBJS}
@ -83,9 +83,19 @@ misc_mosq.o : ../../lib/misc_mosq.c ../../lib/misc_mosq.h
password_mosq.o : ../../src/password_mosq.c ../../src/password_mosq.h password_mosq.o : ../../src/password_mosq.c ../../src/password_mosq.h
${CROSS_COMPILE}${CC} $(APP_CPPFLAGS) $(APP_CFLAGS) -c $< -o $@ ${CROSS_COMPILE}${CC} $(APP_CPPFLAGS) $(APP_CFLAGS) -c $< -o $@
../../lib/libmosquitto.so.${SOVERSION} :
$(MAKE) -C ../../lib
../../lib/libmosquitto.a :
$(MAKE) -C ../../lib libmosquitto.a
install : all install : all
ifeq ($(WITH_TLS),yes)
ifeq ($(WITH_CJSON),yes)
$(INSTALL) -d "${DESTDIR}$(prefix)/bin" $(INSTALL) -d "${DESTDIR}$(prefix)/bin"
$(INSTALL) ${STRIP_OPTS} mosquitto_ctrl "${DESTDIR}${prefix}/bin/mosquitto_ctrl" $(INSTALL) ${STRIP_OPTS} mosquitto_ctrl "${DESTDIR}${prefix}/bin/mosquitto_ctrl"
endif
endif
uninstall : uninstall :
-rm -f "${DESTDIR}${prefix}/bin/mosquitto_ctrl" -rm -f "${DESTDIR}${prefix}/bin/mosquitto_ctrl"

@ -505,7 +505,7 @@ int main(int argc, char *argv[])
}else if(batch_mode == true && idx+3 == argc){ }else if(batch_mode == true && idx+3 == argc){
password_file_tmp = argv[idx]; password_file_tmp = argv[idx];
username = argv[idx+1]; username = argv[idx+1];
password_cmd = argv[idx+1]; password_cmd = argv[idx+2];
}else if(batch_mode == false && idx+2 == argc){ }else if(batch_mode == false && idx+2 == argc){
password_file_tmp = argv[idx]; password_file_tmp = argv[idx];
username = argv[idx+1]; username = argv[idx+1];

@ -45,13 +45,18 @@ struct mosquitto *mosq = NULL;
int last_mid = 0; int last_mid = 0;
static bool timed_out = false; static bool timed_out = false;
static int connack_result = 0; static int connack_result = 0;
bool connack_received = false;
#ifndef WIN32 #ifndef WIN32
void my_signal_handler(int signum) void my_signal_handler(int signum)
{ {
if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){ if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){
if(connack_received){
process_messages = false; process_messages = false;
mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props); mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
}else{
exit(-1);
}
} }
if(signum == SIGALRM){ if(signum == SIGALRM){
timed_out = true; timed_out = true;
@ -123,6 +128,8 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag
UNUSED(flags); UNUSED(flags);
UNUSED(properties); UNUSED(properties);
connack_received = true;
connack_result = result; connack_result = result;
if(!result){ if(!result){
mosquitto_subscribe_multiple(mosq, NULL, cfg.topic_count, cfg.topics, cfg.qos, cfg.sub_opts, cfg.subscribe_props); mosquitto_subscribe_multiple(mosq, NULL, cfg.topic_count, cfg.topics, cfg.qos, cfg.sub_opts, cfg.subscribe_props);

@ -125,7 +125,7 @@ WITH_XTREPORT=no
# Also bump lib/mosquitto.h, CMakeLists.txt, # Also bump lib/mosquitto.h, CMakeLists.txt,
# installer/mosquitto.nsi, installer/mosquitto64.nsi # installer/mosquitto.nsi, installer/mosquitto64.nsi
VERSION=2.0.2 VERSION=2.0.3
# Client library SO version. Bump if incompatible API/ABI changes are made. # Client library SO version. Bump if incompatible API/ABI changes are made.
SOVERSION=1 SOVERSION=1

@ -1,4 +1,4 @@
FROM alpine:latest AS build FROM alpine:edge AS build
# A released dist version, like "1.2.3" # A released dist version, like "1.2.3"
ARG VERSION ARG VERSION
@ -6,14 +6,15 @@ RUN test -n "${VERSION}"
RUN apk --no-cache add \ RUN apk --no-cache add \
build-base \ build-base \
openssl-dev \
c-ares-dev \ c-ares-dev \
ca-certificates \
cjson-dev \
curl \ curl \
util-linux-dev \
libwebsockets-dev \ libwebsockets-dev \
libxslt \ libxslt \
openssl-dev \
python2 \ python2 \
ca-certificates util-linux-dev
# This build procedure is based on: # This build procedure is based on:
# https://github.com/alpinelinux/aports/blob/master/main/mosquitto/APKBUILD # https://github.com/alpinelinux/aports/blob/master/main/mosquitto/APKBUILD
@ -48,6 +49,7 @@ LABEL maintainer="Jonathan Hanson <jonathan@jonathan-hanson.org>" \
RUN apk --no-cache add \ RUN apk --no-cache add \
busybox \ busybox \
ca-certificates \ ca-certificates \
cjson \
openssl \ openssl \
libuuid \ libuuid \
libwebsockets \ libwebsockets \

@ -59,7 +59,7 @@ extern "C" {
#define LIBMOSQUITTO_MAJOR 2 #define LIBMOSQUITTO_MAJOR 2
#define LIBMOSQUITTO_MINOR 0 #define LIBMOSQUITTO_MINOR 0
#define LIBMOSQUITTO_REVISION 2 #define LIBMOSQUITTO_REVISION 3
/* LIBMOSQUITTO_VERSION_NUMBER looks like 1002001 for e.g. version 1.2.1. */ /* 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) #define LIBMOSQUITTO_VERSION_NUMBER (LIBMOSQUITTO_MAJOR*1000000+LIBMOSQUITTO_MINOR*1000+LIBMOSQUITTO_REVISION)

@ -9,7 +9,7 @@
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
Name "Eclipse Mosquitto" Name "Eclipse Mosquitto"
!define VERSION 2.0.2 !define VERSION 2.0.3
OutFile "mosquitto-${VERSION}-install-windows-x86.exe" OutFile "mosquitto-${VERSION}-install-windows-x86.exe"
InstallDir "$PROGRAMFILES\mosquitto" InstallDir "$PROGRAMFILES\mosquitto"

@ -9,7 +9,7 @@
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' !define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
Name "Eclipse Mosquitto" Name "Eclipse Mosquitto"
!define VERSION 2.0.2 !define VERSION 2.0.3
OutFile "mosquitto-${VERSION}-install-windows-x64.exe" OutFile "mosquitto-${VERSION}-install-windows-x64.exe"
!include "x64.nsh" !include "x64.nsh"

@ -869,7 +869,7 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
<para>If mosquitto is being automatically started by an <para>If mosquitto is being automatically started by an
init script it will usually be required to write a pid init script it will usually be required to write a pid
file. This should then be configured as e.g. file. This should then be configured as e.g.
/var/run/mosquitto.pid</para> /var/run/mosquitto/mosquitto.pid</para>
<para>Not reloaded on reload signal.</para> <para>Not reloaded on reload signal.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

@ -145,7 +145,7 @@
# Write process id to a file. Default is a blank string which means # Write process id to a file. Default is a blank string which means
# a pid file shouldn't be written. # a pid file shouldn't be written.
# This should be set to /var/run/mosquitto.pid if mosquitto is # This should be set to /var/run/mosquitto/mosquitto.pid if mosquitto is
# being run automatically on boot with an init script and # being run automatically on boot with an init script and
# start-stop-daemon or similar. # start-stop-daemon or similar.
#pid_file #pid_file

@ -74,9 +74,13 @@ clean:
check: test check: test
test: test:
install: ${PLUGIN_NAME}.so install: all
ifeq ($(WITH_CJSON),yes)
ifeq ($(WITH_TLS),yes)
$(INSTALL) -d "${DESTDIR}$(prefix)/lib" $(INSTALL) -d "${DESTDIR}$(prefix)/lib"
$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${prefix}/lib/${PLUGIN_NAME}.so" $(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${prefix}/lib/${PLUGIN_NAME}.so"
endif
endif
uninstall : uninstall :
-rm -f "${DESTDIR}${prefix}/lib/${PLUGIN_NAME}.so" -rm -f "${DESTDIR}${prefix}/lib/${PLUGIN_NAME}.so"

@ -12,6 +12,8 @@ ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure Restart=on-failure
ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto
ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto
ExecStartPre=/bin/mkdir -m 740 -p /var/run/mosquitto
ExecStartPre=/bin/chown mosquitto: /var/run/mosquitto
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

@ -10,6 +10,8 @@ ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure Restart=on-failure
ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto
ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto
ExecStartPre=/bin/mkdir -m 740 -p /var/run/mosquitto
ExecStartPre=/bin/chown mosquitto: /var/run/mosquitto
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

@ -2,7 +2,7 @@
MAJOR=2 MAJOR=2
MINOR=0 MINOR=0
REVISION=2 REVISION=3
sed -i "s/^VERSION=.*/VERSION=${MAJOR}.${MINOR}.${REVISION}/" config.mk sed -i "s/^VERSION=.*/VERSION=${MAJOR}.${MINOR}.${REVISION}/" config.mk

@ -1,5 +1,5 @@
name: mosquitto name: mosquitto
version: 2.0.2 version: 2.0.3
summary: Eclipse Mosquitto MQTT broker 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 description: This is a message broker that supports version 5.0, 3.1.1, and 3.1 of the MQTT
protocol. protocol.

@ -577,6 +577,7 @@ int bridge__register_local_connections(void)
log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll initial registering bridge: %s", strerror(errno)); log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll initial registering bridge: %s", strerror(errno));
return MOSQ_ERR_UNKNOWN; return MOSQ_ERR_UNKNOWN;
} }
mux__add_out(context);
} }
} }
#endif #endif
@ -776,6 +777,8 @@ void bridge_check(void)
mux__add_out(context); mux__add_out(context);
} }
}else if(rc == MOSQ_ERR_CONN_PENDING){ }else if(rc == MOSQ_ERR_CONN_PENDING){
mux__add_in(context);
mux__add_out(context);
context->bridge->restart_t = 0; context->bridge->restart_t = 0;
}else{ }else{
context->bridge->cur_address++; context->bridge->cur_address++;

@ -664,7 +664,11 @@ int config__read(struct mosquitto__config *config, bool reload)
len = strlen(config->persistence_location) + strlen(config->persistence_file) + 1; len = strlen(config->persistence_location) + strlen(config->persistence_file) + 1;
config->persistence_filepath = mosquitto__malloc(len); config->persistence_filepath = mosquitto__malloc(len);
if(!config->persistence_filepath) return MOSQ_ERR_NOMEM; if(!config->persistence_filepath) return MOSQ_ERR_NOMEM;
snprintf(config->persistence_filepath, len, "%s%s", config->persistence_location, config->persistence_file); #ifdef WIN32
snprintf(config->persistence_filepath, len, "%s\\%s", config->persistence_location, config->persistence_file);
#else
snprintf(config->persistence_filepath, len, "%s/%s", config->persistence_location, config->persistence_file);
#endif
}else{ }else{
config->persistence_filepath = mosquitto__strdup(config->persistence_file); config->persistence_filepath = mosquitto__strdup(config->persistence_file);
if(!config->persistence_filepath) return MOSQ_ERR_NOMEM; if(!config->persistence_filepath) return MOSQ_ERR_NOMEM;

@ -50,6 +50,9 @@ bool db__ready_for_flight(struct mosquitto_msg_data *msgs, int qos)
* There is no queueing option, unless the client is offline and * There is no queueing option, unless the client is offline and
* queue_qos0_messages is enabled. * queue_qos0_messages is enabled.
*/ */
if(db.config->max_queued_messages == 0 && db.config->max_inflight_bytes == 0){
return true;
}
valid_bytes = msgs->msg_bytes - db.config->max_inflight_bytes < db.config->max_queued_bytes; valid_bytes = msgs->msg_bytes - db.config->max_inflight_bytes < db.config->max_queued_bytes;
valid_count = msgs->msg_count - msgs->inflight_maximum < db.config->max_queued_messages; valid_count = msgs->msg_count - msgs->inflight_maximum < db.config->max_queued_messages;

@ -165,6 +165,14 @@ int connect__on_authorised(struct mosquitto *context, void *auth_data_out, uint1
if(context->clean_start == true){ if(context->clean_start == true){
sub__clean_session(found_context); sub__clean_session(found_context);
} }
if((found_context->protocol == mosq_p_mqtt5 && found_context->session_expiry_interval == 0)
|| (found_context->protocol != mosq_p_mqtt5 && found_context->clean_start == true)
|| (context->clean_start == true)
){
context__send_will(found_context);
}
session_expiry__remove(found_context); session_expiry__remove(found_context);
will_delay__remove(found_context); will_delay__remove(found_context);
will__clear(found_context); will__clear(found_context);

@ -59,15 +59,15 @@ Contributors:
static void loop_handle_reads_writes(struct pollfd *pollfds); static void loop_handle_reads_writes(struct pollfd *pollfds);
static struct pollfd *pollfds = NULL; static struct pollfd *pollfds = NULL;
static size_t pollfd_max; static size_t pollfd_max, pollfd_current_max;
#ifndef WIN32 #ifndef WIN32
static sigset_t my_sigblock; static sigset_t my_sigblock;
#endif #endif
int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_count) int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_count)
{ {
int i; size_t i;
int pollfd_index = 0; size_t pollfd_index = 0;
#ifndef WIN32 #ifndef WIN32
sigemptyset(&my_sigblock); sigemptyset(&my_sigblock);
@ -101,6 +101,7 @@ int mux_poll__init(struct mosquitto__listener_sock *listensock, int listensock_c
pollfd_index++; pollfd_index++;
} }
pollfd_current_max = pollfd_index-1;
return MOSQ_ERR_SUCCESS; return MOSQ_ERR_SUCCESS;
} }
@ -120,6 +121,9 @@ int mux_poll__add_out(struct mosquitto *context)
pollfds[i].events = POLLIN | POLLOUT; pollfds[i].events = POLLIN | POLLOUT;
pollfds[i].revents = 0; pollfds[i].revents = 0;
context->pollfd_index = i; context->pollfd_index = i;
if(i > pollfd_current_max){
pollfd_current_max = (size_t )i;
}
break; break;
} }
} }
@ -150,6 +154,9 @@ int mux_poll__add_in(struct mosquitto *context)
pollfds[i].events = POLLIN; pollfds[i].events = POLLIN;
pollfds[i].revents = 0; pollfds[i].revents = 0;
context->pollfd_index = i; context->pollfd_index = i;
if(i > pollfd_current_max){
pollfd_current_max = (size_t )i;
}
break; break;
} }
} }
@ -160,11 +167,24 @@ int mux_poll__add_in(struct mosquitto *context)
int mux_poll__delete(struct mosquitto *context) int mux_poll__delete(struct mosquitto *context)
{ {
size_t pollfd_index;
if(context->pollfd_index != -1){ if(context->pollfd_index != -1){
pollfds[context->pollfd_index].fd = INVALID_SOCKET; pollfds[context->pollfd_index].fd = INVALID_SOCKET;
pollfds[context->pollfd_index].events = 0; pollfds[context->pollfd_index].events = 0;
pollfds[context->pollfd_index].revents = 0; pollfds[context->pollfd_index].revents = 0;
pollfd_index = (size_t )context->pollfd_index;
context->pollfd_index = -1; context->pollfd_index = -1;
/* If this is the highest index, reduce the current max until we find
* the next highest in use index. */
while(pollfd_index == pollfd_current_max
&& pollfd_index > 0
&& pollfds[pollfd_index].fd == INVALID_SOCKET){
pollfd_index--;
pollfd_current_max--;
}
} }
return MOSQ_ERR_SUCCESS; return MOSQ_ERR_SUCCESS;
@ -184,10 +204,10 @@ int mux_poll__handle(struct mosquitto__listener_sock *listensock, int listensock
#ifndef WIN32 #ifndef WIN32
sigprocmask(SIG_SETMASK, &my_sigblock, &origsig); sigprocmask(SIG_SETMASK, &my_sigblock, &origsig);
fdcount = poll(pollfds, pollfd_max, 100); fdcount = poll(pollfds, pollfd_current_max+1, 100);
sigprocmask(SIG_SETMASK, &origsig, NULL); sigprocmask(SIG_SETMASK, &origsig, NULL);
#else #else
fdcount = WSAPoll(pollfds, pollfd_max, 100); fdcount = WSAPoll(pollfds, pollfd_current_max+1, 100);
#endif #endif
db.now_s = mosquitto_time(); db.now_s = mosquitto_time();

@ -1112,6 +1112,10 @@ int mosquitto_security_apply_default(void)
#endif #endif
HASH_ITER(hh_id, db.contexts_by_id, context, ctxt_tmp){ HASH_ITER(hh_id, db.contexts_by_id, context, ctxt_tmp){
if(context->bridge){
continue;
}
/* Check for anonymous clients when allow_anonymous is false */ /* Check for anonymous clients when allow_anonymous is false */
if(db.config->per_listener_settings){ if(db.config->per_listener_settings){
if(context->listener){ if(context->listener){

@ -5,7 +5,7 @@
from mosq_test_helper import * from mosq_test_helper import *
def do_test(proto_ver, clean_session): def do_test(proto_ver, clean_session1, clean_session2):
rc = 1 rc = 1
keepalive = 60 keepalive = 60
@ -13,17 +13,34 @@ def do_test(proto_ver, clean_session):
connect1_packet = mosq_test.gen_connect("will-helper", keepalive=keepalive, proto_ver=proto_ver) connect1_packet = mosq_test.gen_connect("will-helper", keepalive=keepalive, proto_ver=proto_ver)
connack1_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) connack1_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver)
connect2_packet = mosq_test.gen_connect("will-test", keepalive=keepalive, proto_ver=proto_ver, will_topic="will/test", will_payload=b"LWT", clean_session=clean_session) if proto_ver == 5:
connack2a_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) if clean_session1 == False:
if clean_session == False and proto_ver == 4: connect_props1 = mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_SESSION_EXPIRY_INTERVAL, 60)
connack2b_packet = mosq_test.gen_connack(rc=0, flags=1, proto_ver=proto_ver)
else: else:
connack2b_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver) connect_props1 = mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_SESSION_EXPIRY_INTERVAL, 0)
if clean_session2 == False:
connect_props2 = mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_SESSION_EXPIRY_INTERVAL, 60)
else:
connect_props2 = mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_SESSION_EXPIRY_INTERVAL, 0)
else:
connect_props1 = b""
connect_props2 = b""
connect2_packet = mosq_test.gen_connect("will-test", keepalive=keepalive, proto_ver=proto_ver, will_topic="will/test", will_payload=b"LWT", clean_session=clean_session1, properties=connect_props1)
connack2_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver)
connect3_packet = mosq_test.gen_connect("will-test", keepalive=keepalive, proto_ver=proto_ver, clean_session=clean_session2, properties=connect_props2)
if clean_session1 == False and clean_session2 == False:
connack3_packet = mosq_test.gen_connack(rc=0, flags=1, proto_ver=proto_ver)
else:
connack3_packet = mosq_test.gen_connack(rc=0, proto_ver=proto_ver)
subscribe_packet = mosq_test.gen_subscribe(mid, "will/test", 0, proto_ver=proto_ver) subscribe_packet = mosq_test.gen_subscribe(mid, "will/test", 0, proto_ver=proto_ver)
suback_packet = mosq_test.gen_suback(mid, 0, proto_ver=proto_ver) suback_packet = mosq_test.gen_suback(mid, 0, proto_ver=proto_ver)
publish_packet = mosq_test.gen_publish(topic="will/test", qos=0, payload="Client ready", proto_ver=proto_ver) publish_packet = mosq_test.gen_publish(topic="will/test", qos=0, payload="Client ready", proto_ver=proto_ver)
publish_lwt_packet = mosq_test.gen_publish(topic="will/test", qos=0, payload="LWT", proto_ver=proto_ver)
port = mosq_test.get_port() port = mosq_test.get_port()
broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port) broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port)
@ -34,17 +51,21 @@ def do_test(proto_ver, clean_session):
mosq_test.do_send_receive(sock1, subscribe_packet, suback_packet, "suback") mosq_test.do_send_receive(sock1, subscribe_packet, suback_packet, "suback")
# Connect client with will # Connect client with will
sock2 = mosq_test.do_client_connect(connect2_packet, connack2a_packet, timeout=5, port=port) sock2 = mosq_test.do_client_connect(connect2_packet, connack2_packet, timeout=5, port=port)
# Send a "ready" message # Send a "ready" message
sock2.send(publish_packet) sock2.send(publish_packet)
mosq_test.expect_packet(sock1, "publish 1", publish_packet) mosq_test.expect_packet(sock1, "publish 1", publish_packet)
# Connect client with will again as a separate connection, this should # Connect client with will again as a separate connection, this should
# take over from the previous one but not trigger a Will. # take over from the previous one but only trigger a Will if we are taking
sock3 = mosq_test.do_client_connect(connect2_packet, connack2b_packet, timeout=5, port=port) # over a clean session/session-expiry-interval==0 client
sock3 = mosq_test.do_client_connect(connect3_packet, connack3_packet, timeout=5, port=port)
sock2.close() sock2.close()
if clean_session1 == True or clean_session2 == True:
mosq_test.expect_packet(sock1, "publish LWT", publish_lwt_packet)
# Send the "ready" message again # Send the "ready" message again
sock3.send(publish_packet) sock3.send(publish_packet)
mosq_test.expect_packet(sock1, "publish 2", publish_packet) mosq_test.expect_packet(sock1, "publish 2", publish_packet)
@ -63,11 +84,15 @@ def do_test(proto_ver, clean_session):
(stdo, stde) = broker.communicate() (stdo, stde) = broker.communicate()
if rc: if rc:
print(stde.decode('utf-8')) print(stde.decode('utf-8'))
print("proto_ver=%d clean_session=%d" % (proto_ver, clean_session)) print("proto_ver=%d clean_session1=%d clean_session2=%d" % (proto_ver, clean_session1, clean_session2))
exit(rc) exit(rc)
do_test(proto_ver=4, clean_session=True) do_test(proto_ver=4, clean_session1=True, clean_session2=True)
do_test(proto_ver=4, clean_session=False) do_test(proto_ver=4, clean_session1=False, clean_session2=True)
do_test(proto_ver=5, clean_session=True) do_test(proto_ver=4, clean_session1=True, clean_session2=False)
do_test(proto_ver=5, clean_session=False) do_test(proto_ver=4, clean_session1=False, clean_session2=False)
do_test(proto_ver=5, clean_session1=True, clean_session2=True)
do_test(proto_ver=5, clean_session1=False, clean_session2=True)
do_test(proto_ver=5, clean_session1=True, clean_session2=False)
do_test(proto_ver=5, clean_session1=False, clean_session2=False)

@ -1,7 +1,7 @@
<!-- <!--
.. title: Download .. title: Download
.. slug: download .. slug: download
.. date: 2020-12-10 23:34:38 UTC .. date: 2020-12-17 14:21:38 UTC
.. tags: tag .. tags: tag
.. category: category .. category: category
.. link: link .. link: link
@ -11,7 +11,7 @@
# Source # Source
* [mosquitto-2.0.2.tar.gz](https://mosquitto.org/files/source/mosquitto-2.0.2.tar.gz) (319kB) ([GPG signature](https://mosquitto.org/files/source/mosquitto-2.0.2.tar.gz.asc)) * [mosquitto-2.0.3.tar.gz](https://mosquitto.org/files/source/mosquitto-2.0.3.tar.gz) (319kB) ([GPG signature](https://mosquitto.org/files/source/mosquitto-2.0.3.tar.gz.asc))
* [Git source code repository](https://github.com/eclipse/mosquitto) (github.com) * [Git source code repository](https://github.com/eclipse/mosquitto) (github.com)
Older downloads are available at [https://mosquitto.org/files/](../files/) Older downloads are available at [https://mosquitto.org/files/](../files/)
@ -24,8 +24,8 @@ distributions.
## Windows ## Windows
* [mosquitto-2.0.1-install-windows-x64.exe](https://mosquitto.org/files/binary/win64/mosquitto-2.0.1-install-windows-x64.exe) (64-bit build, Windows Vista and up, built with Visual Studio Community 2019) * [mosquitto-2.0.3-install-windows-x64.exe](https://mosquitto.org/files/binary/win64/mosquitto-2.0.3-install-windows-x64.exe) (64-bit build, Windows Vista and up, built with Visual Studio Community 2019)
* [mosquitto-2.0.1-install-windows-x32.exe](https://mosquitto.org/files/binary/win32/mosquitto-2.0.1-install-windows-x86.exe) (32-bit build, Windows Vista and up, built with Visual Studio Community 2019) * [mosquitto-2.0.3-install-windows-x32.exe](https://mosquitto.org/files/binary/win32/mosquitto-2.0.3-install-windows-x86.exe) (32-bit build, Windows Vista and up, built with Visual Studio Community 2019)
Older installers can be found at [https://mosquitto.org/files/binary/](https://mosquitto.org/files/binary/). Older installers can be found at [https://mosquitto.org/files/binary/](https://mosquitto.org/files/binary/).

@ -19,6 +19,10 @@ follow the steps on [Eclipse Security] page to report it.
Listed with most recent first. Further information on security related issues Listed with most recent first. Further information on security related issues
can be found in the [security category]. can be found in the [security category].
* December 2020: Running mosquitto_passwd with the following arguments only
`mosquitto_passwd -b password_file username password` would cause the
username to be used as the password. Affecting versions **2.0.0** to
**2.0.2** inclusive, fixed in **2.0.3**.
* September 2019: [CVE-2019-11779]. Affecting versions **1.5** to **1.6.5** * September 2019: [CVE-2019-11779]. Affecting versions **1.5** to **1.6.5**
inclusive, fixed in **1.6.6** and **1.5.9**. More details at [version-166-released]. inclusive, fixed in **1.6.6** and **1.5.9**. More details at [version-166-released].
* September 2019: [CVE-2019-11778]. Affecting versions **1.6** to **1.6.4** * September 2019: [CVE-2019-11778]. Affecting versions **1.6** to **1.6.4**

@ -0,0 +1,51 @@
<!--
.. title: Version 2.0.3 released.
.. slug: version-2-0-1-released
.. date: 2020-12-17 14:22:16 UTC+00:00
.. tags: Releases
.. category:
.. link:
.. description:
.. type: text
-->
Version 2.0.3 of Mosquitto has been released. This is a bugfix release.
# Security
- Running mosquitto_passwd with the following arguments only
`mosquitto_passwd -b password_file username password` would cause the
username to be used as the password.
# Broker
- Fix excessive CPU use on non-Linux systems when the open file limit is set
high. Closes [#1947].
- Fix LWT not being sent on client takeover when the existing session wasn't
being continued. Closes [#1946].
- Fix bridges possibly not completing connections when WITH_ADNS is in use.
Closes [#1960].
- Fix QoS 0 messages not being delivered if max_queued_messages was set to 0.
Closes [#1956].
- Fix local bridges being disconnected on SIGHUP. Closes [#1942].
- Fix slow initial bridge connections for WITH_ADNS=no.
# Clients
- Fix mosquitto_sub being unable to terminate with Ctrl-C if a successful
connection is not made. Closes [#1957].
# Apps
- Fix `mosquitto_passwd -b` using username as password (not if `-c` is also
used). Closes [#1949].
# Build
- Fix `install` target when using WITH_CJSON=no. Closes [#1938].
- Fix `generic` docker build. Closes [#1945].
[#1938]: https://github.com/eclipse/mosquitto/issues/1938
[#1942]: https://github.com/eclipse/mosquitto/issues/1942
[#1945]: https://github.com/eclipse/mosquitto/issues/1945
[#1946]: https://github.com/eclipse/mosquitto/issues/1946
[#1947]: https://github.com/eclipse/mosquitto/issues/1947
[#1949]: https://github.com/eclipse/mosquitto/issues/1949
[#1956]: https://github.com/eclipse/mosquitto/issues/1956
[#1957]: https://github.com/eclipse/mosquitto/issues/1957
[#1960]: https://github.com/eclipse/mosquitto/issues/1960
Loading…
Cancel
Save