Documentation ¶
Index ¶
- Constants
- func AddUser(username string, homeDir string, primaryGroup string, hashedPassword string, ...) error
- func GetUserGroups(rootDir string, username string) ([]string, error)
- func HashPassword(password string) (string, error)
- func NameIsValid(name string) (err error)
- func PasswordExpiresDaysIsValid(passwordExpiresDays int64) error
- func UIDIsValid(uid int) error
- func UpdateUserPassword(installRoot, username, hashedPassword string) error
- func UserExists(username string, installChroot safechroot.ChrootInterface) (bool, error)
- func UserHomeDirectory(installRoot string, username string) (string, error)
- func UserSSHDirectory(installRoot string, username string) (string, error)
- type GroupEntry
- type PasswdEntry
- type ShadowEntry
Constants ¶
View Source
const ( RootUser = "root" RootHomeDir = "/root" UserHomeDirPrefix = "/home" ShadowFile = "/etc/shadow" PasswdFile = "/etc/passwd" GroupFile = "/etc/group" SSHDirectoryName = ".ssh" SSHAuthorizedKeysFileName = "authorized_keys" )
Variables ¶
This section is empty.
Functions ¶
func AddUser ¶
func AddUser(username string, homeDir string, primaryGroup string, hashedPassword string, uid string, installChroot safechroot.ChrootInterface) error
func HashPassword ¶
func NameIsValid ¶
NameIsValid returns an error if the User name is empty
func PasswordExpiresDaysIsValid ¶
PasswordExpiresDaysISValid returns an error if the expire days is not within bounds set by the chage -M command
func UIDIsValid ¶
UIDIsValid returns an error if the UID is outside bounds UIDs 1-999 are system users and 1000-60000 are normal users Bounds can be checked using: $grep -E '^UID_MIN|^UID_MAX' /etc/login.defs
func UpdateUserPassword ¶
func UserExists ¶
func UserExists(username string, installChroot safechroot.ChrootInterface) (bool, error)
func UserHomeDirectory ¶
UserHomeDirectory returns the home directory for a user.
Types ¶
type GroupEntry ¶
func ReadGroupFile ¶
func ReadGroupFile(rootDir string) ([]GroupEntry, error)
type PasswdEntry ¶
type PasswdEntry struct { Name string Uid int Gid int Description string HomeDirectory string Shell string }
func GetPasswdFileEntryForUser ¶
func GetPasswdFileEntryForUser(rootDir string, user string) (PasswdEntry, error)
func ReadPasswdFile ¶
func ReadPasswdFile(rootDir string) ([]PasswdEntry, error)
type ShadowEntry ¶
type ShadowEntry struct { Name string EncryptedPassword string LastPasswordChange *int MinPasswordAge *int MaxPasswordAge *int PasswordWarningPeriod *int PasswordInactivityPeriod *int AccountExpirationDate *int }
func GetShadowFileEntryForUser ¶
func GetShadowFileEntryForUser(rootDir string, user string) (ShadowEntry, error)
func ReadShadowFile ¶
func ReadShadowFile(rootDir string) ([]ShadowEntry, error)
Click to show internal directories.
Click to hide internal directories.