]> err.no Git - systemd/commitdiff
systemd: Add systemd.setenv for /proc/cmdline parsing.
authorWilliam Douglas <william.r.douglas@gmail.com>
Tue, 7 Feb 2012 20:31:20 +0000 (12:31 -0800)
committerLennart Poettering <lennart@poettering.net>
Wed, 8 Feb 2012 15:33:55 +0000 (16:33 +0100)
Check for systemd.setenv when parsing /proc/cmdline.
ex: systemd.setenv=PATH=/opt/bin

src/main.c

index a849824bb3fb2cf92645690bb16b881533a4e2c4..ed317b44132235a7c4b63e57863813056a0dcd2e 100644 (file)
@@ -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;