]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix: do not set cmdline for uefi images unless asked
authorMatthew Thode <mthode@mthode.org>
Fri, 29 Jan 2021 04:40:59 +0000 (22:40 -0600)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 8 Feb 2021 09:37:22 +0000 (10:37 +0100)
The kernel does not allow the cmdline to be overridden if one is defined
in the uefi image.  This means that bootloaders like systemd-boot or
grub cannot manage boot options (editing at boot for debug being a use
case).  This patchset allows for no cmdline to be set (instead of force
setting one if none is provided).

Fixes: https://github.com/dracutdevs/dracut/issues/1012
Signed-off-by: Matthew Thode <mthode@mthode.org>
dracut.sh

index 056a4114c34c2537842cc8f8b4e870ede049d4e3..ea26b646020f18d8917366d5259d768ffd5e8600 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -2163,13 +2163,16 @@ if [[ $uefi = yes ]]; then
             [ -e "$conf" ] || continue
             printf "%s " "$(< "$conf")" >> "$uefi_outdir/cmdline.txt"
         done
-    else
-        do_print_cmdline > "$uefi_outdir/cmdline.txt"
     fi
-    echo -ne "\x00" >> "$uefi_outdir/cmdline.txt"
 
-    dinfo "Using UEFI kernel cmdline:"
-    dinfo $(tr -d '\000' < "$uefi_outdir/cmdline.txt")
+    if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline = yes && -d "$initdir/etc/cmdline.d" ]]; then
+        echo -ne "\x00" >> "$uefi_outdir/cmdline.txt"
+        dinfo "Using UEFI kernel cmdline:"
+        dinfo $(tr -d '\000' < "$uefi_outdir/cmdline.txt")
+        uefi_cmdline="--add-section .cmdline="${uefi_outdir}/cmdline.txt" --change-section-vma .cmdline=0x30000"
+    else
+        uefi_cmdline=""
+    fi
 
     [[ -s $dracutsysrootdir/usr/lib/os-release ]] && uefi_osrelease="$dracutsysrootdir/usr/lib/os-release"
     [[ -s $dracutsysrootdir/etc/os-release ]] && uefi_osrelease="$dracutsysrootdir/etc/os-release"
@@ -2178,7 +2181,7 @@ if [[ $uefi = yes ]]; then
 
     if objcopy \
            ${uefi_osrelease:+--add-section .osrel=$uefi_osrelease --change-section-vma .osrel=0x20000} \
-           --add-section .cmdline="${uefi_outdir}/cmdline.txt" --change-section-vma .cmdline=0x30000 \
+           ${uefi_cmdline} \
            ${uefi_splash_image:+--add-section .splash="$uefi_splash_image" --change-section-vma .splash=0x40000} \
            --add-section .linux="$kernel_image" --change-section-vma .linux=0x2000000 \
            --add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd=0x3000000 \