Documentation
¶
Overview ¶
Package uxid resolves the uid of a local process to its login and groups, as the name service of the node says them, without letting a name service not answering hold its callers.
A lookup asks the name service, which may be a directory server not answering: nothing interrupts it. So a lookup is given up after a deadline, the lookup itself left to end on its own; at most a few run at once, a caller finding them all taken refused at once rather than piling threads up; and the answers are cached a short time, so a membership changed or an account removed is seen soon. An identity looked up lately is kept longer for when the name service does not answer: a directory down only hits the identities not seen lately, and keeps the others as they were last seen, but a name service answering always has the last word.
Index ¶
Constants ¶
const ( DefaultTimeout = 3 * time.Second DefaultMaxInFlight = 8 DefaultPositiveTTL = 10 * time.Second DefaultNegativeTTL = 10 * time.Second // DefaultStaleTTL is how long an identity looked up is used past its // positive TTL, while the name service does not answer. DefaultStaleTTL = 5 * time.Minute )
Variables ¶
var ( // ErrBusy is returned when the lookups running are at their cap: the // name service is slow, or not answering. ErrBusy = errors.New("the name service lookups running are at their cap") // ErrTimeout is returned when the name service did not answer in time. ErrTimeout = errors.New("the name service did not answer in time") )
Functions ¶
This section is empty.
Types ¶
type Identity ¶
type Identity struct {
UID uint32
Login string
// Groups are the names of the groups the login is a member of,
// its primary group included.
Groups []string
}
Identity is a uid as the name service says it.
func SystemLookup ¶
SystemLookup resolves uid with the name service of the system.
Built without cgo, the os/user package reads /etc/passwd and /etc/group alone, and the accounts of a directory do not resolve.
type LookupFunc ¶
LookupFunc resolves a uid, asking the name service.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves uids with a deadline, a cap on the lookups running, and a cache.
func New ¶
func New(lookup LookupFunc) *Resolver
New returns a resolver asking the name service through lookup, nil for the one of the system, with the default deadline, cap and cache times.