Skip to content

Commit

Permalink
refactor: deprioritize please-sudo (topgrade-rs#541)
Browse files Browse the repository at this point in the history
refactor: deprioritze please-sudo
  • Loading branch information
SteveLauC authored Aug 22, 2023
1 parent dc78b00 commit 13a46a4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/sudo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ impl Sudo {
pub fn detect() -> Option<Self> {
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 })
}

Expand All @@ -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
Expand All @@ -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")
}
Expand Down Expand Up @@ -112,10 +112,10 @@ impl Sudo {
#[strum(serialize_all = "lowercase")]
pub enum SudoKind {
Doas,
Please,
Sudo,
Gsudo,
Pkexec,
Please,
}

impl AsRef<OsStr> for Sudo {
Expand Down

0 comments on commit 13a46a4

Please sign in to comment.