user

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2016 License: Apache-2.0 Imports: 13 Imported by: 54

Documentation

Overview

Package user allows resolving user UIDs/GIDs using various methods. It also provides an implementation for shifting UIDs/GIDs.

Index

Constants

View Source
const DefaultRangeCount = 0x10000

Variables

This section is empty.

Functions

func ShiftFiles added in v1.16.0

func ShiftFiles(filesToShift []string, uidRange *UidRange) error

ShiftFiles shifts filesToshift by the amounts specified in uidRange

Types

type Resolver

type Resolver interface {
	IDs() (uid int, gid int, err error)
}

Resolver defines the interface for resolving a UID/GID.

func IDsFromEtc

func IDsFromEtc(rootPath, username, group string) (Resolver, error)

IDsFromEtc returns a new UID/GID resolver by parsing etc/passwd, and etc/group relative from the given rootPath looking for the given username, or group. If username is empty string the etc/passwd lookup will be omitted. If group is empty string the etc/group lookup will be omitted.

func IDsFromStat

func IDsFromStat(rootPath, file string, r *UidRange) (Resolver, error)

IDsFromStat returns a new UID/GID resolver deriving the UID/GID from file attributes and unshifts the UID/GID if the given range is not nil. If the given id does not start with a slash "/" an error is returned.

func NumericIDs

func NumericIDs(id string) (Resolver, error)

NumericIDs returns a resolver that will resolve constant UID/GID values. If the given id equals to "root" the resolver always resolves UID=0 and GID=0. If the given id is a numeric literal i it always resolves UID=i and GID=i. If the given id is neither "root" nor a numeric literal an error is returned.

type UidRange

type UidRange struct {
	Shift uint32
	Count uint32
}

A UidRange structure used to set uidshift and its range.

func NewBlankUidRange

func NewBlankUidRange() *UidRange

func (*UidRange) Deserialize

func (r *UidRange) Deserialize(uidRange []byte) error

func (*UidRange) Serialize

func (r *UidRange) Serialize() []byte

func (*UidRange) SetRandomUidRange

func (r *UidRange) SetRandomUidRange(uidCount uint32)

func (*UidRange) ShiftRange

func (r *UidRange) ShiftRange(uid uint32, gid uint32) (uint32, uint32, error)

func (*UidRange) UnshiftRange

func (r *UidRange) UnshiftRange(uid, gid uint32) (uint32, uint32, error)

Jump to

Keyboard shortcuts

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