From 4d1e0b9b0d8eddf02884d84304678e41af417c20 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 26 Apr 2020 22:44:21 +0100 Subject: [PATCH] Fix mosquitto_passwd -b not updating passwords for existing users Closes #1664. Thanks to Leon Kiefer. --- ChangeLog.txt | 3 +++ src/mosquitto_passwd.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 31076c5892..8888be827d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,9 @@ Broker: - Report invalid bridge prefix+pattern combinations at config parsing time rather than letting the bridge fail later. Issue #1635. +- Fix `mosquitto_passwd -b` not updating passwords for existing users + correctly. Creating a new user with `-b` worked without problem. + Closes #1664. Client library: - Don't treat an unexpected PUBACK, PUBREL, or PUBCOMP as a fatal error. diff --git a/src/mosquitto_passwd.c b/src/mosquitto_passwd.c index 207996d1c0..a86071f90e 100644 --- a/src/mosquitto_passwd.c +++ b/src/mosquitto_passwd.c @@ -337,7 +337,7 @@ static int update_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const }else{ /* Write out a new line for our matching username */ helper->found = true; - rc = output_new_password(ftmp, username, password); + rc = output_new_password(ftmp, username, helper->password); } return rc; } @@ -349,6 +349,7 @@ int update_pwuser(FILE *fptr, FILE *ftmp, const char *username, const char *pass memset(&helper, 0, sizeof(helper)); helper.username = username; + helper.password = password; rc = pwfile_iterate(fptr, ftmp, update_pwuser_cb, &helper); if(helper.found){