allow pkexec to be used instead of sudo (#201)

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
This commit is contained in:
Marc-Antoine Perennou
2019-08-20 14:02:13 +02:00
committed by Roey Darwish Dror
parent f5c2368a4d
commit fda52486b3
2 changed files with 6 additions and 1 deletions

View File

@@ -80,6 +80,11 @@ pub fn which<T: AsRef<OsStr> + Debug>(binary_name: T) -> Option<PathBuf> {
}
}
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
pub fn sudo() -> Option<PathBuf> {
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