Restore -s option to dinitctl
authorDavin McCall <davmac@davmac.org>
Tue, 10 Sep 2019 21:57:39 +0000 (07:57 +1000)
committerDavin McCall <davmac@davmac.org>
Tue, 10 Sep 2019 21:58:17 +0000 (07:58 +1000)
This is hardly needed since it is the default if run as root now, but is
nice to have for backwards compatibility / overriding -u option.

README.md
doc/manpages/dinitctl.8.m4
src/dinitctl.cc

index db37cee8c8cba64624669d751c265148689376bb..3dd1f7174b27b0cfca737bf10d35672dc2e749f3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -311,12 +311,15 @@ dependents are configured).
 If stopping a service would also require a dependent service to stop, a warning
 will be issued and the `--force` option will be required.
 
 If stopping a service would also require a dependent service to stop, a warning
 will be issued and the `--force` option will be required.
 
-Use the "-u" switch to talk the "user" instance of Dinit, rather than the system
-instance, e.g:
+When run as root, dinitctl (by default) communicates with the system instance of
+Dinit. Otherwise, it communicates with a user (personal) instance. This can be
+overridden (using "-u" or "-s" for the user or system instance, respectively), but
+note that regular users will generally lack the required permission to communicate
+with the system instance. 
 
 
-    dinitctl -u start mysql   # start user mysql service
+Here is an example command for starting a service:
 
 
-The -u flag is implicitely set when calling dinitctl as a regular user, not when root.
+    dinitctl start mysql   # start mysql service
 
 For complete details on the command line, use:
 
 
 For complete details on the command line, use:
 
index d636c0e50faa6ec1f9d0b13f54d0ce70b974c695..655953db3cd51e85a53831988aeca5107e131532 100644 (file)
@@ -48,16 +48,23 @@ dinitctl \- control services supervised by Dinit
 .\"
 \fBdinitctl\fR is a utility to control services being managed by the
 \fBdinit\fR daemon. It allows starting and stopping services, and listing
 .\"
 \fBdinitctl\fR is a utility to control services being managed by the
 \fBdinit\fR daemon. It allows starting and stopping services, and listing
-service status. 
+service status, amongst other actions. It functions by issuing commands to the daemon
+via a control socket.
 .\"
 .SH GENERAL OPTIONS
 .TP
 \fB\-\-help\fR
 display this help and exit
 .TP
 .\"
 .SH GENERAL OPTIONS
 .TP
 \fB\-\-help\fR
 display this help and exit
 .TP
+\fB\-s\fR, \fB\-\-system\fR
+Control the system init process (this is the default unless run as a non-root user). This option
+determines the default path to the control socket used to communicate with the \fBdinit\fR daemon
+process (it does not override the \fB\-s\fR option).
+.TP
 \fB\-u\fR, \fB\-\-user\fR
 \fB\-u\fR, \fB\-\-user\fR
-Control the user init process. The default is to control the system process. This option selects
-the path to the control socket used to communicate with the \fBdinit\fR daemon process.
+Control the user init process (this is the default when not run as root). This option determines
+the default path to the control socket used to communicate with the \fBdinit\fR daemon process
+(it does not override the \fB\-s\fR option).
 .TP
 \fB\-\-socket\-path\fR \fIsocket-path\fR, \fB\-p\fR \fIsocket-path\fR
 Specify the path to the socket used for communicating with the service manager daemon.
 .TP
 \fB\-\-socket\-path\fR \fIsocket-path\fR, \fB\-p\fR \fIsocket-path\fR
 Specify the path to the socket used for communicating with the service manager daemon.
index 1d7b8ea777917c74108e61115641748eb6e49d53..03b2cd1a60141160a53daf468b2c6e1c64b69571 100644 (file)
@@ -110,6 +110,9 @@ int main(int argc, char **argv)
             else if (strcmp(argv[i], "--quiet") == 0) {
                 verbose = false;
             }
             else if (strcmp(argv[i], "--quiet") == 0) {
                 verbose = false;
             }
+            else if (strcmp(argv[i], "--system") == 0 || strcmp(argv[i], "-s") == 0) {
+                user_dinit = false;
+            }
             else if (strcmp(argv[i], "--user") == 0 || strcmp(argv[i], "-u") == 0) {
                 user_dinit = true;
             }
             else if (strcmp(argv[i], "--user") == 0 || strcmp(argv[i], "-u") == 0) {
                 user_dinit = true;
             }
@@ -275,7 +278,8 @@ int main(int argc, char **argv)
           "\n"
           "General options:\n"
           "  --help           : show this help\n"
           "\n"
           "General options:\n"
           "  --help           : show this help\n"
-          "  -u, --user       : control user daemon instead of system daemon\n"
+          "  -s, --system     : control system daemon (default if run as root)\n"
+          "  -u, --user       : control user daemon\n"
           "  --quiet          : suppress output (except errors)\n"
           "  --socket-path <path>, -p <path>\n"
           "                   : specify socket for communication with daemon\n"
           "  --quiet          : suppress output (except errors)\n"
           "  --socket-path <path>, -p <path>\n"
           "                   : specify socket for communication with daemon\n"