Skip to content

Commit 30ce64c

Browse files
committed
grubconfig: set grub.cfg file mode to 0600
See #952
1 parent 766bb80 commit 30ce64c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
shim="shimaa64.efi"
8686
fi
8787
sudo ls /mnt/EFI/centos/{grub.cfg,${shim}}
88+
[ $(stat -c "%a" /mnt/EFI/centos/grub.cfg) == "600" ]
8889
sudo umount /mnt
8990
sudo losetup -D "${device}"
9091
sudo rm -f myimage.raw
@@ -99,3 +100,4 @@ jobs:
99100
--disable-selinux --replace=alongside /target
100101
# Verify we injected static configs
101102
jq -re '.["static-configs"].version' /boot/bootupd-state.json
103+
[ $(stat -c "%a" /boot/grub2/grub.cfg) == "600" ]

src/grubconfigs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ const DROPINDIR: &str = "configs.d";
1717
const GRUBENV: &str = "grubenv";
1818
pub(crate) const GRUBCONFIG: &str = "grub.cfg";
1919
pub(crate) const GRUBCONFIG_BACKUP: &str = "grub.cfg.backup";
20+
// File mode for grub config
21+
// https://github.com/coreos/bootupd/issues/952
22+
const GRUBCONFIG_FILE_MODE: u32 = 0o600;
2023

2124
/// Install the static GRUB config files.
2225
#[context("Installing static GRUB configs")]
@@ -67,7 +70,7 @@ pub(crate) fn install(
6770

6871
let grub2dir = bootdir.sub_dir(GRUB2DIR)?;
6972
grub2dir
70-
.write_file_contents("grub.cfg", 0o644, config.as_bytes())
73+
.write_file_contents("grub.cfg", GRUBCONFIG_FILE_MODE, config.as_bytes())
7174
.context("Copying grub-static.cfg")?;
7275
println!("Installed: grub.cfg");
7376

@@ -103,6 +106,7 @@ pub(crate) fn install(
103106
efidir
104107
.copy_file(&Path::new(CONFIGDIR).join("grub-static-efi.cfg"), target)
105108
.context("Copying static EFI")?;
109+
efidir.set_mode(target, GRUBCONFIG_FILE_MODE)?;
106110
println!("Installed: {target:?}");
107111
if let Some(uuid_path) = uuid_path {
108112
let target = &vendor.join(uuid_path);

0 commit comments

Comments
 (0)