]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
proc-cmdline: allow backslash escapes when parsing /proc/cmdline
authorLennart Poettering <lennart@poettering.net>
Tue, 6 Apr 2021 09:45:47 +0000 (11:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Apr 2021 14:19:35 +0000 (16:19 +0200)
So far when parsing /proc/cmdline we'd consider backslashes as
mechanisms for escaping whitepace or quotes. This changes things so that
they are retained as they are instead. The kernel itself doesn't allow such
escaping, and hence we shouldn't do so either (see lib/cmdline.c in the
kernel sources; it does support "" quotes btw).

This fix is useful to allow specifying backslash escapes in the "root="
cmdline option to be passed through to systemd-fstab-generator. Example:

    root=/dev/disk/by-partlabel/Root\x20Partition

Previously we'd eat up the "\" so that we'd then look for a device
/dev/disk/by-partlabel/Rootx20Partition which never shows up.

src/basic/proc-cmdline.c

index 0b6fb137bdc304e3921aed759b56a4871d6e92f6..410b8a3eb5de67e7d1defd0a5377bf8441520102 100644 (file)
@@ -47,7 +47,7 @@ static int proc_cmdline_extract_first(const char **p, char **ret_word, ProcCmdli
                 _cleanup_free_ char *word = NULL;
                 const char *c;
 
-                r = extract_first_word(&q, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX);
+                r = extract_first_word(&q, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RELAX|EXTRACT_RETAIN_ESCAPE);
                 if (r < 0)
                         return r;
                 if (r == 0)