grub2/0283-Check-if-blsdir-exists-before-attempting-to-get-it-s.patch
Javier Martinez Canillas f6d4ab8f83
Check if blsdir exists before attempting to get it's real path
Resolves: rhbz#1677415

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2019-02-15 18:22:18 +01:00

58 lines
2.4 KiB
Diff

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}"