Fix error messages wrongly being printed when executing blscfg command

Resolves: rhbz#1699761

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-05-15 12:26:03 +02:00
parent a9b371c2fb
commit d8cdcb3a21
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
4 changed files with 79 additions and 1 deletions

View File

@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 14 May 2019 20:37:44 +0200
Subject: [PATCH] Remove bogus load_env after blscfg command in 10_linux
The grubenv is already loaded in the 00_header snippet, so there's
no need to load it anywhere else.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
util/grub.d/10_linux.in | 3 ---
1 file changed, 3 deletions(-)
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 8f7ecf65df9..350903fa5ab 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -162,9 +162,6 @@ set default_kernelopts="root=${linux_root_device_thisversion} ro ${args}"
insmod blscfg
blscfg
-if [ -s \$prefix/grubenv ]; then
- load_env
-fi
EOF
if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then

View File

@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Wed, 15 May 2019 01:46:00 +0200
Subject: [PATCH] blscfg: Don't leave grub_errno set to an error if the command
succeeded
After a command is executed, the function grub_print_error() is called to
print any active error messages if these exist.
The blscfg command calls to the grub_strtol() function to try to convert
the default entry string to a number, in case the default is an index.
If this function is not able to do the conversion, it sets the grub_errno
variable to GRUB_ERR_BAD_NUMBER. But the blscfg command wrongly left that
set and so the caller would be confused thinking that the command failed
and that an error message has to be printed.
This caused the first error in the stack to be printed, polluting the GRUB
output and preventing the menu to be hidden. So reset the grub_error var
to GRUB_ERR_NONE again if was set to GRUB_ERR_BAD_NUMBER by grub_strtol().
Resolves: rhbz#1699761
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/commands/blscfg.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
index bd008b04bec..26dbe873fe4 100644
--- a/grub-core/commands/blscfg.c
+++ b/grub-core/commands/blscfg.c
@@ -999,8 +999,10 @@ is_default_entry(const char *def_entry, struct bls_entry *entry, int idx)
return true;
def_idx = (int)grub_strtol(def_entry, NULL, 0);
- if (grub_errno == GRUB_ERR_BAD_NUMBER)
+ if (grub_errno == GRUB_ERR_BAD_NUMBER) {
+ grub_errno = GRUB_ERR_NONE;
return false;
+ }
if (def_idx == idx)
return true;

View File

@ -298,3 +298,5 @@ Patch0297: 0297-Don-t-assume-that-boot-commands-will-only-return-on-.patch
Patch0298: 0298-Add-10_reset_boot_success-to-Makefile.patch
Patch0299: 0299-Fix-undefined-references-for-fdt-when-building-with-.patch
Patch0300: 0300-blscfg-remove-BLS-file-size-check.patch
Patch0301: 0301-Remove-bogus-load_env-after-blscfg-command-in-10_lin.patch
Patch0302: 0302-blscfg-Don-t-leave-grub_errno-set-to-an-error-if-the.patch

View File

@ -7,7 +7,7 @@
Name: grub2
Epoch: 1
Version: 2.02
Release: 82%{?dist}
Release: 83%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -518,6 +518,11 @@ rm -r /boot/grub2.tmp/ || :
%endif
%changelog
* Wed May 15 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-83
- Fix error messages wrongly being printed when executing blscfg command
Resolves: rhbz#1699761
- Remove bogus load_env after blscfg command in 10_linux
* Tue May 07 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-82
- Make blscfg module compatible at least up to the Fedora 19 GRUB core
Related: rhbz#1652806