donation

package
v0.0.0-...-ae1d4cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: Apache-2.0, MIT Imports: 6 Imported by: 4

Documentation

Overview

Package donation tracks files that are being donated to a child process and using flags to notified the child process where the FDs are.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DonateAndTransferCustomFiles

func DonateAndTransferCustomFiles(cmd *exec.Cmd, nextFD int, files map[int]*os.File) int

DonateAndTransferCustomFiles sets up the flags for passing file descriptors from the host to the sandbox. Making use of the agency is not necessary,

func LogDonations

func LogDonations(cmd *exec.Cmd)

LogDonations logs the FDs we are donating in the command.

Types

type Agency

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

Agency keeps track of files that need to be donated to a child process.

func (*Agency) Close

func (f *Agency) Close()

Close closes any files the agency has taken ownership over.

func (*Agency) Donate

func (f *Agency) Donate(flag string, files ...*os.File)

Donate sets up the given files to be donated to another process. The FD in which the new file will appear in the child process is added as a flag to the child process, e.g. --flag=3. In case the file is nil, -1 is used for the flag value and no file is donated to the next process.

func (*Agency) DonateAndClose

func (f *Agency) DonateAndClose(flag string, files ...*os.File)

DonateAndClose does the same as Donate, but takes ownership of the files passed in.

func (*Agency) DonateDebugLogFile

func (f *Agency) DonateDebugLogFile(flag, logPattern, command, test string, timestamp time.Time) error

DonateDebugLogFile is similar to DonateAndClose but handles the opening of the file using specutils.DebugLogFile() for convenience. It's a noop, if path is empty.

func (*Agency) OpenAndDonate

func (f *Agency) OpenAndDonate(flag, path string, flags int) error

OpenAndDonate is similar to DonateAndClose but handles the opening of the file for convenience. It's a noop, if path is empty.

func (*Agency) Transfer

func (f *Agency) Transfer(cmd *exec.Cmd, nextFD int) int

Transfer sets up all files and flags to cmd. It can be called multiple times to partially transfer files to cmd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL