Skip to content

Commit

Permalink
Merge branch 'fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Feb 13, 2019
2 parents 9378016 + bb72cf9 commit a2d4535
Show file tree
Hide file tree
Showing 27 changed files with 385 additions and 115 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -11,7 +11,7 @@ project(mosquitto)
cmake_minimum_required(VERSION 2.8)
# Only for version 3 and up. cmake_policy(SET CMP0042 NEW)

set (VERSION 1.5.6)
set (VERSION 1.5.7)

add_definitions (-DCMAKE -DVERSION=\"${VERSION}\")

Expand Down
18 changes: 17 additions & 1 deletion ChangeLog.txt
@@ -1,8 +1,24 @@
1.5.7 - 201902xx
1.5.7 - 20190213
================

Broker:
- Fix build failure when using WITH_ADNS=yes
- Ensure that an error occurs if `per_listener_settings true` is given after
other security options. Closes #1149.
- Fix include_dir not sorting config files before loading. This was partially
fixed in 1.5 previously.
- Improve documentation around the `include_dir` option. Closes #1154.
- Fix case where old unreferenced msg_store messages were being saved to the
persistence file, bloating its size unnecessarily. Closes #389.

Library:
- Fix `mosquitto_topic_matches_sub()` not returning MOSQ_ERR_INVAL for
invalid subscriptions like `topic/#abc`. This only affects the return value,
not the match/no match result, which was already correct.

Build:
- Don't require C99 compiler.
- Add rewritten build test script and remove some build warnings.


1.5.6 - 20190206
Expand Down
59 changes: 59 additions & 0 deletions buildtest.py
@@ -0,0 +1,59 @@
#!/usr/bin/python3

build_variants = [
'WITH_ADNS',
'WITH_BRIDGE',
'WITH_DOCS',
'WITH_EC',
'WITH_EPOLL',
'WITH_MEMORY_TRACKING',
'WITH_PERSISTENCE',
'WITH_SHARED_LIBRARIES',
'WITH_SOCKS',
'WITH_SRV',
'WITH_STATIC_LIBRARIES',
'WITH_STRIP',
'WITH_SYSTEMD',
'WITH_SYS_TREE',
'WITH_THREADING',
'WITH_TLS',
'WITH_TLS_PSK',
'WITH_WEBSOCKETS',
'WITH_WRAP',
]

special_variants = [
'WITH_BUNDLED_DEPS',
'WITH_COVERAGE',
]


import random
import subprocess

def run_test(msg, opts):
subprocess.run(["make", "clean"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
print("%s: %s" % (msg, str(opts)))
args = ["make", "-j"] + opts
proc = subprocess.run(args, stdout=subprocess.DEVNULL)
if proc.returncode != 0:
raise RuntimeError("BUILD FAILED: %s" % (' '.join(args)))

def simple_tests():
for bv in build_variants:
for enabled in ["yes", "no"]:
opts = "%s=%s" % (bv, enabled)
run_test("SIMPLE BUILD", [opts])

def random_tests(count=10):
for i in range(1, count):
opts = []
for bv in build_variants:
opts.append("%s=%s" % (bv, random.choice(["yes", "no"])))

run_test("RANDOM BUILD", opts)


if __name__ == "__main__":
simple_tests()
random_tests(100)
4 changes: 2 additions & 2 deletions client/Makefile
Expand Up @@ -21,10 +21,10 @@ static : static_pub static_sub
# libmosquitto only.

static_pub : pub_client.o client_shared.o ../lib/libmosquitto.a
${CROSS_COMPILE}${CC} $^ -o mosquitto_pub ${CLIENT_LDFLAGS} -lssl -lcrypto -lpthread
${CROSS_COMPILE}${CC} $^ -o mosquitto_pub ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS}

static_sub : sub_client.o sub_client_output.o client_shared.o ../lib/libmosquitto.a
${CROSS_COMPILE}${CC} $^ -o mosquitto_sub ${CLIENT_LDFLAGS} -lssl -lcrypto -lpthread
${CROSS_COMPILE}${CC} $^ -o mosquitto_sub ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS}

mosquitto_pub : pub_client.o client_shared.o
${CROSS_COMPILE}${CC} $^ -o $@ ${CLIENT_LDFLAGS}
Expand Down
6 changes: 5 additions & 1 deletion config.mk
Expand Up @@ -105,7 +105,7 @@ WITH_BUNDLED_DEPS:=yes

# Also bump lib/mosquitto.h, CMakeLists.txt,
# installer/mosquitto.nsi, installer/mosquitto64.nsi
VERSION=1.5.6
VERSION=1.5.7

# Client library SO version. Bump if incompatible API/ABI changes are made.
SOVERSION=1
Expand All @@ -129,6 +129,7 @@ else
CFLAGS?=-Wall -ggdb -O2
endif

STATIC_LIB_DEPS:=
LIB_CFLAGS:=${CFLAGS} ${CPPFLAGS} -I. -I.. -I../lib
LIB_CXXFLAGS:=$(CFLAGS) ${CPPFLAGS} -I. -I.. -I../lib
LIB_LDFLAGS:=${LDFLAGS}
Expand Down Expand Up @@ -192,6 +193,7 @@ ifeq ($(WITH_TLS),yes)
LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_TLS
PASSWD_LIBS:=-lcrypto
CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_TLS
STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lssl -lcrypto

ifeq ($(WITH_TLS_PSK),yes)
BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_TLS_PSK
Expand All @@ -204,6 +206,7 @@ ifeq ($(WITH_THREADING),yes)
LIB_LIBS:=$(LIB_LIBS) -lpthread
LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_THREADING
CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_THREADING
STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lpthread
endif

ifeq ($(WITH_SOCKS),yes)
Expand Down Expand Up @@ -249,6 +252,7 @@ ifeq ($(WITH_SRV),yes)
LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_SRV
LIB_LIBS:=$(LIB_LIBS) -lcares
CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -DWITH_SRV
STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lcares
endif

ifeq ($(UNAME),SunOS)
Expand Down
2 changes: 1 addition & 1 deletion installer/mosquitto.nsi
Expand Up @@ -9,7 +9,7 @@
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'

Name "Eclipse Mosquitto"
!define VERSION 1.5.6
!define VERSION 1.5.7
OutFile "mosquitto-${VERSION}-install-windows-x86.exe"

InstallDir "$PROGRAMFILES\mosquitto"
Expand Down
2 changes: 1 addition & 1 deletion installer/mosquitto64.nsi
Expand Up @@ -9,7 +9,7 @@
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'

Name "Eclipse Mosquitto"
!define VERSION 1.5.6
!define VERSION 1.5.7
OutFile "mosquitto-${VERSION}-install-windows-x64.exe"

!include "x64.nsh"
Expand Down
2 changes: 1 addition & 1 deletion lib/mosquitto.h
Expand Up @@ -47,7 +47,7 @@ extern "C" {

#define LIBMOSQUITTO_MAJOR 1
#define LIBMOSQUITTO_MINOR 5
#define LIBMOSQUITTO_REVISION 6
#define LIBMOSQUITTO_REVISION 7
/* 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)

Expand Down
63 changes: 38 additions & 25 deletions lib/util_mosq.c
Expand Up @@ -245,6 +245,7 @@ int mosquitto_topic_matches_sub2(const char *sub, size_t sublen, const char *top
{
int spos, tpos;
bool multilevel_wildcard = false;
int i;

if(!result) return MOSQ_ERR_INVAL;
*result = false;
Expand All @@ -270,31 +271,10 @@ int mosquitto_topic_matches_sub2(const char *sub, size_t sublen, const char *top
tpos = 0;

while(spos < sublen && tpos <= topiclen){
if(sub[spos] == topic[tpos]){
if(tpos == topiclen-1){
/* Check for e.g. foo matching foo/# */
if(spos == sublen-3
&& sub[spos+1] == '/'
&& sub[spos+2] == '#'){
*result = true;
multilevel_wildcard = true;
return MOSQ_ERR_SUCCESS;
}
}
spos++;
tpos++;
if(spos == sublen && tpos == topiclen){
*result = true;
return MOSQ_ERR_SUCCESS;
}else if(tpos == topiclen && spos == sublen-1 && sub[spos] == '+'){
if(spos > 0 && sub[spos-1] != '/'){
return MOSQ_ERR_INVAL;
}
spos++;
*result = true;
return MOSQ_ERR_SUCCESS;
}
}else{
if(topic[tpos] == '+' || topic[tpos] == '#'){
return MOSQ_ERR_INVAL;
}
if(tpos == topiclen || sub[spos] != topic[tpos]){ /* Check for wildcard matches */
if(sub[spos] == '+'){
/* Check for bad "+foo" or "a/+foo" subscription */
if(spos > 0 && sub[spos-1] != '/'){
Expand Down Expand Up @@ -336,6 +316,39 @@ int mosquitto_topic_matches_sub2(const char *sub, size_t sublen, const char *top
multilevel_wildcard = true;
return MOSQ_ERR_SUCCESS;
}

for(i=spos; i<sublen; i++){
if(sub[i] == '#' && i+1 != sublen){
return MOSQ_ERR_INVAL;
}
}

/* Valid input, but no match */
return MOSQ_ERR_SUCCESS;
}
}else{
/* sub[spos] == topic[tpos] */
if(tpos == topiclen-1){
/* Check for e.g. foo matching foo/# */
if(spos == sublen-3
&& sub[spos+1] == '/'
&& sub[spos+2] == '#'){
*result = true;
multilevel_wildcard = true;
return MOSQ_ERR_SUCCESS;
}
}
spos++;
tpos++;
if(spos == sublen && tpos == topiclen){
*result = true;
return MOSQ_ERR_SUCCESS;
}else if(tpos == topiclen && spos == sublen-1 && sub[spos] == '+'){
if(spos > 0 && sub[spos-1] != '/'){
return MOSQ_ERR_INVAL;
}
spos++;
*result = true;
return MOSQ_ERR_SUCCESS;
}
}
Expand Down
49 changes: 49 additions & 0 deletions man/mosquitto.conf.5.xml
Expand Up @@ -349,6 +349,55 @@
file. This option will only be processed from the main
configuration file. The directory specified must not
contain the main configuration file.</para>
<para>The configuration files in
<option>include_dir</option> are loaded in case
sensitive alphabetical order, with the upper case of
each letter ordered before the lower case of the same
letter.</para>
<example title="Load Order for include_dir" label="Load Order for include_dir">
<para>Given the files
<replaceable>b.conf</replaceable>,
<replaceable>A.conf</replaceable>,
<replaceable>01.conf</replaceable>,
<replaceable>a.conf</replaceable>,
<replaceable>B.conf</replaceable>, and
<replaceable>00.conf</replaceable> inside
<option>include_dir</option>, the config files
would be loaded in this order:</para>
<programlisting language="config">
00.conf
01.conf
A.conf
a.conf
B.conf
b.conf
</programlisting></example>
<para>If this option is used multiple times, then each
<option>include_dir</option> option is processed
completely in the order that they are written in the
main configuration file.</para>
<example title="Load Order for Multiple include_dir" label="Load Order for Multiple include_dir">
<para>Assuming a directory
<replaceable>one.d</replaceable> containing
files <replaceable>B.conf</replaceable> and
<replaceable>C.conf</replaceable>, and a second
directory <replaceable>two.d</replaceable>
containing files
<replaceable>A.conf</replaceable> and
<replaceable>D.conf</replaceable>, and a
config:</para>
<programlisting language="config">
include_dir one.d
include_dir two.d
</programlisting><para>Then the config files would be loaded in this order:</para>
<programlisting language="config">
# files from one.d
B.conf
C.conf
# files from two.d
A.conf
D.conf
</programlisting></example>
</listitem>
</varlistentry>
<varlistentry>
Expand Down
4 changes: 4 additions & 0 deletions mosquitto.conf
Expand Up @@ -872,6 +872,10 @@
# in the main file. This option will only be processed from the main
# configuration file. The directory specified must not contain the
# main configuration file.
# Files within include_dir will be loaded sorted in case-sensitive
# alphabetical order, with capital letters ordered first. If this option is
# given multiple times, all of the files from the first instance will be
# processed before the next instance. See the man page for examples.
#include_dir

# =================================================================
Expand Down
2 changes: 1 addition & 1 deletion set-version.sh
Expand Up @@ -2,7 +2,7 @@

MAJOR=1
MINOR=5
REVISION=6
REVISION=7

sed -i "s/^VERSION=.*/VERSION=${MAJOR}.${MINOR}.${REVISION}/" config.mk

Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
@@ -1,5 +1,5 @@
name: mosquitto
version: 1.5.6
version: 1.5.7
summary: Eclipse Mosquitto MQTT broker
description: This is a message broker that supports version 3.1 and 3.1.1 of the MQTT
protocol.
Expand Down
1 change: 0 additions & 1 deletion src/bridge.c
Expand Up @@ -112,7 +112,6 @@ int bridge__new(struct mosquitto_db *db, struct mosquitto__bridge *bridge)
int bridge__connect_step1(struct mosquitto_db *db, struct mosquitto *context)
{
int rc;
int i;
char *notification_topic;
int notification_topic_len;
uint8_t notification_payload;
Expand Down

0 comments on commit a2d4535

Please sign in to comment.