Documentation ¶
Index ¶
- func GroupSerialize(entries []GroupEntry) ([]byte, error)
- func PasswdSerialize(entries []PasswdEntry) ([]byte, error)
- func ShadowEntryValidate(entry ShadowEntry) error
- func ShadowSerialize(entries []ShadowEntry) ([]byte, error)
- type AddUserOpt
- type Config
- type GroupEntry
- type PasswdEntry
- type PasswdPass
- type PasswdPassMode
- type ShadowEntry
- type ShadowPass
- type ShadowPassMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GroupSerialize ¶
func GroupSerialize(entries []GroupEntry) ([]byte, error)
GroupSerialize serializes the given group entries into the format expected at /etc/group.
func PasswdSerialize ¶
func PasswdSerialize(entries []PasswdEntry) ([]byte, error)
PasswdSerialize serializes the given user entries into the format expected at /etc/passwd.
func ShadowEntryValidate ¶
func ShadowEntryValidate(entry ShadowEntry) error
func ShadowSerialize ¶
func ShadowSerialize(entries []ShadowEntry) ([]byte, error)
ShadowSerialize serializes the given shadow entries into the format expected at /etc/shadow.
Types ¶
type AddUserOpt ¶
type AddUserOpt struct {
// contains filtered or unexported fields
}
AddUserOpt represents an option configuring an invocation to UpsertUser().
func OptCreateSkel ¶
func OptCreateSkel() AddUserOpt
OptCreateSkel indicates that a skeleton homedir should be created based on /etc/skel.
func OptErrIfExists ¶
func OptErrIfExists() AddUserOpt
OptErrIfExists will cause UpsertUser to fail if the user already exists.
func OptHomedir ¶
func OptHomedir(dir string) AddUserOpt
OptHomedir configures the homedir for the user.
func OptNoUserGroup ¶
func OptNoUserGroup() AddUserOpt
OptNoUserGroup indicates no user group should be created for any created user.
func OptSystemAccount ¶
func OptSystemAccount() AddUserOpt
OptSystemAccount indicates any created user should use the system UID/GID ranges.
type Config ¶
type Config struct { RootPath string // contains filtered or unexported fields }
Config represents a static user/group configuration which can be mutated.
func ReadConfig ¶
ReadConfig reads the static user/group configuration in the given filesystem root.
func (*Config) SetPassword ¶
func (m *Config) SetPassword(name string, pass ShadowPass) error
SetPassword sets the password on the account.
func (*Config) UpsertMembership ¶
UpsertMembership adds the named user to the named group, if not already a member.
func (*Config) UpsertUser ¶
func (m *Config) UpsertUser(name string, opts ...AddUserOpt) error
UpsertUser creates the given user if it does not exist, or updates the homedir, shell, and user info otherwise.
type GroupEntry ¶
GroupEntry describes a group in an /etc/group file.
func ParseGroup ¶
func ParseGroup(r io.Reader) ([]GroupEntry, error)
ParseGroup parses content formatted as a /etc/group file.
func (GroupEntry) String ¶
func (g GroupEntry) String() string
type PasswdEntry ¶
type PasswdEntry struct { Username string Password PasswdPass UID, GID int UserInfo string HomeDir string ShellPath string }
PasswdEntry represents a line in /etc/passwd.
func ParsePasswd ¶
func ParsePasswd(r io.Reader) ([]PasswdEntry, error)
ParsePasswd parses content formatted as a /etc/passwd file.
func (*PasswdEntry) String ¶
func (e *PasswdEntry) String() string
type PasswdPass ¶
type PasswdPass struct { Mode PasswdPassMode Pass string }
func (*PasswdPass) String ¶
func (p *PasswdPass) String() string
type PasswdPassMode ¶
type PasswdPassMode uint8
const ( PassShadow PasswdPassMode = iota PassPlaintext )
type ShadowEntry ¶
type ShadowEntry struct { Username string Password ShadowPass LastChanged time.Time Expiry time.Time MinChangeDays int MaxChangeDays int WarnBeforeMaxDays int DisableAfterExpiryDays int }
ShadowEntry describes an entry in /etc/shadow.
func ParseShadow ¶
func ParseShadow(r io.Reader) ([]ShadowEntry, error)
ParseShadow parses content formatted as a /etc/shadow file.
func (*ShadowEntry) String ¶
func (e *ShadowEntry) String() string
type ShadowPass ¶
type ShadowPass struct { Mode ShadowPassMode Encrypted string }
ShadowPass represents the shadow configuration for a password field.
func ShadowHash ¶
func ShadowHash(pw string) (ShadowPass, error)
ShadowHash computes the hash of the given password, returning a form which can be written into a shadow file.
func (*ShadowPass) String ¶
func (p *ShadowPass) String() string
type ShadowPassMode ¶
type ShadowPassMode uint8
const ( PassEncrypted ShadowPassMode = iota PassNotRequired PassAccountDisabled )
Valid password modes.