From c1a1c7ed828d9b558077d616481c1527065d71fc Mon Sep 17 00:00:00 2001 From: Lleyton Gray Date: Sun, 29 Dec 2024 19:56:55 -0800 Subject: [PATCH] cleanup: don't use run_as_root in grub, we're already root --- src/backend/postinstall/grub2.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/backend/postinstall/grub2.rs b/src/backend/postinstall/grub2.rs index 0e55fd9..11b98f3 100644 --- a/src/backend/postinstall/grub2.rs +++ b/src/backend/postinstall/grub2.rs @@ -85,7 +85,11 @@ GRUB_ENABLE_BLSCFG={enable_blsconfig} fn grub2_install_bios>(disk: P) -> std::io::Result<()> { info!("Generating GRUB2 configuration..."); // this should probably be run inside a chroot... but we'll see - if let Err(e) = run_as_root("grub2-mkconfig -o /boot/grub2/grub.cfg") { + if let Err(e) = Command::new("grub2-mkconfig") + .arg("-o") + .arg("/boot/grub2/grub.cfg") + .status() + { warn!("Failed to generate GRUB2 configuration: {e}"); // Check if the file still exists @@ -94,10 +98,12 @@ fn grub2_install_bios>(disk: P) -> std::io::Result<()> { } } info!("Blessing the disk with GRUB2..."); - run_as_root(&format!( - "grub2-install --target=i386-pc --recheck --boot-directory=/boot {}", - disk.as_ref().display() - ))?; + Command::new("grub2-install") + .arg("--target=i386-pc") + .arg("--recheck") + .arg("--boot-directory=/boot") + .arg(disk.as_ref()) + .status()?; Ok(()) }