Merge lp:~roger.light/ubuntu/saucy/mosquitto/merge-debian-1.2 into lp:ubuntu/saucy/mosquitto

Proposed by Roger Light
Status: Needs review
Proposed branch: lp:~roger.light/ubuntu/saucy/mosquitto/merge-debian-1.2
Merge into: lp:ubuntu/saucy/mosquitto
Diff against target: 56478 lines (+36649/-9973)
482 files modified
.pc/applied-patches (+0/-7)
.pc/bug-acl-patterns.patch/src/security.c (+0/-764)
.pc/bug-persistence-reloading.patch/src/conf.c (+0/-917)
.pc/bug-proto-number.patch/src/read_handle_server.c (+0/-437)
.pc/enable-libwrap.patch/config.h (+0/-69)
.pc/enable-libwrap.patch/config.mk (+0/-29)
.pc/fix-prefix.patch/client/Makefile (+0/-30)
.pc/fix-prefix.patch/config.mk (+0/-29)
.pc/install-apparmor.patch/Makefile (+0/-59)
.pc/mosquitto.conf.patch/mosquitto.conf (+0/-364)
CMakeLists.txt (+23/-6)
COPYING (+0/-26)
ChangeLog.txt (+423/-0)
LICENSE-3rd-party.txt (+666/-0)
LICENSE.txt (+54/-0)
Makefile (+38/-29)
aclfile.example (+6/-0)
changeset (+1/-0)
client/Makefile (+17/-13)
client/pub_client.c (+280/-80)
client/sub_client.c (+293/-96)
compiling.txt (+11/-9)
config.h (+4/-54)
config.mk (+200/-19)
debian/README-ca_certificates (+1/-0)
debian/README-certs (+3/-0)
debian/README-conf-d (+2/-0)
debian/changelog (+20/-10)
debian/compat (+1/-1)
debian/control (+43/-17)
debian/copyright (+22/-1)
debian/libmosquitto-dev.install (+3/-0)
debian/libmosquitto-dev.lintian-overrides (+3/-0)
debian/libmosquitto0-dev.install (+0/-3)
debian/libmosquitto0.install (+0/-1)
debian/libmosquitto0.symbols (+0/-31)
debian/libmosquitto1.install (+1/-0)
debian/libmosquitto1.symbols (+4/-0)
debian/libmosquittopp-dev.install (+2/-0)
debian/libmosquittopp0-dev.install (+0/-2)
debian/libmosquittopp0.install (+0/-1)
debian/libmosquittopp0.symbols (+0/-33)
debian/libmosquittopp1.install (+1/-0)
debian/libmosquittopp1.symbols (+55/-0)
debian/mosquitto-clients.lintian-overrides (+3/-0)
debian/mosquitto.conf (+10/-0)
debian/mosquitto.dirs (+1/-0)
debian/mosquitto.init (+138/-0)
debian/mosquitto.install (+7/-1)
debian/mosquitto.logrotate (+11/-0)
debian/mosquitto.postrm (+4/-0)
debian/mosquitto.upstart (+2/-2)
debian/patches/bug-acl-patterns.patch (+0/-16)
debian/patches/bug-persistence-reloading.patch (+0/-18)
debian/patches/bug-proto-number.patch (+0/-15)
debian/patches/debian-config.patch (+26/-0)
debian/patches/disable-in-tree-uthash.patch (+954/-0)
debian/patches/enable-libwrap.patch (+9/-20)
debian/patches/fix-prefix.patch (+4/-15)
debian/patches/install-apparmor.patch (+14/-3)
debian/patches/mosquitto.conf.patch (+0/-32)
debian/patches/nostrip.patch (+53/-0)
debian/patches/problem-test.patch (+14/-0)
debian/patches/pynomake.patch (+14/-0)
debian/patches/series (+6/-5)
debian/python-mosquitto.install (+1/-2)
debian/python3-mosquitto.install (+1/-0)
debian/pyversions (+0/-1)
debian/rules (+21/-1)
examples/mysql_log/Makefile (+15/-0)
examples/mysql_log/mysql_log.c (+118/-0)
examples/temperature_conversion/Makefile (+18/-0)
examples/temperature_conversion/main.cpp (+23/-0)
examples/temperature_conversion/readme.txt (+6/-0)
examples/temperature_conversion/temperature_conversion.cpp (+45/-0)
examples/temperature_conversion/temperature_conversion.h (+17/-0)
external_security_checks.txt (+0/-71)
installer/mosquitto-cygwin.nsi (+23/-1)
installer/mosquitto.nsi (+15/-1)
lib/CMakeLists.txt (+30/-5)
lib/Makefile (+58/-29)
lib/cpp/CMakeLists.txt (+1/-1)
lib/cpp/Makefile (+12/-8)
lib/cpp/mosquittopp.cpp (+204/-79)
lib/cpp/mosquittopp.h (+50/-20)
lib/dummypthread.h (+13/-0)
lib/jsws/mosquitto.js (+363/-0)
lib/linker.version (+32/-6)
lib/logging_mosq.c (+12/-23)
lib/logging_mosq.h (+1/-1)
lib/memory_mosq.c (+6/-5)
lib/memory_mosq.h (+1/-1)
lib/messages_mosq.c (+129/-21)
lib/messages_mosq.h (+3/-2)
lib/mosquitto.c (+929/-184)
lib/mosquitto.h (+789/-141)
lib/mosquitto_internal.h (+94/-35)
lib/mqtt3_protocol.h (+9/-0)
lib/net_mosq.c (+432/-135)
lib/net_mosq.h (+21/-8)
lib/python/Makefile (+9/-1)
lib/python/mosquitto.py (+1896/-497)
lib/python/readme.txt (+0/-7)
lib/python/setup.py (+19/-2)
lib/python/sub.py (+26/-17)
lib/read_handle.c (+26/-18)
lib/read_handle.h (+3/-3)
lib/read_handle_client.c (+9/-7)
lib/read_handle_shared.c (+43/-30)
lib/send_client_mosq.c (+52/-11)
lib/send_mosq.c (+94/-22)
lib/send_mosq.h (+5/-5)
lib/thread_mosq.c (+91/-0)
lib/time_mosq.c (+95/-0)
lib/time_mosq.h (+35/-0)
lib/tls_mosq.c (+131/-0)
lib/tls_mosq.h (+49/-0)
lib/util_mosq.c (+180/-12)
lib/util_mosq.h (+8/-2)
lib/will_mosq.c (+50/-33)
lib/will_mosq.h (+4/-3)
man/CMakeLists.txt (+2/-2)
man/Makefile (+20/-20)
man/html.xsl (+7/-0)
man/libmosquitto.3 (+202/-271)
man/libmosquitto.3.xml (+290/-149)
man/manpage.xsl (+13/-0)
man/mosquitto-tls.7 (+151/-0)
man/mosquitto-tls.7.xml (+91/-0)
man/mosquitto.8 (+455/-222)
man/mosquitto.8.xml (+238/-86)
man/mosquitto.conf.5 (+832/-469)
man/mosquitto.conf.5.xml (+666/-138)
man/mosquitto_passwd.1 (+124/-0)
man/mosquitto_passwd.1.xml (+139/-0)
man/mosquitto_pub.1 (+370/-155)
man/mosquitto_pub.1.xml (+175/-73)
man/mosquitto_sub.1 (+311/-161)
man/mosquitto_sub.1.xml (+185/-70)
man/mqtt.7 (+267/-138)
man/mqtt.7.xml (+27/-27)
man/po/libmosquitto/libmosquitto.3.pot (+456/-204)
man/po/mosquitto-tls/mosquitto-tls.7.pot (+140/-0)
man/po/mosquitto.conf/mosquitto.conf.5.pot (+785/-153)
man/po/mosquitto/mosquitto.8.pot (+304/-156)
man/po/mosquitto_pub/mosquitto_pub.1.pot (+276/-132)
man/po/mosquitto_sub/mosquitto_sub.1.pot (+263/-115)
man/po/mqtt/mqtt.7.pot (+24/-16)
misc/currentcost/cc128_read.py (+11/-15)
misc/currentcost/gnome-panel/CurrentCostMQTT.py (+40/-44)
misc/pachube_update.pl (+0/-33)
mosquitto.conf (+422/-55)
pskfile.example (+2/-0)
pwfile.example (+3/-3)
readme-windows.txt (+7/-0)
readme.txt (+11/-4)
security/mosquitto.apparmor (+3/-0)
src/CMakeLists.txt (+35/-15)
src/Makefile (+86/-63)
src/bridge.c (+149/-60)
src/conf.c (+1125/-251)
src/context.c (+43/-31)
src/database.c (+299/-305)
src/db_dump/db_dump.c (+20/-10)
src/lib_load.h (+50/-0)
src/logging.c (+27/-4)
src/loop.c (+171/-73)
src/mosquitto.c (+53/-20)
src/mosquitto_broker.h (+432/-0)
src/mosquitto_passwd.c (+483/-0)
src/mosquitto_plugin.h (+194/-0)
src/mqtt3.h (+0/-370)
src/net.c (+302/-34)
src/persist.c (+129/-81)
src/persist.h (+2/-0)
src/read_handle.c (+108/-16)
src/read_handle_client.c (+51/-22)
src/read_handle_server.c (+270/-146)
src/security.c (+180/-716)
src/security_default.c (+958/-0)
src/security_external.c (+0/-71)
src/send_server.c (+3/-3)
src/service.c (+1/-1)
src/subs.c (+141/-55)
src/sys_tree.c (+343/-0)
src/uthash.h (+948/-0)
test/Makefile (+91/-0)
test/broker/01-connect-anon-denied.conf (+3/-0)
test/broker/01-connect-anon-denied.pwfile (+1/-0)
test/broker/01-connect-anon-denied.py (+42/-0)
test/broker/01-connect-invalid-id-0.py (+41/-0)
test/broker/01-connect-invalid-id-24.py (+42/-0)
test/broker/01-connect-invalid-id-missing.py (+40/-0)
test/broker/01-connect-invalid-protonum.py (+42/-0)
test/broker/01-connect-success.py (+44/-0)
test/broker/01-connect-uname-no-password-denied.conf (+3/-0)
test/broker/01-connect-uname-no-password-denied.pwfile (+1/-0)
test/broker/01-connect-uname-no-password-denied.py (+43/-0)
test/broker/01-connect-uname-password-denied.conf (+3/-0)
test/broker/01-connect-uname-password-denied.pwfile (+1/-0)
test/broker/01-connect-uname-password-denied.py (+43/-0)
test/broker/01-connect-uname-password-success.conf (+3/-0)
test/broker/01-connect-uname-password-success.pwfile (+1/-0)
test/broker/01-connect-uname-password-success.py (+43/-0)
test/broker/02-subpub-qos0.py (+55/-0)
test/broker/02-subpub-qos1.py (+63/-0)
test/broker/02-subpub-qos2.py (+73/-0)
test/broker/02-subscribe-qos0.py (+50/-0)
test/broker/02-subscribe-qos1.py (+50/-0)
test/broker/02-subscribe-qos2.py (+50/-0)
test/broker/02-unsubscribe-qos0.py (+51/-0)
test/broker/02-unsubscribe-qos1.py (+50/-0)
test/broker/02-unsubscribe-qos2.py (+50/-0)
test/broker/03-pattern-matching-helper.py (+32/-0)
test/broker/03-pattern-matching.py (+82/-0)
test/broker/03-publish-b2c-disconnect-qos1-helper.py (+37/-0)
test/broker/03-publish-b2c-disconnect-qos1.conf (+3/-0)
test/broker/03-publish-b2c-disconnect-qos1.py (+78/-0)
test/broker/03-publish-b2c-disconnect-qos2-helper.py (+44/-0)
test/broker/03-publish-b2c-disconnect-qos2.conf (+3/-0)
test/broker/03-publish-b2c-disconnect-qos2.py (+95/-0)
test/broker/03-publish-b2c-timeout-qos1-helper.py (+39/-0)
test/broker/03-publish-b2c-timeout-qos1.conf (+3/-0)
test/broker/03-publish-b2c-timeout-qos1.py (+67/-0)
test/broker/03-publish-b2c-timeout-qos2-helper.py (+44/-0)
test/broker/03-publish-b2c-timeout-qos2.conf (+3/-0)
test/broker/03-publish-b2c-timeout-qos2.py (+77/-0)
test/broker/03-publish-c2b-disconnect-qos2.conf (+2/-0)
test/broker/03-publish-c2b-disconnect-qos2.py (+92/-0)
test/broker/03-publish-c2b-timeout-qos2.conf (+2/-0)
test/broker/03-publish-c2b-timeout-qos2.py (+61/-0)
test/broker/03-publish-qos1.py (+50/-0)
test/broker/03-publish-qos2.py (+55/-0)
test/broker/04-retain-qos0-clear.py (+80/-0)
test/broker/04-retain-qos0-fresh.py (+55/-0)
test/broker/04-retain-qos0-repeated.py (+65/-0)
test/broker/04-retain-qos0.py (+52/-0)
test/broker/04-retain-qos1-qos0.py (+59/-0)
test/broker/05-clean-session-qos1-helper.py (+39/-0)
test/broker/05-clean-session-qos1.py (+71/-0)
test/broker/06-bridge-b2br-disconnect-qos1.conf (+9/-0)
test/broker/06-bridge-b2br-disconnect-qos1.py (+95/-0)
test/broker/06-bridge-b2br-disconnect-qos2.conf (+11/-0)
test/broker/06-bridge-b2br-disconnect-qos2.py (+112/-0)
test/broker/06-bridge-br2b-disconnect-qos1-helper.py (+37/-0)
test/broker/06-bridge-br2b-disconnect-qos1.conf (+10/-0)
test/broker/06-bridge-br2b-disconnect-qos1.py (+91/-0)
test/broker/06-bridge-br2b-disconnect-qos2-helper.py (+42/-0)
test/broker/06-bridge-br2b-disconnect-qos2.conf (+11/-0)
test/broker/06-bridge-br2b-disconnect-qos2.py (+114/-0)
test/broker/06-bridge-reconnect-local-out-helper.py (+39/-0)
test/broker/06-bridge-reconnect-local-out.conf (+9/-0)
test/broker/06-bridge-reconnect-local-out.py (+86/-0)
test/broker/07-will-acl-denied.acl (+2/-0)
test/broker/07-will-acl-denied.conf (+2/-0)
test/broker/07-will-acl-denied.py (+56/-0)
test/broker/07-will-null-helper.py (+33/-0)
test/broker/07-will-null-topic.py (+43/-0)
test/broker/07-will-null.py (+58/-0)
test/broker/07-will-qos0-helper.py (+32/-0)
test/broker/07-will-qos0.py (+57/-0)
test/broker/08-ssl-bridge-helper.py (+34/-0)
test/broker/08-ssl-bridge.conf (+12/-0)
test/broker/08-ssl-bridge.py (+71/-0)
test/broker/08-ssl-connect-cert-auth-crl.conf (+9/-0)
test/broker/08-ssl-connect-cert-auth-crl.py (+49/-0)
test/broker/08-ssl-connect-cert-auth-expired.conf (+8/-0)
test/broker/08-ssl-connect-cert-auth-expired.py (+53/-0)
test/broker/08-ssl-connect-cert-auth-revoked.conf (+9/-0)
test/broker/08-ssl-connect-cert-auth-revoked.py (+52/-0)
test/broker/08-ssl-connect-cert-auth-without.conf (+8/-0)
test/broker/08-ssl-connect-cert-auth-without.py (+52/-0)
test/broker/08-ssl-connect-cert-auth.conf (+8/-0)
test/broker/08-ssl-connect-cert-auth.py (+51/-0)
test/broker/08-ssl-connect-identity.conf (+9/-0)
test/broker/08-ssl-connect-identity.py (+50/-0)
test/broker/08-ssl-connect-no-auth-wrong-ca.conf (+7/-0)
test/broker/08-ssl-connect-no-auth-wrong-ca.py (+49/-0)
test/broker/08-ssl-connect-no-auth.conf (+7/-0)
test/broker/08-ssl-connect-no-auth.py (+51/-0)
test/broker/08-ssl-connect-no-identity.conf (+9/-0)
test/broker/08-ssl-connect-no-identity.py (+50/-0)
test/broker/08-tls-psk-bridge.conf (+14/-0)
test/broker/08-tls-psk-bridge.conf2 (+14/-0)
test/broker/08-tls-psk-bridge.psk (+1/-0)
test/broker/08-tls-psk-bridge.py (+86/-0)
test/broker/08-tls-psk-pub.conf (+15/-0)
test/broker/08-tls-psk-pub.psk (+1/-0)
test/broker/08-tls-psk-pub.py (+76/-0)
test/broker/09-plugin-auth-unpwd-fail.conf (+3/-0)
test/broker/09-plugin-auth-unpwd-fail.py (+45/-0)
test/broker/09-plugin-auth-unpwd-success.conf (+3/-0)
test/broker/09-plugin-auth-unpwd-success.py (+46/-0)
test/broker/10-listener-mount-point-helper.py (+33/-0)
test/broker/10-listener-mount-point.conf (+7/-0)
test/broker/10-listener-mount-point.py (+56/-0)
test/broker/Makefile (+92/-0)
test/broker/c/08-tls-psk-bridge.c (+63/-0)
test/broker/c/08-tls-psk-pub.c (+59/-0)
test/broker/c/Makefile (+23/-0)
test/broker/c/auth_plugin.c (+55/-0)
test/broker/readme.txt (+14/-0)
test/fake_user.c (+114/-0)
test/lib/01-con-discon-success.py (+65/-0)
test/lib/01-keepalive-pingreq.py (+69/-0)
test/lib/01-no-clean-session.py (+56/-0)
test/lib/01-unpwd-set.py (+56/-0)
test/lib/01-will-set.py (+58/-0)
test/lib/01-will-unpwd-set.py (+60/-0)
test/lib/02-subscribe-qos0.py (+75/-0)
test/lib/02-subscribe-qos1.py (+75/-0)
test/lib/02-subscribe-qos2.py (+75/-0)
test/lib/02-unsubscribe.py (+65/-0)
test/lib/03-publish-b2c-qos1.py (+82/-0)
test/lib/03-publish-b2c-qos2.py (+95/-0)
test/lib/03-publish-c2b-qos1-disconnect.py (+77/-0)
test/lib/03-publish-c2b-qos1-timeout.py (+83/-0)
test/lib/03-publish-c2b-qos2-disconnect.py (+93/-0)
test/lib/03-publish-c2b-qos2-timeout.py (+94/-0)
test/lib/03-publish-c2b-qos2.py (+89/-0)
test/lib/03-publish-qos0-no-payload.py (+69/-0)
test/lib/03-publish-qos0.py (+69/-0)
test/lib/04-retain-qos0.py (+59/-0)
test/lib/08-ssl-bad-cacert.py (+38/-0)
test/lib/08-ssl-connect-cert-auth.py (+73/-0)
test/lib/08-ssl-connect-no-auth.py (+70/-0)
test/lib/08-ssl-fake-cacert.py (+61/-0)
test/lib/09-util-topic-matching.py (+27/-0)
test/lib/09-util-topic-tokenise.py (+27/-0)
test/lib/Makefile (+48/-0)
test/lib/c/01-con-discon-success.c (+41/-0)
test/lib/c/01-keepalive-pingreq.c (+33/-0)
test/lib/c/01-no-clean-session.c (+25/-0)
test/lib/c/01-unpwd-set.c (+26/-0)
test/lib/c/01-will-set.c (+26/-0)
test/lib/c/01-will-unpwd-set.c (+27/-0)
test/lib/c/02-subscribe-qos0.c (+47/-0)
test/lib/c/02-subscribe-qos1.c (+47/-0)
test/lib/c/02-subscribe-qos2.c (+47/-0)
test/lib/c/02-unsubscribe.c (+47/-0)
test/lib/c/03-publish-b2c-qos1.c (+64/-0)
test/lib/c/03-publish-b2c-qos2.c (+66/-0)
test/lib/c/03-publish-c2b-qos1-disconnect.c (+57/-0)
test/lib/c/03-publish-c2b-qos1-timeout.c (+49/-0)
test/lib/c/03-publish-c2b-qos2-disconnect.c (+57/-0)
test/lib/c/03-publish-c2b-qos2-timeout.c (+49/-0)
test/lib/c/03-publish-c2b-qos2.c (+48/-0)
test/lib/c/03-publish-qos0-no-payload.c (+48/-0)
test/lib/c/03-publish-qos0.c (+48/-0)
test/lib/c/04-retain-qos0.c (+36/-0)
test/lib/c/08-ssl-bad-cacert.c (+21/-0)
test/lib/c/08-ssl-connect-cert-auth.c (+44/-0)
test/lib/c/08-ssl-connect-no-auth.c (+45/-0)
test/lib/c/08-ssl-fake-cacert.c (+35/-0)
test/lib/c/09-util-topic-matching.c (+26/-0)
test/lib/c/09-util-topic-tokenise.c (+87/-0)
test/lib/c/Makefile (+102/-0)
test/lib/cpp/01-con-discon-success.cpp (+53/-0)
test/lib/cpp/01-keepalive-pingreq.cpp (+41/-0)
test/lib/cpp/01-no-clean-session.cpp (+33/-0)
test/lib/cpp/01-unpwd-set.cpp (+34/-0)
test/lib/cpp/01-will-set.cpp (+37/-0)
test/lib/cpp/01-will-unpwd-set.cpp (+35/-0)
test/lib/cpp/02-subscribe-qos0.cpp (+55/-0)
test/lib/cpp/02-subscribe-qos1.cpp (+56/-0)
test/lib/cpp/02-subscribe-qos2.cpp (+56/-0)
test/lib/cpp/02-unsubscribe.cpp (+55/-0)
test/lib/cpp/03-publish-b2c-qos1.cpp (+76/-0)
test/lib/cpp/03-publish-b2c-qos2.cpp (+78/-0)
test/lib/cpp/03-publish-c2b-qos1-disconnect.cpp (+68/-0)
test/lib/cpp/03-publish-c2b-qos1-timeout.cpp (+60/-0)
test/lib/cpp/03-publish-c2b-qos2-disconnect.cpp (+68/-0)
test/lib/cpp/03-publish-c2b-qos2-timeout.cpp (+60/-0)
test/lib/cpp/03-publish-c2b-qos2.cpp (+59/-0)
test/lib/cpp/03-publish-qos0-no-payload.cpp (+56/-0)
test/lib/cpp/03-publish-qos0.cpp (+56/-0)
test/lib/cpp/04-retain-qos0.cpp (+45/-0)
test/lib/cpp/08-ssl-bad-cacert.cpp (+31/-0)
test/lib/cpp/08-ssl-connect-cert-auth.cpp (+53/-0)
test/lib/cpp/08-ssl-connect-no-auth.cpp (+53/-0)
test/lib/cpp/08-ssl-fake-cacert.cpp (+42/-0)
test/lib/cpp/09-util-topic-matching.cpp (+26/-0)
test/lib/cpp/09-util-topic-tokenise.cpp (+86/-0)
test/lib/cpp/Makefile (+102/-0)
test/lib/python/01-con-discon-success.test (+33/-0)
test/lib/python/01-keepalive-pingreq.test (+25/-0)
test/lib/python/01-no-clean-session.test (+12/-0)
test/lib/python/01-unpwd-set.test (+13/-0)
test/lib/python/01-will-set.test (+13/-0)
test/lib/python/01-will-unpwd-set.test (+14/-0)
test/lib/python/02-subscribe-qos0.test (+35/-0)
test/lib/python/02-subscribe-qos1.test (+35/-0)
test/lib/python/02-subscribe-qos2.test (+35/-0)
test/lib/python/02-unsubscribe.test (+35/-0)
test/lib/python/03-publish-b2c-qos1.test (+45/-0)
test/lib/python/03-publish-b2c-qos2.test (+48/-0)
test/lib/python/03-publish-c2b-qos1-disconnect.test (+48/-0)
test/lib/python/03-publish-c2b-qos1-timeout.test (+44/-0)
test/lib/python/03-publish-c2b-qos2-disconnect.test (+44/-0)
test/lib/python/03-publish-c2b-qos2-timeout.test (+37/-0)
test/lib/python/03-publish-c2b-qos2.test (+36/-0)
test/lib/python/03-publish-qos0-no-payload.test (+36/-0)
test/lib/python/03-publish-qos0.test (+36/-0)
test/lib/python/04-retain-qos0.test (+27/-0)
test/lib/python/08-ssl-bad-cacert.test (+23/-0)
test/lib/python/08-ssl-connect-cert-auth.test (+37/-0)
test/lib/python/08-ssl-connect-no-auth.test (+38/-0)
test/lib/python/08-ssl-fake-cacert.test (+32/-0)
test/lib/python/09-util-topic-matching.test (+26/-0)
test/lib/python/09-util-topic-tokenise.test (+5/-0)
test/lib/python3/01-con-discon-success.test (+33/-0)
test/lib/python3/01-keepalive-pingreq.test (+25/-0)
test/lib/python3/01-no-clean-session.test (+12/-0)
test/lib/python3/01-unpwd-set.test (+13/-0)
test/lib/python3/01-will-set.test (+13/-0)
test/lib/python3/01-will-unpwd-set.test (+14/-0)
test/lib/python3/02-subscribe-qos0.test (+35/-0)
test/lib/python3/02-subscribe-qos1.test (+35/-0)
test/lib/python3/02-subscribe-qos2.test (+35/-0)
test/lib/python3/02-unsubscribe.test (+35/-0)
test/lib/python3/03-publish-b2c-qos1.test (+45/-0)
test/lib/python3/03-publish-b2c-qos2.test (+48/-0)
test/lib/python3/03-publish-c2b-qos1-disconnect.test (+48/-0)
test/lib/python3/03-publish-c2b-qos1-timeout.test (+44/-0)
test/lib/python3/03-publish-c2b-qos2-disconnect.test (+44/-0)
test/lib/python3/03-publish-c2b-qos2-timeout.test (+37/-0)
test/lib/python3/03-publish-c2b-qos2.test (+36/-0)
test/lib/python3/03-publish-qos0-no-payload.test (+36/-0)
test/lib/python3/03-publish-qos0.test (+36/-0)
test/lib/python3/04-retain-qos0.test (+27/-0)
test/lib/python3/08-ssl-bad-cacert.test (+23/-0)
test/lib/python3/08-ssl-connect-cert-auth.test (+34/-0)
test/lib/python3/08-ssl-connect-no-auth.test (+35/-0)
test/lib/python3/08-ssl-fake-cacert.test (+32/-0)
test/lib/python3/09-util-topic-matching.test (+26/-0)
test/lib/python3/09-util-topic-tokenise.test (+5/-0)
test/mosq_test.py (+322/-0)
test/msgsps_common.h (+3/-0)
test/msgsps_pub.c (+135/-0)
test/msgsps_sub.c (+86/-0)
test/packet-gen.c (+53/-0)
test/qos.c (+186/-0)
test/random_client.c (+198/-0)
test/ssl/all-ca.crt (+75/-0)
test/ssl/client-expired.crt (+61/-0)
test/ssl/client-revoked.crt (+61/-0)
test/ssl/client-revoked.csr (+12/-0)
test/ssl/client-revoked.key (+15/-0)
test/ssl/client.crt (+61/-0)
test/ssl/client.csr (+12/-0)
test/ssl/client.key (+15/-0)
test/ssl/crl.pem (+10/-0)
test/ssl/demoCA/crlnumber (+1/-0)
test/ssl/demoCA/index.txt (+1/-0)
test/ssl/demoCA/index.txt.attr (+1/-0)
test/ssl/demoCA/serial (+1/-0)
test/ssl/gen.sh (+70/-0)
test/ssl/openssl.cnf (+406/-0)
test/ssl/readme.txt (+2/-0)
test/ssl/rootCA/crlnumber (+1/-0)
test/ssl/rootCA/index.txt (+2/-0)
test/ssl/rootCA/index.txt.attr (+1/-0)
test/ssl/rootCA/serial (+1/-0)
test/ssl/server.crt (+60/-0)
test/ssl/server.csr (+12/-0)
test/ssl/server.key (+15/-0)
test/ssl/signingCA/crlnumber (+1/-0)
test/ssl/signingCA/index.txt (+4/-0)
test/ssl/signingCA/index.txt.attr (+1/-0)
test/ssl/signingCA/serial (+1/-0)
test/ssl/test-alt-ca.crt (+58/-0)
test/ssl/test-alt-ca.key (+15/-0)
test/ssl/test-bad-root-ca.crt (+17/-0)
test/ssl/test-bad-root-ca.key (+15/-0)
test/ssl/test-ca.srl (+1/-0)
test/ssl/test-fake-root-ca.crt (+17/-0)
test/ssl/test-fake-root-ca.key (+15/-0)
test/ssl/test-root-ca.crt (+17/-0)
test/ssl/test-root-ca.key (+15/-0)
test/ssl/test-signing-ca.crt (+58/-0)
test/ssl/test-signing-ca.key (+15/-0)
test/to-test (+7/-0)
To merge this branch: bzr merge lp:~roger.light/ubuntu/saucy/mosquitto/merge-debian-1.2
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Needs Fixing
Review via email: mp+181952@code.launchpad.net

Description of the change

Merge version 1.2 from Debian unstable.

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

When I attempt the merge I get the following merge conflicts:
Text conflict in Makefile
Text conflict in client/Makefile
Text conflict in config.h
Text conflict in config.mk
Text conflict in mosquitto.conf
Text conflict in src/conf.c
Text conflict in src/read_handle_server.c
Text conflict in src/security.c

review: Needs Fixing

Unmerged revisions

8. By Roger Light

* Merge from Debian unstable. Remaining changes:
  - Install apparmor profile.
* New upstream release: http://mosquitto.org/2013/08/version-1-2-released/
  (closes: #685119).
* Bumped standards release to 3.9.4. No changes needed.
* Added mosquitto-dbg package for binary debug information.
* Added python3-mosquitto binary package.
* Use dh_python2 (and dh_python3) instead of python-support.
* mosquitto now logs to /var/log/mosquitto/ using logrotate.
* mosquitto local config should now be placed in /etc/mosquitto/conf.d/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file '.pc/applied-patches'
2--- .pc/applied-patches 2013-08-23 15:09:02 +0000
3+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
4@@ -1,7 +0,0 @@
5-fix-prefix.patch
6-mosquitto.conf.patch
7-enable-libwrap.patch
8-bug-proto-number.patch
9-bug-persistence-reloading.patch
10-bug-acl-patterns.patch
11-install-apparmor.patch
12
13=== removed directory '.pc/bug-acl-patterns.patch'
14=== removed directory '.pc/bug-acl-patterns.patch/src'
15=== removed file '.pc/bug-acl-patterns.patch/src/security.c'
16--- .pc/bug-acl-patterns.patch/src/security.c 2012-12-28 22:55:03 +0000
17+++ .pc/bug-acl-patterns.patch/src/security.c 1970-01-01 00:00:00 +0000
18@@ -1,764 +0,0 @@
19-/*
20-Copyright (c) 2011,2012 Roger Light <roger@atchoo.org>
21-All rights reserved.
22-
23-Redistribution and use in source and binary forms, with or without
24-modification, are permitted provided that the following conditions are met:
25-
26-1. Redistributions of source code must retain the above copyright notice,
27- this list of conditions and the following disclaimer.
28-2. Redistributions in binary form must reproduce the above copyright
29- notice, this list of conditions and the following disclaimer in the
30- documentation and/or other materials provided with the distribution.
31-3. Neither the name of mosquitto nor the names of its
32- contributors may be used to endorse or promote products derived from
33- this software without specific prior written permission.
34-
35-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
39-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
43-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45-POSSIBILITY OF SUCH DAMAGE.
46-*/
47-
48-#include <config.h>
49-
50-#include <stdio.h>
51-#include <string.h>
52-
53-#include <memory_mosq.h>
54-#include <mqtt3.h>
55-
56-int mosquitto_security_init(mosquitto_db *db)
57-{
58- int rc;
59-
60-#ifdef WITH_EXTERNAL_SECURITY_CHECKS
61- rc = mosquitto_unpwd_init(db);
62- if(rc){
63- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error initialising passwords.");
64- return rc;
65- }
66-
67- rc = mosquitto_acl_init(db);
68- if(rc){
69- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error initialising ACLs.");
70- return rc;
71- }
72-#else
73- /* Load username/password data if required. */
74- if(db->config->password_file){
75- rc = mqtt3_pwfile_parse(db);
76- if(rc){
77- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error opening password file.");
78- return rc;
79- }
80- }
81-
82- /* Load acl data if required. */
83- if(db->config->acl_file){
84- rc = mqtt3_aclfile_parse(db);
85- if(rc){
86- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error opening acl file.");
87- return rc;
88- }
89- }
90-#endif
91- return MOSQ_ERR_SUCCESS;
92-}
93-
94-void mosquitto_security_cleanup(mosquitto_db *db)
95-{
96- mosquitto_acl_cleanup(db);
97- mosquitto_unpwd_cleanup(db);
98-}
99-
100-#ifndef WITH_EXTERNAL_SECURITY_CHECKS
101-
102-int _add_acl(struct _mosquitto_db *db, const char *user, const char *topic, int access)
103-{
104- struct _mosquitto_acl_user *acl_user=NULL, *user_tail;
105- struct _mosquitto_acl *acl, *acl_root=NULL, *acl_tail=NULL;
106- char *local_topic;
107- char *token = NULL;
108- bool new_user = false;
109-
110- if(!db || !topic) return MOSQ_ERR_INVAL;
111-
112- local_topic = _mosquitto_strdup(topic);
113- if(!local_topic){
114- return MOSQ_ERR_NOMEM;
115- }
116-
117- if(db->acl_list){
118- user_tail = db->acl_list;
119- while(user_tail){
120- if(user == NULL){
121- if(user_tail->username == NULL){
122- acl_user = user_tail;
123- break;
124- }
125- }else if(user_tail->username && !strcmp(user_tail->username, user)){
126- acl_user = user_tail;
127- break;
128- }
129- user_tail = user_tail->next;
130- }
131- }
132- if(!acl_user){
133- acl_user = _mosquitto_malloc(sizeof(struct _mosquitto_acl_user));
134- if(!acl_user){
135- _mosquitto_free(local_topic);
136- return MOSQ_ERR_NOMEM;
137- }
138- new_user = true;
139- if(user){
140- acl_user->username = _mosquitto_strdup(user);
141- if(!acl_user->username){
142- _mosquitto_free(local_topic);
143- _mosquitto_free(acl_user);
144- return MOSQ_ERR_NOMEM;
145- }
146- }else{
147- acl_user->username = NULL;
148- }
149- acl_user->next = NULL;
150- acl_user->acl = NULL;
151- }
152-
153- /* Tokenise topic */
154- if(local_topic[0] == '/'){
155- acl_root = _mosquitto_malloc(sizeof(struct _mosquitto_acl));
156- if(!acl_root) return MOSQ_ERR_NOMEM;
157- acl_tail = acl_root;
158- acl_root->child = NULL;
159- acl_root->next = NULL;
160- acl_root->access = MOSQ_ACL_NONE;
161- acl_root->topic = _mosquitto_strdup("/");
162- if(!acl_root->topic) return MOSQ_ERR_NOMEM;
163-
164- token = strtok(local_topic+1, "/");
165- }else{
166- token = strtok(local_topic, "/");
167- }
168-
169- while(token){
170- acl = _mosquitto_malloc(sizeof(struct _mosquitto_acl));
171- if(!acl) return MOSQ_ERR_NOMEM;
172- acl->child = NULL;
173- acl->next = NULL;
174- acl->access = MOSQ_ACL_NONE;
175- acl->topic = _mosquitto_strdup(token);
176- if(!acl->topic) return MOSQ_ERR_NOMEM;
177- if(acl_root){
178- acl_tail->child = acl;
179- acl_tail = acl;
180- }else{
181- acl_root = acl;
182- acl_tail = acl;
183- }
184-
185- token = strtok(NULL, "/");
186- }
187- if(acl_root){
188- acl_tail = acl_root;
189- while(acl_tail->child){
190- acl_tail = acl_tail->child;
191- }
192- acl_tail->access = access;
193- }else{
194- return MOSQ_ERR_INVAL;
195- }
196-
197- /* Add acl to user acl list */
198- if(acl_user->acl){
199- acl_tail = acl_user->acl;
200- while(acl_tail->next){
201- acl_tail = acl_tail->next;
202- }
203- acl_tail->next = acl_root;
204- }else{
205- acl_user->acl = acl_root;
206- }
207-
208- if(new_user){
209- /* Add to end of list */
210- if(db->acl_list){
211- user_tail = db->acl_list;
212- while(user_tail->next){
213- user_tail = user_tail->next;
214- }
215- user_tail->next = acl_user;
216- }else{
217- db->acl_list = acl_user;
218- }
219- }
220-
221- _mosquitto_free(local_topic);
222- return MOSQ_ERR_SUCCESS;
223-}
224-
225-int _add_acl_pattern(struct _mosquitto_db *db, const char *topic, int access)
226-{
227- struct _mosquitto_acl *acl, *acl_root=NULL, *acl_tail=NULL;
228- char *local_topic;
229- char *token = NULL;
230-
231- if(!db || !topic) return MOSQ_ERR_INVAL;
232-
233- local_topic = _mosquitto_strdup(topic);
234- if(!local_topic){
235- return MOSQ_ERR_NOMEM;
236- }
237-
238- /* Tokenise topic */
239- if(local_topic[0] == '/'){
240- acl_root = _mosquitto_malloc(sizeof(struct _mosquitto_acl));
241- if(!acl_root) return MOSQ_ERR_NOMEM;
242- acl_tail = acl_root;
243- acl_root->child = NULL;
244- acl_root->next = NULL;
245- acl_root->access = MOSQ_ACL_NONE;
246- acl_root->topic = _mosquitto_strdup("/");
247- if(!acl_root->topic) return MOSQ_ERR_NOMEM;
248-
249- token = strtok(local_topic+1, "/");
250- }else{
251- token = strtok(local_topic, "/");
252- }
253-
254- while(token){
255- acl = _mosquitto_malloc(sizeof(struct _mosquitto_acl));
256- if(!acl) return MOSQ_ERR_NOMEM;
257- acl->child = NULL;
258- acl->next = NULL;
259- acl->access = MOSQ_ACL_NONE;
260- acl->topic = _mosquitto_strdup(token);
261- if(!acl->topic) return MOSQ_ERR_NOMEM;
262- if(acl_root){
263- acl_tail->child = acl;
264- acl_tail = acl;
265- }else{
266- acl_root = acl;
267- acl_tail = acl;
268- }
269-
270- token = strtok(NULL, "/");
271- }
272-
273- if(acl_root){
274- acl_tail = acl_root;
275- while(acl_tail->child){
276- acl_tail = acl_tail->child;
277- }
278- acl_tail->access = access;
279-
280- if(db->acl_patterns){
281- acl_tail = db->acl_patterns;
282- while(acl_tail->next){
283- acl_tail = acl_tail->next;
284- }
285- acl_tail->next = acl_root;
286- }else{
287- db->acl_patterns = acl_root;
288- }
289- }else{
290- return MOSQ_ERR_INVAL;
291- }
292-
293- _mosquitto_free(local_topic);
294- return MOSQ_ERR_SUCCESS;
295-}
296-
297-int mosquitto_acl_check(struct _mosquitto_db *db, struct mosquitto *context, const char *topic, int access)
298-{
299- char *local_topic;
300- char *token;
301- struct _mosquitto_acl *acl_root, *acl_tail;
302-
303- if(!db || !context || !topic) return MOSQ_ERR_INVAL;
304- if(!db->acl_list) return MOSQ_ERR_SUCCESS;
305- if(!context->acl_list && !db->acl_patterns) return MOSQ_ERR_ACL_DENIED;
306-
307- if(context->acl_list){
308- acl_root = context->acl_list->acl;
309- }else{
310- acl_root = NULL;
311- }
312-
313- /* Loop through all ACLs for this client. */
314- while(acl_root){
315- local_topic = _mosquitto_strdup(topic);
316- if(!local_topic) return MOSQ_ERR_NOMEM;
317-
318- acl_tail = acl_root;
319-
320- if(local_topic[0] == '/'){
321- if(strcmp(acl_tail->topic, "/")){
322- acl_root = acl_root->next;
323- continue;
324- }
325- acl_tail = acl_tail->child;
326- }
327-
328- token = strtok(local_topic, "/");
329- /* Loop through the topic looking for matches to this ACL. */
330- while(token){
331- if(acl_tail){
332- if(!strcmp(acl_tail->topic, "#") && acl_tail->child == NULL){
333- /* We have a match */
334- if(access & acl_tail->access){
335- /* And access is allowed. */
336- _mosquitto_free(local_topic);
337- return MOSQ_ERR_SUCCESS;
338- }else{
339- break;
340- }
341- }else if(!strcmp(acl_tail->topic, token) || !strcmp(acl_tail->topic, "+")){
342- token = strtok(NULL, "/");
343- if(!token && acl_tail->child == NULL){
344- /* We have a match */
345- if(access & acl_tail->access){
346- /* And access is allowed. */
347- _mosquitto_free(local_topic);
348- return MOSQ_ERR_SUCCESS;
349- }else{
350- break;
351- }
352- }
353- }else{
354- break;
355- }
356- acl_tail = acl_tail->child;
357- }else{
358- break;
359- }
360- }
361- _mosquitto_free(local_topic);
362-
363- acl_root = acl_root->next;
364- }
365-
366- acl_root = db->acl_patterns;
367- /* Loop through all pattern ACLs. */
368- while(acl_root){
369- local_topic = _mosquitto_strdup(topic);
370- if(!local_topic) return MOSQ_ERR_NOMEM;
371-
372- acl_tail = acl_root;
373-
374- if(local_topic[0] == '/'){
375- if(strcmp(acl_tail->topic, "/")){
376- acl_root = acl_root->next;
377- continue;
378- }
379- acl_tail = acl_tail->child;
380- }
381-
382- token = strtok(local_topic, "/");
383- /* Loop through the topic looking for matches to this ACL. */
384- while(token){
385- if(acl_tail){
386- if(!strcmp(acl_tail->topic, "#") && acl_tail->child == NULL){
387- /* We have a match */
388- if(access & acl_tail->access){
389- /* And access is allowed. */
390- _mosquitto_free(local_topic);
391- return MOSQ_ERR_SUCCESS;
392- }else{
393- break;
394- }
395- }else if(!strcmp(acl_tail->topic, "%c")){
396- if(!context->id || strcmp(token, context->id)){
397- /* No access */
398- break;
399- }
400- token = strtok(NULL, "/");
401- if(!token && acl_tail->child == NULL){
402- /* We have a match */
403- if(access & acl_tail->access){
404- /* And access is allowed. */
405- _mosquitto_free(local_topic);
406- return MOSQ_ERR_SUCCESS;
407- }else{
408- break;
409- }
410- }
411- }else if(!strcmp(acl_tail->topic, "%u")){
412- if(!context->username || strcmp(token, context->username)){
413- /* No access */
414- break;
415- }
416- token = strtok(NULL, "/");
417- if(!token && acl_tail->child == NULL){
418- /* We have a match */
419- if(access & acl_tail->access){
420- /* And access is allowed. */
421- _mosquitto_free(local_topic);
422- return MOSQ_ERR_SUCCESS;
423- }else{
424- break;
425- }
426- }
427- }else if(!strcmp(acl_tail->topic, token) || !strcmp(acl_tail->topic, "+")){
428- token = strtok(NULL, "/");
429- if(!token && acl_tail->child == NULL){
430- /* We have a match */
431- if(access & acl_tail->access){
432- /* And access is allowed. */
433- _mosquitto_free(local_topic);
434- return MOSQ_ERR_SUCCESS;
435- }else{
436- break;
437- }
438- }
439- }else{
440- break;
441- }
442- acl_tail = acl_tail->child;
443- }else{
444- break;
445- }
446- }
447- _mosquitto_free(local_topic);
448-
449- acl_root = acl_root->next;
450- }
451-
452- return MOSQ_ERR_ACL_DENIED;
453-}
454-
455-int mqtt3_aclfile_parse(struct _mosquitto_db *db)
456-{
457- FILE *aclfile;
458- char buf[1024];
459- char *token;
460- char *user = NULL;
461- char *topic;
462- char *access_s;
463- int access;
464- int rc;
465- int slen;
466- int topic_pattern;
467-
468- if(!db || !db->config) return MOSQ_ERR_INVAL;
469- if(!db->config->acl_file) return MOSQ_ERR_SUCCESS;
470-
471- aclfile = fopen(db->config->acl_file, "rt");
472- if(!aclfile) return 1;
473-
474- // topic [read|write] <topic>
475- // user <user>
476-
477- while(fgets(buf, 1024, aclfile)){
478- slen = strlen(buf);
479- while(slen > 0 && (buf[slen-1] == 10 || buf[slen-1] == 13)){
480- buf[slen-1] = '\0';
481- slen = strlen(buf);
482- }
483- token = strtok(buf, " ");
484- if(token){
485- if(!strcmp(token, "topic") || !strcmp(token, "pattern")){
486- if(!strcmp(token, "topic")){
487- topic_pattern = 0;
488- }else{
489- topic_pattern = 1;
490- }
491-
492- access_s = strtok(NULL, " ");
493- if(!access_s){
494- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty topic in acl_file.");
495- if(user) _mosquitto_free(user);
496- fclose(aclfile);
497- return MOSQ_ERR_INVAL;
498- }
499- token = strtok(NULL, " ");
500- if(token){
501- topic = token;
502- }else{
503- topic = access_s;
504- access_s = NULL;
505- }
506- if(access_s){
507- if(!strcmp(access_s, "read")){
508- access = MOSQ_ACL_READ;
509- }else if(!strcmp(access_s, "write")){
510- access = MOSQ_ACL_WRITE;
511- }else{
512- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty invalid topic access type in acl_file.");
513- if(user) _mosquitto_free(user);
514- fclose(aclfile);
515- return MOSQ_ERR_INVAL;
516- }
517- }else{
518- access = MOSQ_ACL_READ | MOSQ_ACL_WRITE;
519- }
520- if(topic_pattern == 0){
521- rc = _add_acl(db, user, topic, access);
522- }else{
523- rc = _add_acl_pattern(db, topic, access);
524- }
525- if(rc) return rc;
526- }else if(!strcmp(token, "user")){
527- token = strtok(NULL, " ");
528- if(token){
529- if(user) _mosquitto_free(user);
530- user = _mosquitto_strdup(token);
531- if(!user){
532- fclose(aclfile);
533- return MOSQ_ERR_NOMEM;
534- }
535- }else{
536- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Missing username in acl_file.");
537- if(user) _mosquitto_free(user);
538- fclose(aclfile);
539- return 1;
540- }
541- }
542- }
543- }
544-
545- if(user) _mosquitto_free(user);
546- fclose(aclfile);
547-
548- return MOSQ_ERR_SUCCESS;
549-}
550-
551-static void _free_acl(struct _mosquitto_acl *acl)
552-{
553- if(!acl) return;
554-
555- if(acl->child){
556- _free_acl(acl->child);
557- }
558- if(acl->next){
559- _free_acl(acl->next);
560- }
561- if(acl->topic){
562- _mosquitto_free(acl->topic);
563- }
564- _mosquitto_free(acl);
565-}
566-
567-void mosquitto_acl_cleanup(struct _mosquitto_db *db)
568-{
569- int i;
570- struct _mosquitto_acl_user *user_tail;
571-
572- if(!db || !db->acl_list) return;
573-
574- /* As we're freeing ACLs, we must clear context->acl_list to ensure no
575- * invalid memory accesses take place later.
576- * This *requires* the ACLs to be reapplied after mosquitto_acl_cleanup()
577- * is called if we are reloading the config. If this is not done, all
578- * access will be denied to currently connected clients.
579- */
580- if(db->contexts){
581- for(i=0; i<db->context_count; i++){
582- if(db->contexts[i] && db->contexts[i]->acl_list){
583- db->contexts[i]->acl_list = NULL;
584- }
585- }
586- }
587-
588- while(db->acl_list){
589- user_tail = db->acl_list->next;
590-
591- _free_acl(db->acl_list->acl);
592- if(db->acl_list->username){
593- _mosquitto_free(db->acl_list->username);
594- }
595- _mosquitto_free(db->acl_list);
596-
597- db->acl_list = user_tail;
598- }
599-
600- if(db->acl_patterns){
601- _free_acl(db->acl_patterns);
602- }
603-}
604-
605-int mqtt3_pwfile_parse(struct _mosquitto_db *db)
606-{
607- FILE *pwfile;
608- struct _mosquitto_unpwd *unpwd;
609- char buf[256];
610- char *username, *password;
611- int len;
612-
613- if(!db || !db->config) return MOSQ_ERR_INVAL;
614-
615- if(!db->config->password_file) return MOSQ_ERR_SUCCESS;
616-
617- pwfile = fopen(db->config->password_file, "rt");
618- if(!pwfile) return 1;
619-
620- while(!feof(pwfile)){
621- if(fgets(buf, 256, pwfile)){
622- username = strtok(buf, ":");
623- if(username){
624- unpwd = _mosquitto_calloc(1, sizeof(struct _mosquitto_unpwd));
625- if(!unpwd) return MOSQ_ERR_NOMEM;
626- unpwd->username = _mosquitto_strdup(username);
627- if(!unpwd->username) return MOSQ_ERR_NOMEM;
628- len = strlen(unpwd->username);
629- while(unpwd->username[len-1] == 10 || unpwd->username[len-1] == 13){
630- unpwd->username[len-1] = '\0';
631- len = strlen(unpwd->username);
632- }
633- password = strtok(NULL, ":");
634- if(password){
635- unpwd->password = _mosquitto_strdup(password);
636- if(!unpwd->password) return MOSQ_ERR_NOMEM;
637- len = strlen(unpwd->password);
638- while(unpwd->password[len-1] == 10 || unpwd->password[len-1] == 13){
639- unpwd->password[len-1] = '\0';
640- len = strlen(unpwd->password);
641- }
642- }
643- unpwd->next = db->unpwd;
644- db->unpwd = unpwd;
645- }
646- }
647- }
648- fclose(pwfile);
649-
650- return MOSQ_ERR_SUCCESS;
651-}
652-
653-int mosquitto_unpwd_check(struct _mosquitto_db *db, const char *username, const char *password)
654-{
655- struct _mosquitto_unpwd *tail;
656-
657- if(!db || !username) return MOSQ_ERR_INVAL;
658- if(!db->unpwd) return MOSQ_ERR_SUCCESS;
659-
660- tail = db->unpwd;
661- while(tail){
662- if(!strcmp(tail->username, username)){
663- if(tail->password){
664- if(password){
665- if(!strcmp(tail->password, password)){
666- return MOSQ_ERR_SUCCESS;
667- }
668- }else{
669- return MOSQ_ERR_AUTH;
670- }
671- }else{
672- return MOSQ_ERR_SUCCESS;
673- }
674- }
675- tail = tail->next;
676- }
677-
678- return MOSQ_ERR_AUTH;
679-}
680-
681-int mosquitto_unpwd_cleanup(struct _mosquitto_db *db)
682-{
683- struct _mosquitto_unpwd *tail;
684-
685- if(!db) return MOSQ_ERR_INVAL;
686-
687- while(db->unpwd){
688- tail = db->unpwd->next;
689- if(db->unpwd->password) _mosquitto_free(db->unpwd->password);
690- if(db->unpwd->username) _mosquitto_free(db->unpwd->username);
691- _mosquitto_free(db->unpwd);
692- db->unpwd = tail;
693- }
694-
695- return MOSQ_ERR_SUCCESS;
696-}
697-
698-/* Apply security settings after a reload.
699- * Includes:
700- * - Disconnecting anonymous users if appropriate
701- * - Disconnecting users with invalid passwords
702- * - Reapplying ACLs
703- */
704-int mosquitto_security_apply(struct _mosquitto_db *db)
705-{
706- struct _mosquitto_acl_user *acl_user_tail;
707- struct _mosquitto_unpwd *unpwd_tail;
708- bool allow_anonymous;
709- int i;
710- bool unpwd_ok;
711-
712- if(!db) return MOSQ_ERR_INVAL;
713-
714- allow_anonymous = db->config->allow_anonymous;
715-
716- if(db->contexts){
717- for(i=0; i<db->context_count; i++){
718- if(db->contexts[i]){
719- /* Check for anonymous clients when allow_anonymous is false */
720- if(!allow_anonymous && !db->contexts[i]->username){
721- db->contexts[i]->state = mosq_cs_disconnecting;
722- _mosquitto_socket_close(db->contexts[i]);
723- continue;
724- }
725- /* Check for connected clients that are no longer authorised */
726- if(db->unpwd && db->contexts[i]->username){
727- unpwd_ok = false;
728- unpwd_tail = db->unpwd;
729- while(unpwd_tail){
730- if(!strcmp(db->contexts[i]->username, unpwd_tail->username)){
731- if(unpwd_tail->password){
732- if(!db->contexts[i]->password
733- || strcmp(db->contexts[i]->password, unpwd_tail->password)){
734-
735- /* Non matching password to username. */
736- db->contexts[i]->state = mosq_cs_disconnecting;
737- _mosquitto_socket_close(db->contexts[i]);
738- continue;
739- }else{
740- /* Username matches, password matches. */
741- unpwd_ok = true;
742- }
743- }else{
744- /* Username matches, password not in password file. */
745- unpwd_ok = true;
746- }
747- }
748- unpwd_tail = unpwd_tail->next;
749- }
750- if(!unpwd_ok){
751- db->contexts[i]->state = mosq_cs_disconnecting;
752- _mosquitto_socket_close(db->contexts[i]);
753- continue;
754- }
755- }
756- /* Check for ACLs and apply to user. */
757- if(db->acl_list){
758- acl_user_tail = db->acl_list;
759- while(acl_user_tail){
760- if(acl_user_tail->username){
761- if(db->contexts[i]->username){
762- if(!strcmp(acl_user_tail->username, db->contexts[i]->username)){
763- db->contexts[i]->acl_list = acl_user_tail;
764- break;
765- }
766- }
767- }else{
768- if(!db->contexts[i]->username){
769- db->contexts[i]->acl_list = acl_user_tail;
770- break;
771- }
772- }
773- acl_user_tail = acl_user_tail->next;
774- }
775- }
776- }
777- }
778- }
779- return MOSQ_ERR_SUCCESS;
780-}
781-
782-#endif
783
784=== removed directory '.pc/bug-persistence-reloading.patch'
785=== removed directory '.pc/bug-persistence-reloading.patch/src'
786=== removed file '.pc/bug-persistence-reloading.patch/src/conf.c'
787--- .pc/bug-persistence-reloading.patch/src/conf.c 2012-12-28 22:55:03 +0000
788+++ .pc/bug-persistence-reloading.patch/src/conf.c 1970-01-01 00:00:00 +0000
789@@ -1,917 +0,0 @@
790-/*
791-Copyright (c) 2009-2012 Roger Light <roger@atchoo.org>
792-All rights reserved.
793-
794-Redistribution and use in source and binary forms, with or without
795-modification, are permitted provided that the following conditions are met:
796-
797-1. Redistributions of source code must retain the above copyright notice,
798- this list of conditions and the following disclaimer.
799-2. Redistributions in binary form must reproduce the above copyright
800- notice, this list of conditions and the following disclaimer in the
801- documentation and/or other materials provided with the distribution.
802-3. Neither the name of mosquitto nor the names of its
803- contributors may be used to endorse or promote products derived from
804- this software without specific prior written permission.
805-
806-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
807-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
808-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
809-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
810-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
811-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
812-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
813-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
814-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
815-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
816-POSSIBILITY OF SUCH DAMAGE.
817-*/
818-
819-#include <stdio.h>
820-#include <stdlib.h>
821-#include <string.h>
822-
823-#include <config.h>
824-
825-#include <mqtt3.h>
826-#include <memory_mosq.h>
827-
828-static int _conf_parse_bool(char **token, const char *name, bool *value);
829-static int _conf_parse_int(char **token, const char *name, int *value);
830-static int _conf_parse_string(char **token, const char *name, char **value);
831-
832-static void _config_init_reload(mqtt3_config *config)
833-{
834- /* Set defaults */
835- if(config->acl_file) _mosquitto_free(config->acl_file);
836- config->acl_file = NULL;
837- config->allow_anonymous = true;
838- config->autosave_interval = 1800;
839- if(config->clientid_prefixes) _mosquitto_free(config->clientid_prefixes);
840- config->connection_messages = true;
841- config->clientid_prefixes = NULL;
842-#ifndef WIN32
843- config->log_dest = MQTT3_LOG_STDERR;
844- config->log_type = MOSQ_LOG_ERR | MOSQ_LOG_WARNING | MOSQ_LOG_NOTICE | MOSQ_LOG_INFO;
845-#else
846- config->log_dest = MQTT3_LOG_SYSLOG;
847- config->log_type = MOSQ_LOG_ERR | MOSQ_LOG_WARNING;
848-#endif
849- config->log_timestamp = true;
850- if(config->password_file) _mosquitto_free(config->password_file);
851- config->password_file = NULL;
852- config->persistence = false;
853- if(config->persistence_location) _mosquitto_free(config->persistence_location);
854- config->persistence_location = NULL;
855- if(config->persistence_file) _mosquitto_free(config->persistence_file);
856- config->persistence_file = NULL;
857- config->retry_interval = 20;
858- config->store_clean_interval = 10;
859- config->sys_interval = 10;
860-#ifdef WITH_EXTERNAL_SECURITY_CHECKS
861- if(config->db_host) _mosquitto_free(config->db_host);
862- config->db_host = NULL;
863- config->db_port = 0;
864- if(config->db_name) _mosquitto_free(config->db_name);
865- config->db_name = NULL;
866- if(config->db_username) _mosquitto_free(config->db_username);
867- config->db_username = NULL;
868- if(config->db_password) _mosquitto_free(config->db_password);
869- config->db_password = NULL;
870-#endif
871-}
872-
873-void mqtt3_config_init(mqtt3_config *config)
874-{
875- memset(config, 0, sizeof(mqtt3_config));
876- _config_init_reload(config);
877- config->config_file = NULL;
878- config->daemon = false;
879- config->default_listener.host = NULL;
880- config->default_listener.port = 0;
881- config->default_listener.max_connections = -1;
882- config->default_listener.mount_point = NULL;
883- config->default_listener.socks = NULL;
884- config->default_listener.sock_count = 0;
885- config->default_listener.client_count = 0;
886- config->listeners = NULL;
887- config->listener_count = 0;
888- config->pid_file = NULL;
889- config->user = NULL;
890-#ifdef WITH_BRIDGE
891- config->bridges = NULL;
892- config->bridge_count = 0;
893-#endif
894-}
895-
896-void mqtt3_config_cleanup(mqtt3_config *config)
897-{
898- int i, j;
899-
900- if(config->acl_file) _mosquitto_free(config->acl_file);
901- if(config->clientid_prefixes) _mosquitto_free(config->clientid_prefixes);
902- if(config->config_file) _mosquitto_free(config->config_file);
903- if(config->password_file) _mosquitto_free(config->password_file);
904- if(config->persistence_location) _mosquitto_free(config->persistence_location);
905- if(config->persistence_file) _mosquitto_free(config->persistence_file);
906- if(config->persistence_filepath) _mosquitto_free(config->persistence_filepath);
907- if(config->listeners){
908- for(i=0; i<config->listener_count; i++){
909- if(config->listeners[i].host) _mosquitto_free(config->listeners[i].host);
910- if(config->listeners[i].mount_point) _mosquitto_free(config->listeners[i].mount_point);
911- if(config->listeners[i].socks) _mosquitto_free(config->listeners[i].socks);
912- }
913- _mosquitto_free(config->listeners);
914- }
915-#ifdef WITH_BRIDGE
916- if(config->bridges){
917- for(i=0; i<config->bridge_count; i++){
918- if(config->bridges[i].name) _mosquitto_free(config->bridges[i].name);
919- if(config->bridges[i].address) _mosquitto_free(config->bridges[i].address);
920- if(config->bridges[i].clientid) _mosquitto_free(config->bridges[i].clientid);
921- if(config->bridges[i].username) _mosquitto_free(config->bridges[i].username);
922- if(config->bridges[i].password) _mosquitto_free(config->bridges[i].password);
923- if(config->bridges[i].topics){
924- for(j=0; j<config->bridges[i].topic_count; j++){
925- if(config->bridges[i].topics[j].topic) _mosquitto_free(config->bridges[i].topics[j].topic);
926- }
927- _mosquitto_free(config->bridges[i].topics);
928- }
929- }
930- _mosquitto_free(config->bridges);
931- }
932-#endif
933-#ifdef WITH_EXTERNAL_SECURITY_CHECKS
934- if(config->db_host) _mosquitto_free(config->db_host);
935- if(config->db_name) _mosquitto_free(config->db_name);
936- if(config->db_username) _mosquitto_free(config->db_username);
937- if(config->db_password) _mosquitto_free(config->db_password);
938-#endif
939-}
940-
941-static void print_usage(void)
942-{
943- printf("mosquitto is an MQTT v3.1 broker.\n\n");
944- printf("Usage: mosquitto [-c config_file] [-d] [-h] [-p port]\n\n");
945- printf(" -c : specify the broker config file.\n");
946- printf(" -d : put the broker into the background after starting.\n");
947- printf(" -h : display this help.\n");
948- printf(" -p : start the broker listening on the specified port.\n");
949- printf(" Not recommended in conjunction with the -c option.\n");
950- printf("\nSee http://mosquitto.org/ for more information.\n\n");
951-}
952-
953-int mqtt3_config_parse_args(mqtt3_config *config, int argc, char *argv[])
954-{
955- int i;
956- int port_tmp;
957-
958- for(i=1; i<argc; i++){
959- if(!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config-file")){
960- if(i<argc-1){
961- config->config_file = _mosquitto_strdup(argv[i+1]);
962- if(!config->config_file){
963- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
964- return MOSQ_ERR_NOMEM;
965- }
966-
967- if(mqtt3_config_read(config, false)){
968- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open configuration file.");
969- return MOSQ_ERR_INVAL;
970- }
971- }else{
972- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: -c argument given, but no config file specified.");
973- return MOSQ_ERR_INVAL;
974- }
975- i++;
976- }else if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "--daemon")){
977- config->daemon = true;
978- }else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")){
979- print_usage();
980- return MOSQ_ERR_INVAL;
981- }else if(!strcmp(argv[i], "-p") || !strcmp(argv[i], "--port")){
982- if(i<argc-1){
983- port_tmp = atoi(argv[i+1]);
984- if(port_tmp<1 || port_tmp>65535){
985- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid port specified (%d).", port_tmp);
986- return MOSQ_ERR_INVAL;
987- }else{
988- if(config->default_listener.port){
989- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Default listener port specified multiple times. Only the latest will be used.");
990- }
991- config->default_listener.port = port_tmp;
992- }
993- }else{
994- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: -p argument given, but no port specified.");
995- return MOSQ_ERR_INVAL;
996- }
997- i++;
998- }else{
999- fprintf(stderr, "Error: Unknown option '%s'.\n",argv[i]);
1000- print_usage();
1001- return MOSQ_ERR_INVAL;
1002- }
1003- }
1004-
1005- if(config->listener_count == 0 || config->default_listener.host || config->default_listener.port){
1006- config->listener_count++;
1007- config->listeners = _mosquitto_realloc(config->listeners, sizeof(struct _mqtt3_listener)*config->listener_count);
1008- if(!config->listeners){
1009- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
1010- return MOSQ_ERR_NOMEM;
1011- }
1012- if(config->default_listener.port){
1013- config->listeners[config->listener_count-1].port = config->default_listener.port;
1014- }else{
1015- config->listeners[config->listener_count-1].port = 1883;
1016- }
1017- if(config->default_listener.host){
1018- config->listeners[config->listener_count-1].host = config->default_listener.host;
1019- }else{
1020- config->listeners[config->listener_count-1].host = NULL;
1021- }
1022- if(config->default_listener.mount_point){
1023- config->listeners[config->listener_count-1].mount_point = config->default_listener.host;
1024- }else{
1025- config->listeners[config->listener_count-1].mount_point = NULL;
1026- }
1027- config->listeners[config->listener_count-1].max_connections = config->default_listener.max_connections;
1028- config->listeners[config->listener_count-1].client_count = 0;
1029- config->listeners[config->listener_count-1].socks = NULL;
1030- config->listeners[config->listener_count-1].sock_count = 0;
1031- config->listeners[config->listener_count-1].client_count = 0;
1032- }
1033-
1034- return MOSQ_ERR_SUCCESS;
1035-}
1036-
1037-int mqtt3_config_read(mqtt3_config *config, bool reload)
1038-{
1039- int rc = MOSQ_ERR_SUCCESS;
1040- FILE *fptr = NULL;
1041- char buf[1024];
1042- char *token;
1043- int port_tmp;
1044- int log_dest = MQTT3_LOG_NONE;
1045- int log_dest_set = 0;
1046- int log_type = MOSQ_LOG_NONE;
1047- int log_type_set = 0;
1048- int i;
1049-#ifdef WITH_BRIDGE
1050- struct _mqtt3_bridge *cur_bridge = NULL;
1051-#endif
1052- int max_inflight_messages = 20;
1053- int max_queued_messages = 100;
1054-
1055- if(!config->config_file) return 0;
1056-
1057- if(reload){
1058- /* Re-initialise appropriate config vars to default for reload. */
1059- _config_init_reload(config);
1060- }
1061-
1062- fptr = fopen(config->config_file, "rt");
1063- if(!fptr) return 1;
1064-
1065- while(fgets(buf, 1024, fptr)){
1066- if(buf[0] != '#' && buf[0] != 10 && buf[0] != 13){
1067- while(buf[strlen(buf)-1] == 10 || buf[strlen(buf)-1] == 13){
1068- buf[strlen(buf)-1] = 0;
1069- }
1070- token = strtok(buf, " ");
1071- if(token){
1072- if(!strcmp(token, "acl_file")){
1073- if(reload){
1074- if(config->acl_file){
1075- _mosquitto_free(config->acl_file);
1076- config->acl_file = NULL;
1077- }
1078- }
1079- if(_conf_parse_string(&token, "acl_file", &config->acl_file)) return MOSQ_ERR_INVAL;
1080- }else if(!strcmp(token, "address") || !strcmp(token, "addresses")){
1081-#ifdef WITH_BRIDGE
1082- if(reload) continue; // FIXME
1083- if(!cur_bridge || cur_bridge->address){
1084- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1085- return MOSQ_ERR_INVAL;
1086- }
1087- token = strtok(NULL, " ");
1088- if(token){
1089- token = strtok(token, ":");
1090- if(token){
1091- cur_bridge->address = _mosquitto_strdup(token);
1092- if(!cur_bridge->address){
1093- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
1094- return MOSQ_ERR_NOMEM;
1095- }
1096- token = strtok(NULL, ":");
1097- if(token){
1098- port_tmp = atoi(token);
1099- if(port_tmp < 1 || port_tmp > 65535){
1100- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid port value (%d).", port_tmp);
1101- return MOSQ_ERR_INVAL;
1102- }
1103- cur_bridge->port = port_tmp;
1104- }else{
1105- cur_bridge->port = 1883;
1106- }
1107- }
1108- }else{
1109- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty address value in configuration.");
1110- return MOSQ_ERR_INVAL;
1111- }
1112-#else
1113- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1114-#endif
1115- }else if(!strcmp(token, "allow_anonymous")){
1116- if(_conf_parse_bool(&token, "allow_anonymous", &config->allow_anonymous)) return MOSQ_ERR_INVAL;
1117- }else if(!strcmp(token, "autosave_interval")){
1118- if(_conf_parse_int(&token, "autosave_interval", &config->autosave_interval)) return MOSQ_ERR_INVAL;
1119- if(config->autosave_interval < 0) config->autosave_interval = 0;
1120- }else if(!strcmp(token, "bind_address")){
1121- if(reload) continue; // Listener not valid for reloading.
1122- if(_conf_parse_string(&token, "default listener bind_address", &config->default_listener.host)) return MOSQ_ERR_INVAL;
1123- }else if(!strcmp(token, "clientid")){
1124-#ifdef WITH_BRIDGE
1125- if(reload) continue; // FIXME
1126- if(!cur_bridge){
1127- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1128- return MOSQ_ERR_INVAL;
1129- }
1130- token = strtok(NULL, " ");
1131- if(token){
1132- if(cur_bridge->clientid){
1133- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate clientid value in bridge configuration.");
1134- return MOSQ_ERR_INVAL;
1135- }
1136- cur_bridge->clientid = _mosquitto_strdup(token);
1137- if(!cur_bridge->clientid){
1138- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
1139- return MOSQ_ERR_NOMEM;
1140- }
1141- }else{
1142- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty clientid value in configuration.");
1143- return MOSQ_ERR_INVAL;
1144- }
1145-#else
1146- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1147-#endif
1148- }else if(!strcmp(token, "cleansession")){
1149-#ifdef WITH_BRIDGE
1150- if(reload) continue; // FIXME
1151- if(!cur_bridge){
1152- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1153- return MOSQ_ERR_INVAL;
1154- }
1155- if(_conf_parse_bool(&token, "cleansession", &cur_bridge->clean_session)) return MOSQ_ERR_INVAL;
1156-#else
1157- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1158-#endif
1159- }else if(!strcmp(token, "clientid_prefixes")){
1160- if(reload){
1161- if(config->clientid_prefixes){
1162- _mosquitto_free(config->clientid_prefixes);
1163- config->clientid_prefixes = NULL;
1164- }
1165- }
1166- if(_conf_parse_string(&token, "clientid_prefixes", &config->clientid_prefixes)) return MOSQ_ERR_INVAL;
1167- }else if(!strcmp(token, "connection")){
1168-#ifdef WITH_BRIDGE
1169- if(reload) continue; // FIXME
1170- token = strtok(NULL, " ");
1171- if(token){
1172- config->bridge_count++;
1173- config->bridges = _mosquitto_realloc(config->bridges, config->bridge_count*sizeof(struct _mqtt3_bridge));
1174- if(!config->bridges){
1175- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
1176- return MOSQ_ERR_NOMEM;
1177- }
1178- cur_bridge = &(config->bridges[config->bridge_count-1]);
1179- cur_bridge->name = _mosquitto_strdup(token);
1180- cur_bridge->address = NULL;
1181- cur_bridge->keepalive = 60;
1182- cur_bridge->clean_session = false;
1183- cur_bridge->clientid = NULL;
1184- cur_bridge->port = 0;
1185- cur_bridge->topics = NULL;
1186- cur_bridge->topic_count = 0;
1187- cur_bridge->restart_t = 0;
1188- cur_bridge->username = NULL;
1189- cur_bridge->password = NULL;
1190- cur_bridge->notifications = true;
1191- cur_bridge->start_type = bst_automatic;
1192- cur_bridge->idle_timeout = 60;
1193- cur_bridge->threshold = 10;
1194- }else{
1195- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty connection value in configuration.");
1196- return MOSQ_ERR_INVAL;
1197- }
1198-#else
1199- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1200-#endif
1201- }else if(!strcmp(token, "connection_messages")){
1202- if(_conf_parse_bool(&token, token, &config->connection_messages)) return MOSQ_ERR_INVAL;
1203- }else if(!strcmp(token, "idle_timeout")){
1204-#ifdef WITH_BRIDGE
1205- if(reload) continue; // FIXME
1206- if(!cur_bridge){
1207- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1208- return MOSQ_ERR_INVAL;
1209- }
1210- if(_conf_parse_int(&token, "idle_timeout", &cur_bridge->idle_timeout)) return MOSQ_ERR_INVAL;
1211- if(cur_bridge->idle_timeout < 1){
1212- _mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "idle_timeout interval too low, using 1 second.");
1213- cur_bridge->idle_timeout = 1;
1214- }
1215-#else
1216- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1217-#endif
1218- }else if(!strcmp(token, "keepalive_interval")){
1219-#ifdef WITH_BRIDGE
1220- if(reload) continue; // FIXME
1221- if(!cur_bridge){
1222- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1223- return MOSQ_ERR_INVAL;
1224- }
1225- if(_conf_parse_int(&token, "keepalive_interval", &cur_bridge->keepalive)) return MOSQ_ERR_INVAL;
1226- if(cur_bridge->keepalive < 5){
1227- _mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "keepalive interval too low, using 5 seconds.");
1228- cur_bridge->keepalive = 5;
1229- }
1230-#else
1231- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1232-#endif
1233- }else if(!strcmp(token, "listener")){
1234- if(reload) continue; // Listeners not valid for reloading.
1235- token = strtok(NULL, " ");
1236- if(token){
1237- config->listener_count++;
1238- config->listeners = _mosquitto_realloc(config->listeners, sizeof(struct _mqtt3_listener)*config->listener_count);
1239- if(!config->listeners){
1240- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
1241- return MOSQ_ERR_NOMEM;
1242- }
1243- port_tmp = atoi(token);
1244- if(port_tmp < 1 || port_tmp > 65535){
1245- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid port value (%d).", port_tmp);
1246- return MOSQ_ERR_INVAL;
1247- }
1248- config->listeners[config->listener_count-1].mount_point = NULL;
1249- config->listeners[config->listener_count-1].port = port_tmp;
1250- config->listeners[config->listener_count-1].socks = NULL;
1251- config->listeners[config->listener_count-1].sock_count = 0;
1252- config->listeners[config->listener_count-1].client_count = 0;
1253- token = strtok(NULL, " ");
1254- if(token){
1255- config->listeners[config->listener_count-1].host = _mosquitto_strdup(token);
1256- }else{
1257- config->listeners[config->listener_count-1].host = NULL;
1258- }
1259- }else{
1260- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty listener value in configuration.");
1261- return MOSQ_ERR_INVAL;
1262- }
1263- }else if(!strcmp(token, "log_dest")){
1264- token = strtok(NULL, " ");
1265- if(token){
1266- log_dest_set = 1;
1267- if(!strcmp(token, "none")){
1268- log_dest = MQTT3_LOG_NONE;
1269- }else if(!strcmp(token, "syslog")){
1270- log_dest |= MQTT3_LOG_SYSLOG;
1271- }else if(!strcmp(token, "stdout")){
1272- log_dest |= MQTT3_LOG_STDOUT;
1273- }else if(!strcmp(token, "stderr")){
1274- log_dest |= MQTT3_LOG_STDERR;
1275- }else if(!strcmp(token, "topic")){
1276- log_dest |= MQTT3_LOG_TOPIC;
1277- }else{
1278- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid log_dest value (%s).", token);
1279- return MOSQ_ERR_INVAL;
1280- }
1281- }else{
1282- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty log_dest value in configuration.");
1283- return MOSQ_ERR_INVAL;
1284- }
1285- }else if(!strcmp(token, "log_timestamp")){
1286- if(_conf_parse_bool(&token, token, &config->log_timestamp)) return MOSQ_ERR_INVAL;
1287- }else if(!strcmp(token, "log_type")){
1288- token = strtok(NULL, " ");
1289- if(token){
1290- log_type_set = 1;
1291- if(!strcmp(token, "none")){
1292- log_type = MOSQ_LOG_NONE;
1293- }else if(!strcmp(token, "information")){
1294- log_type |= MOSQ_LOG_INFO;
1295- }else if(!strcmp(token, "notice")){
1296- log_type |= MOSQ_LOG_NOTICE;
1297- }else if(!strcmp(token, "warning")){
1298- log_type |= MOSQ_LOG_WARNING;
1299- }else if(!strcmp(token, "error")){
1300- log_type |= MOSQ_LOG_ERR;
1301- }else if(!strcmp(token, "debug")){
1302- log_type |= MOSQ_LOG_DEBUG;
1303- }else{
1304- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid log_type value (%s).", token);
1305- return MOSQ_ERR_INVAL;
1306- }
1307- }else{
1308- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty log_type value in configuration.");
1309- }
1310- }else if(!strcmp(token, "max_connections")){
1311- if(reload) continue; // Listeners not valid for reloading.
1312- token = strtok(NULL, " ");
1313- if(token){
1314- if(config->listener_count > 0){
1315- config->listeners[config->listener_count-1].max_connections = atoi(token);
1316- if(config->listeners[config->listener_count-1].max_connections < 0) config->listeners[config->listener_count-1].max_connections = -1;
1317- }else{
1318- config->default_listener.max_connections = atoi(token);
1319- if(config->default_listener.max_connections < 0) config->default_listener.max_connections = -1;
1320- }
1321- }else{
1322- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty max_connections value in configuration.");
1323- }
1324- }else if(!strcmp(token, "max_inflight_messages")){
1325- token = strtok(NULL, " ");
1326- if(token){
1327- max_inflight_messages = atoi(token);
1328- if(max_inflight_messages < 0) max_inflight_messages = 0;
1329- }else{
1330- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty max_inflight_messages value in configuration.");
1331- }
1332- }else if(!strcmp(token, "max_queued_messages")){
1333- token = strtok(NULL, " ");
1334- if(token){
1335- max_queued_messages = atoi(token);
1336- if(max_queued_messages < 0) max_queued_messages = 0;
1337- }else{
1338- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty max_queued_messages value in configuration.");
1339- }
1340- }else if(!strcmp(token, "mount_point")){
1341- if(reload) continue; // Listeners not valid for reloading.
1342- if(config->listener_count == 0){
1343- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: You must use create a listener before using the mount_point option in the configuration file.");
1344- return MOSQ_ERR_INVAL;
1345- }
1346- if(_conf_parse_string(&token, "mount_point", &config->listeners[config->listener_count-1].mount_point)) return MOSQ_ERR_INVAL;
1347- }else if(!strcmp(token, "notifications")){
1348-#ifdef WITH_BRIDGE
1349- if(reload) continue; // FIXME
1350- if(!cur_bridge){
1351- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1352- return MOSQ_ERR_INVAL;
1353- }
1354- if(_conf_parse_bool(&token, "notifications", &cur_bridge->notifications)) return MOSQ_ERR_INVAL;
1355-#else
1356- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1357-#endif
1358- }else if(!strcmp(token, "password")){
1359-#ifdef WITH_BRIDGE
1360- if(reload) continue; // FIXME
1361- if(!cur_bridge){
1362- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1363- return MOSQ_ERR_INVAL;
1364- }
1365- token = strtok(NULL, " ");
1366- if(token){
1367- if(cur_bridge->password){
1368- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate password value in bridge configuration.");
1369- return MOSQ_ERR_INVAL;
1370- }
1371- cur_bridge->password = _mosquitto_strdup(token);
1372- if(!cur_bridge->password){
1373- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
1374- return MOSQ_ERR_NOMEM;
1375- }
1376- }else{
1377- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty password value in configuration.");
1378- return MOSQ_ERR_INVAL;
1379- }
1380-#else
1381- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1382-#endif
1383- }else if(!strcmp(token, "password_file")){
1384- if(reload){
1385- if(config->password_file){
1386- _mosquitto_free(config->password_file);
1387- config->password_file = NULL;
1388- }
1389- }
1390- if(_conf_parse_string(&token, "password_file", &config->password_file)) return MOSQ_ERR_INVAL;
1391- }else if(!strcmp(token, "persistence") || !strcmp(token, "retained_persistence")){
1392- if(_conf_parse_bool(&token, token, &config->persistence)) return MOSQ_ERR_INVAL;
1393- }else if(!strcmp(token, "persistence_file")){
1394- if(reload) continue; // FIXME
1395- if(_conf_parse_string(&token, "persistence_file", &config->persistence_file)) return MOSQ_ERR_INVAL;
1396- }else if(!strcmp(token, "persistence_location")){
1397- if(reload) continue; // FIXME
1398- if(_conf_parse_string(&token, "persistence_location", &config->persistence_location)) return MOSQ_ERR_INVAL;
1399- }else if(!strcmp(token, "pid_file")){
1400- if(reload) continue; // pid file not valid for reloading.
1401- if(_conf_parse_string(&token, "pid_file", &config->pid_file)) return MOSQ_ERR_INVAL;
1402- }else if(!strcmp(token, "port")){
1403- if(reload) continue; // Listener not valid for reloading.
1404- if(config->default_listener.port){
1405- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Default listener port specified multiple times. Only the latest will be used.");
1406- }
1407- if(_conf_parse_int(&token, "port", &port_tmp)) return MOSQ_ERR_INVAL;
1408- if(port_tmp < 1 || port_tmp > 65535){
1409- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid port value (%d).", port_tmp);
1410- return MOSQ_ERR_INVAL;
1411- }
1412- config->default_listener.port = port_tmp;
1413- }else if(!strcmp(token, "retry_interval")){
1414- if(_conf_parse_int(&token, "retry_interval", &config->retry_interval)) return MOSQ_ERR_INVAL;
1415- if(config->retry_interval < 1 || config->retry_interval > 3600){
1416- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid retry_interval value (%d).", config->retry_interval);
1417- return MOSQ_ERR_INVAL;
1418- }
1419- }else if(!strcmp(token, "start_type")){
1420-#ifdef WITH_BRIDGE
1421- if(reload) continue; // FIXME
1422- if(!cur_bridge){
1423- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1424- return MOSQ_ERR_INVAL;
1425- }
1426- token = strtok(NULL, " ");
1427- if(token){
1428- if(!strcmp(token, "automatic")){
1429- cur_bridge->start_type = bst_automatic;
1430- }else if(!strcmp(token, "lazy")){
1431- cur_bridge->start_type = bst_lazy;
1432- }else if(!strcmp(token, "manual")){
1433- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Manual start_type not supported.");
1434- return MOSQ_ERR_INVAL;
1435- }else if(!strcmp(token, "once")){
1436- cur_bridge->start_type = bst_once;
1437- }else{
1438- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid start_type value in configuration (%s).", token);
1439- return MOSQ_ERR_INVAL;
1440- }
1441- }else{
1442- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty start_type value in configuration.");
1443- return MOSQ_ERR_INVAL;
1444- }
1445-#else
1446- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1447-#endif
1448- }else if(!strcmp(token, "store_clean_interval")){
1449- if(_conf_parse_int(&token, "store_clean_interval", &config->store_clean_interval)) return MOSQ_ERR_INVAL;
1450- if(config->store_clean_interval < 0 || config->store_clean_interval > 65535){
1451- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid store_clean_interval value (%d).", config->store_clean_interval);
1452- return MOSQ_ERR_INVAL;
1453- }
1454- }else if(!strcmp(token, "sys_interval")){
1455- if(_conf_parse_int(&token, "sys_interval", &config->sys_interval)) return MOSQ_ERR_INVAL;
1456- if(config->sys_interval < 1 || config->sys_interval > 65535){
1457- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid sys_interval value (%d).", config->sys_interval);
1458- return MOSQ_ERR_INVAL;
1459- }
1460- }else if(!strcmp(token, "threshold")){
1461-#ifdef WITH_BRIDGE
1462- if(reload) continue; // FIXME
1463- if(!cur_bridge){
1464- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1465- return MOSQ_ERR_INVAL;
1466- }
1467- if(_conf_parse_int(&token, "threshold", &cur_bridge->threshold)) return MOSQ_ERR_INVAL;
1468- if(cur_bridge->threshold < 1){
1469- _mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "threshold too low, using 1 message.");
1470- cur_bridge->threshold = 1;
1471- }
1472-#else
1473- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1474-#endif
1475- }else if(!strcmp(token, "topic")){
1476-#ifdef WITH_BRIDGE
1477- if(reload) continue; // FIXME
1478- if(!cur_bridge){
1479- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1480- return MOSQ_ERR_INVAL;
1481- }
1482- token = strtok(NULL, " ");
1483- if(token){
1484- cur_bridge->topic_count++;
1485- cur_bridge->topics = _mosquitto_realloc(cur_bridge->topics,
1486- sizeof(struct _mqtt3_bridge_topic)*cur_bridge->topic_count);
1487- if(!cur_bridge->topics){
1488- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
1489- return MOSQ_ERR_NOMEM;
1490- }
1491- cur_bridge->topics[cur_bridge->topic_count-1].topic = _mosquitto_strdup(token);
1492- if(!cur_bridge->topics[cur_bridge->topic_count-1].topic){
1493- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
1494- return MOSQ_ERR_NOMEM;
1495- }
1496- cur_bridge->topics[cur_bridge->topic_count-1].direction = bd_out;
1497- cur_bridge->topics[cur_bridge->topic_count-1].qos = 2;
1498- }else{
1499- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty topic value in configuration.");
1500- return MOSQ_ERR_INVAL;
1501- }
1502- token = strtok(NULL, " ");
1503- if(token){
1504- if(!strcasecmp(token, "out")){
1505- cur_bridge->topics[cur_bridge->topic_count-1].direction = bd_out;
1506- }else if(!strcasecmp(token, "in")){
1507- cur_bridge->topics[cur_bridge->topic_count-1].direction = bd_in;
1508- }else if(!strcasecmp(token, "both")){
1509- cur_bridge->topics[cur_bridge->topic_count-1].direction = bd_both;
1510- }else{
1511- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge topic direction '%s'.", token);
1512- return MOSQ_ERR_INVAL;
1513- }
1514- token = strtok(NULL, " ");
1515- if(token){
1516- cur_bridge->topics[cur_bridge->topic_count-1].qos = atoi(token);
1517- if(cur_bridge->topics[cur_bridge->topic_count-1].qos < 0 || cur_bridge->topics[cur_bridge->topic_count-1].qos > 2){
1518- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge QoS level '%s'.", token);
1519- return MOSQ_ERR_INVAL;
1520- }
1521- }
1522- }
1523-#else
1524- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1525-#endif
1526- }else if(!strcmp(token, "user")){
1527- if(reload) continue; // Drop privileges user not valid for reloading.
1528- if(_conf_parse_string(&token, "user", &config->user)) return MOSQ_ERR_INVAL;
1529- }else if(!strcmp(token, "username")){
1530-#ifdef WITH_BRIDGE
1531- if(reload) continue; // FIXME
1532- if(!cur_bridge){
1533- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1534- return MOSQ_ERR_INVAL;
1535- }
1536- token = strtok(NULL, " ");
1537- if(token){
1538- if(cur_bridge->username){
1539- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate username value in bridge configuration.");
1540- return MOSQ_ERR_INVAL;
1541- }
1542- cur_bridge->username = _mosquitto_strdup(token);
1543- if(!cur_bridge->username){
1544- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
1545- return MOSQ_ERR_NOMEM;
1546- }
1547- }else{
1548- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty username value in configuration.");
1549- return MOSQ_ERR_INVAL;
1550- }
1551-#else
1552- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
1553-#endif
1554-#ifdef WITH_EXTERNAL_SECURITY_CHECKS
1555- }else if(!strcmp(token, "db_host")){
1556- if(reload){
1557- if(config->db_host){
1558- _mosquitto_free(config->db_host);
1559- config->db_host = NULL;
1560- }
1561- }
1562- if(_conf_parse_string(&token, "db_host", &config->db_host)) return MOSQ_ERR_INVAL;
1563- }else if(!strcmp(token, "db_name")){
1564- if(reload){
1565- if(config->db_name){
1566- _mosquitto_free(config->db_name);
1567- config->db_name = NULL;
1568- }
1569- }
1570- if(_conf_parse_string(&token, "db_name", &config->db_name)) return MOSQ_ERR_INVAL;
1571- }else if(!strcmp(token, "db_username")){
1572- if(reload){
1573- if(config->db_username){
1574- _mosquitto_free(config->db_username);
1575- config->db_username = NULL;
1576- }
1577- }
1578- if(_conf_parse_string(&token, "db_username", &config->db_username)) return MOSQ_ERR_INVAL;
1579- }else if(!strcmp(token, "db_password")){
1580- if(reload){
1581- if(config->db_password){
1582- _mosquitto_free(config->db_password);
1583- config->db_password = NULL;
1584- }
1585- }
1586- if(_conf_parse_string(&token, "db_password", &config->db_password)) return MOSQ_ERR_INVAL;
1587- }else if(!strcmp(token, "db_port")){
1588- if(_conf_parse_int(&token, "db_port", &config->db_port)) return MOSQ_ERR_INVAL;
1589-#endif
1590- }else if(!strcmp(token, "autosave_on_changes")
1591- || !strcmp(token, "connection_messages")
1592- || !strcmp(token, "trace_level")
1593- || !strcmp(token, "addresses")
1594- || !strcmp(token, "idle_timeout")
1595- || !strcmp(token, "notification_topic")
1596- || !strcmp(token, "round_robin")
1597- || !strcmp(token, "threshold")
1598- || !strcmp(token, "try_private")
1599- || !strcmp(token, "ffdc_output")
1600- || !strcmp(token, "max_log_entries")
1601- || !strcmp(token, "trace_output")){
1602- _mosquitto_log_printf(NULL, MOSQ_LOG_WARNING, "Warning: Unsupported rsmb configuration option \"%s\".", token);
1603- }else{
1604- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Unknown configuration variable \"%s\".", token);
1605- return MOSQ_ERR_INVAL;
1606- }
1607- }
1608- }
1609- }
1610- fclose(fptr);
1611-
1612-#ifdef WITH_PERSISTENCE
1613- if(config->persistence){
1614- if(!config->persistence_file){
1615- config->persistence_file = _mosquitto_strdup("mosquitto.db");
1616- if(!config->persistence_file) return MOSQ_ERR_NOMEM;
1617- }
1618- if(config->persistence_filepath){
1619- _mosquitto_free(config->persistence_filepath);
1620- }
1621- if(config->persistence_location && strlen(config->persistence_location)){
1622- config->persistence_filepath = _mosquitto_malloc(strlen(config->persistence_location) + strlen(config->persistence_file) + 1);
1623- if(!config->persistence_filepath) return MOSQ_ERR_NOMEM;
1624- sprintf(config->persistence_filepath, "%s%s", config->persistence_location, config->persistence_file);
1625- }else{
1626- config->persistence_filepath = _mosquitto_strdup(config->persistence_file);
1627- if(!config->persistence_filepath) return MOSQ_ERR_NOMEM;
1628- }
1629- }
1630-#endif
1631- if(!config->user){
1632- config->user = "mosquitto";
1633- }
1634-
1635- mqtt3_db_limits_set(max_inflight_messages, max_queued_messages);
1636-
1637-#ifdef WITH_BRIDGE
1638- for(i=0; i<config->bridge_count; i++){
1639- if(!config->bridges[i].name || !config->bridges[i].address || !config->bridges[i].port || !config->bridges[i].topic_count){
1640- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration.");
1641- return MOSQ_ERR_INVAL;
1642- }
1643- }
1644-#endif
1645-
1646- if(log_dest_set){
1647- config->log_dest = log_dest;
1648- }
1649- if(log_type_set){
1650- config->log_type = log_type;
1651- }
1652-
1653- return rc;
1654-}
1655-
1656-static int _conf_parse_bool(char **token, const char *name, bool *value)
1657-{
1658- *token = strtok(NULL, " ");
1659- if(*token){
1660- if(!strcmp(*token, "false") || !strcmp(*token, "0")){
1661- *value = false;
1662- }else if(!strcmp(*token, "true") || !strcmp(*token, "1")){
1663- *value = true;
1664- }else{
1665- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Invalid %s value (%s).", name, *token);
1666- }
1667- }else{
1668- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty %s value in configuration.", name);
1669- return MOSQ_ERR_INVAL;
1670- }
1671-
1672- return MOSQ_ERR_SUCCESS;
1673-}
1674-
1675-static int _conf_parse_int(char **token, const char *name, int *value)
1676-{
1677- *token = strtok(NULL, " ");
1678- if(*token){
1679- *value = atoi(*token);
1680- }else{
1681- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty %s value in configuration.", name);
1682- return MOSQ_ERR_INVAL;
1683- }
1684-
1685- return MOSQ_ERR_SUCCESS;
1686-}
1687-
1688-static int _conf_parse_string(char **token, const char *name, char **value)
1689-{
1690- *token = strtok(NULL, " ");
1691- if(*token){
1692- if(*value){
1693- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate %s value in configuration.", name);
1694- return MOSQ_ERR_INVAL;
1695- }
1696- *value = _mosquitto_strdup(*token);
1697- if(!*value){
1698- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory");
1699- return MOSQ_ERR_NOMEM;
1700- }
1701- }else{
1702- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error: Empty %s value in configuration.", name);
1703- return MOSQ_ERR_INVAL;
1704- }
1705- return MOSQ_ERR_SUCCESS;
1706-}
1707
1708=== removed directory '.pc/bug-proto-number.patch'
1709=== removed directory '.pc/bug-proto-number.patch/src'
1710=== removed file '.pc/bug-proto-number.patch/src/read_handle_server.c'
1711--- .pc/bug-proto-number.patch/src/read_handle_server.c 2012-12-28 22:55:03 +0000
1712+++ .pc/bug-proto-number.patch/src/read_handle_server.c 1970-01-01 00:00:00 +0000
1713@@ -1,437 +0,0 @@
1714-/*
1715-Copyright (c) 2009-2012 Roger Light <roger@atchoo.org>
1716-All rights reserved.
1717-
1718-Redistribution and use in source and binary forms, with or without
1719-modification, are permitted provided that the following conditions are met:
1720-
1721-1. Redistributions of source code must retain the above copyright notice,
1722- this list of conditions and the following disclaimer.
1723-2. Redistributions in binary form must reproduce the above copyright
1724- notice, this list of conditions and the following disclaimer in the
1725- documentation and/or other materials provided with the distribution.
1726-3. Neither the name of mosquitto nor the names of its
1727- contributors may be used to endorse or promote products derived from
1728- this software without specific prior written permission.
1729-
1730-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1731-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1732-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1733-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1734-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1735-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1736-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1737-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1738-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1739-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1740-POSSIBILITY OF SUCH DAMAGE.
1741-*/
1742-
1743-#include <stdio.h>
1744-#include <string.h>
1745-
1746-#include <config.h>
1747-
1748-#include <mqtt3.h>
1749-#include <mqtt3_protocol.h>
1750-#include <memory_mosq.h>
1751-#include <send_mosq.h>
1752-#include <util_mosq.h>
1753-
1754-int mqtt3_handle_connect(mosquitto_db *db, int context_index)
1755-{
1756- char *protocol_name;
1757- uint8_t protocol_version;
1758- uint8_t connect_flags;
1759- char *client_id;
1760- char *will_message = NULL, *will_topic = NULL;
1761- struct mosquitto_message *will_struct = NULL;
1762- uint8_t will, will_retain, will_qos, clean_session;
1763- uint8_t username_flag, password_flag;
1764- char *username, *password = NULL;
1765- int i;
1766- int rc;
1767- struct _mosquitto_acl_user *acl_tail;
1768- struct mosquitto *context;
1769-
1770- context = db->contexts[context_index];
1771-
1772- /* Don't accept multiple CONNECT commands. */
1773- if(context->state != mosq_cs_new){
1774- mqtt3_context_disconnect(db, context_index);
1775- return MOSQ_ERR_PROTOCOL;
1776- }
1777-
1778- if(_mosquitto_read_string(&context->in_packet, &protocol_name)){
1779- mqtt3_context_disconnect(db, context_index);
1780- return 1;
1781- }
1782- if(!protocol_name){
1783- mqtt3_context_disconnect(db, context_index);
1784- return 3;
1785- }
1786- if(strcmp(protocol_name, PROTOCOL_NAME)){
1787- if(db->config->connection_messages == true){
1788- _mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "Invalid protocol \"%s\" in CONNECT from %s.",
1789- protocol_name, context->address);
1790- }
1791- _mosquitto_free(protocol_name);
1792- mqtt3_context_disconnect(db, context_index);
1793- return MOSQ_ERR_PROTOCOL;
1794- }
1795- _mosquitto_free(protocol_name);
1796-
1797- if(_mosquitto_read_byte(&context->in_packet, &protocol_version)){
1798- mqtt3_context_disconnect(db, context_index);
1799- return 1;
1800- }
1801- if(protocol_version != PROTOCOL_VERSION){
1802- if(db->config->connection_messages == true){
1803- _mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "Invalid protocol version %d in CONNECT from %s.",
1804- protocol_version, context->address);
1805- }
1806- _mosquitto_free(protocol_name);
1807- _mosquitto_send_connack(context, 1);
1808- mqtt3_context_disconnect(db, context_index);
1809- return MOSQ_ERR_PROTOCOL;
1810- }
1811-
1812- if(_mosquitto_read_byte(&context->in_packet, &connect_flags)){
1813- mqtt3_context_disconnect(db, context_index);
1814- return 1;
1815- }
1816- clean_session = connect_flags & 0x02;
1817- will = connect_flags & 0x04;
1818- will_qos = (connect_flags & 0x18) >> 3;
1819- will_retain = connect_flags & 0x20;
1820- password_flag = connect_flags & 0x40;
1821- username_flag = connect_flags & 0x80;
1822-
1823- if(_mosquitto_read_uint16(&context->in_packet, &(context->keepalive))){
1824- mqtt3_context_disconnect(db, context_index);
1825- return 1;
1826- }
1827-
1828- if(_mosquitto_read_string(&context->in_packet, &client_id)){
1829- mqtt3_context_disconnect(db, context_index);
1830- return 1;
1831- }
1832-
1833- /* clientid_prefixes check */
1834- if(db->config->clientid_prefixes){
1835- if(strncmp(db->config->clientid_prefixes, client_id, strlen(db->config->clientid_prefixes))){
1836- _mosquitto_free(client_id);
1837- _mosquitto_send_connack(context, 2);
1838- mqtt3_context_disconnect(db, context_index);
1839- return MOSQ_ERR_SUCCESS;
1840- }
1841- }
1842-
1843- if(will){
1844- will_struct = _mosquitto_calloc(1, sizeof(struct mosquitto_message));
1845- if(!will_struct){
1846- _mosquitto_free(client_id);
1847- mqtt3_context_disconnect(db, context_index);
1848- return MOSQ_ERR_NOMEM;
1849- }
1850- if(_mosquitto_read_string(&context->in_packet, &will_topic)){
1851- _mosquitto_free(client_id);
1852- mqtt3_context_disconnect(db, context_index);
1853- return 1;
1854- }
1855- if(_mosquitto_read_string(&context->in_packet, &will_message)){
1856- _mosquitto_free(client_id);
1857- mqtt3_context_disconnect(db, context_index);
1858- return 1;
1859- }
1860- }
1861-
1862- if(username_flag){
1863- rc = _mosquitto_read_string(&context->in_packet, &username);
1864- if(rc == MOSQ_ERR_SUCCESS){
1865- if(password_flag){
1866- rc = _mosquitto_read_string(&context->in_packet, &password);
1867- if(rc == MOSQ_ERR_NOMEM){
1868- _mosquitto_free(username);
1869- _mosquitto_free(client_id);
1870- return MOSQ_ERR_NOMEM;
1871- }else if(rc == MOSQ_ERR_PROTOCOL){
1872- /* Password flag given, but no password. Ignore. */
1873- password_flag = 0;
1874- }
1875- }
1876- rc = mosquitto_unpwd_check(db, username, password);
1877- context->username = username;
1878- context->password = password;
1879- if(rc == MOSQ_ERR_AUTH){
1880- _mosquitto_send_connack(context, 2);
1881- mqtt3_context_disconnect(db, context_index);
1882- _mosquitto_free(client_id);
1883- return MOSQ_ERR_SUCCESS;
1884- }else if(rc == MOSQ_ERR_INVAL){
1885- _mosquitto_free(client_id);
1886- return MOSQ_ERR_INVAL;
1887- }
1888- }else if(rc == MOSQ_ERR_NOMEM){
1889- _mosquitto_free(client_id);
1890- return MOSQ_ERR_NOMEM;
1891- }else{
1892- /* Username flag given, but no username. Ignore. */
1893- username_flag = 0;
1894- }
1895- }
1896-
1897- if(!username_flag && db->config->allow_anonymous == false){
1898- _mosquitto_send_connack(context, 2);
1899- mqtt3_context_disconnect(db, context_index);
1900- _mosquitto_free(client_id);
1901- return MOSQ_ERR_SUCCESS;
1902- }
1903-
1904- /* Find if this client already has an entry. This must be done *after* any security checks. */
1905- for(i=0; i<db->context_count; i++){
1906- if(db->contexts[i] && db->contexts[i]->id && !strcmp(db->contexts[i]->id, client_id)){
1907- /* Client does match. */
1908- if(db->contexts[i]->sock == -1){
1909- /* Client is reconnecting after a disconnect */
1910- /* FIXME - does anything else need to be done here? */
1911- }else{
1912- /* Client is already connected, disconnect old version */
1913- if(db->config->connection_messages == true){
1914- _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Client %s already connected, closing old connection.", client_id);
1915- }
1916- }
1917- db->contexts[i]->clean_session = clean_session;
1918- mqtt3_context_cleanup(db, db->contexts[i], false);
1919- db->contexts[i]->state = mosq_cs_connected;
1920- db->contexts[i]->address = _mosquitto_strdup(context->address);
1921- db->contexts[i]->sock = context->sock;
1922- db->contexts[i]->listener = context->listener;
1923- db->contexts[i]->last_msg_in = time(NULL);
1924- db->contexts[i]->last_msg_out = time(NULL);
1925- db->contexts[i]->keepalive = context->keepalive;
1926- context->sock = -1;
1927- context->state = mosq_cs_disconnecting;
1928- context = db->contexts[i];
1929- if(context->msgs){
1930- /* Messages received when the client was disconnected are put
1931- * in the ms_queued state. If we don't change them to the
1932- * appropriate "publish" state, then the queued messages won't
1933- * get sent until the client next receives a message - and they
1934- * will be sent out of order.
1935- * This only sets a single message up to be published, but once
1936- * it is sent the full max_inflight amount of messages will be
1937- * queued up for sending.
1938- */
1939- if(context->msgs->state == ms_queued && context->msgs->direction == mosq_md_out){
1940- switch(context->msgs->qos){
1941- case 0:
1942- context->msgs->state = ms_publish;
1943- break;
1944- case 1:
1945- context->msgs->state = ms_publish_puback;
1946- break;
1947- case 2:
1948- context->msgs->state = ms_publish_pubrec;
1949- break;
1950- }
1951- }
1952- }
1953- break;
1954- }
1955- }
1956-
1957- context->id = client_id;
1958- context->clean_session = clean_session;
1959-
1960- context->will = will_struct;
1961- if(context->will){
1962- context->will->topic = will_topic;
1963- if(will_message){
1964- context->will->payload = (uint8_t *)will_message;
1965- context->will->payloadlen = strlen(will_message);
1966- }else{
1967- context->will->payload = NULL;
1968- context->will->payloadlen = 0;
1969- }
1970- context->will->qos = will_qos;
1971- context->will->retain = will_retain;
1972- }
1973-
1974- /* Associate user with its ACL, assuming we have ACLs loaded. */
1975- if(db->acl_list){
1976- acl_tail = db->acl_list;
1977- while(acl_tail){
1978- if(context->username){
1979- if(acl_tail->username && !strcmp(context->username, acl_tail->username)){
1980- context->acl_list = acl_tail;
1981- break;
1982- }
1983- }else{
1984- if(acl_tail->username == NULL){
1985- context->acl_list = acl_tail;
1986- break;
1987- }
1988- }
1989- acl_tail = acl_tail->next;
1990- }
1991- }else{
1992- context->acl_list = NULL;
1993- }
1994-
1995- if(db->config->connection_messages == true){
1996- _mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "New client connected from %s as %s.", context->address, client_id);
1997- }
1998-
1999- context->state = mosq_cs_connected;
2000- return _mosquitto_send_connack(context, 0);
2001-}
2002-
2003-int mqtt3_handle_disconnect(mosquitto_db *db, int context_index)
2004-{
2005- struct mosquitto *context;
2006-
2007- context = db->contexts[context_index];
2008-
2009- if(!context){
2010- return MOSQ_ERR_INVAL;
2011- }
2012- if(context->in_packet.remaining_length != 0){
2013- return MOSQ_ERR_PROTOCOL;
2014- }
2015- _mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received DISCONNECT from %s", context->id);
2016- context->state = mosq_cs_disconnecting;
2017- mqtt3_context_disconnect(db, context_index);
2018- return MOSQ_ERR_SUCCESS;
2019-}
2020-
2021-
2022-int mqtt3_handle_subscribe(mosquitto_db *db, struct mosquitto *context)
2023-{
2024- int rc = 0;
2025- int rc2;
2026- uint16_t mid;
2027- char *sub;
2028- uint8_t qos;
2029- uint8_t *payload = NULL, *tmp_payload;
2030- uint32_t payloadlen = 0;
2031- int len;
2032- char *sub_mount;
2033-
2034- if(!context) return MOSQ_ERR_INVAL;
2035- _mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received SUBSCRIBE from %s", context->id);
2036- /* FIXME - plenty of potential for memory leaks here */
2037-
2038- if(_mosquitto_read_uint16(&context->in_packet, &mid)) return 1;
2039-
2040- while(context->in_packet.pos < context->in_packet.remaining_length){
2041- sub = NULL;
2042- if(_mosquitto_read_string(&context->in_packet, &sub)){
2043- if(payload) _mosquitto_free(payload);
2044- return 1;
2045- }
2046-
2047- if(sub){
2048- if(_mosquitto_read_byte(&context->in_packet, &qos)){
2049- _mosquitto_free(sub);
2050- if(payload) _mosquitto_free(payload);
2051- return 1;
2052- }
2053- if(qos > 2){
2054- _mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "Invalid QoS in subscription command from %s, disconnecting.",
2055- context->address);
2056- _mosquitto_free(sub);
2057- if(payload) _mosquitto_free(payload);
2058- return 1;
2059- }
2060- if(_mosquitto_fix_sub_topic(&sub)){
2061- _mosquitto_free(sub);
2062- if(payload) _mosquitto_free(payload);
2063- return 1;
2064- }
2065- if(!strlen(sub)){
2066- _mosquitto_log_printf(NULL, MOSQ_LOG_INFO, "Empty subscription string from %s, disconnecting.",
2067- context->address);
2068- _mosquitto_free(sub);
2069- if(payload) _mosquitto_free(payload);
2070- return 1;
2071- }
2072- if(context->listener && context->listener->mount_point){
2073- len = strlen(context->listener->mount_point) + strlen(sub) + 1;
2074- sub_mount = _mosquitto_calloc(len, sizeof(char));
2075- if(!sub_mount){
2076- _mosquitto_free(sub);
2077- if(payload) _mosquitto_free(payload);
2078- return MOSQ_ERR_NOMEM;
2079- }
2080- snprintf(sub_mount, len, "%s%s", context->listener->mount_point, sub);
2081- _mosquitto_free(sub);
2082- sub = sub_mount;
2083-
2084- }
2085- _mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "\t%s (QoS %d)", sub, qos);
2086- /* FIXME - need to deny access to retained messages. */
2087-#if 0
2088- /* Check for topic access */
2089- rc2 = mqtt3_acl_check(db, context, sub, MOSQ_ACL_READ);
2090- if(rc2 == MOSQ_ERR_SUCCESS){
2091- mqtt3_sub_add(context, sub, qos, &db->subs);
2092- if(mqtt3_retain_queue(db, context, sub, qos)) rc = 1;
2093- }else if(rc2 != MOSQ_ERR_ACL_DENIED){
2094- rc = 1;
2095- }
2096-#else
2097- rc2 = mqtt3_sub_add(context, sub, qos, &db->subs);
2098- if(rc2 == MOSQ_ERR_SUCCESS){
2099- if(mqtt3_retain_queue(db, context, sub, qos)) rc = 1;
2100- }else if(rc2 != -1){
2101- rc = rc2;
2102- }
2103-#endif
2104- _mosquitto_free(sub);
2105-
2106- tmp_payload = _mosquitto_realloc(payload, payloadlen + 1);
2107- if(tmp_payload){
2108- payload = tmp_payload;
2109- payload[payloadlen] = qos;
2110- payloadlen++;
2111- }else{
2112- if(payload) _mosquitto_free(payload);
2113-
2114- return MOSQ_ERR_NOMEM;
2115- }
2116- }
2117- }
2118-
2119- if(_mosquitto_send_suback(context, mid, payloadlen, payload)) rc = 1;
2120- _mosquitto_free(payload);
2121-
2122- return rc;
2123-}
2124-
2125-int mqtt3_handle_unsubscribe(mosquitto_db *db, struct mosquitto *context)
2126-{
2127- uint16_t mid;
2128- char *sub;
2129-
2130- if(!context) return MOSQ_ERR_INVAL;
2131- _mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received UNSUBSCRIBE from %s", context->id);
2132-
2133- if(_mosquitto_read_uint16(&context->in_packet, &mid)) return 1;
2134-
2135- while(context->in_packet.pos < context->in_packet.remaining_length){
2136- sub = NULL;
2137- if(_mosquitto_read_string(&context->in_packet, &sub)){
2138- return 1;
2139- }
2140-
2141- if(sub){
2142- _mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "\t%s", sub);
2143- mqtt3_sub_remove(context, sub, &db->subs);
2144- _mosquitto_free(sub);
2145- }
2146- }
2147-
2148- return _mosquitto_send_command_with_mid(context, UNSUBACK, mid, false);
2149-}
2150-
2151
2152=== removed directory '.pc/enable-libwrap.patch'
2153=== removed file '.pc/enable-libwrap.patch/config.h'
2154--- .pc/enable-libwrap.patch/config.h 2013-08-23 15:09:02 +0000
2155+++ .pc/enable-libwrap.patch/config.h 1970-01-01 00:00:00 +0000
2156@@ -1,69 +0,0 @@
2157-/* ============================================================
2158- * Control compile time options.
2159- *
2160- * Largely, these are options that are designed to make mosquitto run more
2161- * easily in restrictive environments by removing features.
2162- * ============================================================ */
2163-
2164-#ifndef CMAKE
2165-/* Only use the compile time options defined here from the standard Makefile. */
2166-
2167-
2168-/* Uncomment to compile with tcpd/libwrap support. */
2169-//#define WITH_WRAP
2170-
2171-/* Compile with database upgrading support? If disabled, mosquitto won't
2172- * automatically upgrade old database versions. */
2173-//#define WITH_DB_UPGRADE
2174-
2175-/* Compile with memory tracking support? If disabled, mosquitto won't track
2176- * heap memory usage nor export '$SYS/broker/heap/current size', but will use
2177- * slightly less memory and CPU time. */
2178-#define WITH_MEMORY_TRACKING
2179-
2180-/* Compile with persistent database support. This allows the broker to store
2181- * retained messages and durable subscriptions to a file periodically and on
2182- * shutdown. This is usually desirable (and is suggested by the MQTT spec), but
2183- * it can be disabled by commenting out this define if required.
2184- */
2185-#define WITH_PERSISTENCE
2186-
2187-/* Compile with bridge support included. This allow the broker to connect to
2188- * other brokers and subscribe/publish to topics. You probably want to leave
2189- * this included unless you want to save a very small amount of memory size and
2190- * CPU time.
2191- */
2192-#define WITH_BRIDGE
2193-
2194-/* Compile with strict protocol support. This means that both the client
2195- * library and the broker will be very strict about protocol compliance on
2196- * incoming data. Neither of them will return an error on incorrect "remaining
2197- * length" values if this is commented out. The old behaviour (prior to 0.12)
2198- * is equivalent to compiling with WITH_STRICT_PROTOCOL defined and means that
2199- * clients will be immediately disconnected from the broker on non-compliance.
2200- */
2201-//#define WITH_STRICT_PROTOCOL
2202-
2203-/* Use the username/password and ACL checks defined in security_external.c
2204- * This is empty by default, but gives a more straightforward way of adding
2205- * support for existing username/password databases to mosquitto.
2206- * Uncommenting without adding your own code to security_external.c will
2207- * result in all access being denied.
2208- * It also enables the db_* config options in mosquitto.conf.
2209- * Get in touch with the authors if you need help adding support for your
2210- * system.
2211- */
2212-//#define WITH_EXTERNAL_SECURITY_CHECKS
2213-#endif
2214-
2215-/* ============================================================
2216- * Compatibility defines
2217- *
2218- * Generally for Windows native support.
2219- * ============================================================ */
2220-#ifdef WIN32
2221-#define snprintf sprintf_s
2222-#define strcasecmp strcmpi
2223-#define strtok_r strtok_s
2224-#define strerror_r(e, b, l) strerror_s(b, l, e)
2225-#endif
2226
2227=== removed file '.pc/enable-libwrap.patch/config.mk'
2228--- .pc/enable-libwrap.patch/config.mk 2013-08-23 15:09:02 +0000
2229+++ .pc/enable-libwrap.patch/config.mk 1970-01-01 00:00:00 +0000
2230@@ -1,29 +0,0 @@
2231-# Also bump lib/mosquitto.h, lib/python/setup.py, CMakeLists.txt,
2232-# installer/mosquitto.nsi, installer/mosquitto-cygwin.nsi
2233-VERSION=0.15
2234-TIMESTAMP:=$(shell date "+%F %T%z")
2235-
2236-#MANCOUNTRIES=en_GB
2237-
2238-CFLAGS=-I. -I.. -ggdb -Wall -O2 -I../lib
2239-
2240-UNAME:=$(shell uname -s)
2241-ifeq ($(UNAME),QNX)
2242- LIBS=-lsocket
2243-else
2244- LIBS=
2245-endif
2246-
2247-LDFLAGS=
2248-# Add -lwrap to LDFLAGS if compiling with tcp wrappers support.
2249-
2250-CC=gcc
2251-INSTALL=install
2252-XGETTEXT=xgettext
2253-MSGMERGE=msgmerge
2254-MSGFMT=msgfmt
2255-DOCBOOK2MAN=docbook2man.pl
2256-
2257-prefix=/usr
2258-mandir=${prefix}/share/man
2259-localedir=${prefix}/share/locale
2260
2261=== removed directory '.pc/fix-prefix.patch'
2262=== removed directory '.pc/fix-prefix.patch/client'
2263=== removed file '.pc/fix-prefix.patch/client/Makefile'
2264--- .pc/fix-prefix.patch/client/Makefile 2011-07-25 22:24:52 +0000
2265+++ .pc/fix-prefix.patch/client/Makefile 1970-01-01 00:00:00 +0000
2266@@ -1,30 +0,0 @@
2267-CC=cc
2268-CFLAGS=-I../lib -Wall -ggdb
2269-LDFLAGS=-L../lib ../lib/libmosquitto.so.0
2270-INSTALL=install
2271-prefix=/usr/local
2272-
2273-.PHONY: all install uninstall clean
2274-
2275-all : mosquitto_pub mosquitto_sub
2276-
2277-mosquitto_pub : pub_client.o ../lib/libmosquitto.so.0
2278- ${CC} $< -o $@ ${LDFLAGS}
2279-
2280-mosquitto_sub : sub_client.o ../lib/libmosquitto.so.0
2281- ${CC} $< -o $@ ${LDFLAGS}
2282-
2283-../lib/libmosquitto.so.0 :
2284- $(MAKE) -C ../lib
2285-
2286-install : all
2287- $(INSTALL) -d ${DESTDIR}$(prefix)/bin
2288- $(INSTALL) -s mosquitto_pub ${DESTDIR}${prefix}/bin/mosquitto_pub
2289- $(INSTALL) -s mosquitto_sub ${DESTDIR}${prefix}/bin/mosquitto_sub
2290-
2291-uninstall :
2292- -rm -f ${DESTDIR}${prefix}/bin/mosquitto_pub
2293- -rm -f ${DESTDIR}${prefix}/bin/mosquitto_sub
2294-
2295-clean :
2296- -rm -f *.o mosquitto_pub mosquitto_sub
2297
2298=== removed file '.pc/fix-prefix.patch/config.mk'
2299--- .pc/fix-prefix.patch/config.mk 2013-08-23 15:09:02 +0000
2300+++ .pc/fix-prefix.patch/config.mk 1970-01-01 00:00:00 +0000
2301@@ -1,29 +0,0 @@
2302-# Also bump lib/mosquitto.h, lib/python/setup.py, CMakeLists.txt,
2303-# installer/mosquitto.nsi, installer/mosquitto-cygwin.nsi
2304-VERSION=0.15
2305-TIMESTAMP:=$(shell date "+%F %T%z")
2306-
2307-#MANCOUNTRIES=en_GB
2308-
2309-CFLAGS=-I. -I.. -ggdb -Wall -O2 -I../lib
2310-
2311-UNAME:=$(shell uname -s)
2312-ifeq ($(UNAME),QNX)
2313- LIBS=-lsocket
2314-else
2315- LIBS=
2316-endif
2317-
2318-LDFLAGS=
2319-# Add -lwrap to LDFLAGS if compiling with tcp wrappers support.
2320-
2321-CC=gcc
2322-INSTALL=install
2323-XGETTEXT=xgettext
2324-MSGMERGE=msgmerge
2325-MSGFMT=msgfmt
2326-DOCBOOK2MAN=docbook2man.pl
2327-
2328-prefix=/usr/local
2329-mandir=${prefix}/share/man
2330-localedir=${prefix}/share/locale
2331
2332=== removed directory '.pc/install-apparmor.patch'
2333=== removed file '.pc/install-apparmor.patch/Makefile'
2334--- .pc/install-apparmor.patch/Makefile 2012-02-07 23:21:39 +0000
2335+++ .pc/install-apparmor.patch/Makefile 1970-01-01 00:00:00 +0000
2336@@ -1,59 +0,0 @@
2337-include config.mk
2338-
2339-DIRS=lib client src man
2340-DISTDIRS=man
2341-
2342-.PHONY : all mosquitto clean reallyclean install uninstall dist sign copy
2343-
2344-all : mosquitto
2345-
2346-mosquitto :
2347- for d in ${DIRS}; do $(MAKE) -C $${d}; done
2348-
2349-clean :
2350- for d in ${DIRS}; do $(MAKE) -C $${d} clean; done
2351-
2352-reallyclean :
2353- for d in ${DIRS}; do $(MAKE) -C $${d} reallyclean; done
2354- -rm -f *.orig
2355-
2356-install : mosquitto
2357- @for d in ${DIRS}; do $(MAKE) -C $${d} install; done
2358- $(INSTALL) -d ${DESTDIR}/etc/mosquitto
2359- $(INSTALL) -m 644 mosquitto.conf ${DESTDIR}/etc/mosquitto/mosquitto.conf
2360- $(INSTALL) -m 644 aclfile.example ${DESTDIR}/etc/mosquitto/aclfile.example
2361- $(INSTALL) -m 644 pwfile.example ${DESTDIR}/etc/mosquitto/pwfile.example
2362-
2363-uninstall :
2364- @for d in ${DIRS}; do $(MAKE) -C $${d} uninstall; done
2365-
2366-dist : reallyclean
2367- @for d in ${DISTDIRS}; do $(MAKE) -C $${d} dist; done
2368-
2369- mkdir -p dist/mosquitto-${VERSION}
2370- cp -r client installer lib logo man misc security service src ChangeLog.txt CMakeLists.txt COPYING Makefile compiling.txt config.h config.mk external_security_checks.txt readme.txt readme-windows.txt mosquitto.conf aclfile.example pwfile.example dist/mosquitto-${VERSION}/
2371- cd dist; tar -zcf mosquitto-${VERSION}.tar.gz mosquitto-${VERSION}/
2372- for m in libmosquitto.3 mosquitto.8 mosquitto.conf.5 mosquitto_pub.1 mosquitto_sub.1 mqtt.7; \
2373- do \
2374- hfile=$$(echo $${m} | sed -e 's/\./-/g'); \
2375- man2html man/$${m} > dist/$${hfile}.html; \
2376- sed -i 's#http://localhost/cgi-bin/man/man2html?8+mosquitto#mosquitto-8.html#' dist/$${hfile}.html; \
2377- sed -i 's#http://localhost/cgi-bin/man/man2html?3+libmosquitto#libmosquitto-3.html#' dist/$${hfile}.html; \
2378- sed -i 's#http://localhost/cgi-bin/man/man2html?5+mosquitto.conf#mosquitto-conf-5.html#' dist/$${hfile}.html; \
2379- sed -i 's#http://localhost/cgi-bin/man/man2html?1+mosquitto_pub#mosquitto_pub-1.html#' dist/$${hfile}.html; \
2380- sed -i 's#http://localhost/cgi-bin/man/man2html?1+mosquitto_sub#mosquitto_sub-1.html#' dist/$${hfile}.html; \
2381- sed -i 's#http://localhost/cgi-bin/man/man2html?7+mqtt#mqtt-7.html#' dist/$${hfile}.html; \
2382- sed -i 's#http://localhost/cgi-bin/man/man2html?5+hosts_access#http://www.linuxmanpages.com/man5/hosts_access.5.php#' dist/$${hfile}.html; \
2383- sed -i 's#http://localhost/cgi-bin/man/man2html#http://mosquitto.org/#' dist/$${hfile}.html; \
2384- sed -i '1,2d' dist/$${hfile}.html; \
2385- done
2386-
2387-
2388-sign : dist
2389- cd dist; gpg --detach-sign -a mosquitto-${VERSION}.tar.gz
2390-
2391-copy : sign
2392- cd dist; scp mosquitto-${VERSION}.tar.gz mosquitto-${VERSION}.tar.gz.asc mosquitto:mosquitto.org/files/source/
2393- cd dist; scp *.html mosquitto:mosquitto.org/man/
2394- scp ChangeLog.txt mosquitto:mosquitto.org/
2395-
2396
2397=== removed directory '.pc/mosquitto.conf.patch'
2398=== removed file '.pc/mosquitto.conf.patch/mosquitto.conf'
2399--- .pc/mosquitto.conf.patch/mosquitto.conf 2013-08-23 15:09:02 +0000
2400+++ .pc/mosquitto.conf.patch/mosquitto.conf 1970-01-01 00:00:00 +0000
2401@@ -1,364 +0,0 @@
2402-# Config file for mosquitto
2403-#
2404-# See mosquitto.conf(5) for more information.
2405-#
2406-# Default values are shown, uncomment to change.
2407-#
2408-# Use the # character to indicate a comment, but only if it is the
2409-# very first character on the line.
2410-
2411-# =================================================================
2412-# General configuration
2413-# =================================================================
2414-
2415-# Time in seconds to wait before resending an outgoing QoS=1 or
2416-# QoS=2 message.
2417-#retry_interval 20
2418-
2419-# Time in seconds between updates of the $SYS tree.
2420-#sys_interval 10
2421-
2422-# Time in seconds between cleaning the internal message store of
2423-# unreferenced messages. Lower values will result in lower memory
2424-# usage but more processor time, higher values will have the
2425-# opposite effect.
2426-# Setting a value of 0 means the unreferenced messages will be
2427-# disposed of as quickly as possible.
2428-#store_clean_interval 10
2429-
2430-# Write process id to a file. Default is a blank string which means
2431-# a pid file shouldn't be written.
2432-# This should be set to /var/run/mosquitto.pid if mosquitto is
2433-# being run automatically on boot with an init script and
2434-# start-stop-daemon or similar.
2435-#pid_file
2436-
2437-# When run as root, drop privileges to this user and its primary
2438-# group.
2439-# Leave blank to stay as root, but this is not recommended.
2440-# If run as a non-root user, this setting has no effect.
2441-# Note that on Windows this has no effect and so mosquitto should
2442-# be started by the user you wish it to run as.
2443-#user mosquitto
2444-
2445-# The maximum number of QoS 1 and 2 messages currently inflight per
2446-# client.
2447-# This includes messages that are partway through handshakes and
2448-# those that are being retried. Defaults to 10. Set to 0 for no
2449-# maximum. Setting to 1 will guarantee in-order delivery of QoS 1
2450-# and 2 messages.
2451-#max_inflight_messages 10
2452-
2453-# The maximum number of QoS 1 and 2 messages to hold in a queue
2454-# above those that are currently in-flight. Defaults to 100. Set
2455-# to 0 for no maximum (not recommended).
2456-#max_queued_messages 100
2457-
2458-# =================================================================
2459-# Default listener
2460-# =================================================================
2461-
2462-# IP address/hostname to bind the default listener to. If not
2463-# given, the default listener will not be bound to a specific
2464-# address and so will be accessible to all network interfaces.
2465-# bind_address ip-address/host name
2466-#bind_address
2467-
2468-# Port to use for the default listener.
2469-#port 1883
2470-
2471-# The maximum number of client connections to allow. This is
2472-# a per listener setting.
2473-# Default is -1, which means unlimited connections.
2474-# Note that other process limits mean that unlimited connections
2475-# are not really possible. Typically the default maximum number of
2476-# connections possible is around 1024.
2477-#max_connections -1
2478-
2479-# =================================================================
2480-# Extra listeners
2481-# =================================================================
2482-
2483-# Listen on a port/ip address combination. By using this variable
2484-# multiple times, mosquitto can listen on more than one port. If
2485-# this variable is used and neither bind_address nor port given,
2486-# then the default listener will not be started.
2487-# The port number to listen on must be given. Optionally, an ip
2488-# address or host name may be supplied as a second argument. In
2489-# this case, mosquitto will attempt to bind the listener to that
2490-# address and so restrict access to the associated network and
2491-# interface. By default, mosquitto will listen on all interfaces.
2492-# listener port-number [ip address/host name]
2493-#listener
2494-
2495-# The maximum number of client connections to allow. This is
2496-# a per listener setting.
2497-# Default is -1, which means unlimited connections.
2498-# Note that other process limits mean that unlimited connections
2499-# are not really possible. Typically the default maximum number of
2500-# connections possible is around 1024.
2501-#max_connections -1
2502-
2503-# The listener can be restricted to operating within a topic hierarchy using
2504-# the mount_point option. This is achieved be prefixing the mount_point string
2505-# to all topics for any clients connected to this listener. This prefixing only
2506-# happens internally to the broker; the client will not see the prefix.
2507-#mount_point
2508-
2509-# =================================================================
2510-# Persistence
2511-# =================================================================
2512-
2513-# If persistence is enabled, save the in-memory database to disk
2514-# every autosave_interval seconds. If set to 0, the persistence
2515-# database will only be written when mosquitto exits.
2516-# Note that writing of the persistence database can be forced by
2517-# sending mosquitto a SIGUSR1 signal.
2518-#autosave_interval 1800
2519-
2520-# Save persistent message data to disk (true/false).
2521-# This saves information about all messages, including
2522-# subscriptions, currently in-flight messages and retained
2523-# messages.
2524-# retained_persistence is a synonym for this option.
2525-#persistence false
2526-
2527-# The filename to use for the persistent database, not including
2528-# the path.
2529-#persistence_file mosquitto.db
2530-
2531-# Location for persistent database. Must include trailing /
2532-# Default is an empty string (current directory).
2533-# Set to /var/lib/mosquitto/ if running as a proper service.
2534-#persistence_location
2535-
2536-# =================================================================
2537-# Logging
2538-# =================================================================
2539-
2540-# Places to log to. Use multiple log_dest lines for multiple
2541-# logging destinations.
2542-# Possible destinations are: stdout stderr syslog topic
2543-# stdout and stderr log to the console on the named output.
2544-# syslog uses the userspace syslog facility which usually ends up
2545-# in /var/log/messages or similar.
2546-# topic logs to the broker topic '$SYS/broker/log/<severity>',
2547-# where severity is one of D, E, W, N, I which are debug, error,
2548-# warning, notice and information.
2549-# Use "log_dest none" if you wish to disable logging.
2550-#log_dest stderr
2551-
2552-# Types of messages to log. Use multiple log_type lines for logging
2553-# multiple types of messages.
2554-# Possible types are: debug, error, warning, notice, information,
2555-# none.
2556-# Note that debug type messages are for decoding the incoming
2557-# network packets.
2558-# They are not logged in syslog.
2559-#log_type error
2560-#log_type warning
2561-#log_type notice
2562-#log_type information
2563-
2564-# If set to true, client connection and disconnection messages will be included
2565-# in the log.
2566-#connection_messages true
2567-
2568-# If set to true, add a timestamp value to each log message.
2569-#log_timestamp true
2570-
2571-# =================================================================
2572-# Security
2573-# =================================================================
2574-
2575-# If set, only clients that have a matching prefix on their
2576-# clientid will be allowed to connect to the broker. By default,
2577-# all clients may connect.
2578-# For example, setting "secure-" here would mean a client "secure-
2579-# client" could connect but another with clientid "mqtt" couldn't.
2580-#clientid_prefixes
2581-
2582-# Boolean value that determines whether clients that connect
2583-# without providing a username are allowed to connect. If set to
2584-# false then a password file should be created (see the
2585-# password_file option) to control authenticated client access.
2586-# Defaults to true.
2587-#allow_anonymous true
2588-
2589-# Control access to the broker using a password file. The file is a
2590-# text file # of lines in the format:
2591-# username:password
2592-# The password (and colon) may be omitted if desired, although this
2593-# offers very little in the way of security.
2594-#password_file
2595-
2596-# Control access to topics on the broker using an access control list
2597-# file. If this parameter is defined then only the topics listed will
2598-# have access.
2599-# Topic access is added with lines of the format:
2600-#
2601-# topic [read|write] <topic>
2602-#
2603-# The access type is controlled using "read" or "write". This parameter
2604-# is optional - if not given then the access is read/write.
2605-# <topic> can contain the + or # wildcards as in subscriptions.
2606-#
2607-# The first set of topics are applied to anonymous clients, assuming
2608-# allow_anonymous is true. User specific topic ACLs are added after a
2609-# user line as follows:
2610-#
2611-# user <username>
2612-#
2613-# The username referred to here is the same as in password_file. It is
2614-# not the clientid.
2615-#
2616-#
2617-# If is also possible to define ACLs based on pattern substitution within the
2618-# topic. The patterns available for substition are:
2619-#
2620-# %c to match the client id of the client
2621-# %u to match the username of the client
2622-#
2623-# The substitution pattern must be the only text for that level of hierarchy.
2624-#
2625-# The form is the same as for the topic keyword, but using pattern as the
2626-# keyword.
2627-# Pattern ACLs apply to all users even if the "user" keyword has previously
2628-# been given.
2629-#
2630-# pattern [read|write] <topic>
2631-#
2632-# Example:
2633-#
2634-# pattern write sensor/%u/data
2635-#
2636-#acl_file
2637-
2638-# =================================================================
2639-# Bridges
2640-# =================================================================
2641-
2642-# Experimental support for connecting multiple MQTT brokers
2643-# together.
2644-# Specify multiple sets of connection, address and topic
2645-# configurations.
2646-# Each connection must have a unique name.
2647-# Only a single address per configuration is currently supported,
2648-# unlike in rsmb.
2649-# The direction that the topic will be shared can be chosen by
2650-# specifying out, in or both, where the default value is out.
2651-# The QoS level of the bridged communication can be specified with the final
2652-# topic option. The default QoS level is 2, to change the QoS the topic
2653-# direction must also be given.
2654-# Multiple topics can be specified per connection, but be careful
2655-# not to create any loops.
2656-#connection <name>
2657-#address <host>[:<port>]
2658-#topic <topic> [[out | in | both] qos-level]
2659-
2660-# Set the client id for this bridge connection. If not defined,
2661-# this defaults to 'name.hostname' where name is the connection
2662-# name and hostname is the hostname of this computer.
2663-#clientid
2664-
2665-# Set the clean session variable for this bridge.
2666-# When set to true, when the bridge disconnects for any reason, all
2667-# messages and subscriptions will be cleaned up on the remote
2668-# broker. Note that with cleansession set to true, there may be a
2669-# significant amount of retained messages sent when the bridge
2670-# reconnects after losing its connection.
2671-# When set to false, the subscriptions and messages are kept on the
2672-# remote broker, and delivered when the bridge reconnects.
2673-#cleansession false
2674-
2675-# If set to true, publish notification messages to the local and remote brokers
2676-# giving information about the state of the bridge connection. Retained
2677-# messages are published to the topic $SYS/bridge/connection/<clientid>/state.
2678-# If the message is 1 then the connection is active, or 0 if the connection has
2679-# failed.
2680-#notifications true
2681-
2682-# Set the keepalive interval for this bridge connection, in
2683-# seconds.
2684-#keepalive_interval 60
2685-
2686-# Set the start type of the bridge. This controls how the bridge starts and
2687-# can be one of three types: automatic, lazy and once. Note that RSMB provides
2688-# a fourth start type "manual" which isn't currently supported by mosquitto.
2689-#
2690-# "automatic" is the default start type and means that the bridge connection
2691-# will be started automatically when the broker starts and also restarted
2692-# after a short delay (30 seconds) if the connection fails.
2693-#
2694-# Bridges using the "lazy" start type will be started automatically when the
2695-# number of queued messages exceeds the number set with the "threshold"
2696-# parameter. It will be stopped automatically after the time set by the
2697-# "idle_timeout" parameter. Use this start type if you wish the connection to
2698-# only be active when it is needed.
2699-#
2700-# A bridge using the "once" start type will be started automatically when the
2701-# broker starts but will not be restarted if the connection fails.
2702-#start_type automatic
2703-
2704-# Set the amount of time a bridge using the lazy start type must be idle before
2705-# it will be stopped. Defaults to 60 seconds.
2706-#idle_timeout 60
2707-
2708-# Set the number of messages that need to be queued for a bridge with lazy
2709-# start type to be restarted. Defaults to 10 messages.
2710-# Must be less than max_queued_messages.
2711-#threshold 10
2712-
2713-# Set the username to use when connecting to an MQTT v3.1 broker
2714-# that requires authentication.
2715-#username
2716-
2717-# Set the password to use when connecting to an MQTT v3.1 broker
2718-# that requires authentication. This option is only used if
2719-# username is also set.
2720-#password
2721-
2722-# =================================================================
2723-# External security checks
2724-# =================================================================
2725-
2726-# This section defines options for potential use with external
2727-# databases.
2728-# They are intended to make it easier to add external security
2729-# checks along with WITH_EXT_SECURITY_CHECKS. If you haven't written
2730-# code to support another database and compiled support in, you are
2731-# unlikely to need to change anything here.
2732-
2733-# Database hostname.
2734-#db_host
2735-
2736-# Database port.
2737-#db_port
2738-
2739-# Database name.
2740-#db_name
2741-
2742-# Database username.
2743-#db_username
2744-
2745-# Database password.
2746-#db_password
2747-
2748-# =================================================================
2749-# Unsupported rsmb options - for the future
2750-# =================================================================
2751-
2752-#autosave_on_changes
2753-#addresses
2754-#notification_topic
2755-#round_robin
2756-
2757-# =================================================================
2758-# rsmb options - unlikely to ever be supported
2759-# =================================================================
2760-
2761-#ffdc_output
2762-#max_log_entries
2763-#trace_level
2764-#trace_output
2765-#try_private
2766
2767=== modified file 'CMakeLists.txt'
2768--- CMakeLists.txt 2012-02-07 23:21:39 +0000
2769+++ CMakeLists.txt 2013-08-24 09:38:26 +0000
2770@@ -1,6 +1,4 @@
2771 # This is a cmake script.
2772-# It is intended to be the default means of building mosquitto, but isn't
2773-# quite ready for all cases yet.
2774
2775 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
2776
2777@@ -8,10 +6,10 @@
2778
2779 cmake_minimum_required(VERSION 2.6)
2780
2781-set (VERSION 0.15)
2782+set (VERSION 1.2)
2783
2784 if (WIN32)
2785- execute_process(COMMAND echo "%DATE% %TIME%" OUTPUT_VARIABLE TIMESTAMP
2786+ execute_process(COMMAND cmd /c echo %DATE% %TIME% OUTPUT_VARIABLE TIMESTAMP
2787 OUTPUT_STRIP_TRAILING_WHITESPACE)
2788 else (WIN32)
2789 execute_process(COMMAND date "+%F %T%z" OUTPUT_VARIABLE TIMESTAMP
2790@@ -33,7 +31,12 @@
2791 else (WIN32)
2792 set (BINDIR bin)
2793 set (SBINDIR sbin)
2794- set (SYSCONFDIR etc/mosquitto)
2795+ if (${CMAKE_INSTALL_PREFIX} STREQUAL /usr)
2796+ set (SYSCONFDIR /etc/mosquitto)
2797+ else (${CMAKE_INSTALL_PREFIX} STREQUAL /usr)
2798+ set (SYSCONFDIR etc/mosquitto)
2799+ endif (${CMAKE_INSTALL_PREFIX} STREQUAL /usr)
2800+
2801 set (LIBDIR lib${LIB_SUFFIX})
2802 set (INCLUDEDIR include)
2803 set (DATAROOTDIR share)
2804@@ -41,6 +44,20 @@
2805 set (SHAREDIR ${DATAROOTDIR}/mosquitto)
2806 endif (WIN32)
2807
2808+option(WITH_TLS
2809+ "Include SSL/TLS support?" ON)
2810+option(WITH_TLS_PSK
2811+ "Include TLS-PSK support (requires WITH_TLS)?" ON)
2812+if (${WITH_TLS} STREQUAL ON)
2813+ find_package(OpenSSL REQUIRED)
2814+ add_definitions("-DWITH_TLS")
2815+ if (${WITH_TLS_PSK} STREQUAL ON)
2816+ add_definitions("-DWITH_TLS_PSK")
2817+ endif (${WITH_TLS_PSK} STREQUAL ON)
2818+else (${WITH_TLS} STREQUAL ON)
2819+ set (OPENSSL_INCLUDE_DIR "")
2820+endif (${WITH_TLS} STREQUAL ON)
2821+
2822 # ========================================
2823 # Include projects
2824 # ========================================
2825@@ -54,4 +71,4 @@
2826 # Install config file
2827 # ========================================
2828
2829-install(FILES mosquitto.conf aclfile.example pwfile.example DESTINATION ${SYSCONFDIR})
2830+install(FILES mosquitto.conf aclfile.example pskfile.example pwfile.example DESTINATION ${SYSCONFDIR})
2831
2832=== removed file 'COPYING'
2833--- COPYING 2012-02-07 23:21:39 +0000
2834+++ COPYING 1970-01-01 00:00:00 +0000
2835@@ -1,26 +0,0 @@
2836-Copyright (c) 2009-2012 Roger Light <roger@atchoo.org>
2837-All rights reserved.
2838-
2839-Redistribution and use in source and binary forms, with or without
2840-modification, are permitted provided that the following conditions are met:
2841-
2842-1. Redistributions of source code must retain the above copyright notice,
2843- this list of conditions and the following disclaimer.
2844-2. Redistributions in binary form must reproduce the above copyright
2845- notice, this list of conditions and the following disclaimer in the
2846- documentation and/or other materials provided with the distribution.
2847-3. Neither the name of mosquitto nor the names of its
2848- contributors may be used to endorse or promote products derived from
2849- this software without specific prior written permission.
2850-
2851-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2852-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2853-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2854-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2855-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2856-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2857-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2858-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2859-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2860-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2861-POSSIBILITY OF SUCH DAMAGE.
2862
2863=== modified file 'ChangeLog.txt'
2864--- ChangeLog.txt 2012-02-07 23:21:39 +0000
2865+++ ChangeLog.txt 2013-08-24 09:38:26 +0000
2866@@ -1,3 +1,426 @@
2867+1.2 - 20130708
2868+==============
2869+
2870+Broker:
2871+- Replace O(n) username lookup on CONNECT with a roughly O(1) hashtable version.
2872+- It is now possible to disable $SYS at compile time.
2873+- Add dropped publish messages to load tree in $SYS. Closes bug #1183318.
2874+- Add support for logging SUBSCRIBE/UNSUBSCRIBE events.
2875+- Add "log_dest file" logging support.
2876+- Auth plugin ACL check function now passes the client id as well as username
2877+ and password.
2878+- The queue_qos0_messages option wasn't working correctly, this has now been
2879+ fixed. Closes bug #1125200.
2880+- Don't drop all messages for disconnected durable clients when
2881+ max_queued_messages=0.
2882+- Add support for "log_type all".
2883+- Add support for "-v" option on the command line to provide the equivalent of
2884+ "log_type all" without needing a config file.
2885+- Add the "upgrade_outgoing_qos" option, a non-standard feature.
2886+- Persistence data is now written to a temporary file which is atomically
2887+ renamed on completion, so a crash during writing will not produce a corrupt
2888+ file.
2889+- mosquitto.conf is now installed as mosquitto.conf.example
2890+- Configuration file errors are now reported with filename and line number.
2891+- The broker now uses a monotonic clock if available, to avoid changes in time
2892+ causing client disconnections or message retries.
2893+- Clean session and keepalive status are now display the log when a client
2894+ connects.
2895+- Add support for TLSv1.2 and TLSv1.1.
2896+- Clients that connect with zero length will topics are now rejected.
2897+- Add the ability to set a maximum allowed PUBLISH payload size.
2898+- Fix an ACL with topic "#" incorrectly granting access to $SYS.
2899+- Fix retained messages incorrectly being set on wildcard topics, leading to
2900+ duplicate retained messages being sent on subscription. Closes bug #1116233.
2901+- Don't discard listener values when no "port" option given. Closes bug
2902+ #1131406.
2903+- Client password check was always failing when security was being reapplied
2904+ after a config reload. This meant that all clients were being disconnected.
2905+ This has been fixed.
2906+- Fix build when WITH_TLS=no. Closes bug #1174971.
2907+- Fix single outgoing packets not being sent in a timely fashion if they were
2908+ not sent in one call to write(). Closes bug #1176796.
2909+- Fix remapping of messages for clients connected to a listener with
2910+ mount_point set. Closes bug #1180765.
2911+- Fix duplicate retained messages being sent for some wildcard patterns.
2912+- If a client connects with a will topic to which they do not have write
2913+ access, they are now disconnected with CONNACK "not authorised".
2914+- Fix retained messages on topic foo being incorrectly delivered to
2915+ subscriptions of /#
2916+- Fix handling of SSL errors on SSL_accept().
2917+- Fix handling of QoS 2 messages on client reconnect.
2918+- Drop privileges now sets supplementary groups correctly.
2919+- Fix load reporting interval (is now 60s).
2920+- Be strict with malformed PUBLISH packets - clients are now disconnected
2921+ rather than the packet discarded. This goes inline with future OASIS spec
2922+ changes and makes other changes more straightforward.
2923+- Process incoming messages denied by ACL properly so that clients don't keep
2924+ resending them.
2925+
2926+- Add support for round_robin bridge option.
2927+- Add bridge support for verifying remote server certificate subject against
2928+ the remote hostname.
2929+- Fix problem with out of order calls to free() when restarting a lazy bridge.
2930+- The broker now attempts to resolve bind_address and bridge addresses
2931+ immediately when parsing the config file in order to detect invalid hosts.
2932+- Bridges now set their notification state before attempting to connect, so if
2933+ they fail to connect the state can still be seen.
2934+- Fix bridge notification payload length - no need to send a null byte.
2935+
2936+- mosquitto_passwd utility now reports errors more clearly.
2937+- Fix "mosquitto_passwd -U".
2938+
2939+
2940+Client library:
2941+- Add support for TLSv1.2 and TLSv1.1, except for on the Python module.
2942+- Add support for verifying remote server certificate subject against the
2943+ remote hostname.
2944+- Add mosquitto_reconnect_async() support and make asynchronous connections
2945+ truely asynchronous rather than simply deferred. DNS lookups are still
2946+ blocking, so asynchronous connections require an IP address instead of
2947+ hostname.
2948+- Allow control of reconnection timeouts in mosquitto_loop_forever() and after
2949+ mosquitto_loop_start() by using mosquitto_reconnect_delay_set().
2950+- Fix building on Android NDK.
2951+- Re-raise unhandled errors in Python so as not to provide confusing error
2952+ messages later on.
2953+- Python module supports IPv6 connections.
2954+- mosquitto_sub_topic_tokenise() was behaving incorrectly if the last topic
2955+ hierarchy had only a single character. This has been fixed. Closes bug
2956+ #1163348.
2957+- Fix possible crash after disconnects when using the threaded interface with
2958+ TLS.
2959+- Allow build/install without Python. Closes bug #1174972.
2960+- Add support for binding connection to a local interface.
2961+- Implement maximum inflight messages handling.
2962+- Fix Python client not handling will_payload==None.
2963+- Fix potential memory leak when setting username/password.
2964+- Fix handling of QoS 2 messages on reconnect.
2965+- Improve handling of mosquitto_disconnect() with threaded mode.
2966+
2967+
2968+Clients:
2969+- Add support for TLSv1.2 and TLSv1.1.
2970+- Sub client can now suppress printing of messages with the retain bit set.
2971+- Add support for binding connection to a local interface.
2972+- Implement maximum inflight messages handling for the pub client.
2973+
2974+1.1.3 - 20130211
2975+================
2976+
2977+Broker:
2978+- mosquitto_passwd utility now uses tmpfile() to generate its temporary data
2979+ storage file. It also creates a backup file that can be used to recover data
2980+ if an errors occur.
2981+
2982+Other:
2983+- Build script fixes to help packaging on Debian.
2984+
2985+1.1.2 - 20130130
2986+================
2987+
2988+Client library:
2989+- Fix tls_cert_reqs not being set to SSL_VERIFY_PEER by default. This meant
2990+ that clients were not verifying the server certificate when connecting over
2991+ TLS. This affects the C, C++ and Python libraries.
2992+
2993+1.1.1 - 20130116
2994+================
2995+
2996+Broker:
2997+- Fix crash on reload if using acl patterns.
2998+
2999+Client library:
3000+- Fix static C++ functions not being exported on Windows. Fixes bug #1098256.
3001+
3002+1.1 - 20121219
3003+==============
3004+
3005+Broker:
3006+- Add $SYS/broker/messages/dropped
3007+- Add $SYS/broker/clients/expired
3008+- Replace $SYS/broker/+/per second/+ with moving average versions published at
3009+ $SYS/broker/load/#
3010+- Add $SYS/broker/load/sockets/+ and $SYS/broker/load/connections/+
3011+- Documentation on password file format has been fixed.
3012+- Disable SSL compression. This reduces memory usage significantly and removes
3013+ the possibility of CRIME type attacks.
3014+- Enable SSL_MODE_RELEASE_BUFFERS mode to reduce SSL memory usage further.
3015+- Add allow_duplicate_messages option.
3016+- ACL files can now have comment lines with # as the first character.
3017+- Display message on startup about which config is being loaded.
3018+- Fix max_inflight_messages and max_queued_messages not being applied.
3019+- Fix documentation error in mosquitto.conf.
3020+- Ensure that QoS 2 queued messages are sent out in a timely manner.
3021+- Local bridges now act on clean_session correctly.
3022+- Local bridges with clean_session==false now remove unused subscriptions on
3023+ broker restart.
3024+- The $SYS/broker/heap/# messages now no longer include "bytes" as part of the
3025+ string for ease of use.
3026+
3027+Client library:
3028+- Free memory used by OpenSSL in mosquitto_lib_cleanup() where possible.
3029+- Change WebSocket subprotocol name to mqttv3.1 to make future changes easier
3030+ and for compatibility with other implementations.
3031+- mosquitto_loop_read() and mosquitto_loop_write() now handle errors
3032+ themselves rather than having mosquitto_loop() handle their errors. This
3033+ makes using them in a separate event loop more straightforward.
3034+- Add mosquitto_loop_forever() / loop_forever() function call to make simple
3035+ clients easier.
3036+- Disable SSL compression. This reduces memory usage significantly and removes
3037+ the possibility of CRIME type attacks.
3038+- Enable SSL_MODE_RELEASE_BUFFERS mode to reduce SSL memory usage further.
3039+- mosquitto_tls_set() will now return an error or raise an exception
3040+ immediately if the CA certificate or client certificate/key cannot be
3041+ accessed.
3042+- Fix potential memory leaks on connection failures.
3043+- Don't produce return error from mosquitto_loop() if a system call is
3044+ interrupted. This prevents disconnects/reconnects in threaded mode and
3045+ simplifies non-threaded client handling.
3046+- Ignore SIGPIPE to prevent unnecessary client quits in threaded mode.
3047+- Fix document error for mosquitto_message_retry_set().
3048+- Fix mosquitto_topic_matches_sub() for subscriptions with + as the final
3049+ character. Fixes bug #1085797.
3050+- Rename all "obj" parameters to "userdata" for consistency with other
3051+ libraries.
3052+- Reset errno before network read/write to ensure EAGAIN isn't mistakenly
3053+ returned.
3054+- The message queue length is now tracked and used to determine the maximum
3055+ number of packets to process at once. This removes the need for the
3056+ max_packets parameter which is now unused.
3057+- Fix incorrect error value in Python error_string() function. Fixes bug
3058+ #1086777.
3059+- Reset last message in/out timer in Python module when we send a PINGREQ.
3060+ Fixes too-early disconnects.
3061+
3062+Clients:
3063+- Clients now display their own version number and library version number in
3064+ their help messages.
3065+- Fix "mosquitto_pub -l -q 2" disconnecting before all messages were
3066+ transmitted.
3067+- Fix potential out-of-bounds array access with client ids. Fixes bug
3068+ #1083182.
3069+
3070+Other:
3071+- mosquitto_passwd can now convert password files with plain text files to
3072+ hashed versions.
3073+
3074+1.0.5 - 20121103
3075+================
3076+
3077+Broker:
3078+- Fix crash when the broker has use_identity_as_username set to true but a
3079+ client connects without a certificate.
3080+- mosquitto_passwd should only be installed if WITH_TLS=yes.
3081+
3082+Library:
3083+- Use symbolic errno values rather than numbers in Python module to avoid
3084+ cross platform issues (incorrect errno on Mac OS).
3085+
3086+Other:
3087+- Build script fixes for FreeBSD.
3088+
3089+1.0.4 - 20121017
3090+================
3091+
3092+Broker:
3093+- Deal with poll() POLLIN/POLLOUT before POLL[RD]HUP to correctly handle the
3094+ case where a client sends data and immediately closes its socket.
3095+
3096+Library:
3097+- Fix memory leak with messages of QoS=2. Fixes bug #1064981.
3098+- Fix potential thread synchronisation problem with outgoing packets in the
3099+ Python module. Fixes bug #1064977.
3100+
3101+Clients:
3102+- Fix "mosquitto_sub -l" incorrectly only sending one message per second.
3103+
3104+1.0.3 - 20120927
3105+================
3106+
3107+Broker:
3108+- Fix loading of psk files.
3109+- Don't return an error when reloading config if an ACL file isn't defined.
3110+ This was preventing psk files being reloaded.
3111+- Clarify meaning of $SYS/broker/clients/total in mosquitto(8) man page.
3112+- Clarify meaning of $SYS/broker/messages/stored in mosquitto(8) man page.
3113+- Fix non-retained message delivery when subscribing to #.
3114+- Fix retained message delivery for subs to foo/# with retained messages at
3115+ foo.
3116+- Include the filename in password/acl file loading errors.
3117+
3118+Library:
3119+- Fix possible AttributeError when self._sock == None in Python module.
3120+- Fix reconnecting after a timeout in Python module.
3121+- Fix reconnecting when there were outgoing packets in the queue in the Python
3122+ module.
3123+- Fix problem with mutex initialisation causing crashes on some Windows
3124+ installations.
3125+
3126+1.0.2 - 20120919
3127+================
3128+
3129+Broker:
3130+- If the broker was configured for persistence, a durable client had a
3131+ subscription to topics in $SYS/# and had messages in its queue when the
3132+ broker restarted, then the persistent database would have messages missing
3133+ and so the broker would not restart properly. This has been fixed.
3134+
3135+Library:
3136+- Fix threading problem on some systems.
3137+
3138+Tests:
3139+- Close socket after 08-ssl-connect-no-auth-wrong-ca.py test to prevent
3140+ subsequent tests having problems.
3141+
3142+Build scripts:
3143+- Install pskfile.example in CMake. Fixes bug #1037504.
3144+
3145+Other:
3146+- Fix db_dump parameter printing message store and sub chunks.
3147+
3148+1.0.1 - 20120815
3149+================
3150+
3151+Broker:
3152+- Fix default log_dest when running as a Windows service.
3153+
3154+Client library:
3155+- Fix incorrect parameters in Python on_log() callback call. Fixes bug
3156+ #1036818.
3157+
3158+Clients:
3159+- Clients now don't display TLS/TLS-PSK usage help if they don't support it.
3160+
3161+Build scripts:
3162+- Fix TLS-PSK support in the CMake build files.
3163+- Fix man page installation in the CMake build files.
3164+- Fix SYSCONFDIR in cmake on *nix when installing to /usr. Fixes bug #1036908.
3165+
3166+Documentation:
3167+- Fix mqtt/MQTT capitalisation in man pages.
3168+- Update compiling.txt.
3169+- Fix incorrect callback docs in mosquitto.py. Fixes bug #1036607.
3170+- Fix various doc typos and remove obsolete script. Fixes bug #1037088.
3171+
3172+1.0 - 20120814
3173+==============
3174+
3175+Broker:
3176+
3177+- Add SSL/TLS support.
3178+- Add TLS-PSK support, providing a simpler encryption method for constrained
3179+ devices.
3180+- Passwords are now salted+hashed if compiled with WITH_TLS (recommended).
3181+- Add mosquitto_passwd for handling password files.
3182+- Add $SYS/broker/publish/messages/{sent|received} to show the number of
3183+ PUBLISH messages sent/received.
3184+- Add $SYS/broker/publish/bytes/{sent|received} to show the number of
3185+ PUBLISH bytes sent/received.
3186+- Add reload parameter for security init/cleanup functions.
3187+- Add option for expiring disconnected persistent clients.
3188+- Add option for queueing of QoS 0 messages when persistent clients are
3189+ disconnected.
3190+- Enforce client id limits in the broker (only when WITH_STRICT_PROTOCOL is
3191+ defined).
3192+- Fix reloading of log configuration.
3193+- Add support for try_private config option for bridge connections.
3194+- Add support for autosave_on_changes config option.
3195+- Add support for include_dir config option.
3196+- Add support for topic remapping.
3197+- Usernames were being lost when a non clean-session client reconnected,
3198+ potentially causing problems with ACLs. This has been fixed.
3199+- Significant improvement to memory handling on Windows.
3200+- Bridges with outgoing topics will now set the retain flag correctly so that
3201+ messages will be retained on the remote broker.
3202+- Incoming bridge connections are now detected by checking if bit 8 of the
3203+ protocol version number is set. This requires support from the remote broker.
3204+- Add support for notification_topic option.
3205+- Add $SYS/broker/subscriptions/count and $SYS/broker/retained messages/count.
3206+- Add restart_timeout to control the amount of time an automatic bridge will
3207+ wait before reconnecting.
3208+- Overlapping subscriptions are now handled properly. Fixes bug #928538.
3209+- Fix reloading of persistence_file and persistence_location.
3210+- Fix broker crash on incorrect protocol number.
3211+- Fix missing COMPAT_ECONNRESET define on Windows.
3212+- Clients that had disconnected were not always being detected immediately on
3213+ Linux. This has been fixed.
3214+- Don't save $SYS messages to the on-disk persistent db. All $SYS messages
3215+ should be reconstructed on a restart. This means bridge connection
3216+ notifications will now be correct on a restart.
3217+- Fix reloading of bridge clients from the persistent db. This means that
3218+ outgoing bridged topics should always work.
3219+- Local bridges are now no longer restricted by local ACLs.
3220+- Discard publish messages with zero length topics.
3221+- Drop to "mosquitto" user even if no config file specified.
3222+- Don't incorrectly allow topic access if ACL patterns but no normal ACL rules
3223+ are defined.
3224+
3225+Client library:
3226+
3227+- Add SSL/TLS support.
3228+- Add TLS-PSK support, providing a simpler encryption method for constrained
3229+ devices.
3230+- Add javascript/websockets client library.
3231+- Add "struct mosquitto *mosq" parameter for all callbacks in the client
3232+ library. This is a binary incompatible change so the soversion of the
3233+ libraries has been incremented. The new parameter should make it easier to
3234+ use callbacks in practice.
3235+- Add mosquitto_want_write() for use when using own select() loop with
3236+ mosquitto_socket().
3237+- Add mosquitto_connect_async() to provide a non-blocking connect client call.
3238+- Add mosquitto_user_data_set() to allow user data pointer to be updated.
3239+- Add "int rc" parameter to disconnect callback to indicate whether disconnect
3240+ was unexpected or the result of calling mosquitto_disconnect().
3241+- Add mosquitto_strerror() for obtaining a string description of error numbers.
3242+- Add mosquitto_connack_string() for obtaining a string description of MQTT
3243+ connection results.
3244+- Add mosquitto_will_clear() and change mosquitto_will_set() to only set the
3245+ will.
3246+- Add mosquitto_sub_topic_tokenise() and mosquitto_sub_topic_tokens_free()
3247+ utility functions to tokenise a subscription/topic string into a string
3248+ array.
3249+- Add mosquitto_topic_matches_sub() to check whether a topic matches a
3250+ subscription.
3251+- Replaced mosquitto_log_init() with mosquitto_log_callback_set() to allow
3252+ clients to decide what to do with log messages.
3253+- Client will now disconnect itself from the broker if it doesn't receive a
3254+ PINGRESP in the keepalive period after sending a PINGREQ.
3255+- Client will now send a PINGREQ if it has not received a message from the
3256+ broker in keepalive seconds.
3257+- mosquitto_new() will now generate a random client id if the id parameter is
3258+ NULL.
3259+- Added max_packets to mosquitto_loop(), mosquitto_loop_read() and
3260+ mosquitto_loop_write() to control the maximum number of packets that are
3261+ handled per call.
3262+- Payload parameters are now void * instead of uint8_t *.
3263+- The clean_session parameter has been moved from mosquitto_connect() to
3264+ mosquitto_new() because it is a client parameter rather than a connection
3265+ parameter.
3266+- Functions now use int instead of uint*_t where possible.
3267+- mosquitto_new() now sets errno to indicate failure type.
3268+- Return MOSQ_ERR_INVAL on zero length topic.
3269+- Fix automatic client id generation on Windows.
3270+- mosquitto_loop_misq() can now return MOSQ_ERR_NO_CONN.
3271+- Compile static library as well as dynamic library with default makefiles.
3272+- Rename C++ namespace from mosquittopp to mosqpp to remove ambiguity.
3273+- C++ lib_init(), lib_version() and lib_cleanup() are now in the mosqpp
3274+ namespace directly, not mosquittopp class members.
3275+- The Python library is now written in pure Python and so no longer depends on
3276+ libmosquitto.
3277+- The Python library includes SSL/TLS support.
3278+- The Python library should now be compatible with Python 3.
3279+
3280+Other:
3281+
3282+- Fix db_dump reading of retained messages.
3283+- Add example of logging all messages to mysql.
3284+- Add C++ client example.
3285+- Fix potential buffer overflow in pub/sub clients.
3286+- Add "make binary" target that doesn't make documents.
3287+- Add "--help" arguments to pub/sub clients.
3288+- Fix building on Solaris.
3289+
3290 0.15 - 20120205
3291 ===============
3292
3293
3294=== added file 'LICENSE-3rd-party.txt'
3295--- LICENSE-3rd-party.txt 1970-01-01 00:00:00 +0000
3296+++ LICENSE-3rd-party.txt 2013-08-24 09:38:26 +0000
3297@@ -0,0 +1,666 @@
3298+============================================================================
3299+uthash.h license
3300+============================================================================
3301+
3302+Copyright (c) 2005-2010, Troy D. Hanson http://uthash.sourceforge.net
3303+All rights reserved.
3304+
3305+Redistribution and use in source and binary forms, with or without
3306+modification, are permitted provided that the following conditions are met:
3307+
3308+ * Redistributions of source code must retain the above copyright
3309+ notice, this list of conditions and the following disclaimer.
3310+
3311+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
3312+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
3313+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
3314+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
3315+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3316+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3317+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
3318+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3319+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3320+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3321+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3322+
3323+
3324+
3325+============================================================================
3326+OpenSSL license
3327+============================================================================
3328+
3329+ LICENSE ISSUES
3330+ ==============
3331+
3332+ The OpenSSL toolkit stays under a dual license, i.e. both the conditions of
3333+ the OpenSSL License and the original SSLeay license apply to the toolkit.
3334+ See below for the actual license texts. Actually both licenses are BSD-style
3335+ Open Source licenses. In case of any license issues related to OpenSSL
3336+ please contact openssl-core@openssl.org.
3337+
3338+ OpenSSL License
3339+ ---------------
3340+
3341+/* ====================================================================
3342+ * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
3343+ *
3344+ * Redistribution and use in source and binary forms, with or without
3345+ * modification, are permitted provided that the following conditions
3346+ * are met:
3347+ *
3348+ * 1. Redistributions of source code must retain the above copyright
3349+ * notice, this list of conditions and the following disclaimer.
3350+ *
3351+ * 2. Redistributions in binary form must reproduce the above copyright
3352+ * notice, this list of conditions and the following disclaimer in
3353+ * the documentation and/or other materials provided with the
3354+ * distribution.
3355+ *
3356+ * 3. All advertising materials mentioning features or use of this
3357+ * software must display the following acknowledgment:
3358+ * "This product includes software developed by the OpenSSL Project
3359+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
3360+ *
3361+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
3362+ * endorse or promote products derived from this software without
3363+ * prior written permission. For written permission, please contact
3364+ * openssl-core@openssl.org.
3365+ *
3366+ * 5. Products derived from this software may not be called "OpenSSL"
3367+ * nor may "OpenSSL" appear in their names without prior written
3368+ * permission of the OpenSSL Project.
3369+ *
3370+ * 6. Redistributions of any form whatsoever must retain the following
3371+ * acknowledgment:
3372+ * "This product includes software developed by the OpenSSL Project
3373+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
3374+ *
3375+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
3376+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3377+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3378+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
3379+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3380+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
3381+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3382+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3383+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3384+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3385+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3386+ * OF THE POSSIBILITY OF SUCH DAMAGE.
3387+ * ====================================================================
3388+ *
3389+ * This product includes cryptographic software written by Eric Young
3390+ * (eay@cryptsoft.com). This product includes software written by Tim
3391+ * Hudson (tjh@cryptsoft.com).
3392+ *
3393+ */
3394+
3395+ Original SSLeay License
3396+ -----------------------
3397+
3398+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3399+ * All rights reserved.
3400+ *
3401+ * This package is an SSL implementation written
3402+ * by Eric Young (eay@cryptsoft.com).
3403+ * The implementation was written so as to conform with Netscapes SSL.
3404+ *
3405+ * This library is free for commercial and non-commercial use as long as
3406+ * the following conditions are aheared to. The following conditions
3407+ * apply to all code found in this distribution, be it the RC4, RSA,
3408+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
3409+ * included with this distribution is covered by the same copyright terms
3410+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
3411+ *
3412+ * Copyright remains Eric Young's, and as such any Copyright notices in
3413+ * the code are not to be removed.
3414+ * If this package is used in a product, Eric Young should be given attribution
3415+ * as the author of the parts of the library used.
3416+ * This can be in the form of a textual message at program startup or
3417+ * in documentation (online or textual) provided with the package.
3418+ *
3419+ * Redistribution and use in source and binary forms, with or without
3420+ * modification, are permitted provided that the following conditions
3421+ * are met:
3422+ * 1. Redistributions of source code must retain the copyright
3423+ * notice, this list of conditions and the following disclaimer.
3424+ * 2. Redistributions in binary form must reproduce the above copyright
3425+ * notice, this list of conditions and the following disclaimer in the
3426+ * documentation and/or other materials provided with the distribution.
3427+ * 3. All advertising materials mentioning features or use of this software
3428+ * must display the following acknowledgement:
3429+ * "This product includes cryptographic software written by
3430+ * Eric Young (eay@cryptsoft.com)"
3431+ * The word 'cryptographic' can be left out if the rouines from the library
3432+ * being used are not cryptographic related :-).
3433+ * 4. If you include any Windows specific code (or a derivative thereof) from
3434+ * the apps directory (application code) you must include an acknowledgement:
3435+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
3436+ *
3437+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
3438+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3439+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3440+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
3441+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3442+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3443+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3444+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3445+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3446+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3447+ * SUCH DAMAGE.
3448+ *
3449+ * The licence and distribution terms for any publically available version or
3450+ * derivative of this code cannot be changed. i.e. this code cannot simply be
3451+ * copied and put under another distribution licence
3452+ * [including the GNU Public Licence.]
3453+ */
3454+
3455+
3456+
3457+============================================================================
3458+pthreads-win32 license
3459+============================================================================
3460+
3461+ GNU LESSER GENERAL PUBLIC LICENSE
3462+ Version 2.1, February 1999
3463+
3464+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
3465+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3466+ Everyone is permitted to copy and distribute verbatim copies
3467+ of this license document, but changing it is not allowed.
3468+
3469+[This is the first released version of the Lesser GPL. It also counts
3470+ as the successor of the GNU Library Public License, version 2, hence
3471+ the version number 2.1.]
3472+
3473+ Preamble
3474+
3475+ The licenses for most software are designed to take away your
3476+freedom to share and change it. By contrast, the GNU General Public
3477+Licenses are intended to guarantee your freedom to share and change
3478+free software--to make sure the software is free for all its users.
3479+
3480+ This license, the Lesser General Public License, applies to some
3481+specially designated software packages--typically libraries--of the
3482+Free Software Foundation and other authors who decide to use it. You
3483+can use it too, but we suggest you first think carefully about whether
3484+this license or the ordinary General Public License is the better
3485+strategy to use in any particular case, based on the explanations below.
3486+
3487+ When we speak of free software, we are referring to freedom of use,
3488+not price. Our General Public Licenses are designed to make sure that
3489+you have the freedom to distribute copies of free software (and charge
3490+for this service if you wish); that you receive source code or can get
3491+it if you want it; that you can change the software and use pieces of
3492+it in new free programs; and that you are informed that you can do
3493+these things.
3494+
3495+ To protect your rights, we need to make restrictions that forbid
3496+distributors to deny you these rights or to ask you to surrender these
3497+rights. These restrictions translate to certain responsibilities for
3498+you if you distribute copies of the library or if you modify it.
3499+
3500+ For example, if you distribute copies of the library, whether gratis
3501+or for a fee, you must give the recipients all the rights that we gave
3502+you. You must make sure that they, too, receive or can get the source
3503+code. If you link other code with the library, you must provide
3504+complete object files to the recipients, so that they can relink them
3505+with the library after making changes to the library and recompiling
3506+it. And you must show them these terms so they know their rights.
3507+
3508+ We protect your rights with a two-step method: (1) we copyright the
3509+library, and (2) we offer you this license, which gives you legal
3510+permission to copy, distribute and/or modify the library.
3511+
3512+ To protect each distributor, we want to make it very clear that
3513+there is no warranty for the free library. Also, if the library is
3514+modified by someone else and passed on, the recipients should know
3515+that what they have is not the original version, so that the original
3516+author's reputation will not be affected by problems that might be
3517+introduced by others.
3518+
3519
3520+ Finally, software patents pose a constant threat to the existence of
3521+any free program. We wish to make sure that a company cannot
3522+effectively restrict the users of a free program by obtaining a
3523+restrictive license from a patent holder. Therefore, we insist that
3524+any patent license obtained for a version of the library must be
3525+consistent with the full freedom of use specified in this license.
3526+
3527+ Most GNU software, including some libraries, is covered by the
3528+ordinary GNU General Public License. This license, the GNU Lesser
3529+General Public License, applies to certain designated libraries, and
3530+is quite different from the ordinary General Public License. We use
3531+this license for certain libraries in order to permit linking those
3532+libraries into non-free programs.
3533+
3534+ When a program is linked with a library, whether statically or using
3535+a shared library, the combination of the two is legally speaking a
3536+combined work, a derivative of the original library. The ordinary
3537+General Public License therefore permits such linking only if the
3538+entire combination fits its criteria of freedom. The Lesser General
3539+Public License permits more lax criteria for linking other code with
3540+the library.
3541+
3542+ We call this license the "Lesser" General Public License because it
3543+does Less to protect the user's freedom than the ordinary General
3544+Public License. It also provides other free software developers Less
3545+of an advantage over competing non-free programs. These disadvantages
3546+are the reason we use the ordinary General Public License for many
3547+libraries. However, the Lesser license provides advantages in certain
3548+special circumstances.
3549+
3550+ For example, on rare occasions, there may be a special need to
3551+encourage the widest possible use of a certain library, so that it becomes
3552+a de-facto standard. To achieve this, non-free programs must be
3553+allowed to use the library. A more frequent case is that a free
3554+library does the same job as widely used non-free libraries. In this
3555+case, there is little to gain by limiting the free library to free
3556+software only, so we use the Lesser General Public License.
3557+
3558+ In other cases, permission to use a particular library in non-free
3559+programs enables a greater number of people to use a large body of
3560+free software. For example, permission to use the GNU C Library in
3561+non-free programs enables many more people to use the whole GNU
3562+operating system, as well as its variant, the GNU/Linux operating
3563+system.
3564+
3565+ Although the Lesser General Public License is Less protective of the
3566+users' freedom, it does ensure that the user of a program that is
3567+linked with the Library has the freedom and the wherewithal to run
3568+that program using a modified version of the Library.
3569+
3570+ The precise terms and conditions for copying, distribution and
3571+modification follow. Pay close attention to the difference between a
3572+"work based on the library" and a "work that uses the library". The
3573+former contains code derived from the library, whereas the latter must
3574+be combined with the library in order to run.
3575+
3576
3577+ GNU LESSER GENERAL PUBLIC LICENSE
3578+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
3579+
3580+ 0. This License Agreement applies to any software library or other
3581+program which contains a notice placed by the copyright holder or
3582+other authorized party saying it may be distributed under the terms of
3583+this Lesser General Public License (also called "this License").
3584+Each licensee is addressed as "you".
3585+
3586+ A "library" means a collection of software functions and/or data
3587+prepared so as to be conveniently linked with application programs
3588+(which use some of those functions and data) to form executables.
3589+
3590+ The "Library", below, refers to any such software library or work
3591+which has been distributed under these terms. A "work based on the
3592+Library" means either the Library or any derivative work under
3593+copyright law: that is to say, a work containing the Library or a
3594+portion of it, either verbatim or with modifications and/or translated
3595+straightforwardly into another language. (Hereinafter, translation is
3596+included without limitation in the term "modification".)
3597+
3598+ "Source code" for a work means the preferred form of the work for
3599+making modifications to it. For a library, complete source code means
3600+all the source code for all modules it contains, plus any associated
3601+interface definition files, plus the scripts used to control compilation
3602+and installation of the library.
3603+
3604+ Activities other than copying, distribution and modification are not
3605+covered by this License; they are outside its scope. The act of
3606+running a program using the Library is not restricted, and output from
3607+such a program is covered only if its contents constitute a work based
3608+on the Library (independent of the use of the Library in a tool for
3609+writing it). Whether that is true depends on what the Library does
3610+and what the program that uses the Library does.
3611+
3612+ 1. You may copy and distribute verbatim copies of the Library's
3613+complete source code as you receive it, in any medium, provided that
3614+you conspicuously and appropriately publish on each copy an
3615+appropriate copyright notice and disclaimer of warranty; keep intact
3616+all the notices that refer to this License and to the absence of any
3617+warranty; and distribute a copy of this License along with the
3618+Library.
3619+
3620+ You may charge a fee for the physical act of transferring a copy,
3621+and you may at your option offer warranty protection in exchange for a
3622+fee.
3623+
3624
3625+ 2. You may modify your copy or copies of the Library or any portion
3626+of it, thus forming a work based on the Library, and copy and
3627+distribute such modifications or work under the terms of Section 1
3628+above, provided that you also meet all of these conditions:
3629+
3630+ a) The modified work must itself be a software library.
3631+
3632+ b) You must cause the files modified to carry prominent notices
3633+ stating that you changed the files and the date of any change.
3634+
3635+ c) You must cause the whole of the work to be licensed at no
3636+ charge to all third parties under the terms of this License.
3637+
3638+ d) If a facility in the modified Library refers to a function or a
3639+ table of data to be supplied by an application program that uses
3640+ the facility, other than as an argument passed when the facility
3641+ is invoked, then you must make a good faith effort to ensure that,
3642+ in the event an application does not supply such function or
3643+ table, the facility still operates, and performs whatever part of
3644+ its purpose remains meaningful.
3645+
3646+ (For example, a function in a library to compute square roots has
3647+ a purpose that is entirely well-defined independent of the
3648+ application. Therefore, Subsection 2d requires that any
3649+ application-supplied function or table used by this function must
3650+ be optional: if the application does not supply it, the square
3651+ root function must still compute square roots.)
3652+
3653+These requirements apply to the modified work as a whole. If
3654+identifiable sections of that work are not derived from the Library,
3655+and can be reasonably considered independent and separate works in
3656+themselves, then this License, and its terms, do not apply to those
3657+sections when you distribute them as separate works. But when you
3658+distribute the same sections as part of a whole which is a work based
3659+on the Library, the distribution of the whole must be on the terms of
3660+this License, whose permissions for other licensees extend to the
3661+entire whole, and thus to each and every part regardless of who wrote
3662+it.
3663+
3664+Thus, it is not the intent of this section to claim rights or contest
3665+your rights to work written entirely by you; rather, the intent is to
3666+exercise the right to control the distribution of derivative or
3667+collective works based on the Library.
3668+
3669+In addition, mere aggregation of another work not based on the Library
3670+with the Library (or with a work based on the Library) on a volume of
3671+a storage or distribution medium does not bring the other work under
3672+the scope of this License.
3673+
3674+ 3. You may opt to apply the terms of the ordinary GNU General Public
3675+License instead of this License to a given copy of the Library. To do
3676+this, you must alter all the notices that refer to this License, so
3677+that they refer to the ordinary GNU General Public License, version 2,
3678+instead of to this License. (If a newer version than version 2 of the
3679+ordinary GNU General Public License has appeared, then you can specify
3680+that version instead if you wish.) Do not make any other change in
3681+these notices.
3682+
3683
3684+ Once this change is made in a given copy, it is irreversible for
3685+that copy, so the ordinary GNU General Public License applies to all
3686+subsequent copies and derivative works made from that copy.
3687+
3688+ This option is useful when you wish to copy part of the code of
3689+the Library into a program that is not a library.
3690+
3691+ 4. You may copy and distribute the Library (or a portion or
3692+derivative of it, under Section 2) in object code or executable form
3693+under the terms of Sections 1 and 2 above provided that you accompany
3694+it with the complete corresponding machine-readable source code, which
3695+must be distributed under the terms of Sections 1 and 2 above on a
3696+medium customarily used for software interchange.
3697+
3698+ If distribution of object code is made by offering access to copy
3699+from a designated place, then offering equivalent access to copy the
3700+source code from the same place satisfies the requirement to
3701+distribute the source code, even though third parties are not
3702+compelled to copy the source along with the object code.
3703+
3704+ 5. A program that contains no derivative of any portion of the
3705+Library, but is designed to work with the Library by being compiled or
3706+linked with it, is called a "work that uses the Library". Such a
3707+work, in isolation, is not a derivative work of the Library, and
3708+therefore falls outside the scope of this License.
3709+
3710+ However, linking a "work that uses the Library" with the Library
3711+creates an executable that is a derivative of the Library (because it
3712+contains portions of the Library), rather than a "work that uses the
3713+library". The executable is therefore covered by this License.
3714+Section 6 states terms for distribution of such executables.
3715+
3716+ When a "work that uses the Library" uses material from a header file
3717+that is part of the Library, the object code for the work may be a
3718+derivative work of the Library even though the source code is not.
3719+Whether this is true is especially significant if the work can be
3720+linked without the Library, or if the work is itself a library. The
3721+threshold for this to be true is not precisely defined by law.
3722+
3723+ If such an object file uses only numerical parameters, data
3724+structure layouts and accessors, and small macros and small inline
3725+functions (ten lines or less in length), then the use of the object
3726+file is unrestricted, regardless of whether it is legally a derivative
3727+work. (Executables containing this object code plus portions of the
3728+Library will still fall under Section 6.)
3729+
3730+ Otherwise, if the work is a derivative of the Library, you may
3731+distribute the object code for the work under the terms of Section 6.
3732+Any executables containing that work also fall under Section 6,
3733+whether or not they are linked directly with the Library itself.
3734+
3735
3736+ 6. As an exception to the Sections above, you may also combine or
3737+link a "work that uses the Library" with the Library to produce a
3738+work containing portions of the Library, and distribute that work
3739+under terms of your choice, provided that the terms permit
3740+modification of the work for the customer's own use and reverse
3741+engineering for debugging such modifications.
3742+
3743+ You must give prominent notice with each copy of the work that the
3744+Library is used in it and that the Library and its use are covered by
3745+this License. You must supply a copy of this License. If the work
3746+during execution displays copyright notices, you must include the
3747+copyright notice for the Library among them, as well as a reference
3748+directing the user to the copy of this License. Also, you must do one
3749+of these things:
3750+
3751+ a) Accompany the work with the complete corresponding
3752+ machine-readable source code for the Library including whatever
3753+ changes were used in the work (which must be distributed under
3754+ Sections 1 and 2 above); and, if the work is an executable linked
3755+ with the Library, with the complete machine-readable "work that
3756+ uses the Library", as object code and/or source code, so that the
3757+ user can modify the Library and then relink to produce a modified
3758+ executable containing the modified Library. (It is understood
3759+ that the user who changes the contents of definitions files in the
3760+ Library will not necessarily be able to recompile the application
3761+ to use the modified definitions.)
3762+
3763+ b) Use a suitable shared library mechanism for linking with the
3764+ Library. A suitable mechanism is one that (1) uses at run time a
3765+ copy of the library already present on the user's computer system,
3766+ rather than copying library functions into the executable, and (2)
3767+ will operate properly with a modified version of the library, if
3768+ the user installs one, as long as the modified version is
3769+ interface-compatible with the version that the work was made with.
3770+
3771+ c) Accompany the work with a written offer, valid for at
3772+ least three years, to give the same user the materials
3773+ specified in Subsection 6a, above, for a charge no more
3774+ than the cost of performing this distribution.
3775+
3776+ d) If distribution of the work is made by offering access to copy
3777+ from a designated place, offer equivalent access to copy the above
3778+ specified materials from the same place.
3779+
3780+ e) Verify that the user has already received a copy of these
3781+ materials or that you have already sent this user a copy.
3782+
3783+ For an executable, the required form of the "work that uses the
3784+Library" must include any data and utility programs needed for
3785+reproducing the executable from it. However, as a special exception,
3786+the materials to be distributed need not include anything that is
3787+normally distributed (in either source or binary form) with the major
3788+components (compiler, kernel, and so on) of the operating system on
3789+which the executable runs, unless that component itself accompanies
3790+the executable.
3791+
3792+ It may happen that this requirement contradicts the license
3793+restrictions of other proprietary libraries that do not normally
3794+accompany the operating system. Such a contradiction means you cannot
3795+use both them and the Library together in an executable that you
3796+distribute.
3797+
3798
3799+ 7. You may place library facilities that are a work based on the
3800+Library side-by-side in a single library together with other library
3801+facilities not covered by this License, and distribute such a combined
3802+library, provided that the separate distribution of the work based on
3803+the Library and of the other library facilities is otherwise
3804+permitted, and provided that you do these two things:
3805+
3806+ a) Accompany the combined library with a copy of the same work
3807+ based on the Library, uncombined with any other library
3808+ facilities. This must be distributed under the terms of the
3809+ Sections above.
3810+
3811+ b) Give prominent notice with the combined library of the fact
3812+ that part of it is a work based on the Library, and explaining
3813+ where to find the accompanying uncombined form of the same work.
3814+
3815+ 8. You may not copy, modify, sublicense, link with, or distribute
3816+the Library except as expressly provided under this License. Any
3817+attempt otherwise to copy, modify, sublicense, link with, or
3818+distribute the Library is void, and will automatically terminate your
3819+rights under this License. However, parties who have received copies,
3820+or rights, from you under this License will not have their licenses
3821+terminated so long as such parties remain in full compliance.
3822+
3823+ 9. You are not required to accept this License, since you have not
3824+signed it. However, nothing else grants you permission to modify or
3825+distribute the Library or its derivative works. These actions are
3826+prohibited by law if you do not accept this License. Therefore, by
3827+modifying or distributing the Library (or any work based on the
3828+Library), you indicate your acceptance of this License to do so, and
3829+all its terms and conditions for copying, distributing or modifying
3830+the Library or works based on it.
3831+
3832+ 10. Each time you redistribute the Library (or any work based on the
3833+Library), the recipient automatically receives a license from the
3834+original licensor to copy, distribute, link with or modify the Library
3835+subject to these terms and conditions. You may not impose any further
3836+restrictions on the recipients' exercise of the rights granted herein.
3837+You are not responsible for enforcing compliance by third parties with
3838+this License.
3839+
3840
3841+ 11. If, as a consequence of a court judgment or allegation of patent
3842+infringement or for any other reason (not limited to patent issues),
3843+conditions are imposed on you (whether by court order, agreement or
3844+otherwise) that contradict the conditions of this License, they do not
3845+excuse you from the conditions of this License. If you cannot
3846+distribute so as to satisfy simultaneously your obligations under this
3847+License and any other pertinent obligations, then as a consequence you
3848+may not distribute the Library at all. For example, if a patent
3849+license would not permit royalty-free redistribution of the Library by
3850+all those who receive copies directly or indirectly through you, then
3851+the only way you could satisfy both it and this License would be to
3852+refrain entirely from distribution of the Library.
3853+
3854+If any portion of this section is held invalid or unenforceable under any
3855+particular circumstance, the balance of the section is intended to apply,
3856+and the section as a whole is intended to apply in other circumstances.
3857+
3858+It is not the purpose of this section to induce you to infringe any
3859+patents or other property right claims or to contest validity of any
3860+such claims; this section has the sole purpose of protecting the
3861+integrity of the free software distribution system which is
3862+implemented by public license practices. Many people have made
3863+generous contributions to the wide range of software distributed
3864+through that system in reliance on consistent application of that
3865+system; it is up to the author/donor to decide if he or she is willing
3866+to distribute software through any other system and a licensee cannot
3867+impose that choice.
3868+
3869+This section is intended to make thoroughly clear what is believed to
3870+be a consequence of the rest of this License.
3871+
3872+ 12. If the distribution and/or use of the Library is restricted in
3873+certain countries either by patents or by copyrighted interfaces, the
3874+original copyright holder who places the Library under this License may add
3875+an explicit geographical distribution limitation excluding those countries,
3876+so that distribution is permitted only in or among countries not thus
3877+excluded. In such case, this License incorporates the limitation as if
3878+written in the body of this License.
3879+
3880+ 13. The Free Software Foundation may publish revised and/or new
3881+versions of the Lesser General Public License from time to time.
3882+Such new versions will be similar in spirit to the present version,
3883+but may differ in detail to address new problems or concerns.
3884+
3885+Each version is given a distinguishing version number. If the Library
3886+specifies a version number of this License which applies to it and
3887+"any later version", you have the option of following the terms and
3888+conditions either of that version or of any later version published by
3889+the Free Software Foundation. If the Library does not specify a
3890+license version number, you may choose any version ever published by
3891+the Free Software Foundation.
3892+
3893
3894+ 14. If you wish to incorporate parts of the Library into other free
3895+programs whose distribution conditions are incompatible with these,
3896+write to the author to ask for permission. For software which is
3897+copyrighted by the Free Software Foundation, write to the Free
3898+Software Foundation; we sometimes make exceptions for this. Our
3899+decision will be guided by the two goals of preserving the free status
3900+of all derivatives of our free software and of promoting the sharing
3901+and reuse of software generally.
3902+
3903+ NO WARRANTY
3904+
3905+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
3906+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
3907+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
3908+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
3909+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
3910+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3911+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
3912+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
3913+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
3914+
3915+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
3916+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
3917+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
3918+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
3919+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
3920+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
3921+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
3922+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
3923+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
3924+DAMAGES.
3925+
3926+ END OF TERMS AND CONDITIONS
3927+
3928
3929+ How to Apply These Terms to Your New Libraries
3930+
3931+ If you develop a new library, and you want it to be of the greatest
3932+possible use to the public, we recommend making it free software that
3933+everyone can redistribute and change. You can do so by permitting
3934+redistribution under these terms (or, alternatively, under the terms of the
3935+ordinary General Public License).
3936+
3937+ To apply these terms, attach the following notices to the library. It is
3938+safest to attach them to the start of each source file to most effectively
3939+convey the exclusion of warranty; and each file should have at least the
3940+"copyright" line and a pointer to where the full notice is found.
3941+
3942+ <one line to give the library's name and a brief idea of what it does.>
3943+ Copyright (C) <year> <name of author>
3944+
3945+ This library is free software; you can redistribute it and/or
3946+ modify it under the terms of the GNU Lesser General Public
3947+ License as published by the Free Software Foundation; either
3948+ version 2.1 of the License, or (at your option) any later version.
3949+
3950+ This library is distributed in the hope that it will be useful,
3951+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3952+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3953+ Lesser General Public License for more details.
3954+
3955+ You should have received a copy of the GNU Lesser General Public
3956+ License along with this library; if not, write to the Free Software
3957+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3958+
3959+Also add information on how to contact you by electronic and paper mail.
3960+
3961+You should also get your employer (if you work as a programmer) or your
3962+school, if any, to sign a "copyright disclaimer" for the library, if
3963+necessary. Here is a sample; alter the names:
3964+
3965+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
3966+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
3967+
3968+ <signature of Ty Coon>, 1 April 1990
3969+ Ty Coon, President of Vice
3970+
3971+That's all there is to it!
3972+
3973
3974=== added file 'LICENSE.txt'
3975--- LICENSE.txt 1970-01-01 00:00:00 +0000
3976+++ LICENSE.txt 2013-08-24 09:38:26 +0000
3977@@ -0,0 +1,54 @@
3978+Copyright (c) 2009-2012 Roger Light <roger@atchoo.org>
3979+All rights reserved.
3980+
3981+Redistribution and use in source and binary forms, with or without
3982+modification, are permitted provided that the following conditions are met:
3983+
3984+1. Redistributions of source code must retain the above copyright notice,
3985+ this list of conditions and the following disclaimer.
3986+2. Redistributions in binary form must reproduce the above copyright
3987+ notice, this list of conditions and the following disclaimer in the
3988+ documentation and/or other materials provided with the distribution.
3989+3. Neither the name of mosquitto nor the names of its
3990+ contributors may be used to endorse or promote products derived from
3991+ this software without specific prior written permission.
3992+
3993+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3994+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3995+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3996+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
3997+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3998+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3999+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4000+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4001+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4002+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4003+POSSIBILITY OF SUCH DAMAGE.
4004+
4005+
4006+
4007+
4008+
4009+uthash.h license:
4010+
4011+Copyright (c) 2005-2010, Troy D. Hanson http://uthash.sourceforge.net
4012+All rights reserved.
4013+
4014+Redistribution and use in source and binary forms, with or without
4015+modification, are permitted provided that the following conditions are met:
4016+
4017+ * Redistributions of source code must retain the above copyright
4018+ notice, this list of conditions and the following disclaimer.
4019+
4020+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
4021+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
4022+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
4023+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
4024+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
4025+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
4026+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
4027+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
4028+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
4029+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
4030+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4031+
4032
4033=== modified file 'Makefile'
4034--- Makefile 2012-02-07 23:21:39 +0000
4035+++ Makefile 2013-08-24 09:38:26 +0000
4036@@ -1,53 +1,62 @@
4037 include config.mk
4038
4039-DIRS=lib client src man
4040+DIRS=lib client src
4041+DOCDIRS=man
4042 DISTDIRS=man
4043
4044-.PHONY : all mosquitto clean reallyclean install uninstall dist sign copy
4045-
4046-all : mosquitto
4047+.PHONY : all mosquitto docs binary clean reallyclean test install uninstall dist sign copy
4048+
4049+all : mosquitto docs
4050+
4051+docs :
4052+ set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d}; done
4053+
4054+binary : mosquitto
4055
4056 mosquitto :
4057- for d in ${DIRS}; do $(MAKE) -C $${d}; done
4058+ set -e; for d in ${DIRS}; do $(MAKE) -C $${d}; done
4059
4060 clean :
4061- for d in ${DIRS}; do $(MAKE) -C $${d} clean; done
4062+ set -e; for d in ${DIRS}; do $(MAKE) -C $${d} clean; done
4063+ set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d} clean; done
4064+ $(MAKE) -C test clean
4065
4066 reallyclean :
4067- for d in ${DIRS}; do $(MAKE) -C $${d} reallyclean; done
4068+ set -e; for d in ${DIRS}; do $(MAKE) -C $${d} reallyclean; done
4069+ set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d} reallyclean; done
4070+ $(MAKE) -C test reallyclean
4071 -rm -f *.orig
4072
4073+test : mosquitto
4074+ $(MAKE) -C test test
4075+
4076 install : mosquitto
4077- @for d in ${DIRS}; do $(MAKE) -C $${d} install; done
4078+ set -e; for d in ${DIRS}; do $(MAKE) -C $${d} install; done
4079+ set -e; for d in ${DOCDIRS}; do $(MAKE) -C $${d} install; done
4080 $(INSTALL) -d ${DESTDIR}/etc/mosquitto
4081- $(INSTALL) -m 644 mosquitto.conf ${DESTDIR}/etc/mosquitto/mosquitto.conf
4082+ $(INSTALL) -m 644 mosquitto.conf ${DESTDIR}/etc/mosquitto/mosquitto.conf.example
4083 $(INSTALL) -m 644 aclfile.example ${DESTDIR}/etc/mosquitto/aclfile.example
4084 $(INSTALL) -m 644 pwfile.example ${DESTDIR}/etc/mosquitto/pwfile.example
4085- $(INSTALL) -d ${DESTDIR}/etc/apparmor.d
4086- $(INSTALL) -m 644 security/mosquitto.apparmor ${DESTDIR}/etc/apparmor.d/usr.sbin.mosquitto
4087+ $(INSTALL) -m 644 pskfile.example ${DESTDIR}/etc/mosquitto/pskfile.example
4088
4089 uninstall :
4090- @for d in ${DIRS}; do $(MAKE) -C $${d} uninstall; done
4091+ set -e; for d in ${DIRS}; do $(MAKE) -C $${d} uninstall; done
4092+ rm -f ${DESTDIR}/etc/mosquitto/mosquitto.conf
4093+ rm -f ${DESTDIR}/etc/mosquitto/aclfile.example
4094+ rm -f ${DESTDIR}/etc/mosquitto/pwfile.example
4095+ rm -f ${DESTDIR}/etc/mosquitto/pskfile.example
4096
4097 dist : reallyclean
4098- @for d in ${DISTDIRS}; do $(MAKE) -C $${d} dist; done
4099+ set -e; for d in ${DISTDIRS}; do $(MAKE) -C $${d} dist; done
4100
4101+ echo $(hg log -r . --template "{node}") > changeset
4102 mkdir -p dist/mosquitto-${VERSION}
4103- cp -r client installer lib logo man misc security service src ChangeLog.txt CMakeLists.txt COPYING Makefile compiling.txt config.h config.mk external_security_checks.txt readme.txt readme-windows.txt mosquitto.conf aclfile.example pwfile.example dist/mosquitto-${VERSION}/
4104+ cp -r client changeset examples installer lib logo man misc security service src test ChangeLog.txt CMakeLists.txt LICENSE.txt LICENSE-3rd-party.txt Makefile compiling.txt config.h config.mk readme.txt readme-windows.txt mosquitto.conf aclfile.example pskfile.example pwfile.example dist/mosquitto-${VERSION}/
4105 cd dist; tar -zcf mosquitto-${VERSION}.tar.gz mosquitto-${VERSION}/
4106- for m in libmosquitto.3 mosquitto.8 mosquitto.conf.5 mosquitto_pub.1 mosquitto_sub.1 mqtt.7; \
4107+ set -e; for m in man/*.xml; \
4108 do \
4109- hfile=$$(echo $${m} | sed -e 's/\./-/g'); \
4110- man2html man/$${m} > dist/$${hfile}.html; \
4111- sed -i 's#http://localhost/cgi-bin/man/man2html?8+mosquitto#mosquitto-8.html#' dist/$${hfile}.html; \
4112- sed -i 's#http://localhost/cgi-bin/man/man2html?3+libmosquitto#libmosquitto-3.html#' dist/$${hfile}.html; \
4113- sed -i 's#http://localhost/cgi-bin/man/man2html?5+mosquitto.conf#mosquitto-conf-5.html#' dist/$${hfile}.html; \
4114- sed -i 's#http://localhost/cgi-bin/man/man2html?1+mosquitto_pub#mosquitto_pub-1.html#' dist/$${hfile}.html; \
4115- sed -i 's#http://localhost/cgi-bin/man/man2html?1+mosquitto_sub#mosquitto_sub-1.html#' dist/$${hfile}.html; \
4116- sed -i 's#http://localhost/cgi-bin/man/man2html?7+mqtt#mqtt-7.html#' dist/$${hfile}.html; \
4117- sed -i 's#http://localhost/cgi-bin/man/man2html?5+hosts_access#http://www.linuxmanpages.com/man5/hosts_access.5.php#' dist/$${hfile}.html; \
4118- sed -i 's#http://localhost/cgi-bin/man/man2html#http://mosquitto.org/#' dist/$${hfile}.html; \
4119- sed -i '1,2d' dist/$${hfile}.html; \
4120+ hfile=$$(echo $${m} | sed -e 's#man/\(.*\)\.xml#\1#' | sed -e 's/\./-/g'); \
4121+ $(XSLTPROC) $(DB_HTML_XSL) $${m} > dist/$${hfile}.html; \
4122 done
4123
4124
4125@@ -55,7 +64,7 @@
4126 cd dist; gpg --detach-sign -a mosquitto-${VERSION}.tar.gz
4127
4128 copy : sign
4129- cd dist; scp mosquitto-${VERSION}.tar.gz mosquitto-${VERSION}.tar.gz.asc mosquitto:mosquitto.org/files/source/
4130- cd dist; scp *.html mosquitto:mosquitto.org/man/
4131- scp ChangeLog.txt mosquitto:mosquitto.org/
4132+ cd dist; scp mosquitto-${VERSION}.tar.gz mosquitto-${VERSION}.tar.gz.asc mosquitto:site/mosquitto.org/files/source/
4133+ cd dist; scp *.html mosquitto:site/mosquitto.org/man/
4134+ scp ChangeLog.txt mosquitto:site/mosquitto.org/
4135
4136
4137=== modified file 'aclfile.example'
4138--- aclfile.example 2011-05-01 20:12:51 +0000
4139+++ aclfile.example 2013-08-24 09:38:26 +0000
4140@@ -1,3 +1,9 @@
4141+# This affects access control for clients with no username.
4142 topic read $SYS/#
4143+
4144+# This only affects clients with username "roger".
4145 user roger
4146 topic foo/bar
4147+
4148+# This affects all clients.
4149+pattern write $SYS/broker/connection/%c/state
4150
4151=== added file 'changeset'
4152--- changeset 1970-01-01 00:00:00 +0000
4153+++ changeset 2013-08-24 09:38:26 +0000
4154@@ -0,0 +1,1 @@
4155+
4156
4157=== modified file 'client/Makefile'
4158--- client/Makefile 2011-07-25 22:24:52 +0000
4159+++ client/Makefile 2013-08-24 09:38:26 +0000
4160@@ -1,20 +1,22 @@
4161-CC=cc
4162-CFLAGS=-I../lib -Wall -ggdb
4163-LDFLAGS=-L../lib ../lib/libmosquitto.so.0
4164-INSTALL=install
4165-prefix=/usr
4166+include ../config.mk
4167
4168-.PHONY: all install uninstall clean
4169+.PHONY: all install uninstall reallyclean clean
4170
4171 all : mosquitto_pub mosquitto_sub
4172
4173-mosquitto_pub : pub_client.o ../lib/libmosquitto.so.0
4174- ${CC} $< -o $@ ${LDFLAGS}
4175-
4176-mosquitto_sub : sub_client.o ../lib/libmosquitto.so.0
4177- ${CC} $< -o $@ ${LDFLAGS}
4178-
4179-../lib/libmosquitto.so.0 :
4180+mosquitto_pub : pub_client.o ../lib/libmosquitto.so.${SOVERSION}
4181+ ${CC} $< -o $@ ${CLIENT_LDFLAGS}
4182+
4183+mosquitto_sub : sub_client.o ../lib/libmosquitto.so.${SOVERSION}
4184+ ${CC} $< -o $@ ${CLIENT_LDFLAGS}
4185+
4186+pub_client.o : pub_client.c ../lib/libmosquitto.so.${SOVERSION}
4187+ ${CC} -c $< -o $@ ${CLIENT_CFLAGS}
4188+
4189+sub_client.o : sub_client.c ../lib/libmosquitto.so.${SOVERSION}
4190+ ${CC} -c $< -o $@ ${CLIENT_CFLAGS}
4191+
4192+../lib/libmosquitto.so.${SOVERSION} :
4193 $(MAKE) -C ../lib
4194
4195 install : all
4196@@ -26,5 +28,7 @@
4197 -rm -f ${DESTDIR}${prefix}/bin/mosquitto_pub
4198 -rm -f ${DESTDIR}${prefix}/bin/mosquitto_sub
4199
4200+reallyclean : clean
4201+
4202 clean :
4203 -rm -f *.o mosquitto_pub mosquitto_sub
4204
4205=== modified file 'client/pub_client.c'
4206--- client/pub_client.c 2012-02-07 23:21:39 +0000
4207+++ client/pub_client.c 2013-08-24 09:38:26 +0000
4208@@ -1,5 +1,5 @@
4209 /*
4210-Copyright (c) 2009-2012 Roger Light <roger@atchoo.org>
4211+Copyright (c) 2009-2013 Roger Light <roger@atchoo.org>
4212 All rights reserved.
4213
4214 Redistribution and use in source and binary forms, with or without
4215@@ -52,7 +52,10 @@
4216
4217 #define STATUS_CONNECTING 0
4218 #define STATUS_CONNACK_RECVD 1
4219+#define STATUS_WAITING 2
4220
4221+/* Global variables for use in callbacks. See sub_client.c for an example of
4222+ * using a struct to hold variables for use in callbacks. */
4223 static char *topic = NULL;
4224 static char *message = NULL;
4225 static long msglen = 0;
4226@@ -60,16 +63,16 @@
4227 static int retain = 0;
4228 static int mode = MSGMODE_NONE;
4229 static int status = STATUS_CONNECTING;
4230-static uint16_t mid_sent = 0;
4231+static int mid_sent = 0;
4232+static int last_mid = -1;
4233 static bool connected = true;
4234 static char *username = NULL;
4235 static char *password = NULL;
4236 static bool disconnect_sent = false;
4237 static bool quiet = false;
4238
4239-void my_connect_callback(void *obj, int result)
4240+void my_connect_callback(struct mosquitto *mosq, void *obj, int result)
4241 {
4242- struct mosquitto *mosq = obj;
4243 int rc = MOSQ_ERR_SUCCESS;
4244
4245 if(!result){
4246@@ -77,7 +80,7 @@
4247 case MSGMODE_CMD:
4248 case MSGMODE_FILE:
4249 case MSGMODE_STDIN_FILE:
4250- rc = mosquitto_publish(mosq, &mid_sent, topic, msglen, (uint8_t *)message, qos, retain);
4251+ rc = mosquitto_publish(mosq, &mid_sent, topic, msglen, message, qos, retain);
4252 break;
4253 case MSGMODE_NULL:
4254 rc = mosquitto_publish(mosq, &mid_sent, topic, 0, NULL, qos, retain);
4255@@ -109,44 +112,35 @@
4256 mosquitto_disconnect(mosq);
4257 }
4258 }else{
4259- switch(result){
4260- case 1:
4261- if(!quiet) fprintf(stderr, "Connection Refused: unacceptable protocol version\n");
4262- break;
4263- case 2:
4264- if(!quiet) fprintf(stderr, "Connection Refused: identifier rejected\n");
4265- break;
4266- case 3:
4267- if(!quiet) fprintf(stderr, "Connection Refused: broker unavailable\n");
4268- break;
4269- case 4:
4270- if(!quiet) fprintf(stderr, "Connection Refused: bad user name or password\n");
4271- break;
4272- case 5:
4273- if(!quiet) fprintf(stderr, "Connection Refused: not authorised\n");
4274- break;
4275- default:
4276- if(!quiet) fprintf(stderr, "Connection Refused: unknown reason\n");
4277- break;
4278+ if(result && !quiet){
4279+ fprintf(stderr, "%s\n", mosquitto_connack_string(result));
4280 }
4281 }
4282 }
4283
4284-void my_disconnect_callback(void *obj)
4285+void my_disconnect_callback(struct mosquitto *mosq, void *obj, int rc)
4286 {
4287 connected = false;
4288 }
4289
4290-void my_publish_callback(void *obj, uint16_t mid)
4291+void my_publish_callback(struct mosquitto *mosq, void *obj, int mid)
4292 {
4293- struct mosquitto *mosq = obj;
4294-
4295- if(mode != MSGMODE_STDIN_LINE && disconnect_sent == false){
4296+ if(mode == MSGMODE_STDIN_LINE){
4297+ if(mid == last_mid){
4298+ mosquitto_disconnect(mosq);
4299+ disconnect_sent = true;
4300+ }
4301+ }else if(disconnect_sent == false){
4302 mosquitto_disconnect(mosq);
4303 disconnect_sent = true;
4304 }
4305 }
4306
4307+void my_log_callback(struct mosquitto *mosq, void *obj, int level, const char *str)
4308+{
4309+ printf("%s\n", str);
4310+}
4311+
4312 int load_stdin(void)
4313 {
4314 long pos = 0, rlen;
4315@@ -215,12 +209,27 @@
4316
4317 void print_usage(void)
4318 {
4319- printf("mosquitto_pub is a simple mqtt client that will publish a message on a single topic and exit.\n\n");
4320+ int major, minor, revision;
4321+
4322+ mosquitto_lib_version(&major, &minor, &revision);
4323+ printf("mosquitto_pub is a simple mqtt client that will publish a message on a single topic and exit.\n");
4324+ printf("mosquitto_pub version %s running on libmosquitto %d.%d.%d.\n\n", VERSION, major, minor, revision);
4325 printf("Usage: mosquitto_pub [-h host] [-p port] [-q qos] [-r] {-f file | -l | -n | -m message} -t topic\n");
4326+ printf(" [-A bind_address]\n");
4327 printf(" [-i id] [-I id_prefix]\n");
4328 printf(" [-d] [--quiet]\n");
4329+ printf(" [-M max_inflight]\n");
4330 printf(" [-u username [-P password]]\n");
4331- printf(" [--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]\n\n");
4332+ printf(" [--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]\n");
4333+#ifdef WITH_TLS
4334+ printf(" [{--cafile file | --capath dir} [--cert file] [--key file] [--insecure]]\n");
4335+#ifdef WITH_TLS_PSK
4336+ printf(" [--psk hex-key --psk-identity identity]\n");
4337+#endif
4338+#endif
4339+ printf(" mosquitto_pub --help\n\n");
4340+ printf(" -A : bind the outgoing socket to this host/ip address. Use to control which interface\n");
4341+ printf(" the client communicates over.\n");
4342 printf(" -d : enable debug messages.\n");
4343 printf(" -f : send the contents of a file as the message.\n");
4344 printf(" -h : mqtt host to connect to. Defaults to localhost.\n");
4345@@ -229,6 +238,7 @@
4346 printf(" broker is using the clientid_prefixes option.\n");
4347 printf(" -l : read messages from stdin, sending a separate message for each line.\n");
4348 printf(" -m : message payload to send.\n");
4349+ printf(" -M : the maximum inflight messages for QoS 1/2..\n");
4350 printf(" -n : send a null (zero length) message.\n");
4351 printf(" -p : network port to connect to. Defaults to 1883.\n");
4352 printf(" -q : quality of service level to use for all messages. Defaults to 0.\n");
4353@@ -237,6 +247,7 @@
4354 printf(" -t : mqtt topic to publish to.\n");
4355 printf(" -u : provide a username (requires MQTT 3.1 broker)\n");
4356 printf(" -P : provide a password (requires MQTT 3.1 broker)\n");
4357+ printf(" --help : display this message.\n");
4358 printf(" --quiet : don't print error messages.\n");
4359 printf(" --will-payload : payload for the client Will, which is sent by the broker in case of\n");
4360 printf(" unexpected disconnection. If not given and will-topic is set, a zero\n");
4361@@ -244,6 +255,24 @@
4362 printf(" --will-qos : QoS level for the client Will.\n");
4363 printf(" --will-retain : if given, make the client Will retained.\n");
4364 printf(" --will-topic : the topic on which to publish the client Will.\n");
4365+#ifdef WITH_TLS
4366+ printf(" --cafile : path to a file containing trusted CA certificates to enable encrypted\n");
4367+ printf(" communication.\n");
4368+ printf(" --capath : path to a directory containing trusted CA certificates to enable encrypted\n");
4369+ printf(" communication.\n");
4370+ printf(" --cert : client certificate for authentication, if required by server.\n");
4371+ printf(" --key : client private key for authentication, if required by server.\n");
4372+ printf(" --tls-version : TLS protocol version, can be one of tlsv1.2 tlsv1.1 or tlsv1.\n");
4373+ printf(" Defaults to tlsv1.2 if available.\n");
4374+ printf(" --insecure : do not check that the server certificate hostname matches the remote\n");
4375+ printf(" hostname. Using this option means that you cannot be sure that the\n");
4376+ printf(" remote host is the server you wish to connect to and so is insecure.\n");
4377+ printf(" Do not use this option in a production environment.\n");
4378+#ifdef WITH_TLS_PSK
4379+ printf(" --psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.\n");
4380+ printf(" --psk-identity : client identity string for TLS-PSK mode.\n");
4381+#endif
4382+#endif
4383 printf("\nSee http://mosquitto.org/ for more information.\n\n");
4384 }
4385
4386@@ -254,22 +283,34 @@
4387 int i;
4388 char *host = "localhost";
4389 int port = 1883;
4390+ char *bind_address = NULL;
4391 int keepalive = 60;
4392- int opt;
4393 char buf[1024];
4394 bool debug = false;
4395 struct mosquitto *mosq = NULL;
4396 int rc;
4397 int rc2;
4398- char hostname[21];
4399+ char hostname[256];
4400 char err[1024];
4401+ int len;
4402+ unsigned int max_inflight = 20;
4403
4404- uint8_t *will_payload = NULL;
4405+ char *will_payload = NULL;
4406 long will_payloadlen = 0;
4407 int will_qos = 0;
4408 bool will_retain = false;
4409 char *will_topic = NULL;
4410
4411+ bool insecure = false;
4412+ char *cafile = NULL;
4413+ char *capath = NULL;
4414+ char *certfile = NULL;
4415+ char *keyfile = NULL;
4416+ char *tls_version = NULL;
4417+
4418+ char *psk = NULL;
4419+ char *psk_identity = NULL;
4420+
4421 for(i=1; i<argc; i++){
4422 if(!strcmp(argv[i], "-p") || !strcmp(argv[i], "--port")){
4423 if(i==argc-1){
4424@@ -285,6 +326,42 @@
4425 }
4426 }
4427 i++;
4428+ }else if(!strcmp(argv[i], "-A")){
4429+ if(i==argc-1){
4430+ fprintf(stderr, "Error: -A argument given but no address specified.\n\n");
4431+ print_usage();
4432+ return 1;
4433+ }else{
4434+ bind_address = argv[i+1];
4435+ }
4436+ i++;
4437+ }else if(!strcmp(argv[i], "--cafile")){
4438+ if(i==argc-1){
4439+ fprintf(stderr, "Error: --cafile argument given but no file specified.\n\n");
4440+ print_usage();
4441+ return 1;
4442+ }else{
4443+ cafile = argv[i+1];
4444+ }
4445+ i++;
4446+ }else if(!strcmp(argv[i], "--capath")){
4447+ if(i==argc-1){
4448+ fprintf(stderr, "Error: --capath argument given but no directory specified.\n\n");
4449+ print_usage();
4450+ return 1;
4451+ }else{
4452+ capath = argv[i+1];
4453+ }
4454+ i++;
4455+ }else if(!strcmp(argv[i], "--cert")){
4456+ if(i==argc-1){
4457+ fprintf(stderr, "Error: --cert argument given but no file specified.\n\n");
4458+ print_usage();
4459+ return 1;
4460+ }else{
4461+ certfile = argv[i+1];
4462+ }
4463+ i++;
4464 }else if(!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")){
4465 debug = true;
4466 }else if(!strcmp(argv[i], "-f") || !strcmp(argv[i], "--file")){
4467@@ -300,6 +377,9 @@
4468 if(load_file(argv[i+1])) return 1;
4469 }
4470 i++;
4471+ }else if(!strcmp(argv[i], "--help")){
4472+ print_usage();
4473+ return 0;
4474 }else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--host")){
4475 if(i==argc-1){
4476 fprintf(stderr, "Error: -h argument given but no host specified.\n\n");
4477@@ -309,6 +389,8 @@
4478 host = argv[i+1];
4479 }
4480 i++;
4481+ }else if(!strcmp(argv[i], "--insecure")){
4482+ insecure = true;
4483 }else if(!strcmp(argv[i], "-i") || !strcmp(argv[i], "--id")){
4484 if(id_prefix){
4485 fprintf(stderr, "Error: -i and -I argument cannot be used together.\n\n");
4486@@ -337,6 +419,15 @@
4487 id_prefix = argv[i+1];
4488 }
4489 i++;
4490+ }else if(!strcmp(argv[i], "--key")){
4491+ if(i==argc-1){
4492+ fprintf(stderr, "Error: --key argument given but no file specified.\n\n");
4493+ print_usage();
4494+ return 1;
4495+ }else{
4496+ keyfile = argv[i+1];
4497+ }
4498+ i++;
4499 }else if(!strcmp(argv[i], "-l") || !strcmp(argv[i], "--stdin-line")){
4500 if(mode != MSGMODE_NONE){
4501 fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
4502@@ -344,13 +435,6 @@
4503 return 1;
4504 }else{
4505 mode = MSGMODE_STDIN_LINE;
4506-#ifndef WIN32
4507- opt = fcntl(fileno(stdin), F_GETFL, 0);
4508- if(opt == -1 || fcntl(fileno(stdin), F_SETFL, opt | O_NONBLOCK) == -1){
4509- fprintf(stderr, "Error: Unable to set stdin to non-blocking.\n");
4510- return 1;
4511- }
4512-#endif
4513 }
4514 }else if(!strcmp(argv[i], "-m") || !strcmp(argv[i], "--message")){
4515 if(mode != MSGMODE_NONE){
4516@@ -367,6 +451,15 @@
4517 mode = MSGMODE_CMD;
4518 }
4519 i++;
4520+ }else if(!strcmp(argv[i], "-M")){
4521+ if(i==argc-1){
4522+ fprintf(stderr, "Error: -M argument given but max_inflight not specified.\n\n");
4523+ print_usage();
4524+ return 1;
4525+ }else{
4526+ max_inflight = atoi(argv[i+1]);
4527+ }
4528+ i++;
4529 }else if(!strcmp(argv[i], "-n") || !strcmp(argv[i], "--null-message")){
4530 if(mode != MSGMODE_NONE){
4531 fprintf(stderr, "Error: Only one type of message can be sent at once.\n\n");
4532@@ -375,6 +468,24 @@
4533 }else{
4534 mode = MSGMODE_NULL;
4535 }
4536+ }else if(!strcmp(argv[i], "--psk")){
4537+ if(i==argc-1){
4538+ fprintf(stderr, "Error: --psk argument given but no key specified.\n\n");
4539+ print_usage();
4540+ return 1;
4541+ }else{
4542+ psk = argv[i+1];
4543+ }
4544+ i++;
4545+ }else if(!strcmp(argv[i], "--psk-identity")){
4546+ if(i==argc-1){
4547+ fprintf(stderr, "Error: --psk-identity argument given but no identity specified.\n\n");
4548+ print_usage();
4549+ return 1;
4550+ }else{
4551+ psk_identity = argv[i+1];
4552+ }
4553+ i++;
4554 }else if(!strcmp(argv[i], "-q") || !strcmp(argv[i], "--qos")){
4555 if(i==argc-1){
4556 fprintf(stderr, "Error: -q argument given but no QoS specified.\n\n");
4557@@ -410,6 +521,15 @@
4558 topic = argv[i+1];
4559 }
4560 i++;
4561+ }else if(!strcmp(argv[i], "--tls-version")){
4562+ if(i==argc-1){
4563+ fprintf(stderr, "Error: --tls-version argument given but no version specified.\n\n");
4564+ print_usage();
4565+ return 1;
4566+ }else{
4567+ tls_version = argv[i+1];
4568+ }
4569+ i++;
4570 }else if(!strcmp(argv[i], "-u") || !strcmp(argv[i], "--username")){
4571 if(i==argc-1){
4572 fprintf(stderr, "Error: -u argument given but no username specified.\n\n");
4573@@ -434,8 +554,8 @@
4574 print_usage();
4575 return 1;
4576 }else{
4577- will_payload = (uint8_t *)argv[i+1];
4578- will_payloadlen = strlen((char *)will_payload);
4579+ will_payload = argv[i+1];
4580+ will_payloadlen = strlen(will_payload);
4581 }
4582 i++;
4583 }else if(!strcmp(argv[i], "--will-qos")){
4584@@ -468,23 +588,6 @@
4585 return 1;
4586 }
4587 }
4588- if(id_prefix){
4589- id = malloc(strlen(id_prefix)+10);
4590- if(!id){
4591- if(!quiet) fprintf(stderr, "Error: Out of memory.\n");
4592- return 1;
4593- }
4594- snprintf(id, strlen(id_prefix)+10, "%s%d", id_prefix, getpid());
4595- }else if(!id){
4596- id = malloc(30);
4597- if(!id){
4598- if(!quiet) fprintf(stderr, "Error: Out of memory.\n");
4599- return 1;
4600- }
4601- memset(hostname, 0, 21);
4602- gethostname(hostname, 20);
4603- snprintf(id, 23, "mosq_pub_%d_%s", getpid(), hostname);
4604- }
4605
4606 if(!topic || mode == MSGMODE_NONE){
4607 fprintf(stderr, "Error: Both topic and message must be supplied.\n");
4608@@ -505,30 +608,100 @@
4609 if(password && !username){
4610 if(!quiet) fprintf(stderr, "Warning: Not using password since username not set.\n");
4611 }
4612+ if((certfile && !keyfile) || (keyfile && !certfile)){
4613+ fprintf(stderr, "Error: Both certfile and keyfile must be provided if one of them is.\n");
4614+ print_usage();
4615+ return 1;
4616+ }
4617+ if((cafile || capath) && psk){
4618+ if(!quiet) fprintf(stderr, "Error: Only one of --psk or --cafile/--capath may be used at once.\n");
4619+ return 1;
4620+ }
4621+ if(psk && !psk_identity){
4622+ if(!quiet) fprintf(stderr, "Error: --psk-identity required if --psk used.\n");
4623+ return 1;
4624+ }
4625+
4626 mosquitto_lib_init();
4627- mosq = mosquitto_new(id, NULL);
4628+
4629+ if(id_prefix){
4630+ id = malloc(strlen(id_prefix)+10);
4631+ if(!id){
4632+ if(!quiet) fprintf(stderr, "Error: Out of memory.\n");
4633+ mosquitto_lib_cleanup();
4634+ return 1;
4635+ }
4636+ snprintf(id, strlen(id_prefix)+10, "%s%d", id_prefix, getpid());
4637+ }else if(!id){
4638+ hostname[0] = '\0';
4639+ gethostname(hostname, 256);
4640+ hostname[255] = '\0';
4641+ len = strlen("mosqpub/-") + 6 + strlen(hostname);
4642+ id = malloc(len);
4643+ if(!id){
4644+ if(!quiet) fprintf(stderr, "Error: Out of memory.\n");
4645+ mosquitto_lib_cleanup();
4646+ return 1;
4647+ }
4648+ snprintf(id, len, "mosqpub/%d-%s", getpid(), hostname);
4649+ if(strlen(id) > MOSQ_MQTT_ID_MAX_LENGTH){
4650+ /* Enforce maximum client id length of 23 characters */
4651+ id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0';
4652+ }
4653+ }
4654+
4655+ mosq = mosquitto_new(id, true, NULL);
4656 if(!mosq){
4657- if(!quiet) fprintf(stderr, "Error: Out of memory.\n");
4658+ switch(errno){
4659+ case ENOMEM:
4660+ if(!quiet) fprintf(stderr, "Error: Out of memory.\n");
4661+ break;
4662+ case EINVAL:
4663+ if(!quiet) fprintf(stderr, "Error: Invalid id.\n");
4664+ break;
4665+ }
4666+ mosquitto_lib_cleanup();
4667 return 1;
4668 }
4669 if(debug){
4670- mosquitto_log_init(mosq, MOSQ_LOG_DEBUG | MOSQ_LOG_ERR | MOSQ_LOG_WARNING
4671- | MOSQ_LOG_NOTICE | MOSQ_LOG_INFO, MOSQ_LOG_STDERR);
4672+ mosquitto_log_callback_set(mosq, my_log_callback);
4673 }
4674- if(will_topic && mosquitto_will_set(mosq, true, will_topic, will_payloadlen, will_payload, will_qos, will_retain)){
4675+ if(will_topic && mosquitto_will_set(mosq, will_topic, will_payloadlen, will_payload, will_qos, will_retain)){
4676 if(!quiet) fprintf(stderr, "Error: Problem setting will.\n");
4677+ mosquitto_lib_cleanup();
4678 return 1;
4679 }
4680 if(username && mosquitto_username_pw_set(mosq, username, password)){
4681 if(!quiet) fprintf(stderr, "Error: Problem setting username and password.\n");
4682- return 1;
4683- }
4684-
4685+ mosquitto_lib_cleanup();
4686+ return 1;
4687+ }
4688+ if((cafile || capath) && mosquitto_tls_set(mosq, cafile, capath, certfile, keyfile, NULL)){
4689+ if(!quiet) fprintf(stderr, "Error: Problem setting TLS options.\n");
4690+ mosquitto_lib_cleanup();
4691+ return 1;
4692+ }
4693+ if(insecure && mosquitto_tls_insecure_set(mosq, true)){
4694+ if(!quiet) fprintf(stderr, "Error: Problem setting TLS insecure option.\n");
4695+ mosquitto_lib_cleanup();
4696+ return 1;
4697+ }
4698+ if(psk && mosquitto_tls_psk_set(mosq, psk, psk_identity, NULL)){
4699+ if(!quiet) fprintf(stderr, "Error: Problem setting TLS-PSK options.\n");
4700+ mosquitto_lib_cleanup();
4701+ return 1;
4702+ }
4703+ if(tls_version && mosquitto_tls_opts_set(mosq, 1, tls_version, NULL)){
4704+ if(!quiet) fprintf(stderr, "Error: Problem setting TLS options.\n");
4705+ mosquitto_lib_cleanup();
4706+ return 1;
4707+ }
4708+ mosquitto_max_inflight_messages_set(mosq, max_inflight);
4709 mosquitto_connect_callback_set(mosq, my_connect_callback);
4710 mosquitto_disconnect_callback_set(mosq, my_disconnect_callback);
4711 mosquitto_publish_callback_set(mosq, my_publish_callback);
4712
4713- rc = mosquitto_connect(mosq, host, port, keepalive, true);
4714+ rc = mosquitto_connect_bind(mosq, host, port, keepalive, bind_address);
4715 if(rc){
4716 if(!quiet){
4717 if(rc == MOSQ_ERR_ERRNO){
4718@@ -542,30 +715,57 @@
4719 fprintf(stderr, "Unable to connect (%d).\n", rc);
4720 }
4721 }
4722+ mosquitto_lib_cleanup();
4723 return rc;
4724 }
4725
4726+ if(mode == MSGMODE_STDIN_LINE){
4727+ mosquitto_loop_start(mosq);
4728+ }
4729+
4730 do{
4731- if(mode == MSGMODE_STDIN_LINE && status == STATUS_CONNACK_RECVD){
4732- if(fgets(buf, 1024, stdin)){
4733- buf[strlen(buf)-1] = '\0';
4734- rc2 = mosquitto_publish(mosq, &mid_sent, topic, strlen(buf), (uint8_t *)buf, qos, retain);
4735- if(rc2){
4736- if(!quiet) fprintf(stderr, "Error: Publish returned %d, disconnecting.\n", rc2);
4737- mosquitto_disconnect(mosq);
4738+ if(mode == MSGMODE_STDIN_LINE){
4739+ if(status == STATUS_CONNACK_RECVD){
4740+ if(fgets(buf, 1024, stdin)){
4741+ buf[strlen(buf)-1] = '\0';
4742+ rc2 = mosquitto_publish(mosq, &mid_sent, topic, strlen(buf), buf, qos, retain);
4743+ if(rc2){
4744+ if(!quiet) fprintf(stderr, "Error: Publish returned %d, disconnecting.\n", rc2);
4745+ mosquitto_disconnect(mosq);
4746+ }
4747+ }else if(feof(stdin)){
4748+ last_mid = mid_sent;
4749+ status = STATUS_WAITING;
4750 }
4751- }else if(feof(stdin) && disconnect_sent == false){
4752- mosquitto_disconnect(mosq);
4753- disconnect_sent = true;
4754+ }else if(status == STATUS_WAITING){
4755+#ifdef WIN32
4756+ Sleep(1000);
4757+#else
4758+ usleep(1000000);
4759+#endif
4760 }
4761+ rc = MOSQ_ERR_SUCCESS;
4762+ }else{
4763+ rc = mosquitto_loop(mosq, -1, 1);
4764 }
4765- rc = mosquitto_loop(mosq, -1);
4766 }while(rc == MOSQ_ERR_SUCCESS && connected);
4767
4768+ if(mode == MSGMODE_STDIN_LINE){
4769+ mosquitto_loop_stop(mosq, false);
4770+ }
4771+
4772 if(message && mode == MSGMODE_FILE){
4773 free(message);
4774 }
4775 mosquitto_destroy(mosq);
4776 mosquitto_lib_cleanup();
4777+
4778+ if(rc){
4779+ if(rc == MOSQ_ERR_ERRNO){
4780+ fprintf(stderr, "Error: %s\n", strerror(errno));
4781+ }else{
4782+ fprintf(stderr, "Error: %s\n", mosquitto_strerror(rc));
4783+ }
4784+ }
4785 return rc;
4786 }
4787
4788=== modified file 'client/sub_client.c'
4789--- client/sub_client.c 2012-02-07 23:21:39 +0000
4790+++ client/sub_client.c 2013-08-24 09:38:26 +0000
4791@@ -1,5 +1,5 @@
4792 /*
4793-Copyright (c) 2009-2012 Roger Light <roger@atchoo.org>
4794+Copyright (c) 2009-2013 Roger Light <roger@atchoo.org>
4795 All rights reserved.
4796
4797 Redistribution and use in source and binary forms, with or without
4798@@ -27,6 +27,7 @@
4799 POSSIBILITY OF SUCH DAMAGE.
4800 */
4801
4802+#include <assert.h>
4803 #include <errno.h>
4804 #include <stdio.h>
4805 #include <stdlib.h>
4806@@ -41,83 +42,105 @@
4807
4808 #include <mosquitto.h>
4809
4810-static char **topics = NULL;
4811-static int topic_count = 0;
4812-static int topic_qos = 0;
4813-static char *username = NULL;
4814-static char *password = NULL;
4815-int verbose = 0;
4816-bool quiet = false;
4817+/* This struct is used to pass data to callbacks.
4818+ * An instance "ud" is created in main() and populated, then passed to
4819+ * mosquitto_new(). */
4820+struct userdata {
4821+ char **topics;
4822+ int topic_count;
4823+ int topic_qos;
4824+ char *username;
4825+ char *password;
4826+ int verbose;
4827+ bool quiet;
4828+ bool no_retain;
4829+};
4830
4831-void my_message_callback(void *obj, const struct mosquitto_message *message)
4832+void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message)
4833 {
4834- if(verbose){
4835+ struct userdata *ud;
4836+
4837+ assert(obj);
4838+ ud = (struct userdata *)obj;
4839+
4840+ if(message->retain && ud->no_retain) return;
4841+
4842+ if(ud->verbose){
4843 if(message->payloadlen){
4844- printf("%s %s\n", message->topic, message->payload);
4845+ printf("%s %s\n", message->topic, (const char *)message->payload);
4846 }else{
4847 printf("%s (null)\n", message->topic);
4848 }
4849 fflush(stdout);
4850 }else{
4851 if(message->payloadlen){
4852- printf("%s\n", message->payload);
4853+ printf("%s\n", (const char *)message->payload);
4854 fflush(stdout);
4855 }
4856 }
4857 }
4858
4859-void my_connect_callback(void *obj, int result)
4860+void my_connect_callback(struct mosquitto *mosq, void *obj, int result)
4861 {
4862- struct mosquitto *mosq = obj;
4863-
4864 int i;
4865+ struct userdata *ud;
4866+
4867+ assert(obj);
4868+ ud = (struct userdata *)obj;
4869+
4870 if(!result){
4871- for(i=0; i<topic_count; i++){
4872- mosquitto_subscribe(mosq, NULL, topics[i], topic_qos);
4873+ for(i=0; i<ud->topic_count; i++){
4874+ mosquitto_subscribe(mosq, NULL, ud->topics[i], ud->topic_qos);
4875 }
4876 }else{
4877- switch(result){
4878- case 1:
4879- if(!quiet) fprintf(stderr, "Connection Refused: unacceptable protocol version\n");
4880- break;
4881- case 2:
4882- if(!quiet) fprintf(stderr, "Connection Refused: identifier rejected\n");
4883- break;
4884- case 3:
4885- if(!quiet) fprintf(stderr, "Connection Refused: broker unavailable\n");
4886- break;
4887- case 4:
4888- if(!quiet) fprintf(stderr, "Connection Refused: bad user name or password\n");
4889- break;
4890- case 5:
4891- if(!quiet) fprintf(stderr, "Connection Refused: not authorised\n");
4892- break;
4893- default:
4894- if(!quiet) fprintf(stderr, "Connection Refused: unknown reason\n");
4895- break;
4896+ if(result && !ud->quiet){
4897+ fprintf(stderr, "%s\n", mosquitto_connack_string(result));
4898 }
4899 }
4900 }
4901
4902-void my_subscribe_callback(void *obj, uint16_t mid, int qos_count, const uint8_t *granted_qos)
4903+void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos)
4904 {
4905 int i;
4906-
4907- if(!quiet) printf("Subscribed (mid: %d): %d", mid, granted_qos[0]);
4908+ struct userdata *ud;
4909+
4910+ assert(obj);
4911+ ud = (struct userdata *)obj;
4912+
4913+ if(!ud->quiet) printf("Subscribed (mid: %d): %d", mid, granted_qos[0]);
4914 for(i=1; i<qos_count; i++){
4915- if(!quiet) printf(", %d", granted_qos[i]);
4916+ if(!ud->quiet) printf(", %d", granted_qos[i]);
4917 }
4918- if(!quiet) printf("\n");
4919+ if(!ud->quiet) printf("\n");
4920+}
4921+
4922+void my_log_callback(struct mosquitto *mosq, void *obj, int level, const char *str)
4923+{
4924+ printf("%s\n", str);
4925 }
4926
4927 void print_usage(void)
4928 {
4929- printf("mosquitto_sub is a simple mqtt client that will subscribe to a single topic and print all messages it receives.\n\n");
4930- printf("Usage: mosquitto_sub [-c] [-h host] [-k keepalive] [-p port] [-q qos] [-v] -t topic ...\n");
4931+ int major, minor, revision;
4932+
4933+ mosquitto_lib_version(&major, &minor, &revision);
4934+ printf("mosquitto_sub is a simple mqtt client that will subscribe to a single topic and print all messages it receives.\n");
4935+ printf("mosquitto_sub version %s running on libmosquitto %d.%d.%d.\n\n", VERSION, major, minor, revision);
4936+ printf("Usage: mosquitto_sub [-c] [-h host] [-k keepalive] [-p port] [-q qos] [-R] [-v] -t topic ...\n");
4937+ printf(" [-A bind_address]\n");
4938 printf(" [-i id] [-I id_prefix]\n");
4939 printf(" [-d] [--quiet]\n");
4940 printf(" [-u username [-P password]]\n");
4941- printf(" [--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]\n\n");
4942+ printf(" [--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]\n");
4943+#ifdef WITH_TLS
4944+ printf(" [{--cafile file | --capath dir} [--cert file] [--key file] [--insecure]]\n");
4945+#ifdef WITH_TLS_PSK
4946+ printf(" [--psk hex-key --psk-identity identity]\n");
4947+#endif
4948+#endif
4949+ printf(" mosquitto_sub --help\n\n");
4950+ printf(" -A : bind the outgoing socket to this host/ip address. Use to control which interface\n");
4951+ printf(" the client communicates over.\n");
4952 printf(" -c : disable 'clean session' (store subscription and pending messages when client disconnects).\n");
4953 printf(" -d : enable debug messages.\n");
4954 printf(" -h : mqtt host to connect to. Defaults to localhost.\n");
4955@@ -127,10 +150,12 @@
4956 printf(" -k : keep alive in seconds for this client. Defaults to 60.\n");
4957 printf(" -p : network port to connect to. Defaults to 1883.\n");
4958 printf(" -q : quality of service level to use for the subscription. Defaults to 0.\n");
4959+ printf(" -R : do not print stale messages (those with retain set).\n");
4960 printf(" -t : mqtt topic to subscribe to. May be repeated multiple times.\n");
4961 printf(" -u : provide a username (requires MQTT 3.1 broker)\n");
4962 printf(" -v : print published messages verbosely.\n");
4963 printf(" -P : provide a password (requires MQTT 3.1 broker)\n");
4964+ printf(" --help : display this message.\n");
4965 printf(" --quiet : don't print error messages.\n");
4966 printf(" --will-payload : payload for the client Will, which is sent by the broker in case of\n");
4967 printf(" unexpected disconnection. If not given and will-topic is set, a zero\n");
4968@@ -138,6 +163,24 @@
4969 printf(" --will-qos : QoS level for the client Will.\n");
4970 printf(" --will-retain : if given, make the client Will retained.\n");
4971 printf(" --will-topic : the topic on which to publish the client Will.\n");
4972+#ifdef WITH_TLS
4973+ printf(" --cafile : path to a file containing trusted CA certificates to enable encrypted\n");
4974+ printf(" certificate based communication.\n");
4975+ printf(" --capath : path to a directory containing trusted CA certificates to enable encrypted\n");
4976+ printf(" communication.\n");
4977+ printf(" --cert : client certificate for authentication, if required by server.\n");
4978+ printf(" --key : client private key for authentication, if required by server.\n");
4979+ printf(" --tls-version : TLS protocol version, can be one of tlsv1.2 tlsv1.1 or tlsv1.\n");
4980+ printf(" Defaults to tlsv1.2 if available.\n");
4981+ printf(" --insecure : do not check that the server certificate hostname matches the remote\n");
4982+ printf(" hostname. Using this option means that you cannot be sure that the\n");
4983+ printf(" remote host is the server you wish to connect to and so is insecure.\n");
4984+ printf(" Do not use this option in a production environment.\n");
4985+#ifdef WITH_TLS_PSK
4986+ printf(" --psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.\n");
4987+ printf(" --psk-identity : client identity string for TLS-PSK mode.\n");
4988+#endif
4989+#endif
4990 printf("\nSee http://mosquitto.org/ for more information.\n\n");
4991 }
4992
4993@@ -148,20 +191,35 @@
4994 int i;
4995 char *host = "localhost";
4996 int port = 1883;
4997+ char *bind_address = NULL;
4998 int keepalive = 60;
4999 bool clean_session = true;
5000 bool debug = false;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: