fakeroot

package
v4.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SubUIDFile is the default path to the subuid file.
	SubUIDFile = "/etc/subuid"
	// SubGIDFile is the default path to the subgid file.
	SubGIDFile = "/etc/subgid"
)

Variables

This section is empty.

Functions

func GetIDRange

func GetIDRange(path string, uid uint32) (*specs.LinuxIDMapping, error)

GetIDRange determines UID/GID mappings based on configuration file provided in path.

Types

type Config

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

Config holds all entries found in the corresponding configuration file and manages its configuration.

func GetConfig

func GetConfig(filename string, edit bool, getUserFn GetUserFn) (*Config, error)

GetConfig parses a subuid/subgid configuration file and returns a Config holding all mapping entries, it allows to pass a custom function getUserFn used to lookup in a custom user database, if there is no custom function, the default one is used.

func (*Config) AddUser

func (c *Config) AddUser(username string) error

AddUser adds a user mapping entry, it will automatically find the first available range. It doesn't return any error if the user is already present and ignores the operation.

func (*Config) Close

func (c *Config) Close() error

Close closes the configuration file handle, if there is any pending updates and the configuration was opened for writing, all entries are written before into the configuration file before closing it.

func (*Config) DisableUser

func (c *Config) DisableUser(username string) error

DisableUser disables a user entry mapping entry. It returns an error if there is no entry for the user but will ignore the operation if the user entry is already disabled.

func (*Config) EnableUser

func (c *Config) EnableUser(username string) error

EnableUser enables a previously disabled user mapping entry. It returns an error if there is no entry for the user but will ignore the operation if the user entry is already enabled.

func (*Config) GetUserEntry

func (c *Config) GetUserEntry(username string) (*Entry, error)

GetUserEntry returns a user entry associated to a user and returns an error if there is no entry for this user.

func (*Config) RemoveUser

func (c *Config) RemoveUser(username string) error

RemoveUser removes a user mapping entry. It returns an error if there is no entry for the user.

type Entry

type Entry struct {
	UID   uint32
	Start uint32
	Count uint32
	// contains filtered or unexported fields
}

Entry represents an entry line of subuid/subgid configuration file.

type GetUserFn

type GetUserFn func(string) (*user.User, error)

GetUserFn defines the user lookup function prototype.

Jump to

Keyboard shortcuts

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