//go:build pam// Copyright 2014 The Gogs Authors. All rights reserved.// Use of this source code is governed by a MIT-style// license that can be found in the LICENSE file.packagepamimport("github.com/msteinert/pam""github.com/pkg/errors")func(c*Config)doAuth(login,passwordstring)error{t,err:=pam.StartFunc(c.ServiceName,login,func(spam.Style,msgstring)(string,error){switchs{casepam.PromptEchoOff:returnpassword,nilcasepam.PromptEchoOn,pam.ErrorMsg,pam.TextInfo:return"",nil}return"",errors.Errorf("unrecognized PAM message style: %v - %s",s,msg)})iferr!=nil{returnerr}err=t.Authenticate(0)iferr!=nil{returnerr}returnt.AcctMgmt(0)}