Documentation
¶
Overview ¶
Package shadow reads and changes local users and groups through the shadow tools or busybox.
Index ¶
Constants ¶
View Source
const ( // DefaultIDMin is the lowest non-system ID, the shadow default for UID_MIN and GID_MIN. DefaultIDMin = 1000 // DefaultIDMax is the highest non-system ID, the shadow default for UID_MAX and GID_MAX. DefaultIDMax = 60000 )
Variables ¶
This section is empty.
Functions ¶
func IsSystemID ¶
IsSystemID reports whether id is outside the non-system range. Nil idMin and idMax default to DefaultIDMin and DefaultIDMax.
Types ¶
type Group ¶
type Group struct {
Name string
GID int
// Members are the users listed as supplementary members.
Members []string
}
Group is a local group.
type Options ¶
type Options struct {
// Root is the directory containing etc/passwd and etc/group, e.g. a jail.
// Empty means "/".
// Busybox does not support a root other than "/".
Root string
}
Options configures the Service.
type Service ¶
type Service interface {
// User returns the named user, nil when it does not exist.
User(name string) (*User, error)
// Group returns the named group, nil when it does not exist.
Group(name string) (*Group, error)
// Users returns all users in file order.
Users() ([]User, error)
// Groups returns all groups in file order.
Groups() ([]Group, error)
// ApplyUser creates or modifies the user.
ApplyUser(ctx context.Context, desired UserSpec) error
// DeleteUser deletes the user.
// removeHome also removes the home. Note that home removal is
// governed by the backing tool and not by the package.
DeleteUser(ctx context.Context, name string, removeHome bool) error
// ApplyGroup creates or modifies the group.
ApplyGroup(ctx context.Context, desired GroupSpec) error
// DeleteGroup deletes the group.
DeleteGroup(ctx context.Context, name string) error
// AddMember adds the user as supplementary member of the group.
AddMember(ctx context.Context, user, group string) error
// RemoveMember removes the user as supplementary member of the group.
RemoveMember(ctx context.Context, user, group string) error
}
Service reads and changes local users and groups. Unsupported operations return an error wrapping errors.ErrUnsupported.
type User ¶
type User struct {
Name string
UID int
GID int
// Group is the primary group name, empty when GID resolves to no group.
Group string
// Groups are the supplementary groups listing the user as a member.
Groups []string
Home string
Shell string
}
User is a local user.
type UserSpec ¶
type UserSpec struct {
Name string
UID *int
// Group empty applies the tool default on creation.
Group string
// Groups is the complete set of supplementary groups.
// Nil is unmanaged, empty removes all supplementary groups.
Groups []string
// Home empty applies the tool default on creation.
Home string
// Shell empty applies the tool default on creation.
Shell string
}
UserSpec is the desired state of a user. Unset fields are unmanaged.
Click to show internal directories.
Click to hide internal directories.