Refactored subprocess spawning and fixed bug that prevented shell commands with arguments from running
This commit is contained in:
parent
d45025f0d2
commit
7566e34efc
1 changed files with 21 additions and 26 deletions
|
@ -424,16 +424,14 @@ impl EventReader {
|
||||||
async fn spawn_subprocess(&self, command_list: &Vec<String>) {
|
async fn spawn_subprocess(&self, command_list: &Vec<String>) {
|
||||||
let mut modifier_was_activated = self.modifier_was_activated.lock().await;
|
let mut modifier_was_activated = self.modifier_was_activated.lock().await;
|
||||||
*modifier_was_activated = true;
|
*modifier_was_activated = true;
|
||||||
match &self.environment.user {
|
match (&self.environment.user, &self.environment.sudo_user) {
|
||||||
Ok(user) if user == &"root".to_string() => {
|
(_, Ok(sudo_user)) => {
|
||||||
match &self.environment.sudo_user {
|
|
||||||
Ok(sudo_user) => {
|
|
||||||
for command in command_list {
|
for command in command_list {
|
||||||
match fork() {
|
match fork() {
|
||||||
Ok(Fork::Child) => {
|
Ok(Fork::Child) => {
|
||||||
Command::new("sh")
|
Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(format!("runuser {} -c {}", sudo_user.as_str(), command))
|
.arg(format!("runuser {} -c '{}'", sudo_user.as_str(), command))
|
||||||
.stdin(Stdio::null())
|
.stdin(Stdio::null())
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
|
@ -446,10 +444,7 @@ impl EventReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {}
|
(Ok(_), Err(_)) => {
|
||||||
}
|
|
||||||
},
|
|
||||||
Ok(_) => {
|
|
||||||
for command in command_list {
|
for command in command_list {
|
||||||
match fork() {
|
match fork() {
|
||||||
Ok(Fork::Child) => {
|
Ok(Fork::Child) => {
|
||||||
|
@ -467,8 +462,8 @@ impl EventReader {
|
||||||
Err(_) => std::process::exit(1),
|
Err(_) => std::process::exit(1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
Err(_) => {},
|
(_, _) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue