pam

package
v0.3.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pam binds libpam through purego, so a program stays CGO_ENABLED=0: transactions, their conversation, and the items lys reads back.

Index

Constants

View Source
const (
	Success = 0
	BufErr  = 5
	ConvErr = 19
)

PAM return codes (security/_pam_types.h).

View Source
const ItemAuthtok = 6

ItemAuthtok is PAM_AUTHTOK.

Variables

This section is empty.

Functions

func CheckLibrary

func CheckLibrary() error

CheckLibrary reports whether libpam and libc bind.

Types

type Converse

type Converse func([]Message) ([]Reply, int32)

Converse answers one batch of messages, or returns a PAM error code that ends the conversation.

type Message

type Message struct {
	Style Style
	Text  string
}

Message is one conversation message, decoded from C.

type Reply

type Reply struct {
	Text string
	Set  bool
}

Reply is one conversation answer; Set false leaves the C response slot NULL (info and error messages).

type Style

type Style int32

Style is a conversation message's PAM style.

const (
	PromptEchoOff Style = 1
	PromptEchoOn  Style = 2
	ErrorMsg      Style = 3
	TextInfo      Style = 4
)

The message styles (security/_pam_types.h).

type Txn

type Txn struct {
	// contains filtered or unexported fields
}

Txn is one libpam transaction.

func Start

func Start(service, user, confdir string, converse Converse) (*Txn, error)

Start opens a transaction for service and user whose conversation calls converse for every batch of messages. confdir, when set, reads the service from that directory with pam_start_confdir instead of /etc/pam.d (tests).

func (*Txn) AcctMgmt

func (t *Txn) AcctMgmt() int32

AcctMgmt is pam_acct_mgmt.

func (*Txn) Authenticate

func (t *Txn) Authenticate() int32

Authenticate is pam_authenticate.

func (*Txn) Authtok

func (t *Txn) Authtok() []byte

Authtok is a copy of the PAM_AUTHTOK item, nil when unset.

func (*Txn) Chauthtok

func (t *Txn) Chauthtok(flags int32) int32

Chauthtok is pam_chauthtok.

func (*Txn) CloseSession

func (t *Txn) CloseSession() int32

CloseSession is pam_close_session.

func (*Txn) End

func (t *Txn) End(status int32)

End closes the transaction and releases the conversation.

func (*Txn) Getenvlist

func (t *Txn) Getenvlist() []string

Getenvlist is the transaction's environment, the C list freed once copied.

func (*Txn) OpenSession

func (t *Txn) OpenSession() int32

OpenSession is pam_open_session.

func (*Txn) Putenv

func (t *Txn) Putenv(kv string) int32

Putenv is pam_putenv.

func (*Txn) Setcred

func (t *Txn) Setcred(flags int32) int32

Setcred is pam_setcred.

func (*Txn) Strerror

func (t *Txn) Strerror(code int32) string

Strerror is pam_strerror.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL