summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2015-10-20 02:04:10 +0000
committerEvgeny Vereshchagin <evvers@ya.ru>2015-10-20 12:55:07 +0000
commite9876fc9c5aeec0144c15cd288852ea6c6ac8c29 (patch)
tree35ff4884e27a98dcd2ba0106120b206f01ada6e0 /src/core
parentec566e4c7cee67ec2c39475ef08f18a9f1b80efd (diff)
run: fix Environment parsing
* `Environment=` resets previous assignments * `Environment='a=1 b=2'` sets `a` to `1` and `b` to `2` * `Environment='"a=1 2" b=2"'` sets `a` to `1 2` and `b` to `2`
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dbus-execute.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index b71e5ad300..98cf0e9ff1 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -1155,18 +1155,24 @@ int bus_exec_context_set_transient_property(
_cleanup_free_ char *joined = NULL;
char **e;
- e = strv_env_merge(2, c->environment, l);
- if (!e)
- return -ENOMEM;
+ if (strv_length(l) == 0) {
+ c->environment = strv_free(c->environment);
+ unit_write_drop_in_private_format(u, mode, name, "Environment=\n");
+ } else {
+ e = strv_env_merge(2, c->environment, l);
+ if (!e)
+ return -ENOMEM;
- strv_free(c->environment);
- c->environment = e;
+ strv_free(c->environment);
+ c->environment = e;
- joined = strv_join_quoted(c->environment);
- if (!joined)
- return -ENOMEM;
+ joined = strv_join_quoted(c->environment);
+ if (!joined)
+ return -ENOMEM;
+
+ unit_write_drop_in_private_format(u, mode, name, "Environment=%s\n", joined);
+ }
- unit_write_drop_in_private_format(u, mode, name, "Environment=%s\n", joined);
}
return 1;