Skip to content

Commit

Permalink
pam: Ensure that the user is properly set in the pam stack
Browse files Browse the repository at this point in the history
Print it once authenticated so that we are sure that the expected user
is passed to the pam stack.
  • Loading branch information
3v1n0 committed Jan 11, 2024
1 parent f02106f commit a03d1a9
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Gimme your password
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
Auth success
Auth user 'user-local-groups' success
AcctMgmt success
>

Expand Down Expand Up @@ -165,7 +165,7 @@ AcctMgmt success
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
Auth success
Auth user 'user-local-groups' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Enter your new password (3 days until mandatory)
>
>

Auth success
Auth user 'user-can-reset' success
AcctMgmt success
>

Expand Down Expand Up @@ -234,7 +234,7 @@ Enter your new password (3 days until mandatory)
>
>

Auth success
Auth user 'user-can-reset' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Enter your new password
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Enter your new password
> *******
Auth success
Auth user 'user-needs-reset' success
AcctMgmt success
>

Expand Down Expand Up @@ -265,7 +265,7 @@ AcctMgmt success
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Enter your new password
> *******
Auth success
Auth user 'user-needs-reset' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Gimme your password
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
Auth success
Auth user 'user1' success
AcctMgmt success
>

Expand Down Expand Up @@ -165,7 +165,7 @@ AcctMgmt success
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
Auth success
Auth user 'user1' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ Gimme your password
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
Auth success
Auth user 'user-integration-switch-mode' success
AcctMgmt success
>

Expand Down Expand Up @@ -363,7 +363,7 @@ AcctMgmt success
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
Auth success
Auth user 'user-integration-switch-mode' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ Gimme your password



Auth error (25): The return value should be ignored by PAM dispatch:
Auth user 'user-integration-switch-broker' error (25): The return value should be ignored by PAM
dispatch:
AcctMgmt error (25): The return value should be ignored by PAM dispatch
>
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Select your provider
Expand Down Expand Up @@ -258,7 +258,7 @@ AcctMgmt error (25): The return value should be ignored by PAM dispatch



Auth error (25): The return value should be ignored by PAM dispatch:
Auth user 'user-integration-switch-broker' error (25): The return value should be ignored by PAM
dispatch:
AcctMgmt error (25): The return value should be ignored by PAM dispatch
>
────────────────────────────────────────────────────────────────────────────────
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Gimme your password
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
Auth success
Auth user 'user-integration-username-switched' success
AcctMgmt success
>

Expand Down Expand Up @@ -231,7 +231,7 @@ AcctMgmt success
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
Auth success
Auth user 'user-integration-username-switched' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ Enter your one time credential
Enter your one time credential
> temporary pass00

Auth success
Auth user 'user-integration-form-w-button' success
AcctMgmt success
>

Expand Down Expand Up @@ -299,7 +299,7 @@ AcctMgmt success
Enter your one time credential
> temporary pass00

Auth success
Auth user 'user-integration-form-w-button' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Unlock your phone +33… or accept request on web interface:

────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Auth success
Auth user 'user-mfa' success
AcctMgmt success
>

Expand Down Expand Up @@ -329,7 +329,7 @@ AcctMgmt success

────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Auth success
Auth user 'user-mfa' success
AcctMgmt success
>

Expand Down Expand Up @@ -362,7 +362,7 @@ AcctMgmt success

────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Auth success
Auth user 'user-mfa' success
AcctMgmt success
>

Expand Down Expand Up @@ -395,7 +395,7 @@ AcctMgmt success

────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Auth success
Auth user 'user-mfa' success
AcctMgmt success
>

Expand Down Expand Up @@ -428,7 +428,7 @@ AcctMgmt success

────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Auth success
Auth user 'user-mfa' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Enter the following code after flashing the address: 1337
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀


Auth success
Auth user 'user-integration-qr-code' success
AcctMgmt success
>

Expand Down Expand Up @@ -317,7 +317,7 @@ Enter the following code after flashing the address: 1337
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀


Auth success
Auth user 'user-integration-qr-code' success
AcctMgmt success
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ invalid password, should be goodpass
Gimme your password
>
PAM ERROR: invalid password, should be goodpass
Auth error (7): Authentication failure: invalid password, should be goodpass
Auth user 'user-integration-max-attempts' error (7): Authentication failure: invalid password, s
hould be goodpass
AcctMgmt error (25): The return value should be ignored by PAM dispatch
>

Expand All @@ -291,15 +292,15 @@ AcctMgmt error (25): The return value should be ignored by PAM dispatch






────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
>
PAM ERROR: invalid password, should be goodpass
Auth error (7): Authentication failure: invalid password, should be goodpass
Auth user 'user-integration-max-attempts' error (7): Authentication failure: invalid password, s
hould be goodpass
AcctMgmt error (25): The return value should be ignored by PAM dispatch
>

Expand All @@ -324,7 +325,6 @@ AcctMgmt error (25): The return value should be ignored by PAM dispatch






────────────────────────────────────────────────────────────────────────────────
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Username: user-unexistent

PAM ERROR: can't select broker: rpc error: code = Unknown desc = can't start authentication tran
saction: user "user-unexistent" does not exist
Auth error (4): System error: can't select broker: rpc error: code = Unknown desc = can't start
Auth user 'user-unexistent' error (4): System error: can't select broker: rpc error: code = Unkn
────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Select your provider
Expand Down Expand Up @@ -161,5 +161,5 @@ Auth error (4): System error: can't select broker: rpc error: code = Unknown des

PAM ERROR: can't select broker: rpc error: code = Unknown desc = can't start authentication tran
saction: user "user-unexistent" does not exist
Auth error (4): System error: can't select broker: rpc error: code = Unknown desc = can't start
Auth user 'user-unexistent' error (4): System error: can't select broker: rpc error: code = Unkn
────────────────────────────────────────────────────────────────────────────────
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Username: user-local-broker



Auth error (25): The return value should be ignored by PAM dispatch:
Auth user 'user-local-broker' error (25): The return value should be ignored by PAM dispatch:
AcctMgmt error (25): The return value should be ignored by PAM dispatch
>
────────────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -159,7 +159,7 @@ AcctMgmt error (25): The return value should be ignored by PAM dispatch



Auth error (25): The return value should be ignored by PAM dispatch:
Auth user 'user-local-broker' error (25): The return value should be ignored by PAM dispatch:
AcctMgmt error (25): The return value should be ignored by PAM dispatch
>
────────────────────────────────────────────────────────────────────────────────
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ Gimme your password
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
PAM ERROR: cancel requested
Auth error (26): Critical error - immediate abort: cancel requested
Auth user 'user-integration-sigint' error (26): Critical error - immediate abort: cancel request
ed
AcctMgmt error (25): The return value should be ignored by PAM dispatch
>

Expand All @@ -159,14 +160,14 @@ AcctMgmt error (25): The return value should be ignored by PAM dispatch






────────────────────────────────────────────────────────────────────────────────
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Gimme your password
PAM ERROR: cancel requested
Auth error (26): Critical error - immediate abort: cancel requested
Auth user 'user-integration-sigint' error (26): Critical error - immediate abort: cancel request
ed
AcctMgmt error (25): The return value should be ignored by PAM dispatch
>

Expand All @@ -192,7 +193,6 @@ AcctMgmt error (25): The return value should be ignored by PAM dispatch






────────────────────────────────────────────────────────────────────────────────
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Enter your one time credential
Enter your one time credential
> temporary pass0

Auth success
Auth user 'user-integration-remember-mode' success
AcctMgmt success
>

Expand Down Expand Up @@ -200,7 +200,7 @@ AcctMgmt success
Enter your one time credential
> temporary pass0

Auth success
Auth user 'user-integration-remember-mode' success
AcctMgmt success
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Username: user name
Expand Down Expand Up @@ -233,7 +233,7 @@ Username: user name
Enter your one time credential
> temporary pass0

Auth success
Auth user 'user-integration-remember-mode' success
AcctMgmt success
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Username: user-integration-remember-mode
Expand Down Expand Up @@ -266,7 +266,7 @@ Username: user-integration-remember-mode
Enter your one time credential
> temporary pass0

Auth success
Auth user 'user-integration-remember-mode' success
AcctMgmt success
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Enter your one time credential
Expand Down Expand Up @@ -299,13 +299,13 @@ Enter your one time credential
Enter your one time credential
> temporary pass0

Auth success
Auth user 'user-integration-remember-mode' success
AcctMgmt success
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Enter your one time credential
> temporary pass0

Auth success
Auth user 'user-integration-remember-mode' success
AcctMgmt success
>

Expand All @@ -332,13 +332,13 @@ AcctMgmt success
Enter your one time credential
> temporary pass0

Auth success
Auth user 'user-integration-remember-mode' success
AcctMgmt success
> ./pam_authd socket=/tmp/pam-cli-tests.sock
Enter your one time credential
> temporary pass0

Auth success
Auth user 'user-integration-remember-mode' success
AcctMgmt success
>

Expand Down
4 changes: 3 additions & 1 deletion pam/main-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func main() {
return "", nil
}))

printResult("Auth", module.Authenticate(mTx, pam.Flags(0), os.Args))
authResult := module.Authenticate(mTx, pam.Flags(0), os.Args)
user, _ := mTx.GetItem(pam.User)
printResult(fmt.Sprintf("Auth user '%s'", user), authResult)

// Simulate setting auth broker as default.
printResult("AcctMgmt", module.AcctMgmt(mTx, pam.Flags(0), os.Args))
Expand Down

0 comments on commit a03d1a9

Please sign in to comment.