From: Davin McCall Date: Tue, 10 Sep 2019 21:57:39 +0000 (+1000) Subject: Restore -s option to dinitctl X-Git-Tag: v0.8.0~42 X-Git-Url: https://git.librecmc.org/?p=oweals%2Fdinit.git;a=commitdiff_plain;h=709a6301607625bcb64eb02f002fffababaa9536 Restore -s option to dinitctl 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. --- diff --git a/README.md b/README.md index db37cee..3dd1f71 100644 --- 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. -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: diff --git a/doc/manpages/dinitctl.8.m4 b/doc/manpages/dinitctl.8.m4 index d636c0e..655953d 100644 --- a/doc/manpages/dinitctl.8.m4 +++ b/doc/manpages/dinitctl.8.m4 @@ -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 -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 +\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 -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. diff --git a/src/dinitctl.cc b/src/dinitctl.cc index 1d7b8ea..03b2cd1 100644 --- a/src/dinitctl.cc +++ b/src/dinitctl.cc @@ -110,6 +110,9 @@ int main(int argc, char **argv) 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; } @@ -275,7 +278,8 @@ int main(int argc, char **argv) "\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 , -p \n" " : specify socket for communication with daemon\n"