package user
import "github.com/moby/sys/user"
Index ¶
- Variables
- func GetAdditionalGroups(additionalGroups []string, group io.Reader) ([]int, error)
- func GetAdditionalGroupsPath(additionalGroups []string, groupPath string) ([]int, error)
- type ExecUser
- func GetExecUser(userSpec string, defaults *ExecUser, passwd, group io.Reader) (*ExecUser, error)
- func GetExecUserPath(userSpec string, defaults *ExecUser, passwdPath, groupPath string) (*ExecUser, error)
- type Group
- func ParseGroup(group io.Reader) ([]Group, error)
- func ParseGroupFile(path string) ([]Group, error)
- func ParseGroupFileFilter(path string, filter func(Group) bool) ([]Group, error)
- func ParseGroupFilter(r io.Reader, filter func(Group) bool) ([]Group, error)
- type IDMap
- func ParseIDMap(r io.Reader) ([]IDMap, error)
- func ParseIDMapFile(path string) ([]IDMap, error)
- func ParseIDMapFileFilter(path string, filter func(IDMap) bool) ([]IDMap, error)
- func ParseIDMapFilter(r io.Reader, filter func(IDMap) bool) ([]IDMap, error)
- type SubID
- func ParseSubID(subid io.Reader) ([]SubID, error)
- func ParseSubIDFile(path string) ([]SubID, error)
- func ParseSubIDFileFilter(path string, filter func(SubID) bool) ([]SubID, error)
- func ParseSubIDFilter(r io.Reader, filter func(SubID) bool) ([]SubID, error)
- type User
Variables ¶
var ( // ErrNoPasswdEntries is returned if no matching entries were found in /etc/group. ErrNoPasswdEntries = errors.New("no matching entries in passwd file") // ErrNoGroupEntries is returned if no matching entries were found in /etc/passwd. ErrNoGroupEntries = errors.New("no matching entries in group file") // ErrRange is returned if a UID or GID is outside of the valid range. ErrRange = fmt.Errorf("uids and gids must be in range %d-%d", minID, maxID) )
Functions ¶
func GetAdditionalGroups ¶
GetAdditionalGroups looks up a list of groups by name or group id against the given /etc/group formatted data. If a group name cannot be found, an error will be returned. If a group id cannot be found, or the given group data is nil, the id will be returned as-is provided it is in the legal range.
func GetAdditionalGroupsPath ¶
GetAdditionalGroupsPath is a wrapper around GetAdditionalGroups that opens the groupPath given and gives it as an argument to GetAdditionalGroups.
Types ¶
type ExecUser ¶
func GetExecUser ¶
GetExecUser parses a user specification string (using the passwd and group readers as sources for /etc/passwd and /etc/group data, respectively). In the case of blank fields or missing data from the sources, the values in defaults is used.
GetExecUser will return an error if a user or group literal could not be found in any entry in passwd and group respectively.
Examples of valid user specifications are:
- ""
- "user"
- "uid"
- "user:group"
- "uid:gid
- "user:gid"
- "uid:group"
It should be noted that if you specify a numeric user or group id, they will not be evaluated as usernames (only the metadata will be filled). So attempting to parse a user with user.Name = "1337" will produce the user with a UID of 1337.
func GetExecUserPath ¶
func GetExecUserPath(userSpec string, defaults *ExecUser, passwdPath, groupPath string) (*ExecUser, error)
GetExecUserPath is a wrapper for GetExecUser. It reads data from each of the given file paths and uses that data as the arguments to GetExecUser. If the files cannot be opened for any reason, the error is ignored and a nil io.Reader is passed instead.
type Group ¶
func ParseGroup ¶
func ParseGroupFile ¶
func ParseGroupFileFilter ¶
func ParseGroupFilter ¶
type IDMap ¶
IDMap represents an entry in /proc/PID/{u,g}id_map
func ParseIDMap ¶
func ParseIDMapFile ¶
func ParseIDMapFileFilter ¶
func ParseIDMapFilter ¶
type SubID ¶
SubID represents an entry in /etc/sub{u,g}id
func ParseSubID ¶
func ParseSubIDFile ¶
func ParseSubIDFileFilter ¶
func ParseSubIDFilter ¶
type User ¶
func ParsePasswd ¶
func ParsePasswdFile ¶
func ParsePasswdFileFilter ¶
func ParsePasswdFilter ¶
Source Files ¶
- Version
- v0.3.0 (latest)
- Published
- Aug 7, 2024
- Platform
- js/wasm
- Imports
- 8 packages
- Last checked
- 1 month ago –
Tools for package owners.