grub2/0208-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch
Javier Martinez Canillas 5b188159a7
Make the grub-switch-to-blscfg and 10_linux scripts more robust
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2020-04-16 21:42:23 +02:00

47 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Thu, 16 Apr 2020 18:53:03 +0200
Subject: [PATCH] grub-switch-to-blscfg: Use install to copy GRUB binary,
modules and config
By default the cp command truncates the destination before copying from the
source, so if interrupted it can lead to a file that's half written.
This behavior can be modified using the --remove-destination option, but is
usually a better choice to use the install tool for this. So let's do that.
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
util/grub-switch-to-blscfg.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in
index 4bbed8e4fe9..3333a620c28 100644
--- a/util/grub-switch-to-blscfg.in
+++ b/util/grub-switch-to-blscfg.in
@@ -273,7 +273,7 @@ copy_bls() {
if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \
! ${grub_editenv} - list | grep -q blsdir; then
grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)"
- cp ${grub_binary} ${grubdir} || exit 1
+ install -m 700 ${grub_binary} ${grubdir} || exit 1
# Create a hidden file to indicate that grub2 now has BLS support.
touch /boot/grub2/.grub2-blscfg-supported
fi
@@ -307,13 +307,13 @@ if [ "${GENERATE}" -eq 1 ] ; then
if [ -n "${mod_dir}" ]; then
for mod in blscfg increment; do
- cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1
+ install -m 700 ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1
done
fi
cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}"
if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then
- cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"
+ install -m 700 "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}"
sed -i"${backupsuffix}" \
-e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \
"${etcdefaultgrub}"