Skip to main content

try_interactive_auth_handoff

Function try_interactive_auth_handoff 

Source
pub fn try_interactive_auth_handoff() -> Result<bool, String>
Expand description

What: Perform interactive privilege-tool authentication with a TUI terminal handoff.

Inputs:

  • None (resolves the active privilege tool from settings).

Output:

  • Ok(true) if the user authenticated successfully.
  • Ok(false) if authentication was denied or cancelled.

§Errors

Returns Err if the terminal cannot be restored/setup or the tool cannot be resolved.

Details:

  • Temporarily restores the terminal (leave alternate screen, disable raw mode) so the user can interact with the privilege tool’s native prompt (password, fingerprint).
  • For sudo: runs sudo -v which refreshes the credential cache.
  • For doas: runs doas true; works seamlessly with persist in doas.conf. Without persist, the initial auth succeeds but subsequent PTY commands may re-prompt.
  • Re-enters TUI (alternate screen, raw mode) regardless of auth outcome.