diff --git a/src/main.rs b/src/main.rs index e0e182be..b7e7165d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,7 @@ fn run() -> Result<(), Error> { let mut report = Report::new(); #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] - let sudo = utils::which("sudo"); + let sudo = utils::sudo(); let run_type = executor::RunType::new(config.dry_run()); #[cfg(feature = "self-update")] diff --git a/src/utils.rs b/src/utils.rs index ceaf3842..65048b5d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -80,6 +80,11 @@ pub fn which + Debug>(binary_name: T) -> Option { } } +#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))] +pub fn sudo() -> Option { + which("sudo").or_else(|| which("pkexec")) +} + /// `std::fmt::Display` implementation for `std::path::Path`. /// /// This struct differs from `std::path::Display` in that in Windows it takes care of printing backslashes