login

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UID_GID_MIN            = 1000
	UID_GID_MAX     uint16 = 1<<15 - 1
	UID_GID_MIN_SYS        = 100
	UID_GID_MAX_SYS        = 999
)

Variables

View Source
var (
	ErrNoAvailableIDs  = errors.New("no available IDs")
	ErrUsernameExists  = errors.New("username exists")
	ErrUsernameLength  = errors.New("username must be longer than 0")
	ErrGroupnameLength = errors.New("group name must be longer than 0")
)

Functions

func AddLoginUser

func AddLoginUser(fs afero.Fs, username, groupname, homeDir, shell, baseDir string) (uint16, uint16, error)

AddLoginUser adds a user that can log in with a valid shell and home directory.

func AddRootUser

func AddRootUser(fs afero.Fs, shell, baseDir string) (uint16, uint16, error)

AddRootUser adds the root user.

func AddSystemUser

func AddSystemUser(fs afero.Fs, username, groupname, homeDir, baseDir string) (uint16, uint16, error)

AddSystemUser adds a system user with no password or valid shell.

func AddUser

func AddUser(fs afero.Fs, username, groupname, homeDir, shell, baseDir string,
	idMin, idMax uint16, createHome, isLoginUser, locked bool) (uint16, uint16, error)

AddUser adds a user to the system.

Types

type GShadowEntry

type GShadowEntry struct {
	Groupname string
	Password  string
	Admins    []string
	Users     []string
	// contains filtered or unexported fields
}

func ParseGShadow

func ParseGShadow(fs afero.Fs, shadowFile string) (map[string]*GShadowEntry, []*GShadowEntry, error)

func (GShadowEntry) String

func (g GShadowEntry) String() string

type GroupEntry

type GroupEntry struct {
	Groupname string
	Password  string
	GID       uint16
	Users     []string
	// contains filtered or unexported fields
}

func ParseGroup

func ParseGroup(fs afero.Fs, groupFile string) (map[uint16]*GroupEntry, map[string]*GroupEntry, []*GroupEntry, error)

func (*GroupEntry) String

func (g *GroupEntry) String() string

type PasswdEntry

type PasswdEntry struct {
	Username string
	Password string
	UID      uint16
	GID      uint16
	Comment  string
	HomeDir  string
	Shell    string
}

func ParsePasswd

func ParsePasswd(fs afero.Fs, passwdFile string) (map[uint16]*PasswdEntry, map[string]*PasswdEntry, []*PasswdEntry, error)

func (PasswdEntry) String

func (p PasswdEntry) String() string

type ShadowEntry

type ShadowEntry struct {
	Username         string
	Password         string
	LastChange       int
	MinAge           int
	MaxAge           int
	WarningPeriod    int
	InactivityPeriod int
	Expiration       int
	Unused           string
}

func ParseShadow

func ParseShadow(fs afero.Fs, shadowFile string) (map[string]*ShadowEntry, []*ShadowEntry, error)

func (ShadowEntry) String

func (s ShadowEntry) String() string

Jump to

Keyboard shortcuts

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