chiark / gitweb /
systemctl: mangle unit name in is-enabled
authorLukas Nykryn <lnykryn@redhat.com>
Thu, 7 Mar 2013 15:09:20 +0000 (16:09 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Mar 2013 15:25:00 +0000 (16:25 +0100)
https://bugs.freedesktop.org/show_bug.cgi?id=56072
https://bugzilla.redhat.com/show_bug.cgi?id=880353

src/systemctl/systemctl.c

index 99286cfc75b61eeceec6d00f7c8244cfd3344aee..72e9c5539b13d53b75719f954f17ee1c2d9cef14 100644 (file)
@@ -3982,6 +3982,7 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
         DBusMessage _cleanup_dbus_message_unref_ *reply = NULL;
         bool enabled;
         char **name;
         DBusMessage _cleanup_dbus_message_unref_ *reply = NULL;
         bool enabled;
         char **name;
+        char *n;
 
         dbus_error_init(&error);
 
 
         dbus_error_init(&error);
 
@@ -3996,7 +3997,14 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
                 STRV_FOREACH(name, args+1) {
                         UnitFileState state;
 
                 STRV_FOREACH(name, args+1) {
                         UnitFileState state;
 
-                        state = unit_file_get_state(arg_scope, arg_root, *name);
+                        n = unit_name_mangle(*name);
+                        if (!n)
+                                return log_oom();
+
+                        state = unit_file_get_state(arg_scope, arg_root, n);
+
+                        free(n);
+
                         if (state < 0)
                                 return state;
 
                         if (state < 0)
                                 return state;
 
@@ -4013,6 +4021,10 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
                 STRV_FOREACH(name, args+1) {
                         const char *s;
 
                 STRV_FOREACH(name, args+1) {
                         const char *s;
 
+                        n = unit_name_mangle(*name);
+                        if (!n)
+                                return log_oom();
+
                         r = bus_method_call_with_reply (
                                         bus,
                                         "org.freedesktop.systemd1",
                         r = bus_method_call_with_reply (
                                         bus,
                                         "org.freedesktop.systemd1",
@@ -4021,8 +4033,11 @@ static int unit_is_enabled(DBusConnection *bus, char **args) {
                                         "GetUnitFileState",
                                         &reply,
                                         NULL,
                                         "GetUnitFileState",
                                         &reply,
                                         NULL,
-                                        DBUS_TYPE_STRING, name,
+                                        DBUS_TYPE_STRING, &n,
                                         DBUS_TYPE_INVALID);
                                         DBUS_TYPE_INVALID);
+
+                        free(n);
+
                         if (r)
                                 return r;
 
                         if (r)
                                 return r;