Documentation
¶
Overview ¶
Package getent resolves users and groups through the host's NSS stack. Built without cgo, os/user reads /etc/passwd and /etc/group alone and misses anything LDAP, SSSD or winbind provide; the getent and id commands resolve through NSS whatever the build. The lookups here try the standard library first, which needs no subprocess, and fall back to those commands.
Index ¶
- func CurrentUser() (*user.User, error)
- func GroupIDs(u *user.User) ([]string, error)
- func GroupMembers(name string) ([]string, error)
- func LookupGroupID(gid string) (*user.Group, error)
- func LookupUser(username string) (*user.User, error)
- func LookupUserID(uid string) (*user.User, error)
- func UserShell(uid string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentUser ¶
CurrentUser returns the user this process runs as.
func GroupIDs ¶
GroupIDs returns the IDs of the groups the user is a member of; libc's getgrouplist handles NSS groups natively.
func GroupMembers ¶
GroupMembers returns the names of the group's members: from getent, which resolves through NSS, or from /etc/group where getent is not available. A group neither source describes is an error; an empty member list is not, since accounts with the group as their primary one are not listed in it.
func LookupGroupID ¶
LookupGroupID looks up a group by GID.
func LookupUser ¶
LookupUser looks up a user by name.
func LookupUserID ¶
LookupUserID looks up a user by UID.
Types ¶
This section is empty.