daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
a1d4eb
From a13006e07ad1c8f3de577b8b64f22a0e044784e7 Mon Sep 17 00:00:00 2001
a1d4eb
From: Michal Sekletar <msekleta@redhat.com>
a1d4eb
Date: Tue, 10 Feb 2015 10:34:20 +0100
a1d4eb
Subject: [PATCH] core: fix enabling units via their absolute paths
a1d4eb
a1d4eb
In case when client requests enable but gives us full path to unit file we
a1d4eb
should call manager_load_unit with 2nd and 3rd argument swapped because we
a1d4eb
don't want to search for unit file in usual places but rather load it directly.
a1d4eb
a1d4eb
Related: #1199981
a1d4eb
---
a1d4eb
 src/core/dbus-manager.c | 4 ++--
a1d4eb
 1 file changed, 2 insertions(+), 2 deletions(-)
a1d4eb
a1d4eb
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
a1d4eb
index cebc730..f35f23b 100644
a1d4eb
--- a/src/core/dbus-manager.c
a1d4eb
+++ b/src/core/dbus-manager.c
a1d4eb
@@ -1603,7 +1603,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
a1d4eb
                 STRV_FOREACH(i, l) {
a1d4eb
                         Unit *u;
a1d4eb
 
a1d4eb
-                        r = manager_load_unit(m, *i, NULL, NULL, &u);
a1d4eb
+                        r = path_is_absolute(*i) ? manager_load_unit(m, NULL, *i, NULL, &u) : manager_load_unit(m, *i, NULL, NULL, &u);
a1d4eb
                         if (r < 0) {
a1d4eb
                                 dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s does not exist.", *i);
a1d4eb
                                 return bus_send_error_reply(connection, message, &error, -ENOENT);
a1d4eb
@@ -1681,7 +1681,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
a1d4eb
                 STRV_FOREACH(i, l) {
a1d4eb
                         Unit *u;
a1d4eb
 
a1d4eb
-                        r = manager_load_unit(m, *i, NULL, NULL, &u);
a1d4eb
+                        r = path_is_absolute(*i) ? manager_load_unit(m, NULL, *i, NULL, &u) : manager_load_unit(m, *i, NULL, NULL, &u);
a1d4eb
                         if (r < 0) {
a1d4eb
                                 dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s does not exist.", *i);
a1d4eb
                                 return bus_send_error_reply(connection, message, &error, -ENOENT);