Skip to content

Commit

Permalink
Merge branch 'master' into mqtt5
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Dec 19, 2018
2 parents 31e6dbb + 84c5d90 commit fcf4cd0
Show file tree
Hide file tree
Showing 71 changed files with 1,115 additions and 553 deletions.
26 changes: 25 additions & 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.3)
set (VERSION 1.5.5)

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

Expand Down Expand Up @@ -73,6 +73,30 @@ endif (${WITH_SOCKS} STREQUAL ON)

option(WITH_SRV "Include SRV lookup support?" OFF)

option(WITH_THREADING "Include client library threading support?" ON)
if (${WITH_THREADING} STREQUAL ON)
add_definitions("-DWITH_THREADING")
if (WIN32)
if (CMAKE_CL_64)
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x64\\pthreadVC2.lib)
else (CMAKE_CL_64)
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x86\\pthreadVC2.lib)
endif (CMAKE_CL_64)
set (PTHREAD_INCLUDE_DIR C:\\pthreads\\Pre-built.2\\include)
else (WIN32)
find_library(LIBPTHREAD pthread)
if (LIBPTHREAD)
set (PTHREAD_LIBRARIES pthread)
else (LIBPTHREAD)
set (PTHREAD_LIBRARIES "")
endif()
set (PTHREAD_INCLUDE_DIR "")
endif (WIN32)
else (${WITH_THREADING} STREQUAL ON)
set (PTHREAD_LIBRARIES "")
set (PTHREAD_INCLUDE_DIR "")
endif (${WITH_THREADING} STREQUAL ON)

option(DOCUMENTATION "Build documentation?" ON)

# ========================================
Expand Down
74 changes: 74 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,78 @@ Client features:
session without requiring a message to be received.


1.5.5 - 20181211
================

Security:
- If `per_listener_settings` is set to true, then the `acl_file` setting was
ignored for the "default listener" only. This has been fixed. This does not
affect any listeners defined with the `listener` option. Closes #1073.

Broker:
- Add `socket_domain` option to allow listeners to disable IPv6 support.
This is required to work around a problem in libwebsockets that means
sockets only listen on IPv6 by default if IPv6 support is compiled in.
Closes #1004.
- When using ADNS, don't ask for all network protocols when connecting,
because this can lead to confusing "Protocol not supported" errors if the
network is down. Closes #1062.
- Fix outgoing retained messages not being sent by bridges on initial
connection. Closes #1040.
- Don't reload auth_opt_ options on reload, to match the behaviour of the
other plugin options. Closes #1068.
- Print message on error when installing/uninstalling as a Windows service.
- All non-error connect/disconnect messages are controlled by the
`connection_messages` option. Closes #772. Closes #613. Closes #537.

Library:
- Fix reconnect delay backoff behaviour. Closes #1027.
- Don't call on_disconnect() twice if keepalive tests fail. Closes #1067.

Client:
- Always print leading zeros in mosquitto_sub when output format is hex.
Closes #1066.

Build:
- Fix building where TLS-PSK is not available. Closes #68.


1.5.4 - 20181108
================

Security:
- When using a TLS enabled websockets listener with "require_certificate"
enabled, the mosquitto broker does not correctly verify client certificates.
This is now fixed. All other security measures operate as expected, and in
particular non-websockets listeners are not affected by this. Closes #996.

Broker:
- Process all pending messages even when a client has disconnected. This means
a client that send a PUBLISH then DISCONNECT quickly, then disconnects will
have its DISCONNECT message processed properly and so no Will will be sent.
Closes #7.
- $SYS/broker/clients/disconnected should never be negative. Closes #287.
- Give better error message if a client sends a password without a username.
Closes #1015.
- Fix bridge not honoring restart_timeout. Closes #1019.
- Don't disconnect a client if an auth plugin denies access to SUBSCRIBE.
Closes #1016.

Library:
- Fix memory leak that occurred if mosquitto_reconnect() was used when TLS
errors were present. Closes #592.
- Fix TLS connections when using an external event loop with
mosquitto_loop_read() and mosquitto_write(). Closes #990.

Build:
- Fix clients not being compiled with threading support when using CMake.
Closes #983.
- Header fixes for FreeBSD. Closes #977.
- Use _GNU_SOURCE to fix build errors in websockets and getaddrinfo usage.
Closes #862 and #933.
- Fix builds on QNX 7.0.0. Closes #1018.


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

Expand All @@ -36,6 +108,8 @@ Broker:
removed. Closes #645.
- Fix Windows version not starting if include_dir did not contain any files.
Closes #566.
- When an authentication plugin denied access to a SUBSCRIBE, the client would
be disconnected incorrectly. This has been fixed. Closes #1016.

Build:
- Various fixes to ease building.
Expand Down
8 changes: 7 additions & 1 deletion client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
${STDBOOL_H_PATH} ${STDINT_H_PATH})
${STDBOOL_H_PATH} ${STDINT_H_PATH} ${PTHREAD_INCLUDE_DIR})
link_directories(${mosquitto_BINARY_DIR}/lib)

set(shared_src client_shared.c client_shared.h client_props.c)
Expand All @@ -11,8 +11,14 @@ endif (${WITH_SRV} STREQUAL ON)
add_executable(mosquitto_pub pub_client.c pub_shared.c ${shared_src})
add_executable(mosquitto_sub sub_client.c sub_client_output.c ${shared_src})


target_link_libraries(mosquitto_pub libmosquitto)
target_link_libraries(mosquitto_sub libmosquitto)

if (QNX)
target_link_libraries(mosquitto_pub socket)
target_link_libraries(mosquitto_sub socket)
endif()

install(TARGETS mosquitto_pub RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}")
install(TARGETS mosquitto_sub RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}")
22 changes: 17 additions & 5 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ include ../config.mk

.PHONY: all install uninstall reallyclean clean static static_pub static_sub

all : mosquitto_pub mosquitto_sub
ifeq ($(WITH_SHARED_LIBRARIES),yes)
SHARED_DEP:=../lib/libmosquitto.so.${SOVERSION}
endif

ifeq ($(WITH_SHARED_LIBRARIES),yes)
ALL_DEPS:= mosquitto_pub mosquitto_sub
else
ifeq ($(WITH_STATIC_LIBRARIES),yes)
ALL_DEPS:= static_pub static_sub
endif
endif

all : ${ALL_DEPS}

static : static_pub static_sub
# This makes mosquitto_pub/sub versions that are statically linked with
Expand All @@ -20,16 +32,16 @@ mosquitto_pub : pub_client.o pub_shared.o client_shared.o client_props.o
mosquitto_sub : sub_client.o sub_client_output.o client_shared.o client_props.o
${CROSS_COMPILE}${CC} $^ -o $@ ${CLIENT_LDFLAGS}

pub_client.o : pub_client.c ../lib/libmosquitto.so.${SOVERSION}
pub_client.o : pub_client.c ${SHARED_DEP}
${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}

pub_shared.o : pub_shared.c ../lib/libmosquitto.so.${SOVERSION}
pub_shared.o : pub_shared.c ${SHARED_DEP}
${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}

sub_client.o : sub_client.c ../lib/libmosquitto.so.${SOVERSION}
sub_client.o : sub_client.c ${SHARED_DEP}
${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}

sub_client_output.o : sub_client_output.c ../lib/libmosquitto.so.${SOVERSION}
sub_client_output.o : sub_client_output.c ${SHARED_DEP}
${CROSS_COMPILE}${CC} -c $< -o $@ ${CLIENT_CFLAGS}

client_shared.o : client_shared.c client_shared.h
Expand Down
16 changes: 10 additions & 6 deletions client/client_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void client_config_cleanup(struct mosq_config *cfg)
free(cfg->keyfile);
free(cfg->ciphers);
free(cfg->tls_version);
# ifdef WITH_TLS_PSK
# ifdef FINAL_WITH_TLS_PSK
free(cfg->psk);
free(cfg->psk_identity);
# endif
Expand Down Expand Up @@ -316,7 +316,7 @@ int client_config_load(struct mosq_config *cfg, int pub_or_sub, int argc, char *
return 1;
}
#endif
#ifdef WITH_TLS_PSK
#ifdef FINAL_WITH_TLS_PSK
if((cfg->cafile || cfg->capath) && cfg->psk){
if(!cfg->quiet) fprintf(stderr, "Error: Only one of --psk or --cafile/--capath may be used at once.\n");
return 1;
Expand Down Expand Up @@ -734,7 +734,7 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
i++;
}
#endif
#ifdef WITH_TLS_PSK
#ifdef FINAL_WITH_TLS_PSK
}else if(!strcmp(argv[i], "--psk")){
if(i==argc-1){
fprintf(stderr, "Error: --psk argument given but no key specified.\n\n");
Expand Down Expand Up @@ -977,7 +977,7 @@ int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg)
mosquitto_lib_cleanup();
return 1;
}
# ifdef WITH_TLS_PSK
# ifdef FINAL_WITH_TLS_PSK
if(cfg->psk && mosquitto_tls_psk_set(mosq, cfg->psk, cfg->psk_identity, NULL)){
if(!cfg->quiet) fprintf(stderr, "Error: Problem setting TLS-PSK options.\n");
mosquitto_lib_cleanup();
Expand Down Expand Up @@ -1038,14 +1038,18 @@ int client_id_generate(struct mosq_config *cfg, const char *id_base)

int client_connect(struct mosquitto *mosq, struct mosq_config *cfg)
{
#ifndef WIN32
char *err;
#else
char err[1024];
#endif
int rc;
int port;

if(cfg->port < 0){
#ifdef WITH_TLS
if(cfg->cafile || cfg->capath
# ifdef WITH_TLS_PSK
# ifdef FINAL_WITH_TLS_PSK
|| cfg->psk
# endif
){
Expand All @@ -1072,7 +1076,7 @@ int client_connect(struct mosquitto *mosq, struct mosq_config *cfg)
if(!cfg->quiet){
if(rc == MOSQ_ERR_ERRNO){
#ifndef WIN32
strerror_r(errno, err, 1024);
err = strerror(errno);
#else
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errno, 0, (LPTSTR)&err, 1024, NULL);
#endif
Expand Down
2 changes: 1 addition & 1 deletion client/client_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct mosq_config {
char *ciphers;
bool insecure;
char *tls_version;
# ifdef WITH_TLS_PSK
# ifdef FINAL_WITH_TLS_PSK
char *psk;
char *psk_identity;
# endif
Expand Down
4 changes: 2 additions & 2 deletions client/pub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void print_usage(void)
#ifdef WITH_TLS
printf(" [{--cafile file | --capath dir} [--cert file] [--key file]\n");
printf(" [--ciphers ciphers] [--insecure]]\n");
#ifdef WITH_TLS_PSK
#ifdef FINAL_WITH_TLS_PSK
printf(" [--psk hex-key --psk-identity identity [--ciphers ciphers]]\n");
#endif
#endif
Expand Down Expand Up @@ -183,7 +183,7 @@ void print_usage(void)
printf(" hostname. Using this option means that you cannot be sure that the\n");
printf(" remote host is the server you wish to connect to and so is insecure.\n");
printf(" Do not use this option in a production environment.\n");
# ifdef WITH_TLS_PSK
# ifdef FINAL_WITH_TLS_PSK
printf(" --psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.\n");
printf(" --psk-identity : client identity string for TLS-PSK mode.\n");
# endif
Expand Down
4 changes: 2 additions & 2 deletions client/sub_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void print_usage(void)
#ifdef WITH_TLS
printf(" [{--cafile file | --capath dir} [--cert file] [--key file]\n");
printf(" [--ciphers ciphers] [--insecure]]\n");
#ifdef WITH_TLS_PSK
#ifdef FINAL_WITH_TLS_PSK
printf(" [--psk hex-key --psk-identity identity [--ciphers ciphers]]\n");
#endif
#endif
Expand Down Expand Up @@ -218,7 +218,7 @@ void print_usage(void)
printf(" hostname. Using this option means that you cannot be sure that the\n");
printf(" remote host is the server you wish to connect to and so is insecure.\n");
printf(" Do not use this option in a production environment.\n");
#ifdef WITH_TLS_PSK
#ifdef FINAL_WITH_TLS_PSK
printf(" --psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.\n");
printf(" --psk-identity : client identity string for TLS-PSK mode.\n");
#endif
Expand Down
4 changes: 2 additions & 2 deletions client/sub_client_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ static void write_payload(const unsigned char *payload, int payloadlen, int hex)
(void)fwrite(payload, 1, payloadlen, stdout);
}else if(hex == 1){
for(i=0; i<payloadlen; i++){
fprintf(stdout, "%x", payload[i]);
fprintf(stdout, "%02x", payload[i]);
}
}else if(hex == 2){
for(i=0; i<payloadlen; i++){
fprintf(stdout, "%X", payload[i]);
fprintf(stdout, "%02X", payload[i]);
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# define _POSIX_C_SOURCE 200809L
#endif

#define _GNU_SOURCE

/* ============================================================
* Compatibility defines
Expand All @@ -36,4 +37,12 @@
#define uthash_malloc(sz) mosquitto__malloc(sz)
#define uthash_free(ptr,sz) mosquitto__free(ptr)


#ifdef WITH_TLS
# include <openssl/opensslconf.h>
# if defined(WITH_TLS_PSK) && !defined(OPENSSL_NO_PSK)
# define FINAL_WITH_TLS_PSK
# endif
#endif

#endif
10 changes: 8 additions & 2 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ WITH_STRIP:=no
# Build static libraries
WITH_STATIC_LIBRARIES:=no

# Build shared libraries
WITH_SHARED_LIBRARIES:=yes

# Build with async dns lookup support for bridges (temporary). Requires glibc.
#WITH_ADNS:=yes

Expand All @@ -101,7 +104,7 @@ WITH_COVERAGE:=no

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

# Client library SO version. Bump if incompatible API/ABI changes are made.
SOVERSION=1
Expand Down Expand Up @@ -146,7 +149,10 @@ ifeq ($(UNAME),Linux)
LIB_LIBS:=$(LIB_LIBS) -lrt
endif

CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib ../lib/libmosquitto.so.${SOVERSION}
CLIENT_LDFLAGS:=$(LDFLAGS) -L../lib
ifeq ($(WITH_SHARED_LIBRARIES),yes)
CLIENT_LDFLAGS:=${CLIENT_LDFLAGS} ../lib/libmosquitto.so.${SOVERSION}
endif

ifeq ($(UNAME),SunOS)
ifeq ($(CC),cc)
Expand Down
13 changes: 0 additions & 13 deletions docker/1.4.10/Dockerfile

This file was deleted.

0 comments on commit fcf4cd0

Please sign in to comment.