tempentries

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package tempentries provides a temporary user and group 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 and disable login for new users via SSH until authd is restarted.
	//
	// 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
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IDGenerator

type IDGenerator interface {
	GenerateUID() (uint32, error)
	GenerateGID() (uint32, error)
}

IDGenerator is the interface that must be implemented by the ID generator.

type NoDataFoundError

type NoDataFoundError = cache.NoDataFoundError

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

type TemporaryRecords

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

TemporaryRecords is the in-memory temporary user and group records.

func NewTemporaryRecords

func NewTemporaryRecords(idGenerator IDGenerator) *TemporaryRecords

NewTemporaryRecords creates a new TemporaryRecords.

func (TemporaryRecords) GroupByID

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

GroupByID returns the group information for the given group ID.

func (TemporaryRecords) GroupByName

func (r TemporaryRecords) GroupByName(name string) (types.GroupEntry, error)

GroupByName returns the group information for the given group name.

func (TemporaryRecords) RegisterGroup

func (r TemporaryRecords) RegisterGroup(name string) (gid uint32, cleanup func(), err error)

RegisterGroup registers a temporary group with a unique GID in our NSS handler (in memory, not in the database).

Returns the generated GID and a cleanup function that should be called to remove the temporary group once the group was added to the database.

func (TemporaryRecords) RegisterPreAuthUser

func (r TemporaryRecords) RegisterPreAuthUser(loginName string) (uint32, error)

RegisterPreAuthUser registers a temporary user with a unique UID in our NSS handler (in memory, not in the database).

The temporary user record is removed when UpdateUser is called with the same username.

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 when UpdateUser is called after the user authenticated successfully.

Returns the generated UID.

func (*TemporaryRecords) RegisterUser

func (r *TemporaryRecords) RegisterUser(name string) (uid uint32, cleanup func(), err error)

RegisterUser registers a temporary user with a unique UID in our NSS handler (in memory, not in the database).

Returns the generated UID and a cleanup function that should be called to remove the temporary user once the user was added to the database.

func (*TemporaryRecords) UserByID

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

UserByID returns the user information for the given user ID.

func (*TemporaryRecords) UserByName

func (r *TemporaryRecords) UserByName(name string) (types.UserEntry, error)

UserByName returns the user information for the given user name.

Jump to

Keyboard shortcuts

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