Documentation
¶
Overview ¶
Package accounts sets up accounts and their groups for windows and linux.
Index ¶
- func AddUserToGroup(ctx context.Context, u *User, g *Group) error
- func CreateGroup(ctx context.Context, groupName string) error
- func CreateUser(ctx context.Context, u *User) error
- func DelUser(ctx context.Context, u *User) error
- func ListGoogleUsers(ctx context.Context) ([]string, error)
- func RemoveUserFromGroup(ctx context.Context, u *User, g *Group) error
- type Group
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUserToGroup ¶
AddUserToGroup adds the user to the named group. Returns the wrapped run error if the command failed.
func CreateGroup ¶
CreateGroup creates a group with the given group name. Returns the wrapped run error if the command failed.
func CreateUser ¶
CreateUser creates a user with the given username. Depending on user configuration, options such as UID and GID may be ignored. If accurate information about the created user is important the caller should call FindUser after creation. Returns the wrapped run error if the command failed.
func DelUser ¶
DelUser removes the user from the OS. Returns the wrapped run error if the command failed.
func ListGoogleUsers ¶
ListGoogleUsers lists users created by the guest agent. See googleUsersFile comment for details. Returns wrapped os errors on failure.
Types ¶
type Group ¶
type Group struct { // Name is the name of the group. Name string // GID is the group id of the group. GID string // Members is the list of members of the group. Members []string }
Group is the common representation of a group across platforms. Redefining this structure - rather than using users.Group - makes the code more simplified avoiding one more level of indirection - the cost of converting between the two types is low (only a few places in the code).
func FindGroup ¶
FindGroup gets the information of the group, returning ErrGroupNotExist if the group does not exist on the system. Returns the wrappe run error if the command failed.
Any group returned by this function is guaranteed to have a valid GID - a call to ValidateUnixGID() will never return an error.
func (*Group) ValidateUnixGID ¶
ValidateUnixGID validates the GID of the group - it determines if the set values are valid integers.
type User ¶
type User struct { // Username is the username of the user. Username string // Password is the password of the user, it's meant to be used only for // windows - specifically for the windows password reset feature. Password string // UID is the user id of the user. UID string // GID is the group id of the user. GID string // Name is the full name of the user. Name string // HomeDir is the home directory of the user. HomeDir string // Shell is the shell of the user. It's meant to be used only for linux. Shell string // contains filtered or unexported fields }
User is the common representation of a user across platforms.
func FindUser ¶
FindUser gets the information of the user, returning user.UnkownUserError if the user does not exist on the system or the wrapped run error if the user list could not be obtained.
Any user returned by this function is guaranteed to have a valid UID and GID - a call to ValidateUnixIDS() will never return an error.
func (*User) SetPassword ¶
SetPassword sets the users password. This is unimplemented on unix.
func (*User) ValidateUnixIDS ¶
ValidateUnixIDS validates the UID and GID of the user - it determines if the set values are valid integers.