From: Michael Stapelberg <stapelberg@debian.org>
Date: Sun, 19 Jan 2014 18:40:56 +0100
Subject: =?utf-8?q?fix_systemctl_enable/disable/=E2=80=A6_error_message_?=
 =?utf-8?q?=E2=80=9CFailed_to_issue_method_call=3A?=
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

No such file or directory”

The bug affected only non-native services, i.e. LSB SysV init scripts,
with isc-dhcp-server.service being an example for this commit message.

The bug was introduced with commit
fdcb1bce7b16f69c4d63451816e2c7f824d090b4. The issue is that
enable_unit() would not return even though the SysV init script was
disabled by enable_sysv_units(). enable_unit() then tried to
disable a native systemd unit called isc-dhcp-server.service, even
though there is no such native unit. This is what caused the “no such
file or directory” error message.

Closes: #734809
---
 src/systemctl/systemctl.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 81ac83e..3147c4a 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4246,10 +4246,6 @@ static int enable_unit(DBusConnection *bus, char **args) {
 
         dbus_error_init(&error);
 
-        r = enable_sysv_units(args);
-        if (r < 0)
-                return r;
-
         if (!args[1])
                 return 0;
 
@@ -4257,6 +4253,13 @@ static int enable_unit(DBusConnection *bus, char **args) {
         if (r < 0)
                 goto finish;
 
+        r = enable_sysv_units(args);
+        if (r < 0)
+                return r;
+
+        if (!args[1])
+                return 0;
+
         if (!bus || avoid_bus()) {
                 if (streq(verb, "enable")) {
                         r = unit_file_enable(arg_scope, arg_runtime, arg_root, mangled_names, arg_force, &changes, &n_changes);
