Documentation
¶
Overview ¶
Package pam provides Linux-PAM binding without cgo. It is not an authentication policy, credential provider, or cancellable worker.
Index ¶
Constants ¶
Variables ¶
var ( ErrClosed = errors.New("pam: library or transaction is closed") ErrBusy = errors.New("pam: active transactions prevent library close") ErrInvalidArgument = errors.New("pam: invalid argument") )
var ErrAllocation = errors.New("pam: native allocation failed")
Functions ¶
This section is empty.
Types ¶
type Conversation ¶
Conversation supplies responses without retaining native or Go buffers. Respond receives a zeroed MaxRespSize-byte answer buffer. Write the answer there and return its length (0..MaxRespSize), without a NUL. For informational messages return zero. The library wipes Text and answer even on error/panic. Do not retain buffers or access them after return, or call Library/Transaction methods from Respond. Respond must return: no timeout cancels a native call. Calls for one conversation are serialized, including foreign-thread entry. Any private secret copies made by the handler remain its responsibility.
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library owns loader references. The zero value is closed. Do not copy it. All operations on a Library and its Transactions must be serialized by one caller/worker. Native calls are synchronous, may block, and have no cancellation guarantee.
func Open ¶
Open loads the system libpam and libc with eager, local symbol resolution. It performs no PAM transaction or authentication. Library operations must be serialized by the caller; Close is rejected while transactions are active.
func (*Library) Start ¶
func (l *Library) Start(service, user string, conversation NativeConversation) (*Transaction, error)
Start requires an explicit service and native conversation; user may be empty (passed as NULL so PAM may prompt). It never authenticates. No service is installed by this library. NativeConversation is a trusted unsafe boundary.
func (*Library) StartConversation ¶
func (l *Library) StartConversation(service, user string, handler Conversation) (*Transaction, error)
StartConversation adds the managed Go bridge; the external NativeConversation API is unchanged. appdata is a numeric opaque void* cookie, NOT a pointer to memory, and neither PAM nor the bridge may dereference it.
type Message ¶
Message is a copied Linux-PAM message. Text may be sensitive and is wiped after Respond returns. Do not retain it; do not log prompts or answers.
type NativeConversation ¶
NativeConversation describes a caller-owned C conversation function and native application data. Function must implement: int conv(int, const struct pam_message **, struct pam_response **, void *). Data must be nil or libc-owned memory, NEVER a Go pointer. Function and Data must remain valid through End, including pam_end's cleanup callbacks. This low-level contract is unsafe by design; use StartConversation for the managed bridge instead.
type Status ¶
type Status int32
Status is a Linux-PAM C int. Only Success indicates success.
const ( Success Status = iota OpenErr SymbolErr ServiceErr SystemErr BufErr PermDenied AuthErr CredInsufficient UserUnknown Maxtries NewAuthtokReqd AcctExpired SessionErr CredExpired CredErr NoModuleData ConvErr AuthtokErr AuthtokRecoveryErr AuthtokLockBusy AuthtokDisableAging TryAgain Ignore Abort AuthtokExpired ModuleUnknown BadItem ConvAgain Incomplete )
Linux-PAM statuses from security/_pam_types.h.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction owns a PAM handle and native argument storage until End returns. Do not copy a Transaction. End must be called exactly once after successful Start; it consumes the transaction even if pam_end reports an error.
func (*Transaction) AcctMgmt ¶
func (t *Transaction) AcctMgmt(flags Flags) error
AcctMgmt fails closed, including PAM_NEW_AUTHTOK_REQD and PAM_INCOMPLETE.
func (*Transaction) Authenticate ¶
func (t *Transaction) Authenticate(flags Flags) error
Authenticate returns an error for every status other than PAM_SUCCESS. Success here is NOT an account authorization decision; call AcctMgmt too.
func (*Transaction) End ¶
func (t *Transaction) End() error
End passes the last operation's status to pam_end and releases native storage only after that call returns. A second End returns ErrClosed, never calls C.