summaryrefslogtreecommitdiff
path: root/src/shared/bus-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-20 15:26:19 +0200
committerLennart Poettering <lennart@poettering.net>2015-10-20 15:26:19 +0200
commitf73e8b9caffa1d9828f23d4d71f587fe47ffacb8 (patch)
tree878508f4bba6bb20abc16f528906784d0afd9bd5 /src/shared/bus-util.c
parent14a081a0ff1db125ade7aea3540e5544fd3e57a9 (diff)
parente9876fc9c5aeec0144c15cd288852ea6c6ac8c29 (diff)
Merge pull request #1616 from evverx/run-fix-environment-parsing
run: fix Environment parsing
Diffstat (limited to 'src/shared/bus-util.c')
-rw-r--r--src/shared/bus-util.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 65ca173876..044862199b 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -31,6 +31,7 @@
#include "bus-message.h"
#include "cgroup-util.h"
#include "def.h"
+#include "env-util.h"
#include "macro.h"
#include "missing.h"
#include "path-util.h"
@@ -1642,8 +1643,44 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
r = sd_bus_message_append(m, "v", "i", i);
} else if (streq(field, "Environment")) {
+ const char *p;
- r = sd_bus_message_append(m, "v", "as", 1, eq);
+ r = sd_bus_message_open_container(m, 'v', "as");
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_message_open_container(m, 'a', "s");
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ p = eq;
+
+ for (;;) {
+ _cleanup_free_ char *word = NULL;
+
+ r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_CUNESCAPE);
+ if (r < 0) {
+ log_error("Failed to parse Environment value %s", eq);
+ return -EINVAL;
+ }
+ if (r == 0)
+ break;
+
+ if (!env_assignment_is_valid(word)) {
+ log_error("Invalid environment assignment: %s", eq);
+ return -EINVAL;
+ }
+
+ r = sd_bus_message_append_basic(m, 's', word);
+ if (r < 0)
+ return bus_log_create_error(r);
+ }
+
+ r = sd_bus_message_close_container(m);
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_message_close_container(m);
} else if (streq(field, "KillSignal")) {
int sig;