osuser

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_UID = 1024
	MAX_UID = 65534
)

Variables

View Source
var (
	ErrEmptyPasswd     = errors.New("empty passwd file")
	ErrNoAvailableUids = errors.New("no available UIDs in passwd file")
)
View Source
var (
	ErrAcquireLock = errors.New("Could not acquire lock")
)

Functions

func CreateUser

func CreateUser(name string) (int, error)

CreateUser creates a new user with the first vacant UID.

func RemoveUser

func RemoveUser(name string) error

RemoveUser deletes an existing user.

Types

type FileLocker

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

FileLocker is the structure that wraps exclusive file locking functionality.

func NewLocker

func NewLocker(filepath string) (*FileLocker, error)

NewLocker creates new locker instance for a file path.

func (*FileLocker) Acquire

func (l *FileLocker) Acquire(timeout time.Duration) error

Acquire tries to lock the file for writing (exclusive lock) using flock(2). If the function cannot obtain a lock during the timeout it will return an error.

func (*FileLocker) Release

func (l *FileLocker) Release()

Release releases the lock on the file.

Jump to

Keyboard shortcuts

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