[Bug 1969367] Re: KeyError in uefi_find_duplicate_entries

Dan Bungert 1969367 at bugs.launchpad.net
Mon Apr 18 16:12:27 UTC 2022


Sounds like Curtin could stand some defensive checks.
Is this also something that should be addressed in grub?

** Also affects: grub2 (Ubuntu)
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/1969367

Title:
  KeyError in uefi_find_duplicate_entries

Status in curtin:
  New
Status in grub2 package in Ubuntu:
  New

Bug description:
  I attempted to install Ubuntu 20.04.03 and 22.04 (beta) over the
  weekend and ran into an issue where part of the Grub install step was
  causing a KeyError. The specific line that was throwing the error is:
  https://github.com/canonical/curtin/blob/master/curtin/commands/curthooks.py#L582

  After investigations it looks like the "BootCurrent" line returned by
  efibootmgr was showing '0000' as the current boot.  However, that line
  had not been processed as it was a USB device that doesn't seem to
  match the expected format in the parse function. That would then lead
  to the '0000' key not being added to the data structure and throwing a
  KeyError.

  I'm not sure if the solution should be to alter the previous line
  (https://github.com/canonical/curtin/blob/master/curtin/commands/curthooks.py#L581)
  to include a check against the keys, or if the regular expression at
  https://github.com/canonical/curtin/blob/60e076ceae67ac4bdea806062df69d0d25e9c32c/curtin/util.py#L932
  should be adjusted to allow for 0-width 'name' fields. (In this case
  the USB boot device was not given a name and therefore seems like it
  would fail the regex.)

  I wasn't able to figure out how I could test either of these
  solutions. My workaround was to replace the 'efibootmgr' executable
  temporarily and change the 'BootCurrent' parameter to '0001' which was
  in the dictionary and therefore would get past the KeyError. It seems
  to have worked for the install. Here is a rough script I did to
  replace it after the package was installed:

  sudo -i
  mv /target/usr/bin/efibootmgr /target/usr/bin/efibootmgr_orig
  echo <<EOF >/target/usr/bin/efibootmgr
  #!/bin/sh
  /target/usr/bin/efibootmgr_orig $@ | sed -e '/^BootCurrent/ s/0000/0001/'
  EOF
  chmod o+x /target/usr/bin/efibootmgr

To manage notifications about this bug go to:
https://bugs.launchpad.net/curtin/+bug/1969367/+subscriptions




More information about the foundations-bugs mailing list