Check if blsdir exists before attempting to get it's real path

Resolves: rhbz#1677415

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-02-15 18:21:14 +01:00
parent e3a408a521
commit f6d4ab8f83
No known key found for this signature in database
GPG key ID: C751E590D63F3D69
3 changed files with 63 additions and 1 deletions

View file

@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Fri, 15 Feb 2019 18:15:45 +0100
Subject: [PATCH] Check if blsdir exists before attempting to get it's real
path
It's wrong to assume that the directory would always exist, grub2-mkconfig
shouldn't fail if that's not the case.
Resolves: rhbz#1677415
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
util/grub.d/10_linux.in | 9 ++++++---
util/grub.d/10_linux_bls.in | 9 ++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 7e80245a151..22a85c69ea0 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -166,9 +166,12 @@ fi
EOF
if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
- blsdir=$(make_system_path_relative_to_its_root "/boot/loader/entries")
- if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then
- ${grub_editenv} - set blsdir="${blsdir}"
+ blsdir="/boot/loader/entries"
+ if [ -d "${blsdir}" ]; then
+ blsdir=$(make_system_path_relative_to_its_root "${blsdir}")
+ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then
+ ${grub_editenv} - set blsdir="${blsdir}"
+ fi
fi
${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"
diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in
index f0ad9a3da25..47b87c8a14b 100644
--- a/util/grub.d/10_linux_bls.in
+++ b/util/grub.d/10_linux_bls.in
@@ -226,9 +226,12 @@ linux_entry ()
populate_menu
if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then
- blsdir=$(make_system_path_relative_to_its_root "/boot/loader/entries")
- if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then
- ${grub_editenv} - set blsdir="${blsdir}"
+ blsdir="/boot/loader/entries"
+ if [ -d "${blsdir}" ]; then
+ blsdir=$(make_system_path_relative_to_its_root "${blsdir}")
+ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then
+ ${grub_editenv} - set blsdir="${blsdir}"
+ fi
fi
${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}"

View file

@ -280,3 +280,4 @@ Patch0279: 0279-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch
Patch0280: 0280-Try-to-set-fPIE-and-friends-on-libgnu.a.patch
Patch0281: 0281-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch
Patch0282: 0282-Set-blsdir-if-the-BLS-directory-path-isn-t-one-of-th.patch
Patch0283: 0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch

View file

@ -7,7 +7,7 @@
Name: grub2
Epoch: 1
Version: 2.02
Release: 69%{?dist}
Release: 70%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -473,6 +473,10 @@ rm -r /boot/grub2.tmp/ || :
%endif
%changelog
* Fri Feb 15 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-70
- Check if blsdir exists before attempting to get it's real path
Resolves: rhbz#1677415
* Wed Feb 13 2019 Javier Martinez Canillas <javierm@redhat.com> - 2.02-69
- Don't make grub_strtoull() print an error if no conversion is performed
Resolves: rhbz#1674512