Skip to content

Commit

Permalink
fix(pam/nativemodel): Do not report the authentication denied PAM err…
Browse files Browse the repository at this point in the history
…or twice (#553)

In case that the authentication failed, the authentication model sends a
pamError that includes the error message and that our pam module will
eventually write.

So, there's no need to handle the error again in the native module or
we'd duplicate such error string

UDENG-4763
  • Loading branch information
3v1n0 committed Sep 24, 2024
2 parents 1f7c6e5 + affbc42 commit faa84f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ invalid password 'wrongpass', should be 'goodpass'
Insert 'r' to cancel the request and go back
Gimme your password:
invalid password 'wrongpass', should be 'goodpass'
invalid password 'wrongpass', should be 'goodpass'
PAM Authenticate() for user "user-integration-max-attempts" exited with error (PAM exit code: 7)
: Authentication failure
acct=incomplete
Expand All @@ -294,6 +293,7 @@ dispatch




────────────────────────────────────────────────────────────────────────────────
> ./pam_authd login socket=${AUTHD_TESTS_CLI_AUTHENTICATE_TESTS_SOCK} force_native_client=true
Username: user-integration-max-attempts
Expand All @@ -316,7 +316,6 @@ invalid password 'wrongpass', should be 'goodpass'
Insert 'r' to cancel the request and go back
Gimme your password:
invalid password 'wrongpass', should be 'goodpass'
invalid password 'wrongpass', should be 'goodpass'
PAM Authenticate() for user "user-integration-max-attempts" exited with error (PAM exit code: 7)
: Authentication failure
acct=incomplete
Expand All @@ -327,4 +326,5 @@ dispatch




────────────────────────────────────────────────────────────────────────────────
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ invalid password 'wrongpass', should be 'goodpass'
Insert 'r' to cancel the request and go back
Gimme your password:
invalid password 'wrongpass', should be 'goodpass'
invalid password 'wrongpass', should be 'goodpass'
PAM ChangeAuthTok() for user "user-integration-max-attempts" exited with error (PAM exit code: 7
): Authentication failure
acct=incomplete
Expand All @@ -294,6 +293,7 @@ dispatch




────────────────────────────────────────────────────────────────────────────────
> ./pam_authd passwd socket=${AUTHD_TESTS_CLI_AUTHTOK_TESTS_SOCK} force_native_client=true
Username: user-integration-max-attempts
Expand All @@ -316,7 +316,6 @@ invalid password 'wrongpass', should be 'goodpass'
Insert 'r' to cancel the request and go back
Gimme your password:
invalid password 'wrongpass', should be 'goodpass'
invalid password 'wrongpass', should be 'goodpass'
PAM ChangeAuthTok() for user "user-integration-max-attempts" exited with error (PAM exit code: 7
): Authentication failure
acct=incomplete
Expand All @@ -327,4 +326,5 @@ dispatch




────────────────────────────────────────────────────────────────────────────────
5 changes: 4 additions & 1 deletion pam/internal/adapter/nativemodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,11 @@ func (m nativeModel) Update(msg tea.Msg) (nativeModel, tea.Cmd) {
case brokers.AuthNext:
m.uiLayout = nil
return m, maybeSendPamError(m.sendInfo(authMsg))
case brokers.AuthDenied, brokers.AuthRetry:
case brokers.AuthRetry:
return m, maybeSendPamError(m.sendError(authMsg))
case brokers.AuthDenied:
// This is handled by the main authentication model
return m, nil
case brokers.AuthCancelled:
return m, sendEvent(isAuthenticatedCancelled{})
default:
Expand Down

0 comments on commit faa84f2

Please sign in to comment.