Blame SOURCES/0269-unix-platform-Initialize-variable-to-fix-grub-instal.patch

4d592c
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4d592c
From: Paul Menzel <pmenzel@molgen.mpg.de>
4d592c
Date: Tue, 23 Oct 2018 15:00:13 +0200
4d592c
Subject: [PATCH] unix/platform: Initialize variable to fix grub-install on
4d592c
 UEFI system
4d592c
MIME-Version: 1.0
4d592c
Content-Type: text/plain; charset=UTF-8
4d592c
Content-Transfer-Encoding: 8bit
4d592c
4d592c
On a UEFI system, were no boot entry *grub* is present, currently,
4d592c
`grub-install` fails with an error.
4d592c
4d592c
    $ efibootmgr
4d592c
    BootCurrent: 0000
4d592c
    Timeout: 0 seconds
4d592c
    BootOrder: 0001,0006,0003,0004,0005
4d592c
    Boot0001  Diskette Drive
4d592c
    Boot0003* USB Storage Device
4d592c
    Boot0004* CD/DVD/CD-RW Drive
4d592c
    Boot0005  Onboard NIC
4d592c
    Boot0006* WDC WD2500AAKX-75U6AA0
4d592c
    $ sudo grub-install /dev/sda
4d592c
    Installing for x86_64-efi platform.
4d592c
    grub-install: error: efibootmgr failed to register the boot entry: Unknown error 22020.
4d592c
4d592c
The error code is always different, and the error message (incorrectly)
4d592c
points to efibootmgr.
4d592c
4d592c
But, the error is in GRUB’s function
4d592c
`grub_install_remove_efi_entries_by_distributor()`, where the variable
4d592c
`rc` for the return value, is uninitialized and never set, when no boot
4d592c
entry for the distributor is found.
4d592c
4d592c
The content of that uninitialized variable is then returned as the error
4d592c
code of efibootmgr.
4d592c
4d592c
Set the variable to 0, so that success is returned, when no entry needs
4d592c
to be deleted.
4d592c
4d592c
Tested on Dell OptiPlex 7010 with firmware A28.
4d592c
4d592c
    $ sudo ./grub-install /dev/sda
4d592c
    Installing for x86_64-efi platform.
4d592c
    Installation finished. No error reported.
4d592c
4d592c
[1]: https://github.com/rhboot/efibootmgr/issues/100
4d592c
4d592c
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
4d592c
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
4d592c
---
4d592c
 grub-core/osdep/unix/platform.c | 2 +-
4d592c
 1 file changed, 1 insertion(+), 1 deletion(-)
4d592c
4d592c
diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c
b71686
index ca448bc11..55b8f4016 100644
4d592c
--- a/grub-core/osdep/unix/platform.c
4d592c
+++ b/grub-core/osdep/unix/platform.c
4d592c
@@ -85,7 +85,7 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor)
4d592c
   pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd;;
4d592c
   char *line = NULL;
4d592c
   size_t len = 0;
4d592c
-  int rc;
4d592c
+  int rc = 0;
4d592c
 
4d592c
   if (!pid)
4d592c
     {