user

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

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

This section is empty.

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 ommitted. If group is empty string the etc/group lookup will be ommitted.

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