diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2018-07-18 12:09:37 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2018-07-18 12:09:37 +0000 |
commit | fed5e5e7015b02b2f0d86cf88a24de8a97d4cfb5 (patch) | |
tree | 3a056f87308c79b68c14ef79a7dc75b4150dbbd1 /main/mqtt-exec | |
parent | 621c593d73ea0cdee440bae26d2570852f5b734f (diff) | |
download | aports-fed5e5e7015b02b2f0d86cf88a24de8a97d4cfb5.tar.bz2 aports-fed5e5e7015b02b2f0d86cf88a24de8a97d4cfb5.tar.xz |
main/mqtt-exec: backport password auth support
Diffstat (limited to 'main/mqtt-exec')
-rw-r--r-- | main/mqtt-exec/0001-authentication-expose-authentication-with-credential.patch | 89 | ||||
-rw-r--r-- | main/mqtt-exec/APKBUILD | 4 |
2 files changed, 92 insertions, 1 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/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" |