pam

package
v0.0.0-...-17244d7 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PromptEchoOff indicates the conversation handler should obtain a
	// string without echoing any text.
	PromptEchoOff Style = C.PAM_PROMPT_ECHO_OFF
	// PromptEchoOn indicates the conversation handler should obtain a
	// string while echoing text.
	PromptEchoOn = C.PAM_PROMPT_ECHO_ON
	// ErrorMsg indicates the conversation handler should display an
	// error message.
	ErrorMsg = C.PAM_ERROR_MSG
	// TextInfo indicates the conversation handler should display some
	// text.
	TextInfo = C.PAM_TEXT_INFO
)

Coversation handler style types.

View Source
const (
	// Service is the name which identifies the PAM stack.
	Service Item = C.PAM_SERVICE
	// User identifies the username identity used by a service.
	User = C.PAM_USER
	// Tty is the terminal name.
	Tty = C.PAM_TTY
	// Rhost is the requesting host name.
	Rhost = C.PAM_RHOST
	// Authtok is the currently active authentication token.
	Authtok = C.PAM_AUTHTOK
	// Oldauthtok is the old authentication token.
	Oldauthtok = C.PAM_OLDAUTHTOK
	// Ruser is the requesting user name.
	Ruser = C.PAM_RUSER
	// UserPrompt is the string use to prompt for a username.
	UserPrompt = C.PAM_USER_PROMPT
)

PAM Item types.

View Source
const (
	// Silent indicates that no messages should be emitted.
	Silent Flags = C.PAM_SILENT
	// DisallowNullAuthtok indicates that authorization should fail
	// if the user does not have a registered authentication token.
	DisallowNullAuthtok = C.PAM_DISALLOW_NULL_AUTHTOK
	// EstablishCred indicates that credentials should be established
	// for the user.
	EstablishCred = C.PAM_ESTABLISH_CRED
	// DeleteCred inidicates that credentials should be deleted.
	DeleteCred = C.PAM_DELETE_CRED
	// ReinitializeCred indicates that credentials should be fully
	// reinitialized.
	ReinitializeCred = C.PAM_REINITIALIZE_CRED
	// RefreshCred indicates that the lifetime of existing credentials
	// should be extended.
	RefreshCred = C.PAM_REFRESH_CRED
	// ChangeExpiredAuthtok indicates that the authentication token
	// should be changed if it has expired.
	ChangeExpiredAuthtok = C.PAM_CHANGE_EXPIRED_AUTHTOK
)

PAM Flag types.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConversationFunc

type ConversationFunc func(Style, string) (string, error)

ConversationFunc is an adapter to allow the use of ordinary functions as conversation callbacks.

func (ConversationFunc) RespondPAM

func (f ConversationFunc) RespondPAM(s Style, msg string) (string, error)

type ConversationHandler

type ConversationHandler interface {
	// RespondPAM receives a message style and a message string. If the
	// message Style is PromptEchoOff or PromptEchoOn then the function
	// should return a response string.
	RespondPAM(Style, string) (string, error)
}

ConversationHandler is an interface for objects that can be used as conversation callbacks during PAM authentication.

type Error

type Error struct {
	Code int
	Msg  string
}

func (Error) Error

func (err Error) Error() string

type Flags

type Flags int

Flags are inputs to various PAM functions than be combined with a bitwise or. Refer to the official PAM documentation for which flags are accepted by which functions.

type Item

type Item int

Item is a an PAM information type.

type Style

type Style int

Style is the type of message that the conversation handler should display.

type Transaction

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

func Start

func Start(service, user string, handler ConversationHandler) (*Transaction, error)

func StartFunc

func StartFunc(service, user string, handler func(Style, string) (string, error)) (*Transaction, error)

func (*Transaction) AccountValidManagement

func (h *Transaction) AccountValidManagement(flags Flags) error

func (*Transaction) Authenticate

func (h *Transaction) Authenticate(flags Flags) error

func (*Transaction) ChangeAuthToken

func (h *Transaction) ChangeAuthToken(flags Flags) error

func (*Transaction) CloseSession

func (h *Transaction) CloseSession(flags Flags) error

func (*Transaction) DeleteEnv

func (h *Transaction) DeleteEnv(name string) error

func (*Transaction) End

func (h *Transaction) End(lastStatus int) error

func (*Transaction) GetEnv

func (h *Transaction) GetEnv(name string) string

func (*Transaction) GetEnvList

func (h *Transaction) GetEnvList() map[string]string

GetEnvList returns a copy of the PAM environment as a map.

func (*Transaction) GetItemStr

func (h *Transaction) GetItemStr(itemType Item) (string, error)

func (*Transaction) LastStatus

func (h *Transaction) LastStatus() int

func (*Transaction) OpenSession

func (h *Transaction) OpenSession(flags Flags) error

func (*Transaction) PutEnv

func (h *Transaction) PutEnv(name, value string) error

func (*Transaction) SetCredentials

func (h *Transaction) SetCredentials(flags Flags) error

func (*Transaction) SetItemStr

func (h *Transaction) SetItemStr(itemType Item, item string) error

Jump to

Keyboard shortcuts

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