idtools

package
v1.4.2-0...-46a61b7 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNamespaceRangesUser

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

AddNamespaceRangesUser takes a name and finds an unused uid, gid pair and calls the appropriate helper function to add the group and then the user to the group in /etc/group and /etc/passwd respectively. This new user's /etc/sub{uid,gid} ranges will be used for user namespace mapping ranges in containers.

func CreateIDMappings

func CreateIDMappings(username, groupname string) ([]IDMap, []IDMap, error)

CreateIDMappings 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 GetRootUIDGID

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 MkdirAllAs

func MkdirAllAs(path string, mode os.FileMode, ownerUID, ownerGID int) error

MkdirAllAs 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 MkdirAllNewAs

func MkdirAllNewAs(path string, mode os.FileMode, ownerUID, ownerGID int) error

MkdirAllNewAs 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 MkdirAs

func MkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int) error

MkdirAs creates a directory and then modifies ownership to the requested uid/gid. If the directory already exists, this function still changes ownership

func ToContainer

func ToContainer(hostID int, idMap []IDMap) (int, error)

ToContainer takes an id mapping, and uses it to translate a host ID to the remapped ID. If no map is provided, then the translation assumes a 1-to-1 mapping and returns the passed in id

func ToHost

func ToHost(contID int, idMap []IDMap) (int, error)

ToHost takes an id mapping and a remapped ID, and translates the ID to the mapped host ID. If no map is provided, then the translation assumes a 1-to-1 mapping and returns the passed in id #

Types

type IDMap

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.

Jump to

Keyboard shortcuts

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