From 4b3c76d97a77263c32582ace16a00171e144f2d6 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sat, 7 Nov 2020 23:47:49 +0000 Subject: [PATCH] mosquitto_ctrl: Allow optional client and password when creating a client. --- apps/mosquitto_ctrl/dynsec.c | 2 +- apps/mosquitto_ctrl/dynsec_client.c | 36 +++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/apps/mosquitto_ctrl/dynsec.c b/apps/mosquitto_ctrl/dynsec.c index 79855f30..8ecb761f 100644 --- a/apps/mosquitto_ctrl/dynsec.c +++ b/apps/mosquitto_ctrl/dynsec.c @@ -38,7 +38,7 @@ void dynsec__print_usage(void) printf("Set group for anonymous clients: setAnonymousGroup \n"); printf("\nClients\n-------\n"); - printf("Create a new client: createClient [password]\n"); + printf("Create a new client: createClient [-c clientid] [-p password]\n"); printf("Delete a client: deleteClient \n"); printf("Set a client password: setClientPassword [password]\n"); printf("Add a role to a client: addClientRole [priority]\n"); diff --git a/apps/mosquitto_ctrl/dynsec_client.c b/apps/mosquitto_ctrl/dynsec_client.c index 0f9695f9..d6bc3a11 100644 --- a/apps/mosquitto_ctrl/dynsec_client.c +++ b/apps/mosquitto_ctrl/dynsec_client.c @@ -25,14 +25,35 @@ Contributors: int dynsec_client__create(int argc, char *argv[], cJSON *j_command) { - char *username = NULL, *password = NULL; + char *username = NULL, *password = NULL, *clientid = NULL; char prompt[200], verify_prompt[200]; char password_buf[200]; int rc; + int i; + bool request_password = true; + + username = argv[0]; + + for(i=1; i