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`.
This commit is contained in:
@@ -138,6 +138,21 @@ bool strv_env_is_valid(char **e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool strv_env_name_is_valid(char **l) {
|
||||
char **p, **q;
|
||||
|
||||
STRV_FOREACH(p, l) {
|
||||
if (!env_name_is_valid(*p))
|
||||
return false;
|
||||
|
||||
STRV_FOREACH(q, p + 1)
|
||||
if (streq(*p, *q))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool strv_env_name_or_assignment_is_valid(char **l) {
|
||||
char **p, **q;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ bool strv_env_is_valid(char **e);
|
||||
#define strv_env_clean(l) strv_env_clean_with_callback(l, NULL, NULL)
|
||||
char **strv_env_clean_with_callback(char **l, void (*invalid_callback)(const char *p, void *userdata), void *userdata);
|
||||
|
||||
bool strv_env_name_is_valid(char **l);
|
||||
bool strv_env_name_or_assignment_is_valid(char **l);
|
||||
|
||||
char **strv_env_merge(unsigned n_lists, ...);
|
||||
|
||||
Reference in New Issue
Block a user