fix: do not set cmdline for uefi images unless asked

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>
master
Matthew Thode 2021-01-28 22:40:59 -06:00 committed by Harald Hoyer
parent 4026cd3b01
commit 8a2edb1e4d
1 changed files with 9 additions and 6 deletions

View File

@ -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 \