summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorFilipe Brandenburger <filbranden@google.com>2015-09-06 23:06:53 -0700
committerFilipe Brandenburger <filbranden@google.com>2015-11-11 07:55:23 -0800
commitb4c14404b3e8753c41bac0b1d49369230a15c544 (patch)
tree88670a957a28cb72ab7eedb70c178b2a2aab7041 /src/shared
parent3116c225d2e3c0d8e6b3f4d4a9b48443cc7baf2d (diff)
execute: Add new PassEnvironment= directive
This directive allows passing environment variables from the system manager to spawned services. Variables in the system manager can be set inside a container by passing `--set-env=...` options to systemd-spawn. Tested with an on-disk test.service unit. Tested using multiple variable names on a single line, with an empty setting to clear the current list of variables, with non-existing variables. Tested using `systemd-run -p PassEnvironment=VARNAME` to confirm it works with transient units. Confirmed that `systemctl show` will display the PassEnvironment settings. Checked that man pages are generated correctly. No regressions in `make check`.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-util.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index a13991a960..73ceeba18f 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1654,7 +1654,7 @@ 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")) {
+ } else if (STR_IN_SET(field, "Environment", "PassEnvironment")) {
const char *p;
r = sd_bus_message_open_container(m, 'v', "as");
@@ -1678,9 +1678,16 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
if (r == 0)
break;
- if (!env_assignment_is_valid(word)) {
- log_error("Invalid environment assignment: %s", eq);
- return -EINVAL;
+ if (streq(field, "Environment")) {
+ if (!env_assignment_is_valid(word)) {
+ log_error("Invalid environment assignment: %s", word);
+ return -EINVAL;
+ }
+ } else { /* PassEnvironment */
+ if (!env_name_is_valid(word)) {
+ log_error("Invalid environment variable name: %s", word);
+ return -EINVAL;
+ }
}
r = sd_bus_message_append_basic(m, 's', word);