tempentries

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 19 Imported by: 0 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 tempentries provides a temporary pre-authentication records.

Index

Constants

View Source
const (
	// MaxPreAuthUsers is the maximum number of pre-auth users that can be registered. If this limit is reached,
	// RegisterPreAuthUser will return an error until an existing reservation is released.
	//
	// This value must be significantly smaller (less than half) than the number of UIDs which can be generated (as
	// defined by UID_MIN and UID_MAX in the config file), otherwise finding a unique UID by trial and error can take
	// too long.
	MaxPreAuthUsers = 4096

	// MaxPreAuthUserNameLength is the maximum length of the pre-auth user name.
	MaxPreAuthUserNameLength = 256

	// UserPrefix is the prefix used as login name by the pre-auth temporary users.
	UserPrefix = "authd-pre-auth-user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NoDataFoundError

type NoDataFoundError = db.NoDataFoundError

NoDataFoundError is the error returned when no entry is found in the database.

type PreAuthUserRecords

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

PreAuthUserRecords tracks temporary users that have done a pre-auth request.

func NewPersistentPreAuthUserRecords added in v0.7.2

func NewPersistentPreAuthUserRecords() (*PreAuthUserRecords, error)

NewPersistentPreAuthUserRecords restores pidfds and sealed reservation metadata handed back by systemd.

func NewPreAuthUserRecords

func NewPreAuthUserRecords() *PreAuthUserRecords

NewPreAuthUserRecords creates a new instance of [preAuthUserRecords] that can be used to track the temporary preauth user entries.

func NewStoredPreAuthUserRecords added in v0.7.2

func NewStoredPreAuthUserRecords(store systemd.DescriptorStore) (*PreAuthUserRecords, error)

NewStoredPreAuthUserRecords allows tests to supply a descriptor store.

func (*PreAuthUserRecords) AddOwner added in v0.7.2

func (r *PreAuthUserRecords) AddOwner(name string, owner *proc.Process) (uint32, error)

AddOwner attaches a connection's process to an existing reservation before returning its UID to NSS. Repeated lookups from one process are idempotent.

func (*PreAuthUserRecords) CheckNotReserved added in v0.7.2

func (r *PreAuthUserRecords) CheckNotReserved(id uint32) error

CheckNotReserved prevents assigning a pending account's IDs elsewhere.

func (*PreAuthUserRecords) Close added in v0.7.2

func (r *PreAuthUserRecords) Close() error

Close releases runtime copies without removing systemd's stored references.

func (*PreAuthUserRecords) GroupByID

func (r *PreAuthUserRecords) GroupByID(gid uint32) (types.GroupEntry, error)

GroupByID returns the private-group information for the given user ID.

func (*PreAuthUserRecords) HoldUser added in v0.7.2

func (r *PreAuthUserRecords) HoldUser(name string) (uid uint32, release func(), complete func() error, err error)

HoldUser finds and pins a reservation during account creation, even if all SSH owners exit. Complete it only after saving the account, then release it.

func (*PreAuthUserRecords) MarkCompleted added in v0.7.2

func (r *PreAuthUserRecords) MarkCompleted(uid uint32) error

MarkCompleted releases a reservation after its permanent account exists.

func (*PreAuthUserRecords) RegisterPreAuthUser

func (r *PreAuthUserRecords) RegisterPreAuthUser(loginName string, uid uint32, owners ...*proc.Process) (err error)

RegisterPreAuthUser reserves a unique UID in our NSS handler. If a store is configured, the reservation is saved before this method returns.

The temporary user record is removed after calling the completion function returned by PreAuthUserRecords.HoldUser, once the account is saved.

This method is called when a user logs in for the first time via SSH, in which case sshd checks if the user exists on the system (before authentication), and denies the login if the user does not exist. We pretend that the user exists by creating this temporary user record, which is converted into a permanent user record after successful authentication.

func (*PreAuthUserRecords) ReservedIDs added in v0.7.2

func (r *PreAuthUserRecords) ReservedIDs() ([]uint32, error)

ReservedIDs returns IDs held for pending account creation.

func (*PreAuthUserRecords) ReservedUsers added in v0.7.2

func (r *PreAuthUserRecords) ReservedUsers() map[uint32]string

ReservedUsers returns the login name for each reserved UID.

func (*PreAuthUserRecords) UserByID

func (r *PreAuthUserRecords) UserByID(uid uint32) (types.UserEntry, error)

UserByID returns the user information for the given user ID.

Jump to

Keyboard shortcuts

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