Documentation ¶
Overview ¶
Package system implements cross-platform abstractions for user-management access-control and sub-process execution geared at executing sub-process with best-effort sandboxing.
The system package provides the following platform specific types and methods.
system.User system.User.Remove() system.Group system.Process system.Process.Wait() bool system.Process.Kill() system.SetSize(columns, rows uint16) error system.CreateUser(homeFolder string, groups []*Group) (*User, error) system.FindGroup(name string) (*Group, error) system.StartProcess(options ProcessOptions) (*Process, error) system.KillByOwner(user *User) error
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUserGroupNotFound = errors.New("User group doesn't exist!")
ErrUserGroupNotFound indicates that a given user-group doesn't exist.
Functions ¶
func KillByOwner ¶
KillByOwner will kill all process with the given owner.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a representation of a system user-group.
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process is a representation of a system process.
func StartProcess ¶
func StartProcess(options ProcessOptions) (*Process, error)
StartProcess starts a new process with given arguments, environment variables, and current working folder, running as given user.
Returns an human readable error explaining why the sub-process couldn't start if not successful.
type ProcessOptions ¶
type ProcessOptions struct { Arguments []string // Command and arguments, default to shell Environment map[string]string // Environment variables WorkingFolder string // Working directory, if not HOME Owner *User // User to run process as, nil to use current Stdin io.ReadCloser // Stream with stdin, or nil if nothing Stdout io.WriteCloser // Stream for stdout Stderr io.WriteCloser // Stream for stderr, or nil if using stdout TTY bool // Start as TTY, if supported, ignores stderr }
ProcessOptions are the arguments given for StartProcess. This structure is platform independent.
type User ¶
type User struct {
// contains filtered or unexported fields
}
User is a representation of a system user account.
func CreateUser ¶
CreateUser will create a new user, with the given homeFolder, set the user owner of the homeFolder, and assign the user membership of given groups.