getent

package
v0.78.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentUser

func CurrentUser() (*user.User, error)

CurrentUser returns the user this process runs as.

func GroupIDs

func GroupIDs(u *user.User) ([]string, error)

GroupIDs returns the IDs of the groups the user is a member of; libc's getgrouplist handles NSS groups natively.

func GroupMembers

func GroupMembers(name string) ([]string, error)

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

func LookupGroupID(gid string) (*user.Group, error)

LookupGroupID looks up a group by GID.

func LookupUser

func LookupUser(username string) (*user.User, error)

LookupUser looks up a user by name.

func LookupUserID

func LookupUserID(uid string) (*user.User, error)

LookupUserID looks up a user by UID.

func UserShell

func UserShell(uid string) (string, error)

UserShell returns the login shell getent reports for the user with this UID. It reaches shells that /etc/passwd does not list, because getent resolves through the host's NSS stack.

Types

This section is empty.

Jump to

Keyboard shortcuts

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