diff options
-rw-r--r-- | src/main.rs | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs index 89db44c..c07af1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -261,28 +261,9 @@ fn validate_credentials(user_id: &str, user_password: &str) -> io::Result<bool> )) } -fn replace_slice<T>(src: &mut [T], old: &[T], new: &[T]) -where - T: Clone + PartialEq, -{ - let iteration = if src.starts_with(old) { - src[..old.len()].clone_from_slice(new); - old.len() - } else { - 1 - }; - - if src.len() > old.len() { - replace_slice(&mut src[iteration..], old, new); - } -} - fn modify_cmdline(old: &str, new: &str) -> Result<()> { - let boot = boot_dev()?; - - let mut cmdline = fs::read(boot)?; - replace_slice(&mut cmdline, old.as_bytes(), new.as_bytes()); - fs::write(boot, cmdline)?; + let cmdline = fs::read_to_string("/boot/cmdline.txt")?; + fs::write("/boot/cmdline.txt", cmdline.replace(old, new))?; nix::unistd::sync(); Ok(()) |