Skip to main content

validate_password

Function validate_password 

Source
pub fn validate_password(
    tool: PrivilegeTool,
    password: &str,
) -> Result<bool, String>
Expand description

What: Validate a password against the privilege tool.

Inputs:

  • tool: Resolved privilege tool.
  • password: Password to validate.

Output:

  • Ok(true) if valid, Ok(false) if invalid.
  • Err if the tool doesn’t support stdin password or the check fails.

§Errors

  • Returns Err if the tool does not support stdin password validation.
  • Returns Err if the validation command cannot be executed.

Details:

  • Only works for tools with supports_stdin_password (currently sudo only).
  • First invalidates cached credentials, then tests the password.