]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: print better message if default target is masked
authorDavid Tardon <dtardon@redhat.com>
Wed, 2 Mar 2022 20:02:21 +0000 (21:02 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 27 Feb 2023 21:45:15 +0000 (06:45 +0900)
If the default target is masked, `systemctl get-default` prints

  Failed to get default target: Operation not possible due to RF-kill

That's a bit too cryptic, so let's make it clear what's actually
happening.

Fixes #26589.

src/core/dbus-manager.c
src/systemctl/systemctl-set-default.c

index 20e1ffe26f35b2ab04f00483922caf733e58d8bc..047a7b442401fc768a9c37feff7b7da803903746 100644 (file)
@@ -2200,6 +2200,8 @@ static int method_get_default_target(sd_bus_message *message, void *userdata, sd
                 return r;
 
         r = unit_file_get_default(m->unit_file_scope, NULL, &default_target);
+        if (r == -ERFKILL)
+                sd_bus_error_setf(error, BUS_ERROR_UNIT_MASKED, "Unit file is masked.");
         if (r < 0)
                 return r;
 
index c2dbf97649e06f2dfda6ee9c5f8a06935ac568d5..7ddba172722f4458122225f8e3d484eec5c5e8d8 100644 (file)
@@ -50,6 +50,8 @@ static int determine_default(char **ret_name) {
 
         if (install_client_side()) {
                 r = unit_file_get_default(arg_scope, arg_root, ret_name);
+                if (r == -ERFKILL)
+                        return log_error_errno(r, "Failed to get default target: Unit file is masked.");
                 if (r < 0)
                         return log_error_errno(r, "Failed to get default target: %m");
                 return 0;