dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Blob Blame History Raw
From 86ccda12838942a4df2c974bad9386a60835ba67 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 27 Sep 2013 00:11:54 +0200
Subject: [PATCH] systemctl: make sure set-property mangles unit names

---
 src/systemctl/systemctl.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 57e5bb9..16da293 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3828,7 +3828,8 @@ static int append_assignment(DBusMessageIter *iter, const char *assignment) {
 
 static int set_property(DBusConnection *bus, char **args) {
 
-        _cleanup_free_ DBusMessage *m = NULL, *reply = NULL;
+        _cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL;
+        _cleanup_free_ char *n = NULL;
         DBusMessageIter iter, sub;
         dbus_bool_t runtime;
         DBusError error;
@@ -3849,7 +3850,11 @@ static int set_property(DBusConnection *bus, char **args) {
 
         runtime = arg_runtime;
 
-        if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &args[1]) ||
+        n = unit_name_mangle(args[1]);
+        if (!n)
+                return log_oom();
+
+        if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &n) ||
             !dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &runtime) ||
             !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(sv)", &sub))
                 return log_oom();