fix: wrap the password in quotes

#1460
This commit is contained in:
MystiPanda 2024-07-24 14:22:23 +08:00
parent 9528606906
commit 88d98517c8
No known key found for this signature in database

View File

@ -30,7 +30,7 @@ pub struct JsonResponse {
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
pub fn sudo(passwd: &String, cmd: String) -> StdCommand { pub fn sudo(passwd: &String, cmd: String) -> StdCommand {
let shell = format!("echo {} | sudo -S {}", passwd, cmd); let shell = format!("echo \"{}\" | sudo -S {}", passwd, cmd);
let mut command = StdCommand::new("bash"); let mut command = StdCommand::new("bash");
command.arg("-c").arg(shell); command.arg("-c").arg(shell);
command command