Documentation ¶
Index ¶
- Constants
- Variables
- func CanIdmapMount(path string, fstype string) bool
- func GetCaps(path string) ([]byte, error)
- func SetCaps(path string, caps []byte, uid int64) error
- func ShiftACL(path string, shiftIds func(uid int64, gid int64) (int64, int64)) error
- func ShiftOwner(basepath string, path string, uid int, gid int) error
- func SupportsVFS3FSCaps(prefix string) bool
- func UnshiftACL(value string, set *Set) (string, error)
- func UnshiftCaps(value string, set *Set) (string, error)
- type ByHostID
- type Entry
- type IdmapStorageType
- type Range
- type Set
- func (m *Set) AddSafe(i Entry) error
- func (m *Set) Append(s string) (*Set, error)
- func (m *Set) Equals(other *Set) bool
- func (m *Set) FilterPOSIX() *Set
- func (m *Set) HostIDsIntersect(i Entry) bool
- func (m *Set) Includes(sub *Set) bool
- func (m *Set) Intersects(i Entry) bool
- func (m *Set) Len() int
- func (m *Set) Less(i, j int) bool
- func (m *Set) ShiftFromNS(uid int64, gid int64) (int64, int64)
- func (m *Set) ShiftIntoNS(uid int64, gid int64) (int64, int64)
- func (m *Set) ShiftPath(p string, skipper ShiftSkipper) error
- func (m *Set) Split(minSize int64, maxSize int64, minHost int64, maxHost int64) (*Set, error)
- func (m *Set) Swap(i, j int)
- func (m *Set) ToGIDMappings() []syscall.SysProcIDMap
- func (m *Set) ToJSON() (string, error)
- func (m *Set) ToLXCString() []string
- func (m *Set) ToUIDMappings() []syscall.SysProcIDMap
- func (m *Set) UnshiftPath(p string, skipper ShiftSkipper) error
- func (m *Set) Usable() error
- func (m *Set) ValidRanges() ([]*Range, error)
- type ShiftSkipper
Constants ¶
const ( // VFS3FSCapsUnknown indicates unknown support for VFS v3 fscaps. VFS3FSCapsUnknown = int32(-1) // VFS3FSCapsUnsupported indicates the kernel does not support VFS v3 fscaps. VFS3FSCapsUnsupported = int32(0) // VFS3FSCapsSupported indicates the kernel supports VFS v3 fscaps. VFS3FSCapsSupported = int32(1) )
const ( IdmapStorageNone = "none" IdmapStorageIdmapped = "idmapped" )
Variables ¶
var DefaultFullKernelSet = &Set{Entries: []Entry{ {true, false, int64(0), int64(0), int64(4294967294)}, {false, true, int64(0), int64(0), int64(4294967294)}, }}
DefaultFullKernelSet is the default Set of uid/gid with no mapping at all.
var ErrHostIDIsSubID = fmt.Errorf("Host ID is in the range of subids")
ErrHostIDIsSubID indicates that an expected host ID is part of a subid range.
var ErrNoSuitableSubmap = fmt.Errorf("Couldn't find a suitable submap")
ErrNoSuitableSubmap indicates that it was impossible to split a submap with the requested characteristics.
var ErrNoUserMap = fmt.Errorf("No map found for user")
ErrNoUserMap indicates that no entry could be found for the user.
var ErrSubidUnsupported = fmt.Errorf("System doesn't support subuid/subgid")
ErrSubidUnsupported indicates that the system is lacking support for subuid/subgid.
var VFS3FSCaps = VFS3FSCapsUnknown
VFS3FSCaps can be set to tell the shifter if VFS v3 fscaps are supported.
Functions ¶
func CanIdmapMount ¶
func ShiftACL ¶
ShiftACL updates the uid and gid for ACL entries through the provided mapper function.
func ShiftOwner ¶
ShiftOwner updates the uid and gid for a file within a specific basepath.
func SupportsVFS3FSCaps ¶
SupportsVFS3FSCaps checks whether the kernel supports VFS v3 fscaps.
func UnshiftACL ¶
UnshiftACL unshifts the uid/gid in the raw ACL entry.
Types ¶
type Entry ¶
type Entry struct { IsUID bool `json:"Isuid"` IsGID bool `json:"Isgid"` HostID int64 `json:"Hostid"` // id as seen on the host - i.e. 100000 NSID int64 `json:"Nsid"` // id as seen in the ns - i.e. 0 MapRange int64 `json:"Maprange"` }
Entry is a single idmap entry (line).
func (*Entry) HostIDsCoveredBy ¶
HostIDsCoveredBy returns whether or not the entry is covered by the supplied host UID and GID ID maps. If e.IsUID is true then host IDs must be covered by an entry in allowedHostUIDs, and if e.IsGID is true then host IDs must be covered by an entry in allowedHostGIDs.
func (*Entry) HostIDsIntersect ¶
HostIDsIntersect checks whether the provided entry intersects with the host IDs of the existing one.
func (*Entry) Intersects ¶
Intersects checks whether the provided entry intersects with the existing one.
func (*Entry) ToLXCString ¶
ToLXCString converts an Entry into its LXC representation.
type IdmapStorageType ¶
type IdmapStorageType string
type Set ¶
type Set struct {
Entries []Entry
}
Set is a list of Entry with some functions on it.
func NewSetFromCurrentProcess ¶
NewSetFromCurrentProcess returns a Set from the process' current uid/gid map.
func NewSetFromIncusIDMap ¶
NewSetFromIncusIDMap parses an Incus raw.idmap into a new idmap Set.
func NewSetFromJSON ¶
NewSetFromJSON unpacks an idmap Set from its JSON representation.
func NewSetFromSystem ¶
NewSetFromSystem returns a Set for the specified user from the system's subuid/subgid configuration.
func (*Set) AddSafe ¶
AddSafe adds an entry to the idmap set, breaking apart any ranges that the new idmap intersects with in the process.
func (*Set) FilterPOSIX ¶
FilterPOSIX returns a copy of the set with only entries that have a minimum of 65536 IDs.
func (*Set) HostIDsIntersect ¶
HostIDsIntersect checks if any of the Entry hostids in the set intersects with the provided entry.
func (*Set) Includes ¶
Includes checks whether the provided Set is fully covered by the current Set.
func (*Set) Intersects ¶
Intersects checks if any of the Entry in the set intersects with the provided entry.
func (*Set) ShiftFromNS ¶
ShiftFromNS shifts the provided uid and gid into their host equivalent.
func (*Set) ShiftIntoNS ¶
ShiftIntoNS shifts the provided uid and gid into their container equivalent.
func (*Set) ShiftPath ¶
func (m *Set) ShiftPath(p string, skipper ShiftSkipper) error
ShiftPath shifts a whole filesystem tree.
func (*Set) Split ¶
Split returns a new Set made from a subset of the original set. The minimum and maximum number of uid/gid included is configurable as is the minimum and maximum host ID.
func (*Set) ToGIDMappings ¶
func (m *Set) ToGIDMappings() []syscall.SysProcIDMap
ToGIDMappings converts an idmapset to a slice of syscall.SysProcIDMap.
func (*Set) ToLXCString ¶
ToLXCString converts the set to a slice of LXC configuration entries.
func (*Set) ToUIDMappings ¶
func (m *Set) ToUIDMappings() []syscall.SysProcIDMap
ToUIDMappings converts an idmapset to a slice of syscall.SysProcIDMap.
func (*Set) UnshiftPath ¶
func (m *Set) UnshiftPath(p string, skipper ShiftSkipper) error
UnshiftPath unshifts a whole filesystem tree.
func (*Set) ValidRanges ¶
ValidRanges turns the set into a slice of Range.