Documentation
¶
Overview ¶
Package helper runs external helpers with optional sandboxing and manages their status/args pipes.
Index ¶
Constants ¶
const ( // FortifyHelper is set to 1 when args fd is enabled and 0 otherwise. FortifyHelper = "FORTIFY_HELPER" // FortifyStatus is set to 1 when stat fd is enabled and 0 otherwise. FortifyStatus = "FORTIFY_STATUS" )
Variables ¶
var BubblewrapName = "bwrap"
BubblewrapName is the file name or path to bubblewrap.
var (
ErrContainsNull = errors.New("argument contains null character")
)
var (
WaitDelay = 2 * time.Second
)
Functions ¶
func InternalChildStub ¶
func InternalChildStub()
InternalChildStub is an internal function but exported because it is cross-package; it is part of the implementation of the helper stub.
func InternalReplaceExecCommand ¶
InternalReplaceExecCommand is an internal function but exported because it is cross-package; it is part of the implementation of the helper stub.
func MustNewCheckedArgs ¶
MustNewCheckedArgs returns a checked argument writer for args and panics if check fails. Callers must not retain any references to args.
Types ¶
type Helper ¶
type Helper interface { // Stdin sets the standard input of Helper. Stdin(r io.Reader) Helper // Stdout sets the standard output of Helper. Stdout(w io.Writer) Helper // Stderr sets the standard error of Helper. Stderr(w io.Writer) Helper // SetEnv sets the environment of Helper. SetEnv(env []string) Helper // Start starts the helper process. // A status pipe is passed to the helper if stat is true. Start(ctx context.Context, stat bool) error // Wait blocks until Helper exits and releases all its resources. Wait() error fmt.Stringer }
func MustNewBwrap ¶
func MustNewBwrap( conf *bwrap.Config, name string, wt io.WriterTo, argF func(argsFD, statFD int) []string, extraFiles []*os.File, syncFd *os.File, ) Helper
MustNewBwrap initialises a new Bwrap instance with wt as the null-terminated argument writer. If wt is nil, the child process spawned by bwrap will not get an argument pipe. Function argF returns an array of arguments passed directly to the child process.
func New ¶
New initialises a new direct Helper instance with wt as the null-terminated argument writer. Function argF returns an array of arguments passed directly to the child process.
func NewBwrap ¶
func NewBwrap( conf *bwrap.Config, name string, wt io.WriterTo, argF func(argsFd, statFd int) []string, extraFiles []*os.File, syncFd *os.File, ) (Helper, error)
NewBwrap initialises a new Bwrap instance with wt as the null-terminated argument writer. If wt is nil, the child process spawned by bwrap will not get an argument pipe. Function argF returns an array of arguments passed directly to the child process.