[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#925309: Wrong prefix directory hardcoded in signed GRUB image



Control: reassign -1 grub-efi-amd64-bin
Control: tags -1 patch

On 13/12/2022 at 16:00, Pascal Hambourg wrote:
On 24/03/2019 at 01:10, Colin Watson wrote:

Possibly.  The prefix parameter given to grub-mkimage's -p option has to
be an actual path, not a variable reference.  In order to make it use
$cmdpath, we'd need another one of the arrangements we use for some of
the other pre-built images to use a config file embedded in a memdisk.

An initial config file (memdisk)/grub.cfg is now embedded in the signed core image along with the font file.

1) If /EFI/debian/grub.cfg exists, it is still used even if /EFI/<id>/grub.cfg also exists. This is an issue when installing multiple instances of GRUB for different Debian systems if one has the default <id>="debian". Is it conceivable to reverse the order and use $cmdpath/grub.cfg first ?

Patch attached.
The config file embedded in the normal disk boot image was obviously designed for the CD boot image. This patch uses a separate config file which searches in $cmdpath then $prefix.

2) The file /EFI/<id>/BOOT${ARCH}.CSV always contains the name "debian" regardless of the identifier <id> specified by --bootloader-id on the grub-install command line or $GRUB_DISTRIBUTOR in /etc/default/grub.

I will look into this next.
From a6b8a5b2f0e1c45803238501defcc4492a74e854 Mon Sep 17 00:00:00 2001
From: Pascal Hambourg <pascal@plouf.fr.eu.org>
Date: Thu, 22 Dec 2022 00:40:48 +0100
Subject: [PATCH] Make normal disk boot image search grub.cfg in $cmdpath first

The grub.cfg file embedded in the normal disk boot image is for a CD
boot image, not a normal disk boot image.

Instead, use a new grub.cfg file which searches for the next grub.cfg
in $cmdpath (boot image path) first, then $prefix so that it works
with --bootloader-id or GRUB_DISTRIBUTOR other than the default.
---
 debian/build-efi-images | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/debian/build-efi-images b/debian/build-efi-images
index cbf95553f..4640b872d 100755
--- a/debian/build-efi-images
+++ b/debian/build-efi-images
@@ -63,6 +63,14 @@ echo 'normal (memdisk)/grub.cfg' >"$workdir/grub-bootstrap.cfg"
 
 # Skeleton configuration file which finds the real boot disk.
 cat >"$workdir/grub.cfg" <<EOF
+if [ -e \$cmdpath/grub.cfg ]; then
+	source \$cmdpath/grub.cfg
+else
+	source \$prefix/grub.cfg
+fi
+EOF
+
+cat >"$workdir/grub-cd.cfg" <<EOF
 if [ -z "\$prefix" -o ! -e "\$prefix" ]; then
 	if ! search --file --set=root /.disk/info; then
 		search --file --set=root /.disk/mini-info
@@ -105,6 +113,15 @@ done
 # Let's show what's here so we have it in build logs
 mdir -/ -i "$workdir/memdisk.fat"
 
+mkfs.msdos -C "$workdir/memdisk-cd.fat" $FATFS_SIZE
+mcopy -i "$workdir/memdisk-cd.fat" "$workdir/grub-cd.cfg" ::grub.cfg
+mmd -i "$workdir/memdisk-cd.fat" ::fonts
+for FONT in $FONTS; do
+    mcopy -i "$workdir/memdisk-cd.fat" "$FONT" ::fonts/$(basename $FONT)
+done
+# Let's show what's here so we have it in build logs
+mdir -/ -i "$workdir/memdisk-cd.fat"
+
 mkfs.msdos -C "$workdir/memdisk-netboot.fat" $FATFS_SIZE
 mcopy -i "$workdir/memdisk-netboot.fat" "$workdir/grub-netboot.cfg" ::grub.cfg
 mmd -i "$workdir/memdisk-netboot.fat" ::fonts
@@ -231,7 +248,7 @@ echo "Including modules $CD_MODULES in $outdir/gcd$efi_name.efi"
     -o "$outdir/gcd$efi_name.efi" \
     -c "$workdir/grub-bootstrap.cfg" \
     -d "$grub_core" \
-    -m "$workdir/memdisk.fat" \
+    -m "$workdir/memdisk-cd.fat" \
     -p /boot/grub \
     --sbat "$sbat_csv" \
     $CD_MODULES
-- 
2.30.2


Reply to: