Skip to content

Commit

Permalink
always give 'interaction is required' once if a conversation error oc…
Browse files Browse the repository at this point in the history
…curred (#2)
  • Loading branch information
squell authored Dec 19, 2024
1 parent 169fe60 commit fd3cfec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/sudo/pam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,15 @@ pub fn attempt_authenticate<C: Converser>(
}

// there was an authentication error, we can retry
Err(PamError::Pam(PamErrorType::AuthError | PamErrorType::ConversationError, _)) => {
Err(PamError::Pam(
err_type @ (PamErrorType::AuthError | PamErrorType::ConversationError),
_,
)) => {
max_tries -= 1;
if max_tries == 0 {
return Err(Error::MaxAuthAttempts(current_try));
} else if non_interactive {
if non_interactive || err_type == PamErrorType::ConversationError {
return Err(Error::InteractionRequired);
} else if max_tries == 0 {
return Err(Error::MaxAuthAttempts(current_try));
} else {
user_warn!("Authentication failed, try again.");
}
Expand Down

0 comments on commit fd3cfec

Please sign in to comment.