diff --git a/crates/common/src/constants.rs b/crates/common/src/constants.rs index 48ed910..28958e3 100644 --- a/crates/common/src/constants.rs +++ b/crates/common/src/constants.rs @@ -2,16 +2,28 @@ pub const GP_USER_AGENT: &str = "PAN GlobalProtect"; pub const GP_SERVICE_LOCK_FILE: &str = "/var/run/gpservice.lock"; pub const GP_CALLBACK_PORT_FILENAME: &str = "gpcallback.port"; -// Release binaries are hardcoded paths -#[cfg(not(debug_assertions))] +// Release binaries - macOS (Apple Silicon Homebrew) +#[cfg(all(not(debug_assertions), target_os = "macos"))] +pub const GP_CLIENT_BINARY: &str = "/opt/homebrew/bin/gpclient"; +#[cfg(all(not(debug_assertions), target_os = "macos"))] +pub const GP_SERVICE_BINARY: &str = "/opt/homebrew/bin/gpservice"; +#[cfg(all(not(debug_assertions), target_os = "macos"))] +pub const GP_GUI_BINARY: &str = "/opt/homebrew/bin/gpgui"; +#[cfg(all(not(debug_assertions), target_os = "macos"))] +pub const GP_GUI_HELPER_BINARY: &str = "/opt/homebrew/bin/gpgui-helper"; +#[cfg(all(not(debug_assertions), target_os = "macos"))] +pub const GP_AUTH_BINARY: &str = "/opt/homebrew/bin/gpauth"; + +// Release binaries - Linux +#[cfg(all(not(debug_assertions), not(target_os = "macos")))] pub const GP_CLIENT_BINARY: &str = "/usr/bin/gpclient"; -#[cfg(not(debug_assertions))] +#[cfg(all(not(debug_assertions), not(target_os = "macos")))] pub const GP_SERVICE_BINARY: &str = "/usr/bin/gpservice"; -#[cfg(not(debug_assertions))] +#[cfg(all(not(debug_assertions), not(target_os = "macos")))] pub const GP_GUI_BINARY: &str = "/usr/bin/gpgui"; -#[cfg(not(debug_assertions))] +#[cfg(all(not(debug_assertions), not(target_os = "macos")))] pub const GP_GUI_HELPER_BINARY: &str = "/usr/bin/gpgui-helper"; -#[cfg(not(debug_assertions))] +#[cfg(all(not(debug_assertions), not(target_os = "macos")))] pub const GP_AUTH_BINARY: &str = "/usr/bin/gpauth"; // Debug binaries are set in build.rs via environment variables diff --git a/crates/gpapi/src/process/command_traits.rs b/crates/gpapi/src/process/command_traits.rs index 6bfbb18..b859392 100644 --- a/crates/gpapi/src/process/command_traits.rs +++ b/crates/gpapi/src/process/command_traits.rs @@ -11,10 +11,18 @@ pub trait CommandExt { impl CommandExt for Command { fn new_pkexec>(program: S) -> Command { - let mut cmd = Command::new("pkexec"); - cmd.arg("--user").arg("root").arg(program); - - cmd + #[cfg(target_os = "macos")] + { + let mut cmd = Command::new("sudo"); + cmd.arg(program); + cmd + } + #[cfg(not(target_os = "macos"))] + { + let mut cmd = Command::new("pkexec"); + cmd.arg("--user").arg("root").arg(program); + cmd + } } fn into_non_root(mut self) -> anyhow::Result {