Documentation ¶
Index ¶
- Variables
- func GetGroup() (io.ReadCloser, error)
- func GetGroupFile() (string, error)
- func GetPasswd() (io.ReadCloser, error)
- func GetPasswdFile() (string, error)
- type ExecUser
- type Group
- func CurrentGroup() (Group, error)
- func LookupGid(gid int) (Group, error)
- func LookupGroup(groupname string) (Group, error)
- 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 User
- func CurrentUser() (User, error)
- func LookupUid(uid int) (User, error)
- func LookupUser(username string) (User, error)
- func ParsePasswd(passwd io.Reader) ([]User, error)
- func ParsePasswdFile(path string) ([]User, error)
- func ParsePasswdFileFilter(path string, filter func(User) bool) ([]User, error)
- func ParsePasswdFilter(r io.Reader, filter func(User) bool) ([]User, error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrRange = fmt.Errorf("Uids and gids must be in range %d-%d", minId, maxId)
)
var ( // The current operating system does not provide the required data for user lookups. ErrUnsupported = errors.New("user lookup: operating system does not provide passwd-formatted data") )
Functions ¶
func GetGroup ¶ added in v1.4.0
func GetGroup() (io.ReadCloser, error)
func GetGroupFile ¶ added in v1.4.0
func GetPasswd ¶ added in v1.4.0
func GetPasswd() (io.ReadCloser, error)
func GetPasswdFile ¶ added in v1.4.0
Types ¶
type ExecUser ¶ added in v1.4.0
func GetExecUser ¶ added in v1.4.0
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"
func GetExecUserFile ¶ added in v1.4.0
func GetExecUserFile(userSpec string, defaults *ExecUser, passwdPath, groupPath string) (*ExecUser, error)
GetExecUserFile 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 CurrentGroup ¶ added in v1.4.0
CurrentGroup looks up the current user's group by their primary group id's entry in /etc/passwd. If the group cannot be found (or there is no /etc/group file on the filesystem), then CurrentGroup returns an error.
func LookupGid ¶ added in v1.4.0
LookupGid looks up a group by its group id in /etc/group. If the group cannot be found (or there is no /etc/group file on the filesystem), then LookupGid returns an error.
func LookupGroup ¶ added in v1.4.0
LookupGroup looks up a group by its name in /etc/group. If the group cannot be found (or there is no /etc/group file on the filesystem), then LookupGroup returns an error.
func ParseGroupFile ¶ added in v1.4.0
func ParseGroupFileFilter ¶ added in v1.4.0
type User ¶
func CurrentUser ¶ added in v1.4.0
CurrentUser looks up the current user by their user id in /etc/passwd. If the user cannot be found (or there is no /etc/passwd file on the filesystem), then CurrentUser returns an error.
func LookupUid ¶ added in v1.4.0
LookupUid looks up a user by their user id in /etc/passwd. If the user cannot be found (or there is no /etc/passwd file on the filesystem), then LookupId returns an error.
func LookupUser ¶ added in v1.4.0
LookupUser looks up a user by their username in /etc/passwd. If the user cannot be found (or there is no /etc/passwd file on the filesystem), then LookupUser returns an error.