]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: discard comments in cmdline files
authorrindeal <dev.rindeal@gmail.com>
Fri, 16 Aug 2024 00:16:57 +0000 (02:16 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 16 Aug 2024 08:15:39 +0000 (17:15 +0900)
It was quite a surprise to find my comments in a booted kernel cmdline.

src/kernel-install/90-loaderentry.install.in

index c9ba111393f3af79e530152e29db7f51a96aea89..832a82794cac677d56cb181e292854791446f5d5 100755 (executable)
@@ -73,12 +73,12 @@ SORT_KEY="$IMAGE_ID"
 
 if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then
     if [ -f "$KERNEL_INSTALL_CONF_ROOT/cmdline" ]; then
-        BOOT_OPTIONS="$(tr -s "$IFS" ' ' <"$KERNEL_INSTALL_CONF_ROOT/cmdline")"
+        BOOT_OPTIONS="$(grep -Gv '^\s*#' "$KERNEL_INSTALL_CONF_ROOT/cmdline" | tr -s "$IFS" ' ')"
     fi
 elif [ -f /etc/kernel/cmdline ]; then
-    BOOT_OPTIONS="$(tr -s "$IFS" ' ' </etc/kernel/cmdline)"
+    BOOT_OPTIONS="$(grep -Gv '^\s*#' /etc/kernel/cmdline | tr -s "$IFS" ' ')"
 elif [ -f /usr/lib/kernel/cmdline ]; then
-    BOOT_OPTIONS="$(tr -s "$IFS" ' ' </usr/lib/kernel/cmdline)"
+    BOOT_OPTIONS="$(grep -Gv '^\s*#' /usr/lib/kernel/cmdline | tr -s "$IFS" ' ')"
 elif ! systemd-detect-virt --container --quiet; then
     BOOT_OPTIONS="$(tr -s "$IFS" '\n' </proc/cmdline | grep -ve '^BOOT_IMAGE=' -e '^initrd=' | tr '\n' ' ')"
 else