]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: usable status command for special units (#4072)
authorCireo <reid.price@gmail.com>
Thu, 1 Sep 2016 09:04:36 +0000 (02:04 -0700)
committerLennart Poettering <lennart@poettering.net>
Thu, 1 Sep 2016 09:04:36 +0000 (11:04 +0200)
Prior to this commit, users could be given an unusable command to run if
they attempted to stop or start special services.  For example:

    $ systemctl stop -- -.mount
    Failed to stop -.mount: Operation refused, unit -.mount may be \
        requested by dependency only.
    See system logs and 'systemctl status -.mount' for details.

    $ systemctl status -.mount
    systemctl: invalid option -- '.'

This adds a '--' to the example command in these situations.

src/systemctl/systemctl.c

index 682805045d97ee335fe6f3b11f0a1431d2cae254..59124411688350e0bc88d6818244fa36905a1be2 100644 (file)
@@ -2720,9 +2720,10 @@ static int start_unit_one(
 
                 if (!sd_bus_error_has_name(error, BUS_ERROR_NO_SUCH_UNIT) &&
                     !sd_bus_error_has_name(error, BUS_ERROR_UNIT_MASKED))
-                        log_error("See %s logs and 'systemctl%s status %s' for details.",
+                        log_error("See %s logs and 'systemctl%s status%s %s' for details.",
                                    arg_scope == UNIT_FILE_SYSTEM ? "system" : "user",
                                    arg_scope == UNIT_FILE_SYSTEM ? "" : " --user",
+                                   name[0] == '-' ? " --" : "",
                                    name);
 
                 return r;