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
- func GetGroupEntries(dbLocked *UserDBLocked) (entries []types.GroupEntry, err error)
- func SaveGroupEntries(dbLocked *UserDBLocked, entries []types.GroupEntry) (err error)
- func UpdateGroups(dbLocked *UserDBLocked, username string, newGroups []string, ...) (err error)
- func Z_ForTests_RestoreDefaultOptions()
- func Z_ForTests_SetGroupPath(inputGroupPath, outputGroupPath string)
- type Option
- type UserDBLocked
- func (l *UserDBLocked) GetGroupEntries() (entries []types.GroupEntry, err error)
- func (l *UserDBLocked) GetLocalGroupEntries() (entries []types.GroupEntry, err error)
- func (l *UserDBLocked) GetLocalUserEntries() (entries []types.UserEntry, err error)
- func (l *UserDBLocked) GetUserEntries() (entries []types.UserEntry, err error)
- func (l *UserDBLocked) IsUniqueGID(gid uint32) (unique bool, err error)
- func (l *UserDBLocked) IsUniqueGroupName(group string) (unique bool, err error)
- func (l *UserDBLocked) IsUniqueUID(uid uint32) (unique bool, err error)
- func (l *UserDBLocked) IsUniqueUserName(name string) (unique bool, err error)
- func (l *UserDBLocked) MustBeLocked()
Constants ¶
const ( // Z_ForTests_GroupFilePathEnv is the env variable to set the group file path during // integration tests. // nolint:revive,nolintlint // We want to use underscores in the function name here. Z_ForTests_GroupFilePathEnv = "AUTHD_INTEGRATIONTESTS_GROUP_FILE_PATH" // Z_ForTests_GroupFileOutputPathEnv is the env variable to set the group file output // path during integration tests. // nolint:revive,nolintlint // We want to use underscores in the function name here. Z_ForTests_GroupFileOutputPathEnv = "AUTHD_INTEGRATIONTESTS_GROUP_OUTPUT_FILE_PATH" )
const (
// GroupFile is the default local group file.
GroupFile = "/etc/group"
)
Variables ¶
This section is empty.
Functions ¶
func GetGroupEntries ¶
func GetGroupEntries(dbLocked *UserDBLocked) (entries []types.GroupEntry, err error)
GetGroupEntries returns a copy of the current group entries.
func SaveGroupEntries ¶
func SaveGroupEntries(dbLocked *UserDBLocked, entries []types.GroupEntry) (err error)
SaveGroupEntries saves the provided group entries to the local group file.
func UpdateGroups ¶
func UpdateGroups(dbLocked *UserDBLocked, username string, newGroups []string, oldGroups []string) (err error)
UpdateGroups updates the local groups for a user, adding them to the groups in newGroups which they are not already part of, and removing them from the groups in oldGroups which are not in newGroups.
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_SetGroupPath ¶
func Z_ForTests_SetGroupPath(inputGroupPath, outputGroupPath 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 Option ¶
type Option func(*options)
Option represents an optional function to override UserDBLocked default values.
type UserDBLocked ¶
type UserDBLocked struct {
// contains filtered or unexported fields
}
UserDBLocked is a struct that holds the current users and groups while ensuring that the system's user database is locked to prevent concurrent modifications.
func WithUserDBLock ¶
func WithUserDBLock(args ...Option) (userDB *UserDBLocked, unlock func() error, err error)
WithUserDBLock gets an UserDBLocked instance with a lock on the system's user database. It returns an unlock function that should be called to unlock it.
It can called safely multiple times and will return always a the same UserDBLocked with increased reference counting (that must be released through returned the unlock function).
func (*UserDBLocked) GetGroupEntries ¶
func (l *UserDBLocked) GetGroupEntries() (entries []types.GroupEntry, err error)
GetGroupEntries gets the group entries.
func (*UserDBLocked) GetLocalGroupEntries ¶
func (l *UserDBLocked) GetLocalGroupEntries() (entries []types.GroupEntry, err error)
GetLocalGroupEntries gets the local group entries.
func (*UserDBLocked) GetLocalUserEntries ¶
func (l *UserDBLocked) GetLocalUserEntries() (entries []types.UserEntry, err error)
GetLocalUserEntries gets the local group entries.
func (*UserDBLocked) GetUserEntries ¶
func (l *UserDBLocked) GetUserEntries() (entries []types.UserEntry, err error)
GetUserEntries gets the user entries.
func (*UserDBLocked) IsUniqueGID ¶
func (l *UserDBLocked) IsUniqueGID(gid uint32) (unique bool, err error)
IsUniqueGID returns if a user exists for the given UID.
func (*UserDBLocked) IsUniqueGroupName ¶
func (l *UserDBLocked) IsUniqueGroupName(group string) (unique bool, err error)
IsUniqueGroupName returns if a user exists for the given UID.
func (*UserDBLocked) IsUniqueUID ¶
func (l *UserDBLocked) IsUniqueUID(uid uint32) (unique bool, err error)
IsUniqueUID returns if a user exists for the given UID.
func (*UserDBLocked) IsUniqueUserName ¶
func (l *UserDBLocked) IsUniqueUserName(name string) (unique bool, err error)
IsUniqueUserName returns if a user exists for the given name.
func (*UserDBLocked) MustBeLocked ¶
func (l *UserDBLocked) MustBeLocked()
MustBeLocked ensures wether the entries are locked.