diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-08-15 13:30:15 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-08-15 13:30:43 +0200 |
commit | 3411fef68cb2821687ae033b064ef44711380182 (patch) | |
tree | 0220fb7fd8ca189acdf81c3f67ccef5247b90e27 | |
parent | f52cb98b5da3a9080391c14c829080a2404c95eb (diff) |
Revert "overwrite boot partition to modify cmdline"
This reverts commit ce337ea566a7cda7c9a89c4080fa24a15256a1ed.
-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(()) |