- Add GELI passphrase passthrough support to default grub.cfg

- Add detection for EFI mode at boot
 - Don't clobber ${PREFIX}/etc/grub.d/40_custom on re-install
 - Bump PORTREV
This commit is contained in:
Kris Moore 2014-10-22 17:02:59 +00:00
parent fc6c6e172d
commit be6fb223ff
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=371362
6 changed files with 59 additions and 23 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= grub2-pcbsd
PORTVERSION= 2.02p
PORTREVISION= 8
PORTREVISION= 9
CATEGORIES= sysutils
MASTER_SITES= http://www.pcbsd.org/~kris/software/ \
ftp://ftp.pcbsd.org/pub/software/
@ -88,6 +88,7 @@ post-install:
@${INSTALL_SCRIPT} ${WRKDIR}/10_kfreebsd ${STAGEDIR}${PREFIX}/etc/grub.d/
@${INSTALL_SCRIPT} ${WRKDIR}/10_ktrueos ${STAGEDIR}${PREFIX}/etc/grub.d/
@${INSTALL_SCRIPT} ${WRKDIR}/30_os-prober ${STAGEDIR}${PREFIX}/etc/grub.d/
@${MV} ${STAGEDIR}${PREFIX}/etc/grub.d/40_custom ${STAGEDIR}/${PREFIX}/etc/grub.d/40_custom.dist
.include <bsd.port.post.mk>

View file

@ -104,6 +104,11 @@ fi
export menuentry_id_option
if [ x"\${gelipassphrase}" != x ]; then
set pass=\$gelipassphrase
export pass
fi
if [ "\${prev_saved_entry}" ]; then
set saved_entry="\${prev_saved_entry}"
save_env saved_entry
@ -206,9 +211,20 @@ EOF
fi
cat << EOF
if [ x"\${grub_platform}" = xpc ] ; then
set gfxmode=${GRUB_GFXMODE}
load_video
insmod gfxterm
else
# EFI
insmod efi_gop
insmod gfxterm
insmod font
insmod videotest
insmod videoinfo
set gfxmode=${GRUB_GFXMODE}
set gfxpayload=vga=normal
fi
EOF
# Gettext variables and module

View file

@ -90,6 +90,9 @@ display_loaderopts()
rm /tmp/.sObjs.$$
done
# Using GELI encryption?
haveGELI="false"
# Now lets echo out the modules to load
if [ "$haveObjs" = "1" ] ; then
while read line
@ -108,6 +111,10 @@ display_loaderopts()
echo "$line" >> /tmp/.lSysCtls.$$
continue
fi
# Are we loading GELI module?
if [ "$module" = "geom_eli" ] ; then haveGELI="true" ; fi
echo " kfreebsd_module_elf ${loadPrefix}/@/boot/${mPath}/${module}.ko"
done < /tmp/.lRObjs.$$
fi
@ -131,6 +138,14 @@ display_loaderopts()
umount /mnt.$$ >/dev/null
rmdir /mnt.$$ >/dev/null
fi
# Set the grub.platform kenv variable
echo " set kFreeBSD.grub.platform=\$grub_platform"
# See if we need to do GELI passphrase passthrough
if [ "$haveGELI" = "true" ] ; then
echo " set kFreeBSD.kern.geom.eli.passphrase=\$pass"
fi
}
detect_beadm()

View file

@ -1,23 +1,5 @@
--- grub-core/disk/geli.c.orig 2014-05-15 14:00:10.000000000 -0400
+++ grub-core/disk/geli.c 2014-09-26 10:18:53.325111693 -0400
@@ -225,7 +225,7 @@
/* Look for GELI magic sequence. */
if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC))
- || grub_le_to_cpu32 (header->version) > 5
+ || grub_le_to_cpu32 (header->version) > 7
|| grub_le_to_cpu32 (header->version) < 1)
grub_util_error ("%s", _("wrong ELI magic or version"));
@@ -265,7 +265,7 @@
/* Look for GELI magic sequence. */
if (grub_memcmp (header.magic, GELI_MAGIC, sizeof (GELI_MAGIC))
- || grub_le_to_cpu32 (header.version) > 5
+ || grub_le_to_cpu32 (header.version) > 7
|| grub_le_to_cpu32 (header.version) < 1)
{
grub_dprintf ("geli", "wrong magic %02x\n", header.magic[0]);
@@ -430,6 +430,9 @@
if (!grub_password_get (passphrase, MAX_PASSPHRASE))
return grub_error (GRUB_ERR_BAD_ARGUMENT, "Passphrase not supplied");

View file

@ -0,0 +1,22 @@
#!/bin/sh
PREFIX=${PKG_PREFIX-/usr/local}
if [ "$2" != "POST-INSTALL" ] ; then
exit 0
fi
# If this is during staging, we can skip for now
echo $PREFIX | grep -q '/stage/'
if [ $? -eq 0 ] ; then
exit 0
fi
# Copy over user-editable 40_custom script
if [ ! -e "${PREFIX}/etc/grub.d/40_custom" ] ; then
cp ${PREFIX}/etc/grub.d/40_custom.dist ${PREFIX}/etc/grub.d/40_custom
chmod 755 ${PREFIX}/etc/grub.d/40_custom
fi
exit 0

View file

@ -155,7 +155,7 @@ man/man1/grub-syslinux2cfg.1.gz
man/man8/grub-macbless.8.gz
etc/grub.d/00_header
etc/grub.d/30_os-prober
etc/grub.d/40_custom
etc/grub.d/40_custom.dist
etc/grub.d/41_custom
etc/grub.d/10_kfreebsd
etc/grub.d/10_ktrueos