Skip to content

Commit

Permalink
Improve mosquitto_ctrl documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Mar 26, 2021
1 parent 20e154c commit 3ac2c3e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
2 changes: 2 additions & 0 deletions apps/mosquitto_ctrl/dynsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ void dynsec__print_usage(void)
printf("acltype: publishClientSend|publishClientReceive\n");
printf(" |subscribeLiteral|subscribePattern\n");
printf(" |unsubscribeLiteral|unsubscribePattern\n");
printf("\nFor more information see:\n");
printf(" https://mosquitto.org/documentation/dynamic-security/\n\n");
}

cJSON *cJSON_AddIntToObject(cJSON * const object, const char * const name, int number)
Expand Down
3 changes: 2 additions & 1 deletion apps/mosquitto_ctrl/mosquitto_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ static void print_usage(void)
printf("\nGeneral usage: mosquitto_ctrl <module> <module-command> <command-options>\n");
printf("For module specific help use: mosquitto_ctrl <module> help\n");
printf("\nModules available: dynsec\n");
printf("\nSee https://mosquitto.org/man/mosquitto_ctrl-1.html for more information.\n\n");
printf("\nFor more information see:\n");
printf(" https://mosquitto.org/man/mosquitto_ctrl-1.html\n\n");
}


Expand Down
22 changes: 20 additions & 2 deletions man/mosquitto_ctrl.1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>mosquitto_ctrl</command>
<arg choice='opt'>connection-options</arg>
<arg choice='opt'>connection-options | -o config-file</arg>
<arg choice='plain'>module-name</arg>
<arg choice='plain'>module-command</arg>
<arg choice='opt'>command-options</arg>
Expand Down Expand Up @@ -132,7 +132,11 @@
<para>The options below may be given on the command line, but may also
be placed in a config file located at
<option>$XDG_CONFIG_HOME/mosquitto_ctrl</option> or
<option>$HOME/.config/mosquitto_ctrl</option> with one pair of
<option>$HOME/.config/mosquitto_ctrl</option>.</para>
<para>The config file may be specified manually with the
<option>-o <replaceable>config-file</replaceable></option>
option.</para>
<para>The config file should have one pair of
<option>-option <replaceable>value</replaceable></option>
per line. The values in the config file will be used as defaults
and can be overridden by using the command line. The exceptions to
Expand Down Expand Up @@ -320,6 +324,20 @@
being sent than would normally be necessary.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-o</option> <replaceable>config-file</replaceable></term>
<listitem>
<para>Provide a path to a config file to load options from. The config file should have one pair of
<option>-option <replaceable>value</replaceable></option>
per line. The values in the config file will be used as defaults
and can be overridden by using the command line. The exceptions to
this are the message type options, of which only one can be
specified. Note also that currently some options cannot be negated,
e.g. <option>-S</option>. Config file lines that have a
<option>#</option> as the first character are treated as comments
and not processed any further.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-p</option></term>
<term><option>--port</option></term>
Expand Down
36 changes: 33 additions & 3 deletions www/pages/documentation/dynamic-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ application.
The initial configuration is the only time that `mosquitto_ctrl` does not
connect to a broker to carry out the configuration. All other commands require
a connection to a broker, and hence a username, password, and whatever else is
required for that particular connection.
required for that particular connection. It is strongly recommended that your
broker connection uses encryption so that your configuration, including new
passwords, is not transmitted in plain text.

The connection options must be given before the `dynsec` part of the command
line:
Expand All @@ -357,8 +359,36 @@ For example:
mosquitto_ctrl -u admin -h localhost dynsec <command> ...
```

It is possible to provide the admin password on the command line, but this is
not recommended.
It is possible to provide the admin password on the command line using `-P
password`, but this is not recommended. If you do not provide a password,
mosquitto_ctrl will ask you to enter the password when it is needed.

### Using an options file

For convenience, mosquitto_ctrl can load an options file which contains a list
of options it should use. This means you can set the encryption options, host,
admin username and any other options once and not have to add them to the
command line every time.

mosquitto_ctrl will try to load a configuration file from a default location.
For Windows this is at `%USER_PROFILE%\mosquitto_ctrl.conf`. For other systems,
it will try `$XDG_CONFIG_HOME/mosquitto_ctrl.conf` or
`$HOME/.config/mosquitto_ctrl.conf`.

You may override this behaviour by manually specifying an options file with
`-o <path to options file>`.

The options file should contain a list of options, one per line, exactly as
they would be provided on the command line. For example:

```
--cafile /path/to/my/CA.crt
--certfile /path/to/my/client.crt
--keyfile /path/to/my/client.key
-u admin
-h mosquitto.example.com
```

### mosquitto_ctrl options

Expand Down

0 comments on commit 3ac2c3e

Please sign in to comment.