From ce337ea566a7cda7c9a89c4080fa24a15256a1ed Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Fri, 5 May 2023 18:22:01 +0200 Subject: overwrite boot partition to modify cmdline should be more reliable than trying to write a regular file --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2997ec7..696a2ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -157,8 +157,10 @@ fn validate_credentials(user_id: &str, user_password: &str) -> io::Result } fn modify_cmdline(old: &str, new: &str) -> Result<()> { - let cmdline = fs::read_to_string("/boot/cmdline.txt")?; - fs::write("/boot/cmdline.txt", cmdline.replace(old, new))?; + let boot = boot_dev()?; + + let cmdline = fs::read_to_string(boot)?; + fs::write(boot, cmdline.replace(old, new))?; Ok(()) } @@ -254,8 +256,6 @@ fn switch_to_inactive_root() -> Result<()> { let old = String::from("root=PARTUUID=00000000-0") + &old.chars().last().unwrap().to_string(); let new = String::from("root=PARTUUID=00000000-0") + &new.chars().last().unwrap().to_string(); - println!("[admind] rewrite cmdline {} -> {}", old, new); - modify_cmdline(&old, &new)?; Ok(()) } -- cgit v1.2.3