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`
This commit is contained in:
Evgeny Vereshchagin
2015-10-20 12:55:07 +00:00
parent ec566e4c7c
commit e9876fc9c5
2 changed files with 53 additions and 10 deletions
+15 -9
View File
@@ -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;