dockertest: github.com/ory/dockertest/docker/pkg/idtools Index | Files

package idtools

import "github.com/ory/dockertest/docker/pkg/idtools"

Index

Package Files

idtools.go idtools_unix.go usergroupadd_linux.go utils_unix.go

func AddNamespaceRangesUser Uses

func AddNamespaceRangesUser(name string) (int, int, error)

AddNamespaceRangesUser takes a username and uses the standard system utility to create a system user/group pair used to hold the /etc/sub{uid,gid} ranges which will be used for user namespace mapping ranges in containers.

func CanAccess Uses

func CanAccess(path string, pair IDPair) bool

CanAccess takes a valid (existing) directory and a uid, gid pair and determines if that uid, gid pair has access (execute bit) to the directory

func GetRootUIDGID Uses

func GetRootUIDGID(uidMap, gidMap []IDMap) (int, int, error)

GetRootUIDGID retrieves the remapped root uid/gid pair from the set of maps. If the maps are empty, then the root uid/gid will default to "real" 0/0

func LookupGID Uses

func LookupGID(gid int) (user.Group, error)

LookupGID uses traditional local system files lookup (from libcontainer/user) on a group ID, followed by a call to `getent` for supporting host configured non-files passwd and group dbs

func LookupGroup Uses

func LookupGroup(groupname string) (user.Group, error)

LookupGroup uses traditional local system files lookup (from libcontainer/user) on a group name, followed by a call to `getent` for supporting host configured non-files passwd and group dbs

func LookupUID Uses

func LookupUID(uid int) (user.User, error)

LookupUID uses traditional local system files lookup (from libcontainer/user) on a uid, followed by a call to `getent` for supporting host configured non-files passwd and group dbs

func LookupUser Uses

func LookupUser(username string) (user.User, error)

LookupUser uses traditional local system files lookup (from libcontainer/user) on a username, followed by a call to `getent` for supporting host configured non-files passwd and group dbs

func MkdirAllAndChown Uses

func MkdirAllAndChown(path string, mode os.FileMode, owner IDPair) error

MkdirAllAndChown creates a directory (include any along the path) and then modifies ownership to the requested uid/gid. If the directory already exists, this function will still change ownership to the requested uid/gid pair.

func MkdirAllAndChownNew Uses

func MkdirAllAndChownNew(path string, mode os.FileMode, owner IDPair) error

MkdirAllAndChownNew creates a directory (include any along the path) and then modifies ownership ONLY of newly created directories to the requested uid/gid. If the directories along the path exist, no change of ownership will be performed

func MkdirAndChown Uses

func MkdirAndChown(path string, mode os.FileMode, owner IDPair) error

MkdirAndChown creates a directory and then modifies ownership to the requested uid/gid. If the directory already exists, this function still changes ownership. Note that unlike os.Mkdir(), this function does not return IsExist error in case path already exists.

type IDMap Uses

type IDMap struct {
    ContainerID int `json:"container_id"`
    HostID      int `json:"host_id"`
    Size        int `json:"size"`
}

IDMap contains a single entry for user namespace range remapping. An array of IDMap entries represents the structure that will be provided to the Linux kernel for creating a user namespace.

type IDMappings Uses

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

IDMappings contains a mappings of UIDs and GIDs

func NewIDMappings Uses

func NewIDMappings(username, groupname string) (*IDMappings, error)

NewIDMappings takes a requested user and group name and using the data from /etc/sub{uid,gid} ranges, creates the proper uid and gid remapping ranges for that user/group pair

func NewIDMappingsFromMaps Uses

func NewIDMappingsFromMaps(uids []IDMap, gids []IDMap) *IDMappings

NewIDMappingsFromMaps creates a new mapping from two slices Deprecated: this is a temporary shim while transitioning to IDMapping

func (*IDMappings) Empty Uses

func (i *IDMappings) Empty() bool

Empty returns true if there are no id mappings

func (*IDMappings) GIDs Uses

func (i *IDMappings) GIDs() []IDMap

GIDs return the UID mapping TODO: remove this once everything has been refactored to use pairs

func (*IDMappings) RootPair Uses

func (i *IDMappings) RootPair() IDPair

RootPair returns a uid and gid pair for the root user. The error is ignored because a root user always exists, and the defaults are correct when the uid and gid maps are empty.

func (*IDMappings) ToContainer Uses

func (i *IDMappings) ToContainer(pair IDPair) (int, int, error)

ToContainer returns the container UID and GID for the host uid and gid

func (*IDMappings) ToHost Uses

func (i *IDMappings) ToHost(pair IDPair) (IDPair, error)

ToHost returns the host UID and GID for the container uid, gid. Remapping is only performed if the ids aren't already the remapped root ids

func (*IDMappings) UIDs Uses

func (i *IDMappings) UIDs() []IDMap

UIDs return the UID mapping TODO: remove this once everything has been refactored to use pairs

type IDPair Uses

type IDPair struct {
    UID int
    GID int
}

IDPair is a UID and GID pair

Package idtools imports 15 packages (graph) and is imported by 2 packages. Updated 2018-04-11. Refresh now. Tools for package owners.