From f6d4ab8f83d8f35dfcf5f9df53e4c5db8a25b995 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 15 Feb 2019 18:21:14 +0100 Subject: [PATCH] Check if blsdir exists before attempting to get it's real path Resolves: rhbz#1677415 Signed-off-by: Javier Martinez Canillas --- ...exists-before-attempting-to-get-it-s.patch | 57 +++++++++++++++++++ grub.patches | 1 + grub2.spec | 6 +- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch diff --git a/0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch b/0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch new file mode 100644 index 00000000..6ab14e8c --- /dev/null +++ b/0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch @@ -0,0 +1,57 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +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 +--- + 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}" diff --git a/grub.patches b/grub.patches index 52b31361..2c85d8d8 100644 --- a/grub.patches +++ b/grub.patches @@ -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 diff --git a/grub2.spec b/grub2.spec index 039246f1..d0186f9b 100644 --- a/grub2.spec +++ b/grub2.spec @@ -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 - 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 - 2.02-69 - Don't make grub_strtoull() print an error if no conversion is performed Resolves: rhbz#1674512