]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
proc-cmdline: teach proc_cmdline_get_key() the same flags magic as proc_cmdline_parse() 10534/head
authorLennart Poettering <lennart@poettering.net>
Fri, 26 Oct 2018 10:02:55 +0000 (12:02 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 26 Oct 2018 10:03:32 +0000 (12:03 +0200)
src/basic/proc-cmdline.c

index b8839ef52cb546aeff4b13e2d27a2e7087e577ad..205ea08f6da1b02f3b929ff1e0403e7708639949 100644 (file)
@@ -159,7 +159,7 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) {
         p = line;
         for (;;) {
                 _cleanup_free_ char *word = NULL;
-                const char *e;
+                const char *e, *k, *q;
 
                 r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
                 if (r < 0)
@@ -167,13 +167,23 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) {
                 if (r == 0)
                         break;
 
+                k = word;
+
                 /* Automatically filter out arguments that are intended only for the initrd, if we are not in the
                  * initrd. */
-                if (!in_initrd() && startswith(word, "rd."))
+                q = startswith(word, "rd.");
+                if (q) {
+                        if (!in_initrd())
+                                continue;
+
+                        if (FLAGS_SET(flags, PROC_CMDLINE_STRIP_RD_PREFIX))
+                                k = q;
+
+                } else if (FLAGS_SET(flags, PROC_CMDLINE_RD_STRICT) && in_initrd())
                         continue;
 
                 if (value) {
-                        e = proc_cmdline_key_startswith(word, key);
+                        e = proc_cmdline_key_startswith(k, key);
                         if (!e)
                                 continue;
 
@@ -188,7 +198,7 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) {
                                 found = true;
 
                 } else {
-                        if (streq(word, key))
+                        if (streq(k, key))
                                 found = true;
                 }
         }