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)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 15 May 2021 17:29:10 +0000 (19:29 +0200)
commit634c0e5e1034b58ef99bc8729db7c68219c947ab
tree2db63478375867a0533b9c5d5a5b845960b5cb47
parentd62208c253daa55128adfa4f43886298bea28b01
proc-cmdline: allow backslash escapes when parsing /proc/cmdline

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.

(cherry picked from commit d997861ea7dae633174cd80ab55552c020526b62)
(cherry picked from commit 0e6d3243ad3c5ae719c23e14b159c27344523583)
src/basic/proc-cmdline.c