fakeroot

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: BSD-3-Clause Imports: 17 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 FindFake added in v1.1.0

func FindFake() (string, error)

Look for fakeroot-sysv first and then fakeroot, since fakeroot-sysv is much faster than fakeroot-tcp.

func GetFakeArgs added in v1.1.0

func GetFakeArgs() []string

Get the args needed to execute the fakeroot mapped into the container

func GetFakeBinds added in v1.1.0

func GetFakeBinds(fakerootPath string) ([]string, error)

Get the binds needed to map the fakeroot command into the container The incoming parameter is the path to fakeroot

func GetIDRange

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

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

func IsUIDMapped added in v1.1.0

func IsUIDMapped(uid uint32) bool

IsUIDMapped returns true if the given uid is mapped in SubUIDFile and otherwise it returns false

func UnshareRootMapped added in v1.1.0

func UnshareRootMapped(args []string, includeMountNamespace bool) error

re-exec the command effectively under unshare -r or unshare -rm

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