diff options
author | William Douglas <william.r.douglas@gmail.com> | 2012-02-07 12:31:20 -0800 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-02-08 16:33:55 +0100 |
commit | 9e7c53579a1d16287134e64f78ec5e1451aa2506 (patch) | |
tree | 181d285a3a82b32b6c031deeeba62f301f3249f3 | |
parent | e0d25329b23a43332ea340f9907721873a316f4e (diff) |
systemd: Add systemd.setenv for /proc/cmdline parsing.
Check for systemd.setenv when parsing /proc/cmdline.
ex: systemd.setenv=PATH=/opt/bin
-rw-r--r-- | src/main.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c index a849824bb3..ed317b4413 100644 --- a/src/main.c +++ b/src/main.c @@ -323,6 +323,26 @@ static int parse_proc_cmdline_word(const char *word) { log_warning("Failed to parse default standard error switch %s. Ignoring.", word + 31); else arg_default_std_error = r; + } else if (startswith(word, "systemd.setenv=")) { + char *cenv, *eq; + int r; + + cenv = strdup(word + 15); + if (!cenv) + return -ENOMEM; + + eq = strchr(cenv, '='); + if (!eq) { + r = unsetenv(cenv); + if (r < 0) + log_warning("unsetenv failed %s. Ignoring.", strerror(errno)); + } else { + *eq = 0; + r = setenv(cenv, eq + 1, 1); + if (r < 0) + log_warning("setenv failed %s. Ignoring.", strerror(errno)); + } + free(cenv); #ifdef HAVE_SYSV_COMPAT } else if (startswith(word, "systemd.sysv_console=")) { int r; |