Files
Gogs/internal/auth/pam/pam.go

30 lines
589 B
Go
Raw Permalink Normal View History

//go:build pam
2015-04-23 13:58:57 +02:00
package pam
import (
"github.com/cockroachdb/errors"
2015-04-23 13:58:57 +02:00
"github.com/msteinert/pam"
)
func (c *Config) doAuth(login, password string) error {
t, err := pam.StartFunc(c.ServiceName, login, func(s pam.Style, msg string) (string, error) {
2015-04-23 13:58:57 +02:00
switch s {
case pam.PromptEchoOff:
return password, nil
2015-04-23 13:58:57 +02:00
case pam.PromptEchoOn, pam.ErrorMsg, pam.TextInfo:
return "", nil
}
return "", errors.Errorf("unrecognized PAM message style: %v - %s", s, msg)
2015-04-23 13:58:57 +02:00
})
if err != nil {
return err
}
err = t.Authenticate(0)
if err != nil {
return err
}
return t.AcctMgmt(0)
2015-04-23 13:58:57 +02:00
}