1
0
Fork 0
forked from forgejo/forgejo

Various fixes in login sources (#10428)

This commit is contained in:
guillep2k 2020-02-23 16:52:05 -03:00 committed by GitHub
parent 542bd59239
commit 09dbd85a3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 66 additions and 21 deletions

View file

@ -13,7 +13,7 @@ import (
)
// Auth pam auth service
func Auth(serviceName, userName, passwd string) error {
func Auth(serviceName, userName, passwd string) (string, error) {
t, err := pam.StartFunc(serviceName, userName, func(s pam.Style, msg string) (string, error) {
switch s {
case pam.PromptEchoOff:
@ -25,12 +25,14 @@ func Auth(serviceName, userName, passwd string) error {
})
if err != nil {
return err
return "", err
}
if err = t.Authenticate(0); err != nil {
return err
return "", err
}
return nil
// PAM login names might suffer transformations in the PAM stack.
// We should take whatever the PAM stack returns for it.
return t.GetItem(pam.User)
}