chiark / gitweb /
util-lib: read $SYSTEMD_PROC_CMDLINE if set when looking for the kernel cmdline
authorLennart Poettering <lennart@poettering.net>
Mon, 12 Dec 2016 12:42:06 +0000 (13:42 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
if we want to parse the kernel command line, let's check the
$SYSTEMD_PROC_CMDLINE environment variable first. This is useful for debugging
purposes.

src/basic/proc-cmdline.c

index 281833f..acdfec0 100644 (file)
 #include "virt.h"
 
 int proc_cmdline(char **ret) {
+        const char *e;
         assert(ret);
 
+        /* For testing purposes it is sometimes useful to be able to override what we consider /proc/cmdline to be */
+        e = secure_getenv("SYSTEMD_PROC_CMDLINE");
+        if (e) {
+                char *m;
+
+                m = strdup(e);
+                if (!m)
+                        return -ENOMEM;
+
+                *ret = m;
+                return 0;
+        }
+
         if (detect_container() > 0)
                 return get_process_cmdline(1, 0, false, ret);
         else