diff --git a/src/main.rs b/src/main.rs index 22db6f3..b5428b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,4 +84,5 @@ async fn main() { // Main mainCommand(loaded_prefs); + } diff --git a/src/utils/luks.rs b/src/utils/luks.rs index b5799de..e6158c7 100644 --- a/src/utils/luks.rs +++ b/src/utils/luks.rs @@ -36,13 +36,17 @@ pub fn check_luks(mount_address: &String, user_password: &Option, pref: cmd }; - let mut child = command.spawn().expect("Failed to spawn cryptsetup command"); + let mut child = match command.spawn() { + Ok(child) => child, + Err(_) => return false, // Return false if spawn fails + }; if let Some(password) = user_password { if let Some(stdin) = child.stdin.as_mut() { stdin .write_all(format!("{}\n", password).as_bytes()) .expect("Failed to write sudo password to stdin"); + stdin.flush().expect("Failed to flush stdin"); } } @@ -96,6 +100,7 @@ pub fn lock(user_password: &Option, address: &String, config: &HashMap, address: &String, config: &HashMap