taskcluster-worker: github.com/taskcluster/taskcluster-worker/engines/native/system Index | Files

package system

import "github.com/taskcluster/taskcluster-worker/engines/native/system"

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

Package Files

doc.go errors.go group_linux.go process_posix.go system.go system_posix.go user_linux.go utils.go

Variables

var ErrUserGroupNotFound = errors.New("user group doesn't exist")

ErrUserGroupNotFound indicates that a given user-group doesn't exist.

func ChangeOwner Uses

func ChangeOwner(filepath string, user *User) error

ChangeOwner changes the owner of filepath to the given user

func KillByOwner Uses

func KillByOwner(user *User) error

KillByOwner will kill all process with the given owner.

func KillProcessTree Uses

func KillProcessTree(root *Process) error

KillProcessTree will kill root and all of its descendents.

type Group Uses

type Group struct {
    // contains filtered or unexported fields
}

Group is a representation of a system user-group.

func FindGroup Uses

func FindGroup(name string) (*Group, error)

FindGroup will find the user-group given by name.

type Process Uses

type Process struct {
    // contains filtered or unexported fields
}

Process is a representation of a system process.

func StartProcess Uses

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.

func (*Process) Kill Uses

func (p *Process) Kill()

Kill the process

func (*Process) SetSize Uses

func (p *Process) SetSize(columns, rows uint16)

SetSize of the TTY, if running as TTY or do nothing.

func (*Process) Wait Uses

func (p *Process) Wait() bool

Wait for process to terminate, returns true, if exited zero.

type ProcessOptions Uses

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 Uses

type User struct {
    // contains filtered or unexported fields
}

User is a representation of a system user account.

func CreateUser Uses

func CreateUser(homeFolder string, groups []*Group) (*User, error)

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.

func CurrentUser Uses

func CurrentUser() (*User, error)

CurrentUser will get a User record representing the current user.

func (*User) Home Uses

func (u *User) Home() string

Home returns the user home folder`

func (*User) Name Uses

func (u *User) Name() string

Name returns the user name

func (*User) Remove Uses

func (u *User) Remove()

Remove will remove a user and all associated resources.

Package system imports 20 packages (graph) and is imported by 2 packages. Updated 2017-04-16. Refresh now. Tools for package owners.