aboutsummaryrefslogtreecommitdiffstats
path: root/main/mqtt-exec
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2018-07-18 12:07:07 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2018-07-18 14:15:45 +0200
commit5355d992fa03c14b831db7f730cec65475757aa4 (patch)
tree0d6ab96f4f2b57bccad332839f93a8673e003cc5 /main/mqtt-exec
parent46eeaeb856c3f54e2bd5641aac51a9b2ddb9fb8c (diff)
downloadaports-5355d992fa03c14b831db7f730cec65475757aa4.tar.bz2
aports-5355d992fa03c14b831db7f730cec65475757aa4.tar.xz
main/mqtt-exec: backport password auth support
and remove unused patch
Diffstat (limited to 'main/mqtt-exec')
-rw-r--r--main/mqtt-exec/0001-authentication-expose-authentication-with-credential.patch89
-rw-r--r--main/mqtt-exec/0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch77
-rw-r--r--main/mqtt-exec/APKBUILD4
3 files changed, 92 insertions, 78 deletions
diff --git a/main/mqtt-exec/0001-authentication-expose-authentication-with-credential.patch b/main/mqtt-exec/0001-authentication-expose-authentication-with-credential.patch
new file mode 100644
index 0000000000..aba1cee9fa
--- /dev/null
+++ b/main/mqtt-exec/0001-authentication-expose-authentication-with-credential.patch
@@ -0,0 +1,89 @@
+From 5ee7377172dc0f30a64d009210db7efbf5d2219f Mon Sep 17 00:00:00 2001
+From: Kevin Daudt <me@ikke.info>
+Date: Wed, 14 Mar 2018 22:50:28 +0100
+Subject: [PATCH] authentication: expose authentication with credentials
+
+libmosquitto supports authentication with credentials, so allow settings
+credentials through parameters.
+---
+ mqtt-exec.c | 20 +++++++++++++++++++-
+ 1 file changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/mqtt-exec.c b/mqtt-exec.c
+index fc5ab03..28251fb 100644
+--- a/mqtt-exec.c
++++ b/mqtt-exec.c
+@@ -71,8 +71,10 @@ int usage(int retcode)
+ " -i,--id ID The id to use for this client\n"
+ " -k,--keepalive SEC Set keepalive to SEC. Default is 60\n"
+ " -p,--port PORT Set TCP port to PORT. Default is 1883\n"
++" -P,--password PASSWORD Set password for authentication\n"
+ " -q,--qos QOS Set Quality of Serive to level. Default is 0\n"
+ " -t,--topic TOPIC Set MQTT topic to TOPIC. May be repeated\n"
++" -u,--username USERNAME Set username for authentication\n"
+ " -v,--verbose Pass over the topic to application as firs arg\n"
+ " --will-topic TOPIC Set the client Will topic to TOPIC\n"
+ " --will-payload MSG Set the client Will message to MSG\n"
+@@ -119,6 +121,8 @@ int main(int argc, char *argv[])
+ {"qos", required_argument, 0, 'q' },
+ {"topic", required_argument, 0, 't' },
+ {"verbose", no_argument, 0, 'v' },
++ {"username", required_argument, 0, 'u' },
++ {"password", required_argument, 0, 'P' },
+ {"will-topic", required_argument, 0, 0x1001 },
+ {"will-payload", required_argument, 0, 0x1002 },
+ {"will-qos", required_argument, 0, 0x1003 },
+@@ -145,6 +149,8 @@ int main(int argc, char *argv[])
+ char hostname[256];
+ static char id[MOSQ_MQTT_ID_MAX_LENGTH+1];
+ struct mosquitto *mosq = NULL;
++ char *username = NULL;
++ char *password = NULL;
+
+ char *will_payload = NULL;
+ int will_qos = 0;
+@@ -166,7 +172,7 @@ int main(int argc, char *argv[])
+ memset(hostname, 0, sizeof(hostname));
+ memset(id, 0, sizeof(id));
+
+- while ((c = getopt_long(argc, argv, "cdh:i:k:p:q:t:v", opts, &i)) != -1) {
++ while ((c = getopt_long(argc, argv, "cdh:i:k:p:P:q:t:u:v", opts, &i)) != -1) {
+ switch(c) {
+ case 'c':
+ clean_session = false;
+@@ -191,6 +197,8 @@ int main(int argc, char *argv[])
+ case 'p':
+ port = atoi(optarg);
+ break;
++ case 'P':
++ password = optarg;
+ case 'q':
+ ud.qos = atoi(optarg);
+ if (!valid_qos_range(ud.qos, "QoS"))
+@@ -202,6 +210,8 @@ int main(int argc, char *argv[])
+ sizeof(char *) * ud.topic_count);
+ ud.topics[ud.topic_count-1] = optarg;
+ break;
++ case 'u':
++ username = optarg;
+ case 'v':
+ ud.verbose = 1;
+ break;
+@@ -286,6 +296,14 @@ int main(int argc, char *argv[])
+ goto cleanup;
+ }
+
++ if (!username != !password) {
++ fprintf(stderr, "Need to set both username and password\n");
++ goto cleanup;
++ }
++
++ if (username && password)
++ mosquitto_username_pw_set(mosq, username, password);
++
+ #ifdef WITH_TLS
+ if ((cafile || capath) && mosquitto_tls_set(mosq, cafile, capath, certfile,
+ keyfile, NULL)) {
+--
+2.18.0
+
diff --git a/main/mqtt-exec/0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch b/main/mqtt-exec/0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch
deleted file mode 100644
index e2ea3dbe1e..0000000000
--- a/main/mqtt-exec/0001-implement-v-verbose-to-optionally-pass-the-the-topic.patch
+++ /dev/null
@@ -1,77 +0,0 @@
-From 9b550ad2043dee35b42d053899fed62b6ac53c92 Mon Sep 17 00:00:00 2001
-From: Natanael Copa <ncopa@alpinelinux.org>
-Date: Wed, 4 Dec 2013 15:27:47 +0100
-Subject: [PATCH] implement -v/--verbose to optionally pass the the topic
-
----
- mqtt-exec.c | 21 +++++++++++++--------
- 1 file changed, 13 insertions(+), 8 deletions(-)
-
-diff --git a/mqtt-exec.c b/mqtt-exec.c
-index be52ba4..e6ab0ee 100644
---- a/mqtt-exec.c
-+++ b/mqtt-exec.c
-@@ -25,9 +25,12 @@ void message_cb(struct mosquitto *mosq, void *obj,
- const struct mosquitto_message *msg)
- {
- struct userdata *ud = (struct userdata *)obj;
-- if (msg->payloadlen) {
-+ if (msg->payloadlen || ud->verbose) {
- if (ud->command_argv && fork() == 0) {
-- ud->command_argv[ud->command_argc-1] = msg->payload;
-+ if (ud->verbose)
-+ ud->command_argv[ud->command_argc-2] = msg->topic;
-+ ud->command_argv[ud->command_argc-1] =
-+ msg->payloadlen ? msg->payload : NULL;
- execv(ud->command_argv[0], ud->command_argv);
- perror(ud->command_argv[0]);
- _exit(1);
-@@ -74,6 +77,7 @@ int main(int argc, char *argv[])
- {"keepalive", required_argument, 0, 'k' },
- {"port", required_argument, 0, 'p' },
- {"topic", required_argument, 0, 't' },
-+ {"verbose", no_argument, 0, 'v' },
- { 0, 0, 0, 0}
- };
- int debug = 0;
-@@ -91,7 +95,7 @@ int main(int argc, char *argv[])
- memset(hostname, 0, sizeof(hostname));
- memset(id, 0, sizeof(id));
-
-- while ((c = getopt_long(argc, argv, "dh:k:p:t:", opts, &i)) != -1) {
-+ while ((c = getopt_long(argc, argv, "dh:k:p:t:v", opts, &i)) != -1) {
- switch(c) {
- case 'd':
- debug = 1;
-@@ -108,6 +112,9 @@ int main(int argc, char *argv[])
- case 't':
- ud.topic = optarg;
- break;
-+ case 'v':
-+ ud.verbose = 1;
-+ break;
- case '?':
- return usage(1);
- }
-@@ -116,15 +123,13 @@ int main(int argc, char *argv[])
- if ((ud.topic == NULL) || (optind == argc))
- return usage(1);
-
-- ud.command_argc = (argc - optind) + 1;
-+ ud.command_argc = (argc - optind) + 1 + ud.verbose;
- ud.command_argv = malloc((ud.command_argc + 1) * sizeof(char *));
- if (ud.command_argv == NULL)
- return perror_ret("malloc");
-
-- for (i=0; i < ud.command_argc; i++)
-- ud.command_argv[i] = argv[optind+i];
-- ud.command_argv[ud.command_argc-1] = NULL;
-- ud.command_argv[ud.command_argc] = NULL;
-+ for (i=0; i <= ud.command_argc; i++)
-+ ud.command_argv[i] = optind+i < argc ? argv[optind+i] : NULL;
-
- /* generate an id */
- gethostname(hostname, sizeof(hostname)-1);
---
-1.8.5.1
-
diff --git a/main/mqtt-exec/APKBUILD b/main/mqtt-exec/APKBUILD
index 976343be70..1d2fe05e4e 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=1
+pkgrel=2
pkgdesc="simple MQTT client that executes a command on messages"
url="https://github.com/ncopa/mqtt-exec"
arch="all"
@@ -12,6 +12,7 @@ makedepends="$depends_dev mosquitto-dev"
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
mqtt-exec.initd
"
@@ -39,4 +40,5 @@ package() {
}
sha512sums="1448b2dda0f27a5275c113331ea2bc073ec1740797c1bb5b472ee3e0fd4d3ef4bcdfa6dc42e7540ee154b291c3d70df89f0646899ebb1bfe585d1384797de5e7 mqtt-exec-0.4.tar.gz
+418058ecc05922df186d0dcbfeab7656977256a143f0346406598d1cf7331d3ba95a9b004bf3b6581be2e3cb2fbf5e69d7954b4c7ac488863f0318506c7f1c7c 0001-authentication-expose-authentication-with-credential.patch
b04b3f43d9079783d5a9af01aba49fa20431e528237e80790cd6ef89ea019d632866d1e2acfc619c3a90ed2cf4469422bac44727088392394792be68a6d13fae mqtt-exec.initd"