From 9c6e5cf6c8e597efbf6a10399371789fddafac12 Mon Sep 17 00:00:00 2001 From: Nicolas Frayer Date: Tue, 16 Jul 2024 11:36:09 +0200 Subject: [PATCH] grub2-mkconfig: Prevent mkconfig from overwriting grub cfg stub Resolves: #RHEL-32099 Signed-off-by: Nicolas Frayer --- ...nsure-grub-cfg-stub-is-not-overwritt.patch | 40 +++++++++++++++++++ grub.patches | 3 +- grub2.spec | 6 ++- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch diff --git a/0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch b/0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch new file mode 100644 index 0000000..fc76a5e --- /dev/null +++ b/0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nicolas Frayer +Date: Tue, 16 Jul 2024 11:11:43 +0200 +Subject: [PATCH] grub2-mkconfig: Ensure grub cfg stub is not overwritten + +/boot/efi/EFI/$os_name/grub.cfg contains a grub cfg stub +that should not be overwritten by grub2-mkconfig. +Ensure that we prevent this from happening. + +Signed-off-by: Marta Lewandowska +Signed-off-by: Nicolas Frayer +--- + util/grub-mkconfig.in | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index 34f7c13fc521..34d0120d0ba2 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -114,6 +114,20 @@ do + esac + done + ++os_name=$(grep '^ID=' /etc/os-release | sed 's/ID=//') ++if test "$os_name" = '"rhel"'; then ++ os_name=redhat ++elif test "$os_name" = '"centos"'; then ++ os_name=centos ++fi ++if test "x${grub_cfg}" = "x/boot/efi/EFI/$os_name/grub.cfg" &&\ ++ mountpoint -q /boot/efi; then ++ gettext_printf "Running \`grub2-mkconfig -o %s' will overwrite the GRUB wrapper.\n" "$grub_cfg" 1>&2 ++ gettext_printf "Please run \`grub2-mkconfig -o /boot/grub2/grub.cfg' instead to update grub.cfg.\n" 1>&2 ++ gettext_printf "GRUB configuration file was not updated.\n" 1>&2 ++ exit 1 ++fi ++ + if [ "x$EUID" = "x" ] ; then + EUID=`id -u` + fi diff --git a/grub.patches b/grub.patches index 9df6ce7..ce57635 100644 --- a/grub.patches +++ b/grub.patches @@ -347,4 +347,5 @@ Patch0346: 0346-chainloader-remove-device-path-debug-message.patch Patch0347: 0347-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch Patch0348: 0348-add-flag-to-only-search-root-dev.patch Patch0349: 0349-Ignore-warnings-for-incompatible-types.patch -Patch0350: 0350-fs-xfs-Fix-XFS-directory-extent-parsing.patch \ No newline at end of file +Patch0350: 0350-fs-xfs-Fix-XFS-directory-extent-parsing.patch +Patch0351: 0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch diff --git a/grub2.spec b/grub2.spec index b06cb7a..187c3f4 100644 --- a/grub2.spec +++ b/grub2.spec @@ -17,7 +17,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 120%{?dist} +Release: 121%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPL-3.0-or-later URL: http://www.gnu.org/software/grub/ @@ -573,6 +573,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Tue Jul 16 2024 Nicolas Frayer - 2.06-121 +- grub2-mkconfig: Prevent mkconfig from overwriting grub cfg stub +- Resolves: #RHEL-32099 + * Mon Jun 24 2024 Troy Dawson - Bump release for June 2024 mass rebuild