Commit Graph

1292 Commits

Author SHA1 Message Date
Roger A. Light
37ce51703f Fix websockets listeners not causing the main loop not to wake up.
Closes #1936. Thanks to sectokia.
2020-12-10 12:31:52 +00:00
Roger A. Light
b7f0161f52 Fix DH group not being set for TLS connections.
This meant ciphers using DHE couldn't be used.

Closes #1925. Closes #1476. Thanks to Jonathan Sönnerup, Valerii
Demeshko, and sectokia.
2020-12-09 15:40:45 +00:00
Roger A. Light
9968e35981 Fix websockets connections on Windows blocking subsequent connections.
Closes #1934. Thanks to sectokia.
2020-12-09 11:39:53 +00:00
Roger A. Light
74faabc7c1 Fix invalid free 2020-12-06 21:27:26 +00:00
Roger A. Light
c25229c13a Fix build using WITH_TLS=no when the openssl headers aren't available. 2020-12-04 23:44:38 +00:00
Roger A. Light
09ee0c31f5 Build fix for Xcode 12.
Closes #1831. Thanks to Tristan79 and andreas-kluge.
2020-12-02 22:47:34 +00:00
Roger A. Light
1636e47202 libressl does not support SSL_CTX_set_ciphersuites. 2020-12-02 22:39:48 +00:00
Roger A. Light
ea1d496299 Reply to $CONTROL QoS>0 msgs even if WITH_CONTROL disabled. 2020-12-02 19:49:17 +00:00
Roger A. Light
27a160d127 Enable WITH_CONTROL in cmake. 2020-12-02 19:49:15 +00:00
Roger A. Light
26ffe1300a Various Windows build fixes. 2020-12-02 19:49:14 +00:00
Pierre Hallot
8f0bdd5fd3 Find package libwebsockets if the option is ON.
Otherwise, if the package is not installed, configuration will work, but building will fail.

Signed-off-by: Pierre Hallot <hallotpierre@gmail.com>
2020-12-02 11:54:28 +00:00
Roger A. Light
828e7ae130 More conversion fixes. 2020-12-02 10:41:58 +00:00
Roger A. Light
df1802d8f1 Fix client state conversion warnings. 2020-12-02 10:26:22 +00:00
Roger A. Light
9e6efd2f32 Stop listeners before removing clients to avoid use after free. 2020-12-02 09:41:12 +00:00
Roger A. Light
232a759320 Log client port on new connections.
Closes #1911. Thanks to twegener-embertec.
2020-12-01 22:38:59 +00:00
Roger A. Light
a7f044bcea Respect receive-maximum on bridges. 2020-12-01 21:38:56 +00:00
Roger A. Light
3731535298 Add SPDX license identifiers. 2020-12-01 20:46:56 +00:00
Roger A. Light
04c110183c Bridge support for MQTT v5 maximum-qos. 2020-12-01 18:15:29 +00:00
Roger A. Light
ca4b23486b Bridges now obey MQTT v5 server-keepalive. 2020-12-01 16:08:05 +00:00
Roger A. Light
e030ca45cd Fix connack error printing. 2020-12-01 15:57:37 +00:00
Roger A. Light
0c22f475ff Fix bridges incorrectly setting Wills to manage remote notifications.
This is for when `notifications_local_only` was set true.

Closes #1902. Thanks to marcinkowskip.
2020-12-01 14:33:13 +00:00
Roger A. Light
b34dcd2a67 Final remove support for legacy libwebsockets
This means libwebsockets < 2.4.0.
2020-12-01 13:41:14 +00:00
Roger A. Light
c39a42adcc Report an error if the config file is set to a directory.
Closes #1814. Thanks to Odysseus1710.
2020-12-01 12:17:31 +00:00
Roger A. Light
c2f62f03aa Set SSL_OP_SINGLE_DH_USE to protect against weak dhparam primes. 2020-12-01 10:55:00 +00:00
Roger A. Light
b7e6638fd8 Add ciphers_tls1.3 option, to allow setting TLS v1.3 ciphersuites.
Closes #1825. Thanks to Valentin Dimov.
2020-12-01 10:45:10 +00:00
Roger A. Light
13bdd255a1 Fix incorrect array address on error. 2020-11-30 10:31:14 +00:00
Roger A. Light
56b2e35346 Don't kick clients on refused unsubscribe. 2020-11-25 23:25:09 +00:00
Roger A. Light
584cf51ba7 Update to EPL-2.0 2020-11-25 17:34:21 +00:00
Roger A. Light
dac841a342 Better outgoing QoS 0 limiting. 2020-11-25 10:00:45 +00:00
Roger A. Light
c09f8ee3a7 We don't really mind if this fails. 2020-11-24 13:14:34 +00:00
Roger A. Light
05d4766aef Fix plugin callback not being correctly removed. 2020-11-24 13:09:57 +00:00
Roger A. Light
adfa9f1e21 Always zero terminate payloads (removes uhpa support) 2020-11-24 12:24:40 +00:00
Roger A. Light
95c098a807 Integrate debugging only xtreport code. 2020-11-24 12:04:37 +00:00
Roger A. Light
2755fe3c4c Apply limits to QoS 0 outgoing messages. 2020-11-24 12:04:07 +00:00
Roger A. Light
4667c9d5bc Change max_queued_messages default to 1000. 2020-11-24 10:13:21 +00:00
Roger A. Light
0c6365726f Coverity Scan issues.
1436823
1436837
1436843
1432792
1436847
1436848
1436849
2020-11-24 10:06:28 +00:00
Roger A. Light
d142ff69a6 Fix Coverity Scan issues.
511427
1431133
1436823
1436837
1436838
1436929
2020-11-24 00:22:34 +00:00
Roger A. Light
c3ae8c174f Simplify net__socket_accept() use.
Closes Coverity 1436829.
2020-11-23 23:55:15 +00:00
Roger A. Light
4da1f15b41 Fix Coverity Scan errors.
1436854
1436844
2020-11-23 23:41:49 +00:00
Roger A. Light
d26534e22b Fix Coverity scan issues.
1302840
1353078
1431131
1431134
1431135
1436826
1436827
1436828
1436830
1436831
1436834
1436835
1436838
1436839
1436840
1436844
1436846
1436853
1436854
1436859
1436860
1436861
1436863
1436867
2020-11-23 22:05:12 +00:00
Roger A. Light
3aca8c1d8e Guard against libwebsockets assert in 3.2.1 and up. 2020-11-22 23:38:32 +00:00
Roger A. Light
8787ec7b2e Remove non-existant linker functions. 2020-11-20 16:04:39 +00:00
Roger A. Light
b81f0d6782 Set to NULL for safety. 2020-11-18 15:45:10 +00:00
Roger A. Light
524510f4f6 Fix some plugin memory not being freed on exit. 2020-11-18 11:46:10 +00:00
Roger A. Light
f02c67fecf Fix file logging on Windows.
Closes #1880. Thanks to J1EXA, richl, and EnneiteZer.
2020-11-17 11:08:20 +00:00
Roger A. Light
47f4cb8159 Fix potential null dereference. 2020-11-17 11:00:24 +00:00
Roger A. Light
5db9884bac Fix poll() build 2020-11-17 10:51:50 +00:00
Roger A. Light
e7a4e73cd8 Fix listener not being reassociated with client.
This occurred when reloading a persistence file and
`per_listener_settings true` is set and the client did not set a
username.

Closes #1891. Thanks to Mikkel Nepper-Christensen.
2020-11-12 17:36:49 +00:00
Roger A. Light
90ce92144c Fix websockets build. 2020-11-06 18:23:55 +00:00
Roger A. Light
26e8cc3fb9 Fix connack props not being freed on error. 2020-11-06 18:12:12 +00:00
Roger A. Light
8de1216105 No need to call time() when logging. 2020-11-06 17:16:35 +00:00
Roger A. Light
b816d46508 Use db as a global var instead of passing to functions.
This allows a big swath of ifdefs to be removed. It also means savings as the db var is not passed around all of the time, and makes it easier to remove the final broker call to mosquitto_time() call in packet_mosq.c. In one test this reduced the calls to mosquitto_time() from 295k to 48k.
2020-11-06 17:16:23 +00:00
Roger A. Light
108b23ce6d Reduce use of mosquitto_time() and time(). 2020-11-06 14:20:39 +00:00
Roger A. Light
e6b8fc5bbd Fix oversize packet check in CONNECT. 2020-11-06 12:02:43 +00:00
Roger A. Light
3091d624ed Free plugin identifier. 2020-11-06 11:41:33 +00:00
Roger A. Light
c5ba597588 Fix use after free (unreleased) 2020-11-06 11:19:27 +00:00
Roger A. Light
693f6ad36e Only make keepalive checks every 5 seconds. 2020-11-05 21:43:23 +00:00
Roger A. Light
23d3c2641e Optimise epoll event to context/listener mapping. Allows quicker lookups. 2020-11-05 16:10:50 +00:00
Roger A. Light
2a1df4ddb2 Breaking: Drop privileges after loading the configuration
This change means privileges are dropped before loading certificates, starting logging, creating the pid file etc. are carried out, so all of those actions must now be changed to ensure that the unprivileged user can carry them out.
2020-11-05 12:05:07 +00:00
Roger A. Light
c5fee09c24 Basic client disconnect event support for plugins. 2020-11-05 10:52:21 +00:00
Roger A. Light
4d6384c758 Build and conversion fixes for build variants. 2020-11-05 10:23:01 +00:00
Roger A. Light
e6dd08074d TLS certificates for the server are now reloaded on SIGHUP. 2020-11-04 22:57:10 +00:00
Roger A. Light
b2560f5e06 Move certificate loading to its own function. 2020-11-04 22:21:17 +00:00
Roger A. Light
24462a816b Tidy up headers. 2020-11-04 22:20:50 +00:00
Roger A. Light
801e31efda Dynsec: Validate user/group/role names as UTF-8. 2020-11-04 13:32:27 +00:00
Roger A. Light
7462fec1c8 Dynsec: Check ACLs are valid topic filters. 2020-11-04 12:20:14 +00:00
Roger A. Light
1191a42c2e Fix more incorrect quota handling.
Must check QoS, and directions were wrong.
2020-11-02 23:14:21 +00:00
Roger A. Light
042c2733f2 Test and fix for message expiry not increasing send quota. 2020-11-02 23:09:18 +00:00
Roger A. Light
31b1cbb23f dynsec: Clients can be created with no password.
They will be unable to log in until a password is created.
2020-10-29 14:35:11 +00:00
Roger A. Light
fcb8bc0b9b Fix use of incorrect callback list. 2020-10-28 11:23:48 +00:00
Roger A. Light
e01d391c0b Fix crash on Windows if loading a plugin fails.
Closes #1866. Thanks to roebotron.
2020-10-27 18:25:00 +00:00
Roger A. Light
451b8d0f59 Remove allocs in logging. 2020-10-27 17:13:28 +00:00
Roger A. Light
edee5aaf8d Add the bridge_bind_address option.
Closes #1311. Thanks to beville.
2020-10-27 16:32:21 +00:00
Roger A. Light
443275a2d0 Fix more "incorrect" disconnect messages. 2020-10-27 15:35:40 +00:00
Roger A. Light
dcf6372a2a Add support for bridge retain-available. 2020-10-27 13:52:35 +00:00
Roger A. Light
291b711bd4 Fix incorrect disconnect messages. 2020-10-27 12:37:54 +00:00
Roger A. Light
d8f5aacd7f Add the bridge_max_packet_size option.
Closes #265.
2020-10-27 11:35:06 +00:00
Roger A. Light
916c3744f3 Fix log_timestamp_format not applying to log_dest topic.
Closes #1862. Thanks to Kaushik-27.
2020-10-27 10:35:45 +00:00
Roger A. Light
88b5daee66 Try very hard not to produce "Socket error" message.
This happens when an unhandled error occurs on a socket/read write. The
message is confusing to people.
2020-10-27 10:04:22 +00:00
Roger A. Light
fdff255916 New dynamic security plugin. 2020-10-27 00:54:55 +00:00
Roger A. Light
3b99fbbe8c Return MOSQ_ERR_NOT_SUPPORTED on unsupported plugin event. 2020-10-26 11:41:33 +00:00
Roger A. Light
95e009c429 Document what to do on non-matching plugin versions. 2020-10-24 00:17:13 +01:00
Roger A. Light
42b9d94e91 Tell plugins which plugin versions the broker supports. 2020-10-24 00:13:45 +01:00
Roger A. Light
06b933c3ba Add tick event to plugin interface. 2020-10-23 22:51:08 +01:00
Roger A. Light
9d68da4664 Fix plugin payload modification. 2020-10-21 16:24:43 +01:00
Roger A. Light
e69dedfc27 Make more portable. 2020-10-21 13:37:54 +01:00
Roger A. Light
6035d8015b Consistent naming. 2020-10-21 13:33:33 +01:00
Roger A. Light
c51f2300f1 Log warning if starting in local only mode. 2020-10-21 13:27:39 +01:00
Roger A. Light
1851a0e1b1 Add support for pbkdf2 hash iterations. 2020-10-21 13:19:32 +01:00
Roger A. Light
4ae8971ce1 The broker now sends the receive-maximum property for MQTT v5 CONNACKs. 2020-10-21 13:19:07 +01:00
Roger A. Light
4f61f6c161 Fix conversion errors. 2020-10-17 01:23:08 +01:00
Roger A. Light
ef68063985 Convert default security to "plugin" mode.
This converts password_file and acl_file checks to act like a v5 plugin.
2020-10-15 14:50:46 +01:00
Roger A. Light
f18f1a08a9 Merge branch 'feature/add-deny-option-for-acl' of git://github.com/BrandtHill/mosquitto into BrandtHill-feature/add-deny-option-for-acl 2020-10-14 11:30:16 +01:00
Roger A. Light
94c4108977 The pid_file option will now always attempt to write a pid file.
This happens regardless of whether the `-d` argument is used when
running the broker.

Closes #1845. Thanks to habazut.
2020-10-13 21:14:48 +01:00
Roger A. Light
89733138bb CMake build fixes. 2020-10-13 16:07:35 +01:00
Roger A. Light
24a9c7d508 Build variant fixes. 2020-10-13 16:06:12 +01:00
Roger A. Light
d70ffd4b00 Move db_dump to apps directory. 2020-10-13 16:06:08 +01:00
Roger A. Light
b404d56281 Move deps directory to root. 2020-10-13 16:06:06 +01:00
Roger A. Light
f85e004415 Move password functions to own file. 2020-10-13 16:05:34 +01:00
Roger A. Light
4472c1f441 Added support for controlling UNSUBSCRIBE calls in v5 plugin ACL checks. 2020-10-09 14:02:02 +01:00
Roger A. Light
a65f946e83 Move headers to own directory. 2020-10-07 22:06:01 +01:00
Roger A. Light
908b33c0bd Update uthash to 2.1.0. 2020-10-01 17:03:04 +01:00
Roger Light
5b4884a855 Callback struct padding for future use. 2020-09-30 10:26:17 +01:00
Roger Light
bcf7545015 Export broker plugin functions on Windows. 2020-09-30 10:21:26 +01:00
Roger Light
ff2636b3ae Build fix for Windows. 2020-09-30 09:47:24 +01:00
Roger Light
e8a641c759 Fix plugin interface on example debug and defer plugins. 2020-09-30 09:43:53 +01:00
Roger A. Light
67549f48ba context->mosq in websockets. 2020-09-25 09:15:22 +01:00
Roger A. Light
7cce159ff4 Don't free will_struct after the client context owns it. 2020-09-25 09:14:31 +01:00
Roger A. Light
c7f429cab2 Deprecation warnings. 2020-09-24 21:42:51 +01:00
Roger A. Light
c90e49af1b Merge remote-tracking branch 'origin/fixes' into develop 2020-09-24 17:03:14 +01:00
Roger A. Light
0ad7bbbd29 Plugin header update with description. 2020-09-24 09:47:05 +01:00
Roger A. Light
36950cc71e mosquitto_plugin_publish no longer exists. 2020-09-24 09:14:51 +01:00
Roger A. Light
54b9571516 Enable TLS with certfile+keyfile, not capath/cafile. 2020-09-23 23:31:00 +01:00
Roger A. Light
5371bd09d1 Add support for PBKDF2-SHA512 password hashing. 2020-09-23 22:57:26 +01:00
Roger A. Light
c927446264 Fix $CONTROL plugin unregistering. 2020-09-23 17:03:01 +01:00
Roger A. Light
d8d24e76eb Free plugin identifier on cleanup. 2020-09-23 15:38:25 +01:00
Roger A. Light
5d6bdc5de4 Allow CONTROL messages to set a reason code/string for PUBACK/PUBREC. 2020-09-23 10:25:03 +01:00
Roger A. Light
cf1c156765 New plugin interface
This is not specific to authentication, and allows plugins greater flexibility in what events they are interested in. It also adds message handling, and $CONTROL handling.
2020-09-22 14:49:28 +01:00
Roger A. Light
43b3184492 Rename to indicate these are public functions. 2020-09-18 21:29:42 +01:00
Roger A. Light
2f89203c67 Always ensure the client is in the hash before deleting. 2020-09-17 13:26:31 +01:00
Roger A. Light
7ad1ec819c Cleanup bridge ssl_ctx on exit. 2020-09-17 12:45:57 +01:00
Roger A. Light
a57e41beff Fix use after free (develop branch only). 2020-09-17 11:55:53 +01:00
Roger A. Light
20feb10366 Fix leak on malformed v5 subscribe. 2020-09-17 11:44:22 +01:00
Roger A. Light
97bd527df0 Breaking: allow_anonymous defaults to false. 2020-09-17 11:29:32 +01:00
Roger A. Light
d7d3087b04 Breaking: Bind to loopback if no listeners are configured. 2020-09-17 11:10:40 +01:00
Roger A. Light
5daa5ee162 Add support for $CONTROL/ topics in plugins. 2020-09-10 15:32:47 +01:00
Roger A. Light
f0862e26ec Add mosquitto_kick_client_by_clientid() and mosquitto_kick_client_by_username()
These can be used by plugins to disconnect clients.
2020-09-07 13:51:44 +01:00
Roger A. Light
3f1515e337 Fix missing argument. 2020-09-05 23:16:21 +01:00
Roger A. Light
bb5456729d Move keepalive check code to separate file.
This is in preparation for changing to a tree based implementation.
2020-09-05 22:59:50 +01:00
Roger A. Light
961ffcb2ae Remove redundant keepalive check.
Websockets clients are now part of the by_sock hashtable, so this isn't
needed.
2020-09-05 21:18:45 +01:00
Roger A. Light
219f2c20d2 Ensure all websockets outgoing buffer is used. 2020-09-02 22:24:29 +01:00
Roger A. Light
c1b009e4df Fix memory leak on handling QoS 2 PUBLISH.
In some circumstances, Mosquitto could leak memory when handling PUBLISH  messages. This is limited to incoming QoS 2 messages, and is related to the combination of the broker having persistence enabled, a clean session=false client, which was connected prior to the broker restarting, then has reconnected and has now sent messages at a sufficiently high rate that the incoming queue at the broker has filled up and hence messages are being dropped. This is more likely to have an effect where max_queued_messages is a small value. This has now been fixed.

Closes #1793. Thanks to mbates14.
2020-08-19 14:38:57 +01:00
Roger A. Light
b3b58cc635 Build warning fixes. 2020-08-19 14:04:02 +01:00
Roger A. Light
4dc835b73d Fix possible memory leaks on errors during persistence write. 2020-08-19 11:12:05 +01:00
Roger A. Light
18e79eac22 Use hash_find rather than hash_iter for unpwd check. 2020-08-18 15:34:57 +01:00
Roger A. Light
b66ffb8039 Move unpwd to security_options struct. 2020-08-18 15:20:48 +01:00
Roger A. Light
581e843131 Move keepalive check to its own function. 2020-08-18 08:40:33 +01:00
Roger A. Light
cae55aa381 Make correct allow_anonymous check in pwfile security.
We always get passed the client even if it doesn't have a
username/password now.
2020-08-18 08:32:21 +01:00
Roger A. Light
a5f02f31fc Json helper functions. 2020-08-17 23:03:38 +01:00
Roger A. Light
b91e78318d Don't always iterate over entire inflight messages list
If we have e.g. max_inflight_messages set to 1000, and currently have 999 messages inflight, then when we send a new message to a client we have to iterate over the whole list to get to the newest message. This change means that we start of the back of the list to find the newest items, which reduces overhead.
2020-08-17 23:03:25 +01:00
Brandt Hill
16eecfcbc5 Add 'deny' as an option for topics/patterns in acl file to allow certain topics to be explicitly denied when they might otherwise be allowed through a more open read/write/readwrite option. Example: 'topic readwrite test/#' and 'topic deny test/hello/#' may be added so that a user can read/write to all test/# topics, except for test/hello/#.
Signed-off-by: Brandt Hill <brandtlarsonhill@gmail.com>

Change variable name for clarity. Remember to initialize bool (I'm bad at C).

Signed-off-by: Brandt Hill <brandtlarsonhill@gmail.com>

Add documentation to config man page

Signed-off-by: Brandt Hill <brandtlarsonhill@gmail.com>

Add test case for deny option

Signed-off-by: Brandt Hill <brandtlarsonhill@gmail.com>

Add deny acls to top of the list to preserve early exit

Signed-off-by: Brandt Hill <brandtlarsonhill@gmail.com>

change comments

Signed-off-by: Brandt Hill <brandtlarsonhill@gmail.com>
2020-08-17 00:13:10 -05:00
Roger Light
58aa41c813 Optimise use of db__message_write()
New messages are now queued for clients when old ones are sent, rather than on every iteration of the main loop. This produces good performance improvements.
2020-08-12 15:29:08 +01:00
Roger A. Light
2dc8d2a19a Allow plugins to send messages to specific clients. 2020-08-12 15:18:17 +01:00
Roger A. Light
e56b953abd Free memory after sending queued plugin message. 2020-08-12 15:18:17 +01:00
Roger A. Light
a913a05fbd Documentation and error checking. 2020-08-12 15:18:17 +01:00
Roger A. Light
d6f4f4e0bc Add mosquitto_broker_publish_copy()
Rename mosquitto_plugin_publish() to mosquitto_broker_publish().

These two functions achieve the same thing. *_publish() publishes the payload and frees it later. *_publish_copy() takes a copy of the payload, so the plugin still owns the memory it passed to the function.
2020-08-12 15:18:17 +01:00
Roger A. Light
de5a820fe2 Start of dynamic control topics. 2020-08-12 15:18:17 +01:00
Roger A. Light
32ed4809ed Build fix for NetBSD.
Thanks to Greg Troxel.
2020-08-11 16:21:19 +01:00
Roger Light
60dc8f5e4c Fix service path quoting on Windows.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=565671
2020-08-11 09:09:31 +01:00
Roger Light
3eb60e2e6a Fix some winsock argument types. 2020-08-11 08:43:24 +01:00
Roger A. Light
f180e923ef Merge branch 'lazy_ssl' of git://github.com/abiliojr/mosquitto into abiliojr-lazy_ssl 2020-08-07 16:42:30 +01:00
Roger A. Light
43df213ecb Merge branch 'improve-client-store' of git://github.com/dbeinder/mosquitto into dbeinder-improve-client-store 2020-08-07 09:11:43 +01:00
david-beinder
212fd8635f Store username and listener of persistent clients
Signed-off-by: david-beinder <david.beinder@mce.li>
2020-08-07 08:32:14 +02:00
Roger A. Light
94d04136f8 Fix potential memory leaks.
Closes #1773. Closes #1774. Thanks to Yingpei Zeng.
2020-08-06 21:28:09 +01:00
Roger A. Light
7cb72cf1ba Fix incorrect NULL check.
Coverity Scan 1431137.
2020-08-06 13:50:52 +01:00
Roger A. Light
94b39d12ac Fix potential NULL dereference.
Coverity Scan 1431139.
2020-08-06 13:47:41 +01:00
Roger A. Light
872222c3c9 Remove unused values.
Coverity Scan 1431134, 1431136, 1431140.
2020-08-06 13:42:35 +01:00
Roger A. Light
618cd7006b Don't try to start DLT logging if DLT unavailable.
This is to avoid a long delay when shutting down the broker.

Closes #1735. Thanks to Colin Law.
2020-08-04 11:17:04 +01:00
Roger A. Light
84e4ba2c1e Send DISCONNECT with malformed-packet reason code on bad PUBLISHes. 2020-08-02 23:12:47 +01:00
Roger A. Light
b1e9377a20 Send DISCONNECT with malformed-packet reason code on bad SUBSCRIBEs. 2020-08-02 15:10:12 +01:00
Roger A. Light
8416b007ec Send DISCONNECT with malformed-packet reason code on bad UNSUBSCRIBEs. 2020-08-02 14:22:40 +01:00
Roger A. Light
1f717873d6 Log protocol error message where appropriate from a bad UNSUBSCRIBE
Rather than the generic "socket error".

Related to #1765.
2020-07-31 23:01:15 +01:00
Abilio Marques
d5aae3eca7 lazy init SSL
Signed-off-by: Abilio Marques <abiliojr@gmail.com>
2020-07-23 17:48:56 +02:00
Simon Tate
1608151569 Fix bridge reconnect
In the mux_epoll__add_in function, no context->events was set. Previously this was set to match the ev.events (EPOLLIN). Adding this back in, keeps the code consistent to before it was refactored to split out epoll and poll functions, as well as being consistent with the other mux_epoll__ functions.

If this is not set, the connection is never fully established when the broker comes back up.

Fixes #1680.

Signed-off-by: Simon Tate <simon.tate@bt.com>
2020-07-20 15:47:48 +01:00
Roger A. Light
2b1a22776b Only call setvbuf on open files. 2020-07-19 21:59:28 +01:00
Roger A. Light
86e7eed8b7 Fix minor leak when cleaning a bridge on exit. 2020-07-16 12:03:39 +01:00
Roger A. Light
4f9a1a53ce Fix incorrect store ref count usage. 2020-07-16 11:18:04 +01:00
Roger A. Light
54f3b686dc Fix "slow" file based logging by switching to line based buffering.
Closes #1689. Closes #1741. Thanks to Brett M. Gordon and tt92.
2020-07-15 22:28:19 +01:00
Roger A. Light
8234d24b1b Fix websockets clients sometimes not being disconnected promptly.
Closes #1718. Thanks to Luca Casonato.
2020-07-15 22:06:29 +01:00
Roger A. Light
b4e0dfa598 Fix autosave_interval not being triggered by messages being delivered.
Closes #1726. Thanks to nduhme.
2020-07-15 19:29:40 +01:00
Roger A. Light
4e0312c55f Fix messages being queued for disconnected bridges
This occurred incorrectly when clean start was set to true.

Closes #1729. Thanks to Andreyooo.
2020-07-15 17:08:00 +01:00
Roger A. Light
1d66d3e443 Fix bridge topic remapping when using "" as the topic.
Closes #1749. Thanks to cieslarchristian.
2020-07-15 00:19:44 +01:00
Roger A. Light
5a56f066a8 Change systemd unit files to create /var/log/mosquitto
This happens before starting the broker.

Also don't quit with an error if opening the log file isn't possible.

Closes #821.
2020-07-14 20:10:54 +01:00
Roger A. Light
abb31ffe8d Fix broker refusing to start if only websockets listeners were defined.
Closes #1740. Thanks to OkenKhuman.
2020-07-14 17:27:57 +01:00
Roger A. Light
f46187d5e5 Add mosquitto_client_protocol_version() function.
This can be used by plugins to determine which version of MQTT a client
has connected with.
2020-07-12 23:01:20 +01:00
Sigmund Vik
5481575f8b Fix FormatMessage warnings for Windows.
From the FormatMessage() Win32 API documentation: "The lpBuffer
parameter is a pointer to an LPTSTR; you must cast the pointer
to an LPTSTR (for example, (LPTSTR)&lpBuffer)."

https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage#parameters

This commit fixes warnings like these:
warning C4047: 'function': 'LPSTR' differs in levels of indirection from 'char **'
warning C4024: 'FormatMessageA': different types for formal and actual parameter 5

Signed-off-by: Sigmund Vik <sigmund_vik@yahoo.com>
2020-07-12 22:34:20 +01:00
Sigmund Vik
a75d574870 Fix sys_tree macro stubs with no arguments.
This fixes Visual Studio compiler warnings like this one:
"warning C4003: not enough arguments for function-like
macro invocation 'G_MSGS_DROPPED_INC'"

Signed-off-by: Sigmund Vik <sigmund_vik@yahoo.com>
2020-07-12 22:26:00 +01:00
Sigmund Vik
20972a2819 Add broker ready message.
Before this commit there was no good way to detect that the
Mosquitto broker was done with its startup phase on systems
without systemd.

On such systems it was tricky to e.g. start the broker from
a test where ports are dynamically assigned and one have to
deal with potential port conflicts.  Without a way to know
that the broker is done with its startup phase, there was no
way to know if the broker was able to acquire the port (for
both IPv4 and IPv6) without waiting for some unknown period
of time (when many tests are run in parallel a single process
might be starved for resources).

With this new broker ready message it is easy for the parent
process to monitor the broker output and figure out when the
port was successfully acquired.

Signed-off-by: Sigmund Vik <sigmund_vik@yahoo.com>
2020-07-10 22:48:58 +01:00
Roger A. Light
abc191ad00 db_dump: Fix mosquitto_msg_store usage. 2020-07-10 22:00:11 +01:00
Roger A. Light
a07edaa4a0 db_dump: Print error when file not accessible. 2020-07-10 21:46:44 +01:00
Roger A. Light
6deb417804 Simplify db__message_store() interface. 2020-07-10 16:09:33 +01:00
Roger A. Light
3e595d557e Add db__msg_store_free() for freeing stored messages. 2020-07-10 13:31:37 +01:00
Roger A. Light
e3e8dc4ea4 Allow send__pub{ack,rec,rel,comp} to send properties. 2020-07-10 12:29:53 +01:00
Roger Light
318dead6bf Function to allow plugins to publish messages. 2020-06-30 10:31:34 +01:00
Roger A. Light
e54bac2a54 No need to pass separate username/password here. 2020-06-30 10:21:43 +01:00
Roger A. Light
73cc271d37 Allow auth plugin to see all logins, unless accepted by password file. 2020-06-30 10:07:54 +01:00
Roger A. Light
2e32634a95 DLT logging is now configurable at runtime with log_dest dlt.
Closes #1735. Thanks to Brian Orpin.
2020-06-30 00:51:57 +01:00
Jasper Lievisse Adriaanse
2758401829 only link with libm on OpenBSD
fixes "ld: error: unable to find library -ldl"

Signed-off-by: Jasper Lievisse Adriaanse <jasper@humppa.nl>
2020-06-17 15:54:24 +01:00
Roger A. Light
4b541ad5ca Fix usage message not mentioning v5.0.
Closes #1713. Thanks to whnr.
2020-06-09 15:42:51 +01:00
Roger A. Light
6bd435d721 Fix possible assert crash associated with bridge reconnecting.
This only occurs when compiled without epoll support.

Closes #1700. Thanks to Matthias Urlichs.
2020-05-25 23:38:13 +01:00
Roger A. Light
eae8c9aab4 Fix check when loading persistence file of a different version
Closes #1684. Thanks to grekhss.
2020-05-15 22:11:26 +01:00
Roger A. Light
762ad432e8 Fix support for openssl 3.0 2020-05-12 13:39:49 +01:00
Roger A. Light
e755827f4f Free outgoing client messages even for non-bridges. 2020-05-05 15:37:04 +01:00
Roger A. Light
ee7d1981ff Merge branch 'rfc-bridge-local-clean' of git://github.com/etactica/mosquitto into etactica-rfc-bridge-local-clean 2020-05-05 14:33:02 +01:00
Roger A. Light
d3247a830a Fix memory leak when connecting clients are rejected. 2020-05-05 14:31:13 +01:00
Roger A. Light
bfc82ea91a Fix incorrect check. 2020-05-05 13:13:24 +01:00
Roger A. Light
4960fc0702 Don't disconnect clients that are already disconnected.
This prevents the session expiry being extended on SIGHUP.

Closes #1521. Thanks to Christoph Krey.
2020-05-01 22:45:40 +01:00
Roger A. Light
c5d6f32341 Be more tolerant when loading persistence files. 2020-05-01 21:51:07 +01:00
Roger A. Light
eeaafed485 Fix memory leak when connecting clients rejected. 2020-04-30 17:31:13 +01:00
Roger A. Light
ff2b111cb3 Fix minor memory leak when load bridge prefixes. 2020-04-30 17:06:51 +01:00