Commit Graph

273 Commits

Author SHA1 Message Date
Roger A. Light
a224a8f217 Don't busy loop with mosquitto_pub -l on a slow connection. 2020-08-13 14:32:47 +01:00
Roger A. Light
9929ce0a26 All clients exit with an error exit code on CONNACK failure.
Closes #1778. Thanks to jflambert.
2020-08-12 09:44:42 +01:00
Roger A. Light
1b060bb064 Guard against use-after-free.
Coverity Scan 1431131, 1431135, 1431141.
2020-08-06 13:36:24 +01:00
Roger A. Light
e272f8fbca mosquitto_pub: Close file on file too large.
This wasn't a problem because this error caused the program to
exit, so there was no real resource leak.

Coverity Scan 1430457.
2020-07-15 12:04:20 +01:00
Roger A. Light
f846711ea2 mosquitto_pub now sends 0 length files without an error when using -f. 2020-07-15 12:03:15 +01:00
Roger A. Light
cadcde52a4 Remove duplicate code.
Coverity Scan 1430458.
2020-07-15 12:00:29 +01:00
Roger A. Light
5b4b079105 mosquitto_pub: Print reason string on publish error, if it exists. 2020-07-10 17:10:23 +01:00
Abilio Marques
22ffefe7f6 remove cjson stranded reference when building WITH_CJSON=no
Signed-off-by: Abilio Marques <abiliojr@gmail.com>
2020-05-20 11:17:13 +01:00
Roger A. Light
24049b1a1e Fix mosquitto_sub %j or %J not working on Windows.
Closes #1674. Thanks to amigian74.
2020-05-06 22:24:58 +01:00
Roger A. Light
c766bdfeb0 Display time out message only on SIGALRM. 2020-05-06 22:23:06 +01:00
Roger A. Light
b726e2f1ec mosquitto_sub %j and %J timestamps are now in a ISO 8601 compatible format. 2020-05-06 22:21:21 +01:00
Roger A. Light
40bad1a999 Fix conversion warnings in client code
Issue #1653.
2020-04-16 23:26:14 +01:00
Roger A. Light
0da723c1ec Add --random-filter to mosquitto_sub. 2020-03-03 14:12:30 +00:00
Roger A. Light
d96543c0b8 Merge branch 'fixes' into develop 2020-03-03 12:54:57 +00:00
Roger A. Light
b0a065f790 Update changelog. Release page. Bump copyright. 2020-02-27 23:26:58 +00:00
Roger A. Light
f16d9e2bcf Add file missing from earlier commit. 2020-02-06 21:06:03 +00:00
Roger A. Light
17e20de9e7 Fix session-expiry-interval for v5 clients using -c.
Default behaviour for v5 clients using `-c` is now to use infinite length
sessions, as with v3 clients.

Closes #1546. Thanks to Kiran Pradeep.
2020-02-06 16:14:29 +00:00
Roger A. Light
019d4214b8 Fix session-expiry-interval for v5 clients using -c.
Default behaviour for v5 clients using `-c` is now to use infinite length
sessions, as with v3 clients.

Closes #1546. Thanks to Kiran Pradeep.
2020-02-06 16:12:56 +00:00
Roger A. Light
56d0b950ac Fix --remove-retained not obeying the -T option.
This means `--remove-retained -t bbc/# -T bbc/one/#` would remove all
retained messages in `bbc/#`, instead of leaving all of the topics in
`bbc/one/#`.

Closes #1585. Thanks to Simon Moser.
2020-02-05 15:19:55 +00:00
Roger A. Light
3671a6dfdb Add -x argument to all clients.
This allows the session-expiry-interval property to be easily set for
MQTT v5 clients.
2020-01-30 11:19:09 +00:00
Roger A. Light
4e1e0f955f Record of which client argument letters are in use. 2020-01-30 11:09:04 +00:00
Roger A. Light
6aa9b91fff Add testing target for compiling test client fixes. 2020-01-02 21:40:03 +00:00
Roger A. Light
d60e86d2a3 Add TCP_NODELAY support to lib and clients.
Closes #1526. Thanks to Felix Moessbauer.
2019-12-18 17:04:43 +00:00
Roger A. Light
c0443637e8 Merge branch 'master'
Conflicts:
	ChangeLog.txt
	config.mk
	src/context.c
	src/loop.c
	src/subs.c
	test/broker/01-connect-bad-packet.py
	test/broker/02-subpub-qos1-bad-pubcomp.py
	test/broker/02-subpub-qos1-bad-pubrec.py
	test/broker/02-subpub-qos2-bad-puback-1.py
	test/broker/02-subpub-qos2-bad-puback-2.py
	test/broker/02-subpub-qos2-bad-pubcomp.py
	test/broker/02-subpub-qos2.py
	test/broker/07-will-null-topic.py
2019-12-03 13:59:05 +00:00
Basavesh Shivakumar
9bebab46ca In sub_client.c, call mosquitto_destroy()
Fixes: #1513 and frees resources when someone terminates
via SIGTERM or SIGINT.

Signed-off-by: Basavesh Shivakumar <basavesh.shivakumar@gmail.com>
2019-11-27 17:33:11 -05:00
Roger A. Light
1e04b22833 Fix mosquitto_pub -l not sending the final line of stdin
This would happen if the final line did not end with a new line.

Closes #1473. Thanks to majekw.
2019-11-07 18:25:56 +00:00
Roger A. Light
6bde209799 Added CLIENT_STATIC_LDADD to makefile builds
This allow more libraries to be linked when compiling the clients with a
static libmosquitto, as required for e.g. openssl on some systems.

Closes #1371. Thanks to Fabrice Fontaine.
2019-11-06 15:04:54 +00:00
Roger A. Light
22eb193309 Merge branch 'stdin-fix-1' of git://github.com/majekw/mosquitto into majekw-stdin-fix-1 2019-11-06 13:24:38 +00:00
Roger A. Light
9cdc822a19 Add changelog, change msg text for previous merge. 2019-11-06 13:17:23 +00:00
Roger Light
dc21bc513c
Merge pull request #1430 from abiliojr/exit-on-no-subscription
mosquitto_sub: Exit on all subscription denied
2019-11-06 13:13:38 +00:00
Roger A. Light
aabf850a62 Separate pub client loops for better readability. 2019-11-06 12:16:56 +00:00
Roger A. Light
74e1f77310 Fix for previous commit
Stdin mode wouldn't work with normal compiler optimisation levels.
2019-11-06 11:51:25 +00:00
Roger Light
4e7e6c641f
Merge pull request #1473 from majekw/stdin-rewrite
mosquitto_pub: split main loop.
2019-11-06 10:16:43 +00:00
Roger Light
1c6666b63a Add user-property output support to sub/rr. 2019-10-15 15:54:46 +01:00
Roger A. Light
59c0bfe6e1 Add support for v5 property printing to mosquitto_sub/rr in non-JSON mode. 2019-10-15 15:23:29 +01:00
Roger A. Light
9e4226622f Add --pretty option to mosquitto_sub/rr
If active, this produces formatted JSON output rather than the normal
minimised output.
2019-10-15 14:44:25 +01:00
Roger Light
e5237ae7e5 Add support for sub/rr v5 prop output in JSON mode 2019-10-15 14:26:51 +01:00
Roger A. Light
ad5c2e11d9 Use cJSON for producing JSON output in clients.
Closes #1222. Thanks to Ben Barbour.
2019-10-15 11:59:22 +01:00
majekw
50c9a4b0b0 Fix mosquitto_pub -l hang when stdin stream ends. Closes #1448.
Signed-off-by: Marek Wodzinski <majek@w7i.pl>
2019-10-10 13:00:22 +02:00
Roger A. Light
8a4ae28fa9 Fix duplicate cfg definition in rr_client.
Closes #1453. Thanks to jveber.
2019-10-09 14:01:44 +01:00
Roger A. Light
499e2f2e98 Add support for unix sockets to broker, lib, and clients. 2019-10-08 20:55:31 +01:00
Marek Wodzinski
ede9f2a51d mosquitto_pub: split main loop.
Main loop has two different logics inside: one for stdin input,
second for all other cases. Exit loop condition is also different
for both variants. This commit splits these two variants into
two separate loops.

Signed-off-by: Marek Wodzinski <majek@w7i.pl>
2019-10-06 01:39:27 +02:00
Abilio Marques
fb8d03db28 mosquitto_sub exits if no subscription is granted
Signed-off-by: Abilio Marques <abiliojr@gmail.com>
2019-09-26 08:36:54 +02:00
Roger A. Light
54ed3c0fc9 Merge branch 'master' into develop 2019-09-25 19:09:10 +01:00
Roger A. Light
0a8358243b mosquitto_sub: Fix -E not working unless -d was also specified.
Closes #1418. Thanks to Lichard Torman.
2019-09-21 22:30:21 +01:00
Roger A. Light
c1e488cb88 Add timeout return code (27) for sub/rr using -W.
Closes #275.
2019-09-04 14:29:26 +01:00
Roger A. Light
a0e7165a9c Fix WITH_STATIC_LIBRARIES using CMake on Windows
Closes #1369. Thanks to TimmvonderMehden
2019-08-06 12:01:29 +01:00
YangHau
b2aed5cb7e feat: Remove unecessary if statement
free() would take no action if the arguement is a NULL pointer.
Therefore, the if statement is totally unnecessary.
See ISO-IEC 9899

Signed-off-by: YangHau <vulxj0j8j8@gmail.com>
2019-08-01 19:28:39 +08:00
Roger A. Light
a22ccbd884 Clients: improve error msgs when connecting v3.x broker with v5 client
Closes #1344. Thanks to HowJMay.
2019-08-01 11:40:55 +01:00
Roger Light
1079a1b697
Merge pull request #1342 from HowJMay/remove_redundant_reset
Remove redundant initialization in clients
2019-08-01 09:59:52 +01:00
Roger A. Light
b807daed28 Fix error codes not being returned when mosquitto_pub exits.
Closes #1354. Thanks to Ben Barbour.
2019-07-24 12:08:43 +01:00
YangHau
9bb9b6e721 Remove redundant initialization in clients
the `memset(&cfg, 0, sizeof(struct mosq_config));` already exsits in
`client_config_load()`'s `init_config()` function call.
So calling it in main function is totally unnecessary.

Signed-off-by: YangHau <vulxj0j8j8@gmail.com>
2019-07-12 16:53:29 +08:00
Roger A. Light
af7760f1b6 Fix build for WITH_SOCKS=no. 2019-06-13 16:23:55 +01:00
Roger A. Light
c685b7ecf4 Fix mosquitto_pub -l not handling zero length input.
Closes #1302. Thanks to Marcus Watkins.
2019-06-06 23:21:07 +01:00
Roger A. Light
31f448f35a Fix MQTT v5 clients not being able to specify a password without a username.
Thanks to Erik Moqvist.

Closes #1274.
2019-06-06 23:01:04 +01:00
Roger A. Light
4d54a51c62 Stop some error messages being printed even when --quiet was used.
Thanks to Rob de Jonge.

Closes #1284.
2019-06-06 22:58:02 +01:00
Roger A. Light
7d954fa52e Fix mosquitto_pub -l not handling network failures.
Closes #1152. Thanks to Dustin Sallings.
2019-05-29 18:49:08 +01:00
Roger A. Light
1bafe0ee2e Fix double free on exit in mosquitto_pub.
Closes #1280. Thanks to Lucky Saini.
2019-05-29 18:42:38 +01:00
Roger A. Light
b4dfeb3767 Fix MQTT v5 clients not being able to specify a password without a username.
Thanks to Erik Moqvist.

Closes #1274.
2019-05-21 23:56:22 +01:00
Roger A. Light
999c478c88 Fixes for bug #1273
* Fix Will message for a persistent client incorrectly being sent when the client reconnects after a clean disconnect.
* Fix Will message for a persistent client not being sent on disconnect.
* Fix mosquitto_pub not using the `-c` option.

Thanks to Yannic Schröder.

Closes #1273.
2019-05-21 17:08:52 +01:00
Roger A. Light
29cf965b4f Fix mosquitto_pub exiting with error code 0 when an error occurred.
Thanks to janniswarnat.

Closes #1285.
2019-05-21 11:39:19 +01:00
Roger A. Light
7a33a129d6 Stop some error messages being printed even when --quiet was used.
Thanks to Rob de Jonge.

Closes #1284.
2019-05-21 11:23:00 +01:00
Roger A. Light
a47da31679 Update changelog, improve warning message from last commit. 2019-05-10 07:25:49 +01:00
Till Zimmermann
8518d08ff3 Fixed Segmentation Fault / NULLptr dereference
Signed-off-by: Till Zimmermann <tzimmermann@uni-osnabrueck.de>
2019-05-09 13:08:19 +02:00
Roger A. Light
203949a512 Fix -L url parsing.
Closes #1248. Thanks to Andrew J Freyer.
2019-04-30 13:24:33 +01:00
Roger A. Light
439575475c Use CMAKE_INSTALL_* variables when installing in CMake.
Closes #1049. Thanks to Greg Troxel.
2019-04-26 17:07:05 +01:00
Roger A. Light
3b4a5419c3 Build fixes around CFLAGS et al.
- Split CFLAGS and CPPFLAGS, and LDFLAGS and LDADD/LIBADD.
- test/unit now respects CPPFLAGS and LDFLAGS.

Closes #1232. Thanks to Greg Troxel.
2019-04-26 17:06:54 +01:00
Roger A. Light
5c0c830229 Fix compilation on musl C systems due to missing sys/time.h header.
Thanks to maxice8.
2019-04-25 21:22:51 +01:00
Roger A. Light
4dcd977932 Windows build fixes. 2019-04-17 20:09:59 +01:00
Roger A. Light
6438ce861e Minor build variant fixes. 2019-04-17 11:00:54 +01:00
Roger A. Light
810940dd5d Fix mosquitto_rr cmake build. 2019-04-17 10:39:51 +01:00
Roger A. Light
cba3380b98 Fix mosquitto_sub encoding of special characters with %j format.
Thanks to Ben Barbour.

Closes #1220.
2019-04-11 21:05:47 +01:00
Roger A. Light
cd8f12f68a Improve some client error messages. 2019-04-11 19:34:01 +01:00
Roger A. Light
54be8d0a46 Fix rr static build. 2019-04-11 19:34:01 +01:00
Roger A. Light
4995436b5a Add --repeat and --repeat-delay to mosquitto_pub. 2019-04-11 19:13:59 +01:00
Roger A. Light
dec769ce33 Client and doc ALPN additions
Add ALPN support for all clients, update documentation, and add to ChangeLog.
2019-04-11 11:52:34 +01:00
Roger A. Light
e4d0d52b01 Fix Coverity Scan 1400483-1400485.
Logically dead code.
2019-04-05 22:02:11 +01:00
Roger A. Light
925debb8a5 Add mosquitto_rr, the "request-response" client. 2019-04-01 22:31:05 +01:00
Roger A. Light
b95a5d87d2 Alphabetic client option order. 2019-03-30 21:18:30 +00:00
Roger A. Light
ec3fd361be https links where possible. 2019-03-30 20:34:40 +00:00
Roger A. Light
320ddc1303 Merge branch 'master'
Conflicts:
	CMakeLists.txt
	ChangeLog.txt
	client/Makefile
	config.mk
	installer/mosquitto.nsi
	installer/mosquitto64.nsi
	lib/mosquitto.h
	lib/mqtt3_protocol.h
	lib/util_mosq.c
	set-version.sh
	snap/snapcraft.yaml
	src/bridge.c
	src/database.c
	src/handle_connack.c
	src/loop.c
	src/persist.c
	test/broker/Makefile
2019-03-16 10:05:38 +00:00
Roger A. Light
2dd24449ad Fix "unused parameter" warnings. 2019-03-13 14:46:05 +00:00
Roger A. Light
0941638143 Fix signed/unsigned comparion warnings.
Closes #1196.
2019-03-13 13:51:08 +00:00
Roger A. Light
754ac55151 Add warning to mosquitto_pub if publish rejected. 2019-03-13 11:24:14 +00:00
Roger A. Light
1ce1bce941 Add --remove-retained to mosquitto_sub
This can be used to clear retained messages on a broker.
2019-03-02 22:14:54 +00:00
Roger A. Light
ce31269e05 Update changelog, bump version, bump copyright year. 2019-02-28 16:56:15 +00:00
Roger A. Light
1924afe49e Add explicit support for TLS v1.3 and drop TLS v1.0. 2019-02-27 22:50:01 +00:00
Roger A. Light
deb2fdfc98 Use lib provided random id. Change lib generated id to alphanumeric only. 2019-02-27 14:53:07 +00:00
Roger A. Light
5aabc171b0 Merge branch 'mqtt5' into develop 2019-02-26 18:51:31 +00:00
Roger A. Light
e862a047a8 Rework TLS engine support. 2019-02-26 17:11:29 +00:00
Nicolás Pernas Maradei
20894fcbce Add engine private key password support
Some OpenSSL engines (selectable via tls_engine option) may require a
password to make use of private keys created with them in the first place.

The TPM engine for example, will require a password to access the underlying
TPM's Storage Root Key (SRK), which is the root key of a hierarchy of keys
associated with a TPM; it is generated within a TPM and is a non-migratable
key. Each owned TPM contains a SRK, generated by the TPM at the request
of the Owner. [1]

By default, the engine will prompt the user to introduce the SRK password
before any private keys created with the engine can be used. This could
be inconvenient when running on an unattended system.

Here's where the new tls_engine_kpass_sha option comes in handy. The user
can specify a SHA1 hash of its engine private key password via command
line or config file and it will be passed on to the engine directly.

This commit adds support for both clients (libmosquitto) and broker.

[1] https://goo.gl/qQoXBY

Signed-off-by: Nicolás Pernas Maradei <nicopernas@gmail.com>
2019-02-26 15:50:37 +00:00
Nicolás Pernas Maradei
f88cc06435 Add TLS engine and keyform support to libmosquitto
- Clients can now offload crypto tasks to an external crypto device through
  the OpenSSL ENGINE API.
- The keyfiles can now be treated as PEM or ENGINE keys.
- Two new functions were added to libmosquitto to set up the previously
  mentioned features.
- Both mosquitto_sub and mosquitto_pub include support to turn on the mentioned
  features through command line options.

Signed-off-by: Nicolás Pernas Maradei <nicopernas@gmail.com>
2019-02-26 15:48:00 +00:00
Roger A. Light
084062c85e Merge branch 'fixes' into mqtt5 2019-02-12 17:05:42 +00:00
Roger A. Light
9999faf9da Add rewritten build test script and remove some build warnings. 2019-02-12 13:24:54 +00:00
Roger A. Light
05458eb35d Fix some unused variable warnings. 2019-02-08 13:01:07 +00:00
Roger A. Light
a4f68869bf Fix cmake client build with TLS. 2019-02-08 13:01:07 +00:00
Roger A. Light
70c4097b6f Fix comparison of boolean values in CMake build.
Closes #1101. Thanks to Mojca Miklavec and Andrew L. Moore.
2019-02-08 13:01:07 +00:00
Roger A. Light
4a2e569171 -V now accepts 5, 311, 31, as well as mqttv5` etc. 2019-01-09 18:06:20 +00:00
Roger A. Light
326292681a Add maximum-qos support to broker and client.
This comes in the form of:

* Per listener maximum_qos option, which can be in the range 0-2.
* Changes to mosquitto_publish*() to return MOSQ_ERR_QOS_NOT_SUPPORTED
  if attempting to publish with a higher QoS than supported.
* Bridges will downgrade messages to match the maximum QoS.

More tests on the broker side (specifically bridges) are required. This
needs bridge support for MQTT 5 first.
2019-01-09 18:03:01 +00:00
Roger Light
930a314caf Add reason_code to on_publish_v5 callback. 2019-01-09 17:06:43 +00:00