Skip to content

Commit

Permalink
grub-install on EFI if forced
Browse files Browse the repository at this point in the history
UEFI Secure Boot requires signed grub binaries to work, so grub-
install should not be used. However, users who have Secure Boot
disabled and wish to use the command should not be prevented from
doing so if they invoke --force.

fixes bz#1917213 / bz#2240994

Signed-off-by: Marta Lewandowska <mlewando@redhat.com>
  • Loading branch information
marta-lewandowska authored and nfrayer committed Nov 7, 2023
1 parent 9f0f2df commit 0d383a5
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions util/grub-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,22 +899,6 @@ main (int argc, char *argv[])

platform = grub_install_get_target (grub_install_source_directory);

switch (platform)
{
case GRUB_INSTALL_PLATFORM_ARM_EFI:
case GRUB_INSTALL_PLATFORM_ARM64_EFI:
case GRUB_INSTALL_PLATFORM_I386_EFI:
case GRUB_INSTALL_PLATFORM_IA64_EFI:
case GRUB_INSTALL_PLATFORM_X86_64_EFI:
is_efi = 1;
grub_util_error (_("this utility cannot be used for EFI platforms"
" because it does not support UEFI Secure Boot"));
break;
default:
is_efi = 0;
break;
}

{
char *platname = grub_install_get_platform_name (platform);
fprintf (stderr, _("Installing for %s platform.\n"), platname);
Expand Down Expand Up @@ -1027,6 +1011,32 @@ main (int argc, char *argv[])
grub_hostfs_init ();
grub_host_init ();

switch (platform)
{
case GRUB_INSTALL_PLATFORM_I386_EFI:
case GRUB_INSTALL_PLATFORM_X86_64_EFI:
case GRUB_INSTALL_PLATFORM_ARM_EFI:
case GRUB_INSTALL_PLATFORM_ARM64_EFI:
case GRUB_INSTALL_PLATFORM_RISCV32_EFI:
case GRUB_INSTALL_PLATFORM_RISCV64_EFI:
case GRUB_INSTALL_PLATFORM_IA64_EFI:
is_efi = 1;
if (!force)
grub_util_error (_("This utility should not be used for EFI platforms"
" because it does not support UEFI Secure Boot."
" If you really wish to proceed, invoke the --force"
" option.\nMake sure Secure Boot is disabled before"
" proceeding"));
break;
default:
is_efi = 0;
break;

/* pacify warning. */
case GRUB_INSTALL_PLATFORM_MAX:
break;
}

/* Find the EFI System Partition. */
if (is_efi)
{
Expand Down

0 comments on commit 0d383a5

Please sign in to comment.