Skip to content

Commit

Permalink
Merge branch 'develop' into mqtt5
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Oct 2, 2018
2 parents 4ee6941 + 1867f30 commit 6c9e8d5
Show file tree
Hide file tree
Showing 319 changed files with 20,480 additions and 647 deletions.
22 changes: 15 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ cpp/*.test
*.pyc
*.vglog

build/

client/mosquitto_pub
client/mosquitto_sub

dist/

examples/mysql_log/mosquitto_mysql_log
examples/temperature_conversion/mqtt_temperature_conversion

lib/cpp/libmosquittopp.so*
lib/cpp/libmosquittopp.a
lib/libmosquitto.so*
lib/libmosquitto.a

man/mosquitto.8
man/mosquitto-tls.7
man/mosquitto.conf.5
Expand All @@ -19,9 +30,11 @@ man/mosquitto_passwd.1
man/mosquitto_pub.1
man/mosquitto_sub.1
man/mqtt.7

src/db_dump/mosquitto_db_dump
src/mosquitto
src/mosquitto_passwd

test/broker/broker.pid
test/test_client
test/fake_user
Expand All @@ -32,15 +45,10 @@ test/msgsps_sub.dat
test/broker/c/auth_plugin.so
test/broker/c/*.test

lib/cpp/libmosquittopp.so*
lib/cpp/libmosquittopp.a
lib/libmosquitto.so*
lib/libmosquitto.a

test/ssl/*.csr

test/lib/c/*.test
test/lib/cpp/*.test

build/
dist/
www/cache/
__pycache__
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
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.1)
set (VERSION 1.5.3)

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

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Foundation IP policy.
Please read the [Eclipse Foundation policy on accepting contributions via Git](http:https://wiki.eclipse.org/Development_Resources/Contributing_via_Git).

1. Sign the [Eclipse ECA](http:https://www.eclipse.org/legal/ECA.php)
1. Register for an Eclipse Foundation User ID. You can register [here](https://dev.eclipse.org/site_login/createaccount.php).
2. Log into the [Projects Portal](https://projects.eclipse.org/), and click on the '[Eclipse ECA](https://projects.eclipse.org/user/sign/eca)' link.
2. Go to your [account settings](https://dev.eclipse.org/site_login/myaccount.php#open_tab_accountsettings) and add your GitHub username to your account.
1. Register for an Eclipse Foundation User ID. You can register [here](https://accounts.eclipse.org/user/register).
2. Log into the [Accounts Portal](https://accounts.eclipse.org/), and click on the '[Eclipse Contributor Agreement](https://accounts.eclipse.org/user/eca)' link.
2. Go to your [account settings](https://accounts.eclipse.org/user/edit) and add your GitHub username to your account.
3. Make sure that you _sign-off_ your Git commits in the following format:
``` Signed-off-by: John Smith <[email protected]> ``` This is usually at the bottom of the commit message. You can automate this by adding the '-s' flag when you make the commits. e.g. ```git commit -s -m "Adding a cool feature"```
4. Ensure that the email address that you make your commits with is the same one you used to sign up to the Eclipse Foundation website with.
Expand Down
59 changes: 59 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
1.6 - 2018xxxx
==============

Client library features:
- Add mosquitto_subscribe_multiple() for sending subscriptions to multiple
topics in one command.

Client features:
- Add -E to mosquitto_sub, which causes it to exit immediately after having
its subscriptions acknowledged. Use with -c to create a durable client
session without requiring a message to be received.


1.5.3 - 20180925
================

Security:
- Fix CVE-2018-12543. If a message is sent to Mosquitto with a topic that
begins with $, but is not $SYS, then an assert that should be unreachable is
triggered and Mosquitto will exit.

Broker:
- Elevate log level to warning for situation when socket limit is hit.
- Remove requirement to use `user root` in snap package config files.
- Fix retained messages not sent by bridges on outgoing topics at the first
connection. Closes #701.
- Documentation fixes. Closes #520, #600.
- Fix duplicate clients being added to by_id hash before the old client was
removed. Closes #645.
- Fix Windows version not starting if include_dir did not contain any files.
Closes #566.

Build:
- Various fixes to ease building.


1.5.2 - 20180919
================

Broker:
- Fix build when using WITH_ADNS=yes.
- Fix incorrect call to setsockopt() for TCP_NODELAY. Closes #941.
- Fix excessive CPU usage when the number of sockets exceeds the system limit.
Closes #948.
- Fix for bridge connections when using WITH_ADNS=yes.
- Fix round_robin false behaviour. Closes #481.
- Fix segfault on HUP when bridges and security options are configured.
Closes #965.

Library:
- Fix situation where username and password is used with SOCKS5 proxy. Closes
#927.
- Fix SOCKS5 behaviour when passing IP addresses. Closes #927.

Build:
- Make it easier to build without bundled uthash.h using "WITH_BUNDLED_DEPS=no".
- Fix build with OPENSSL_NO_ENGINE. Closes #932.


1.5.1 - 20180816
================

Expand Down
5 changes: 5 additions & 0 deletions client/client_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
}
}
i++;
}else if(!strcmp(argv[i], "-E")){
if(pub_or_sub == CLIENT_PUB){
goto unknown_option;
}
cfg->exit_after_sub = true;
}else if(!strcmp(argv[i], "-F")){
if(pub_or_sub == CLIENT_PUB){
goto unknown_option;
Expand Down
1 change: 1 addition & 0 deletions client/client_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct mosq_config {
bool clean_session;
char **topics; /* sub */
int topic_count; /* sub */
bool exit_after_sub; /* sub */
bool no_retain; /* sub */
bool retained_only; /* sub */
char **filter_outs; /* sub */
Expand Down
12 changes: 8 additions & 4 deletions client/sub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag
cfg = (struct mosq_config *)obj;

if(!result){
for(i=0; i<cfg->topic_count; i++){
mosquitto_subscribe(mosq, NULL, cfg->topics[i], cfg->qos);
}
mosquitto_subscribe_multiple(mosq, NULL, cfg->topic_count, (const char **)cfg->topics, cfg->qos);

for(i=0; i<cfg->unsub_topic_count; i++){
mosquitto_unsubscribe(mosq, NULL, cfg->unsub_topics[i]);
}
Expand All @@ -123,6 +122,10 @@ void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_c
if(!cfg->quiet) printf(", %d", granted_qos[i]);
}
if(!cfg->quiet) printf("\n");

if(cfg->exit_after_sub){
mosquitto_disconnect(mosq);
}
}

void my_log_callback(struct mosquitto *mosq, void *obj, int level, const char *str)
Expand All @@ -139,7 +142,7 @@ void print_usage(void)
printf("mosquitto_sub version %s running on libmosquitto %d.%d.%d.\n\n", VERSION, major, minor, revision);
printf("Usage: mosquitto_sub {[-h host] [-p port] [-u username [-P password]] -t topic | -L URL [-t topic]}\n");
printf(" [-c] [-k keepalive] [-q qos]\n");
printf(" [-C msg_count] [-R] [--retained-only] [-T filter_out] [-U topic ...]\n");
printf(" [-C msg_count] [-E] [-R] [--retained-only] [-T filter_out] [-U topic ...]\n");
printf(" [-F format]\n");
#ifndef WIN32
printf(" [-W timeout_secs]\n");
Expand Down Expand Up @@ -168,6 +171,7 @@ void print_usage(void)
printf(" -c : disable 'clean session' (store subscription and pending messages when client disconnects).\n");
printf(" -C : disconnect and exit after receiving the 'msg_count' messages.\n");
printf(" -d : enable debug messages.\n");
printf(" -E : Exit once all subscriptions have been acknowledged by the broker.\n");
printf(" -F : output format.\n");
printf(" -h : mqtt host to connect to. Defaults to localhost.\n");
printf(" -i : id to use for this client. Defaults to mosquitto_sub_ appended with the process id.\n");
Expand Down
31 changes: 14 additions & 17 deletions config.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#ifndef CONFIG_H
/* ============================================================
* Control compile time options.
* ============================================================
*
* Compile time options have moved to config.mk.
*/
* Platform options
* ============================================================ */

#ifdef __APPLE__
# define __DARWIN_C_SOURCE
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__SYMBIAN32__) || defined(__QNX__)
# define _XOPEN_SOURCE 700
# define __BSD_VISIBLE 1
# define HAVE_NETINET_IN_H
#else
# define _XOPEN_SOURCE 700
# define _DEFAULT_SOURCE 1
# define _POSIX_C_SOURCE 200809L
#endif


/* ============================================================
Expand All @@ -27,16 +36,4 @@
#define uthash_malloc(sz) mosquitto__malloc(sz)
#define uthash_free(ptr,sz) mosquitto__free(ptr)

#ifdef __APPLE__
# define __DARWIN_C_SOURCE
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__SYMBIAN32__) || defined(__QNX__)
# define _XOPEN_SOURCE 700
# define __BSD_VISIBLE 1
# define HAVE_NETINET_IN_H
#else
# define _XOPEN_SOURCE 700
# define _DEFAULT_SOURCE 1
# define _POSIX_C_SOURCE 200809L
#endif

#endif
16 changes: 12 additions & 4 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ WITH_STATIC_LIBRARIES:=no
# Build with epoll support.
WITH_EPOLL:=yes

# Build with bundled uthash.h
WITH_BUNDLED_DEPS:=yes

# =============================================================================
# End of user configuration
# =============================================================================


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

# Client library SO version. Bump if incompatible API/ABI changes are made.
SOVERSION=1
Expand Down Expand Up @@ -272,9 +275,11 @@ ifeq ($(WITH_WEBSOCKETS),static)
endif

INSTALL?=install
prefix=/usr/local
mandir=${prefix}/share/man
localedir=${prefix}/share/locale
prefix?=/usr/local
incdir?=${prefix}/include
libdir?=${prefix}/lib${LIB_SUFFIX}
localedir?=${prefix}/share/locale
mandir?=${prefix}/share/man
STRIP?=strip

ifeq ($(WITH_STRIP),yes)
Expand All @@ -287,3 +292,6 @@ ifeq ($(WITH_EPOLL),yes)
endif
endif

ifeq ($(WITH_BUNDLED_DEPS),yes)
BROKER_CFLAGS:=$(BROKER_CFLAGS) -Ideps
endif
2 changes: 1 addition & 1 deletion installer/mosquitto.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
!define env_hklm 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'

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

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

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

!include "x64.nsh"
Expand Down
24 changes: 13 additions & 11 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,24 @@ all : ${ALL_DEPS}
$(MAKE) -C cpp

install : all
$(INSTALL) -d "${DESTDIR}$(prefix)/lib${LIB_SUFFIX}/"
$(INSTALL) ${STRIP_OPTS} libmosquitto.so.${SOVERSION} "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so.${SOVERSION}"
ln -sf libmosquitto.so.${SOVERSION} "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so"
$(INSTALL) -d "${DESTDIR}${libdir}/"
$(INSTALL) ${STRIP_OPTS} libmosquitto.so.${SOVERSION} "${DESTDIR}${libdir}/libmosquitto.so.${SOVERSION}"
ln -sf libmosquitto.so.${SOVERSION} "${DESTDIR}${libdir}/libmosquitto.so"
ifeq ($(WITH_STATIC_LIBRARIES),yes)
$(INSTALL) libmosquitto.a "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.a"
${CROSS_COMPILE}${STRIP} -g --strip-unneeded "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.a"
$(INSTALL) ${STRIP_OPTS} libmosquitto.a "${DESTDIR}${libdir}/libmosquitto.a"
endif
$(INSTALL) -d "${DESTDIR}${prefix}/include/"
$(INSTALL) mosquitto.h "${DESTDIR}${prefix}/include/mosquitto.h"
$(INSTALL) -d "${DESTDIR}${incdir}/"
$(INSTALL) mosquitto.h "${DESTDIR}${incdir}/mosquitto.h"
$(INSTALL) -d "${DESTDIR}${libdir}/pkgconfig"
$(INSTALL) -m644 ../libmosquitto.pc.in "${DESTDIR}${libdir}/pkgconfig/libmosquitto.pc"
sed -i -e "s#@CMAKE_INSTALL_PREFIX@#${prefix}#" -e "s#@VERSION@#${VERSION}#" "${DESTDIR}${libdir}/pkgconfig/libmosquitto.pc"
$(MAKE) -C cpp install

uninstall :
-rm -f "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so.${SOVERSION}"
-rm -f "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.so"
-rm -f "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquitto.a"
-rm -f "${DESTDIR}${prefix}/include/mosquitto.h"
-rm -f "${DESTDIR}${libdir}/libmosquitto.so.${SOVERSION}"
-rm -f "${DESTDIR}${libdir}/libmosquitto.so"
-rm -f "${DESTDIR}${libdir}/libmosquitto.a"
-rm -f "${DESTDIR}${incdir}/mosquitto.h"

reallyclean : clean

Expand Down
19 changes: 18 additions & 1 deletion lib/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,24 @@ int mosquitto_subscribe(struct mosquitto *mosq, int *mid, const char *sub, int q
if(mosquitto_sub_topic_check(sub)) return MOSQ_ERR_INVAL;
if(mosquitto_validate_utf8(sub, strlen(sub))) return MOSQ_ERR_MALFORMED_UTF8;

return send__subscribe(mosq, mid, sub, qos);
return send__subscribe(mosq, mid, 1, &sub, qos);
}


int mosquitto_subscribe_multiple(struct mosquitto *mosq, int *mid, int sub_count, const char **sub, int qos)
{
int i;

if(!mosq || !sub_count || !sub) return MOSQ_ERR_INVAL;
if(qos < 0 || qos > 2) return MOSQ_ERR_INVAL;
if(mosq->sock == INVALID_SOCKET) return MOSQ_ERR_NO_CONN;

for(i=0; i<sub_count; i++){
if(mosquitto_sub_topic_check(sub[i])) return MOSQ_ERR_INVAL;
if(mosquitto_validate_utf8(sub[i], strlen(sub[i]))) return MOSQ_ERR_MALFORMED_UTF8;
}

return send__subscribe(mosq, mid, sub_count, sub, qos);
}


Expand Down
27 changes: 15 additions & 12 deletions lib/cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@ endif
all : ${ALL_DEPS}

install : all
$(INSTALL) -d "${DESTDIR}$(prefix)/lib${LIB_SUFFIX}/"
$(INSTALL) ${STRIP_OPTS} libmosquittopp.so.${SOVERSION} "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.so.${SOVERSION}"
ln -sf libmosquittopp.so.${SOVERSION} "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.so"
$(INSTALL) -d "${DESTDIR}${libdir}/"
$(INSTALL) ${STRIP_OPTS} libmosquittopp.so.${SOVERSION} "${DESTDIR}${libdir}/libmosquittopp.so.${SOVERSION}"
ln -sf libmosquittopp.so.${SOVERSION} "${DESTDIR}${libdir}/libmosquittopp.so"
ifeq ($(WITH_STATIC_LIBRARIES),yes)
$(INSTALL) libmosquittopp.a "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.a"
${CROSS_COMPILE}${STRIP} -g --strip-unneeded "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.a"
$(INSTALL) libmosquittopp.a "${DESTDIR}${libdir}/libmosquittopp.a"
${CROSS_COMPILE}${STRIP} -g --strip-unneeded "${DESTDIR}${libdir}/libmosquittopp.a"
endif
$(INSTALL) -d "${DESTDIR}${prefix}/include/"
$(INSTALL) mosquittopp.h "${DESTDIR}${prefix}/include/mosquittopp.h"

$(INSTALL) -d "${DESTDIR}${incdir}/"
$(INSTALL) mosquittopp.h "${DESTDIR}${incdir}/mosquittopp.h"
$(INSTALL) -d "${DESTDIR}${libdir}/pkgconfig/"
$(INSTALL) -m644 ../../libmosquittopp.pc.in "${DESTDIR}${libdir}/pkgconfig/libmosquittopp.pc"
sed -i -e "s#@CMAKE_INSTALL_PREFIX@#${prefix}#" -e "s#@VERSION@#${VERSION}#" "${DESTDIR}${libdir}/pkgconfig/libmosquittopp.pc"

uninstall :
-rm -f "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.so.${SOVERSION}"
-rm -f "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.so"
-rm -f "${DESTDIR}${prefix}/lib${LIB_SUFFIX}/libmosquittopp.a"
-rm -f "${DESTDIR}${prefix}/include/mosquittopp.h"
-rm -f "${DESTDIR}${libdir}/libmosquittopp.so.${SOVERSION}"
-rm -f "${DESTDIR}${libdir}/libmosquittopp.so"
-rm -f "${DESTDIR}${libdir}/libmosquittopp.a"
-rm -f "${DESTDIR}${incdir}/mosquittopp.h"

clean :
-rm -f *.o libmosquittopp.so.${SOVERSION} libmosquittopp.a
Expand Down
Loading

0 comments on commit 6c9e8d5

Please sign in to comment.