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

Bug#826665: libdebian-installer: libd-i EFI detection can pass while efibootmgr's/efivar's will fail



Package: libdebian-installer
Version: 0.102
Severity: normal
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu yakkety ubuntu-patch

Dear Maintainer,

EFI detection in libd-i can in some cases pass while efibootmgr will fail to
set BootEntry due to efivar's checks actually looking for efivars or vars
instead of just the existence of /sys/firmware/efi.

In Ubuntu; I'm applying the following patch to libdebian-installer's detection
code:

  * src/system/efi.c: validate the presence of efivars *or* vars under
    /sys/firmware/efi to decide whether we should show the system as running
    in EFI mode; either of these paths is required for efibootmgr to set a
    BootEntry at the end of installation.

Admittedly, this can still fail if for some reason efivars or vars are present
but empty, but this isn't any different than for /sys/firmware/efi itself.

/sys/firmware/efi/vars should mostly always be around, as it appears to come
straight from the kernel; /sys/firmware/efi/efivars is typically to be mounted
by the init system (this happens at least in systemd src/core/mount-setup.c).

In Ubuntu this is bug:
https://bugs.launchpad.net/ubuntu/+source/libdebian-installer/+bug/1582320

Thanks for considering the patch.


-- System Information:
Debian Release: stretch/sid
  APT prefers yakkety
  APT policy: (500, 'yakkety'), (99, 'yakkety-proposed')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.4.0-23-generic (SMP w/4 CPU cores)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
diff -Nru libdebian-installer-0.102ubuntu1/src/system/efi.c libdebian-installer-0.102ubuntu2/src/system/efi.c
--- libdebian-installer-0.102ubuntu1/src/system/efi.c	2015-12-23 19:24:26.000000000 -0500
+++ libdebian-installer-0.102ubuntu2/src/system/efi.c	2016-06-03 21:22:39.000000000 -0400
@@ -26,8 +26,9 @@
  * exists */
 int di_system_is_efi(void)
 {
-	int ret = access("/sys/firmware/efi", R_OK);
-	if (ret == 0)
+	int efivars_access = access("/sys/firmware/efi/efivars", R_OK);
+	int vars_access = access("/sys/firmware/efi/vars", R_OK);
+	if (efivars_access == 0 || vars_access == 0)
 	{
 		/* Have we been told to ignore EFI in partman-efi? */
 		ret = access("/var/lib/partman/ignore_uefi", R_OK);

Reply to: