A WiFi security auditing software
deps: declare pkexec and diagnose it when the agent is launched (#184)
Martin Olivier334243edb1b1
diff --git a/crates/common/src/deps.rs b/crates/common/src/deps.rsindex 561278b..ee98b49 100644--- a/crates/common/src/deps.rs+++ b/crates/common/src/deps.rs@@ -28,6 +28,7 @@ pub struct Tool {pub const MDK4: &str = "mdk4";pub const CRUNCH: &str = "crunch";pub const SYSTEMCTL: &str = "systemctl";+pub const PKEXEC: &str = "pkexec";/// Every external tool airgorah shells out to.pub const TOOLS: &[Tool] = &[@@ -103,6 +104,11 @@ pub const TOOLS: &[Tool] = &[requirer: Requirer::Both,optional: true,},+ Tool {+ name: PKEXEC,+ requirer: Requirer::Gui,+ optional: true,+ },];/// Whether a tool is available on the current process's `PATH`.diff --git a/crates/gui/src/backend/client.rs b/crates/gui/src/backend/client.rsindex 0503bc9..d0d16d9 100644--- a/crates/gui/src/backend/client.rs+++ b/crates/gui/src/backend/client.rs@@ -185,7 +185,14 @@ fn spawn_agent() -> Result<Child, AgentError> {command} else {// Normal case: escalate only the agent, via polkit.- let mut command = Command::new("pkexec");+ if !deps::is_installed(deps::PKEXEC) {+ return Err(AgentError(+ "could not find 'pkexec' to start the privileged agent, install polkit, or run airgorah as root"+ .to_string(),+ ));+ }++ let mut command = Command::new(deps::PKEXEC);command.arg(&agent);command};