Documentation
¶
Overview ¶
Package localentries provides functions to access the local user and group database.
Package localentries provides functions to access local passwd entries.
Package localentries provides functions to retrieve passwd and group entries and to update the groups of a user.
Index ¶
- Constants
- Variables
- func Clean(args ...Option) (err error)
- func CleanUser(user string, args ...Option) (err error)
- func Update(username string, newGroups []string, oldGroups []string, args ...Option) (err error)
- func Z_ForTests_RestoreDefaultOptions()
- func Z_ForTests_SetGpasswdCmd(gpasswdCmd []string)
- func Z_ForTests_SetGroupPath(groupPath string)
- type Group
- type Option
- type Passwd
Constants ¶
const GroupFile = "/etc/group"
GroupFile is the default local group file.
Variables ¶
var ErrGroupNotFound = errors.New("group not found")
ErrGroupNotFound is returned when a group is not found.
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound is returned when a user is not found.
Functions ¶
func Update ¶
Update synchronizes for the given user the local group list with the current group list from UserInfo.
func Z_ForTests_RestoreDefaultOptions ¶
func Z_ForTests_RestoreDefaultOptions()
Z_ForTests_RestoreDefaultOptions restores the defaultOptions to their original values.
nolint:revive,nolintlint // We want to use underscores in the function name here.
func Z_ForTests_SetGpasswdCmd ¶
func Z_ForTests_SetGpasswdCmd(gpasswdCmd []string)
Z_ForTests_SetGpasswdCmd sets the gpasswdCmd for the defaultOptions. Tests using this can't be run in parallel. Call Z_ForTests_RestoreDefaultOptions to restore the original value.
nolint:revive,nolintlint // We want to use underscores in the function name here.
func Z_ForTests_SetGroupPath ¶
func Z_ForTests_SetGroupPath(groupPath string)
Z_ForTests_SetGroupPath sets the groupPath for the defaultOptions. Tests using this can't be run in parallel. Call Z_ForTests_RestoreDefaultOptions to restore the original value.
nolint:revive,nolintlint // We want to use underscores in the function name here.
Types ¶
type Group ¶
Group represents a group entry.
func GetGroupByName ¶
GetGroupByName returns the group with the given name.
func GetGroupEntries ¶
GetGroupEntries returns all group entries.
type Option ¶
type Option func(*options)
Option represents an optional function to override UpdateLocalGroups default values.
type Passwd ¶
Passwd represents a passwd entry.
func GetPasswdByName ¶
GetPasswdByName returns the user with the given name.
func GetPasswdEntries ¶
GetPasswdEntries returns all passwd entries.