Correct and elaborate about -c option

* with -c file is only written and must not exist
* without -c file is read then written and must exist

Signed-off-by: Mikkel Kirkgaard Nielsen <miki+eclipse@mikini.dk>
This commit is contained in:
Mikkel Kirkgaard Nielsen 2026-02-11 18:12:08 +01:00
parent 3bddd1affe
commit e2b4efd0bb
2 changed files with 9 additions and 6 deletions

View file

@ -117,7 +117,7 @@ static void print_usage(void)
printf(" mosquitto_passwd [-H argon2id | -H sha512-pbkdf2] [-c] -b passwordfile username password\n");
printf(" mosquitto_passwd -U passwordfile\n");
printf(" -b : run in batch mode to allow passing passwords on the command line.\n");
printf(" -c : create a new password file. This will overwrite existing files.\n");
printf(" -c : create a new password file, ie. file must not exist. Without this, file must exist.\n");
printf(" -D : delete the username rather than adding/updating its password.\n");
printf(" -H : specify the hashing algorithm. Defaults to argon2id, which is recommended.\n");
printf(" Mosquitto 2.0 and earlier defaulted to sha512-pbkdf2.\n");

View file

@ -76,11 +76,14 @@
<term><option>-c</option></term>
<listitem>
<para>
Create a new password file. If the file already
exists, it will be overwritten. If the filename
is specified as a dash <option>-</option>
then the output will be to stdout. This only really
makes sense with <option>-b</option>.
Create a new password file. It is an error if the
file already exists. If the filename is specified as
a dash <option>-</option> then the output will be to
stdout. This only really makes sense with
<option>-b</option>.
Without this, the password file must exist and user
is added, updated, or deleted as per file contents and
-D option.
</para>
</listitem>
</varlistentry>