aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2019-10-09 15:09:16 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2019-10-09 15:09:59 +0200
commitb3a1521e79545ce777729fb02cb8368b564c6fbf (patch)
tree5ec4e5aaab19c0916d3bdacbff7622a3550e20d2
parentba758acb507ca6ff0bd1f5eea29ba81660283882 (diff)
downloadaports-b3a1521e79545ce777729fb02cb8368b564c6fbf.tar.bz2
aports-b3a1521e79545ce777729fb02cb8368b564c6fbf.tar.xz
main/mqtt-exec: let libmosquitto generate client id
-rw-r--r--main/mqtt-exec/0001-Let-library-generate-client-id-when-unset.patch68
-rw-r--r--main/mqtt-exec/APKBUILD4
2 files changed, 71 insertions, 1 deletions
diff --git a/main/mqtt-exec/0001-Let-library-generate-client-id-when-unset.patch b/main/mqtt-exec/0001-Let-library-generate-client-id-when-unset.patch
new file mode 100644
index 0000000000..bd6411e5e3
--- /dev/null
+++ b/main/mqtt-exec/0001-Let-library-generate-client-id-when-unset.patch
@@ -0,0 +1,68 @@
+From 5ba6139990373e77d638f4dd903281673e145e7e Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 9 Oct 2019 15:00:51 +0200
+Subject: [PATCH] Let library generate client id when unset
+
+---
+ mqtt-exec.c | 17 ++++-------------
+ 1 file changed, 4 insertions(+), 13 deletions(-)
+
+diff --git a/mqtt-exec.c b/mqtt-exec.c
+index 5c69325..ca585f9 100644
+--- a/mqtt-exec.c
++++ b/mqtt-exec.c
+@@ -151,8 +151,7 @@ int main(int argc, char *argv[])
+ int keepalive = 60;
+ int i, c, rc = 1;
+ struct userdata ud;
+- char hostname[256];
+- static char id[MOSQ_MQTT_ID_MAX_LENGTH+1];
++ char *id = NULL;
+ struct mosquitto *mosq = NULL;
+ char *username = NULL;
+ char *password = NULL;
+@@ -174,9 +173,6 @@ int main(int argc, char *argv[])
+
+ memset(&ud, 0, sizeof(ud));
+
+- memset(hostname, 0, sizeof(hostname));
+- memset(id, 0, sizeof(id));
+-
+ while ((c = getopt_long(argc, argv, "cdh:i:k:p:P:q:t:u:v", opts, &i)) != -1) {
+ switch(c) {
+ case 'c':
+@@ -194,7 +190,7 @@ int main(int argc, char *argv[])
+ MOSQ_MQTT_ID_MAX_LENGTH);
+ return 1;
+ }
+- strncpy(id, optarg, sizeof(id)-1);
++ id = optarg;
+ break;
+ case 'k':
+ keepalive = atoi(optarg);
+@@ -276,12 +272,6 @@ int main(int argc, char *argv[])
+ for (i=0; i <= ud.command_argc; i++)
+ ud.command_argv[i] = optind+i < argc ? argv[optind+i] : NULL;
+
+- if (id[0] == '\0') {
+- /* generate an id */
+- gethostname(hostname, sizeof(hostname)-1);
+- snprintf(id, sizeof(id), "mqttexe/%x-%s", getpid(), hostname);
+- }
+-
+ mosquitto_lib_init();
+ mosq = mosquitto_new(id, clean_session, &ud);
+ if (mosq == NULL)
+@@ -289,7 +279,8 @@ int main(int argc, char *argv[])
+
+ if (debug) {
+ printf("host=%s:%d\nid=%s\ntopic_count=%zu\ncommand=%s\n",
+- host, port, id, ud.topic_count, ud.command_argv[0]);
++ host, port, id ? id : "(null)", ud.topic_count,
++ ud.command_argv[0]);
+ mosquitto_log_callback_set(mosq, log_cb);
+ }
+
+--
+2.23.0
+
diff --git a/main/mqtt-exec/APKBUILD b/main/mqtt-exec/APKBUILD
index b9c3cde014..98f35288f4 100644
--- a/main/mqtt-exec/APKBUILD
+++ b/main/mqtt-exec/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=mqtt-exec
pkgver=0.4
-pkgrel=4
+pkgrel=5
pkgdesc="simple MQTT client that executes a command on messages"
url="https://github.com/ncopa/mqtt-exec"
arch="all"
@@ -13,6 +13,7 @@ options="!check" # no checks available.
subpackages="$pkgname-dbg $pkgname-openrc"
source="mqtt-exec-$pkgver.tar.gz::https://github.com/ncopa/mqtt-exec/archive/v$pkgver.tar.gz
0001-authentication-expose-authentication-with-credential.patch
+ 0001-Let-library-generate-client-id-when-unset.patch
mqtt-exec.initd
"
@@ -32,4 +33,5 @@ package() {
sha512sums="1448b2dda0f27a5275c113331ea2bc073ec1740797c1bb5b472ee3e0fd4d3ef4bcdfa6dc42e7540ee154b291c3d70df89f0646899ebb1bfe585d1384797de5e7 mqtt-exec-0.4.tar.gz
418058ecc05922df186d0dcbfeab7656977256a143f0346406598d1cf7331d3ba95a9b004bf3b6581be2e3cb2fbf5e69d7954b4c7ac488863f0318506c7f1c7c 0001-authentication-expose-authentication-with-credential.patch
+7007ad1afcba6b5c0e6224a30e3a6c1b9ce178603b27f575bb76d7b979b8e7f4c4c1226afa3ff8cf1f217fff832d0a69cff1cfbc205203dcb8a98afbf6f345ed 0001-Let-library-generate-client-id-when-unset.patch
7e0c461d5ed73fb8bac1da5f78bb7d8204f692fc3980ee916057c19c3673591d4143a71cc846f863566abfcc9ada22281bb690bc146e9ae37f43896248e5ed4a mqtt-exec.initd"