From 13a46a44a8cc7c3f89ad22f28fb0889a417d5e29 Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Tue, 22 Aug 2023 09:14:29 +0800 Subject: [PATCH] refactor: deprioritize please-sudo (#541) refactor: deprioritze please-sudo --- src/sudo.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sudo.rs b/src/sudo.rs index 094ac42f..b51a283a 100644 --- a/src/sudo.rs +++ b/src/sudo.rs @@ -26,10 +26,10 @@ impl Sudo { pub fn detect() -> Option { which("doas") .map(|p| (p, SudoKind::Doas)) - .or_else(|| which("please").map(|p| (p, SudoKind::Please))) .or_else(|| which("sudo").map(|p| (p, SudoKind::Sudo))) .or_else(|| which("gsudo").map(|p| (p, SudoKind::Gsudo))) .or_else(|| which("pkexec").map(|p| (p, SudoKind::Pkexec))) + .or_else(|| which("please").map(|p| (p, SudoKind::Please))) .map(|(path, kind)| Self { path, kind }) } @@ -55,12 +55,6 @@ impl Sudo { // See: https://man.openbsd.org/doas cmd.arg("echo"); } - SudoKind::Please => { - // From `man please` - // -w, --warm - // Warm the access token and exit. - cmd.arg("-w"); - } SudoKind::Sudo => { // From `man sudo` on macOS: // -v, --validate @@ -85,6 +79,12 @@ impl Sudo { // See: https://linux.die.net/man/1/pkexec cmd.arg("echo"); } + SudoKind::Please => { + // From `man please` + // -w, --warm + // Warm the access token and exit. + cmd.arg("-w"); + } } cmd.status_checked().wrap_err("Failed to elevate permissions") } @@ -112,10 +112,10 @@ impl Sudo { #[strum(serialize_all = "lowercase")] pub enum SudoKind { Doas, - Please, Sudo, Gsudo, Pkexec, + Please, } impl AsRef for Sudo {