usermgr

package
v1.9.9 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package usermgr provides Linux system user account management.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupported = errors.New("user management is not supported on this platform")
	ErrRootDeletion = errors.New("cannot delete root user")
	ErrUserNotFound = errors.New("user not found")
	ErrInvalidInput = errors.New("invalid input")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	List(ctx context.Context) ([]*User, error)
	Get(ctx context.Context, username string) (*User, error)
	Add(ctx context.Context, u *User, password string) error
	Edit(ctx context.Context, username string, u *User, password string) error
	Delete(ctx context.Context, username string, removeHome bool) error
	Lock(ctx context.Context, username string) error
	Unlock(ctx context.Context, username string) error
	AvailableShells(ctx context.Context) ([]string, error)
}

Client defines the interface for system user management.

func NewClient

func NewClient() (Client, error)

NewClient creates a user management client for Linux.

type User

type User struct {
	Username string   `json:"username"`
	UID      int      `json:"uid"`
	GID      int      `json:"gid"`
	Comment  string   `json:"comment"` // GECOS field (full name)
	HomeDir  string   `json:"homeDir"`
	Shell    string   `json:"shell"`
	Locked   bool     `json:"locked"` // shadow entry starts with "!"
	System   bool     `json:"system"` // UID < 1000
	Groups   []string `json:"groups"` // supplementary groups
}

User represents a Linux system user account.

func (*User) IsRoot

func (u *User) IsRoot() bool

IsRoot returns true if this is the root user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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