grub2.spec: Conditionally set grub config stub to 0600 mode

When upgrading from <=2.06-90 to newer versions, the grub config stub
may have different mode than 0600, so set the latter if this is the case.

Resolves: #RHEL-45870
Signed-off-by: Leo Sandoval <lsandova@redhat.com>
This commit is contained in:
Leo Sandoval 2024-08-02 10:23:32 -06:00
parent 93795b8bea
commit d5d341df5d

View File

@ -16,7 +16,7 @@
Name: grub2
Epoch: 1
Version: 2.06
Release: 90%{?dist}
Release: 91%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -338,6 +338,13 @@ fi
if test ! -f ${GRUB_HOME}/grub.cfg; then
# there's no config in GRUB home, create one
grub2-mkconfig -o ${GRUB_HOME}/grub.cfg
else
GRUB_CFG_MODE=$(stat --format="%a" ${GRUB_HOME}/grub.cfg)
if ! test "${GRUB_CFG_MODE}" = "600"; then
# when upgrading from <=2.06-90 to newer versions, the grub config stub
# may have different mode than 0600, so set the latter if this is the case
chmod 0600 ${GRUB_HOME}/grub.cfg
fi
fi
# make sure grub.cfg is present before grepping it
@ -540,6 +547,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
%endif
%changelog
* Fri Aug 2 2024 Leo Sandoval <lsandova@redhat.com> - 2.06-91
- Set /boot/grub2/grub.cfg to 0600 mode if present
- Resolves: #RHEL-45870
* Thu Aug 1 2024 Nicolas Frayer <nfrayer@redhat.com> - 2.06-90
- grub2-mkconfig: Remove mountpoint check
- Related: #RHEL-32099