grub/grub-core/osdep/unix
Paul Menzel 91ac8687a9 unix/platform: Initialize variable to fix grub-install on UEFI system
On a UEFI system, were no boot entry *grub* is present, currently,
`grub-install` fails with an error.

    $ efibootmgr
    BootCurrent: 0000
    Timeout: 0 seconds
    BootOrder: 0001,0006,0003,0004,0005
    Boot0001  Diskette Drive
    Boot0003* USB Storage Device
    Boot0004* CD/DVD/CD-RW Drive
    Boot0005  Onboard NIC
    Boot0006* WDC WD2500AAKX-75U6AA0
    $ sudo grub-install /dev/sda
    Installing for x86_64-efi platform.
    grub-install: error: efibootmgr failed to register the boot entry: Unknown error 22020.

The error code is always different, and the error message (incorrectly)
points to efibootmgr.

But, the error is in GRUB’s function
`grub_install_remove_efi_entries_by_distributor()`, where the variable
`rc` for the return value, is uninitialized and never set, when no boot
entry for the distributor is found.

The content of that uninitialized variable is then returned as the error
code of efibootmgr.

Set the variable to 0, so that success is returned, when no entry needs
to be deleted.

Tested on Dell OptiPlex 7010 with firmware A28.

    $ sudo ./grub-install /dev/sda
    Installing for x86_64-efi platform.
    Installation finished. No error reported.

[1]: https://github.com/rhboot/efibootmgr/issues/100

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 13:46:34 -04:00
..
compress.c Rewrite grub-install, grub-mkrescue, grub-mkstandalone and grub-mknetdir 2013-11-16 20:21:16 +01:00
config.c * grub-core/osdep/unix/config.c: Remove extraneous comma. 2014-09-21 17:49:13 +02:00
cputime.c unix/cputime.c: Cache sc_clk_tck and check it for sanity. 2015-01-21 17:42:15 +01:00
dl.c Move OS-dependent mprotect for module loading to grub-core/osdep/*/dl.c 2013-12-08 18:08:23 +01:00
emuconsole.c * grub-core/osdep/unix/emuconsole.c (put): Pacify the compiler on 2013-11-13 13:34:57 +00:00
exec.c unix exec: avoid atexit handlers when child exits 2020-09-21 12:02:37 -04:00
getroot.c grub-probe: Don't skip /dev/mapper/dm-* devices 2020-09-21 13:19:10 -04:00
hostdisk.c Support lseek64. 2020-09-21 11:32:45 -04:00
password.c unix: do not close stdin in grub_passwd_get 2015-11-18 22:23:58 +03:00
platform.c unix/platform: Initialize variable to fix grub-install on UEFI system 2020-09-21 13:46:34 -04:00
random.c Add a wrapper for fopen. On unix-like systems just pass-through. On 2013-10-13 20:36:28 +02:00
relpath.c unix/relpath: memory leak 2015-06-19 18:38:25 +03:00
sleep.c Move sleep routines to grub-core/osdep. 2013-10-08 17:38:46 +02:00