[systemd-commits] 2 commits - man/systemd.xml src/main.c
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Feb 8 07:34:05 PST 2012
man/systemd.xml | 16 ++++++++++++++++
src/main.c | 20 ++++++++++++++++++++
2 files changed, 36 insertions(+)
New commits:
commit aa704ba8c2a1adce92ba8a154f70f1bdc950be1e
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Feb 8 16:33:16 2012 +0100
man: document systemd.setenv=
diff --git a/man/systemd.xml b/man/systemd.xml
index 121cb21..f0bc552 100644
--- a/man/systemd.xml
+++ b/man/systemd.xml
@@ -1068,6 +1068,22 @@
above.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><varname>systemd.setenv=</varname></term>
+
+ <listitem><para>Takes a string
+ argument in the form
+ VARIABLE=VALUE. May be used to set
+ environment variables for the init
+ process and all its children at boot
+ time. May be used more than once to
+ set multiple variables. If the equal
+ sign and variable are missing unsets
+ an environment variable which might be
+ passed in from the initial ram
+ disk.</para></listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
commit 9e7c53579a1d16287134e64f78ec5e1451aa2506
Author: William Douglas <william.r.douglas at gmail.com>
Date: Tue Feb 7 12:31:20 2012 -0800
systemd: Add systemd.setenv for /proc/cmdline parsing.
Check for systemd.setenv when parsing /proc/cmdline.
ex: systemd.setenv=PATH=/opt/bin
diff --git a/src/main.c b/src/main.c
index a849824..ed317b4 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;
More information about the systemd-commits
mailing list