pub fn detect_privilege_tool() -> Option<PrivilegeTool>Expand description
What: Detect the preferred privilege escalation tool available on PATH.
Inputs: None.
Output:
Some(PrivilegeTool::Doas)whendoasis available.Some(PrivilegeTool::Sudo)when onlysudois available.Nonewhen neither tool is installed.
Details:
- Preference order (doas first, sudo fallback) matches Pacsea’s
Autoprivilege mode: sudo is present on most systems by default, so an installed doas signals a deliberate user choice. - Callers with an explicit user configuration should honor it via
is_privilege_tool_availableinstead of calling this. - Password handling is intentionally out of scope for arch-toolkit.
§Example
use arch_toolkit::install::detect_privilege_tool;
match detect_privilege_tool() {
Some(tool) => println!("Privilege tool: {tool}"),
None => eprintln!("No privilege tool (sudo/doas) found."),
}