jail

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AwaitFifoOpen

func AwaitFifoOpen(ctx context.Context, id string) error

AwaitFifoOpen waits for a runj-entrypoint process to open the fifo passed to it. The fifo is used to indicate when runj-entrypoint should start the process inside the jail.

func CleanupEntrypoint

func CleanupEntrypoint(id string) error

CleanupEntrypoint sends a SIGTERM to the PID recorded in the state file. This function returns with no error even if the process is not running or cannot be signaled.

func ConfPath

func ConfPath(id string) string

ConfPath returns the expected file path for a given jail's config file

func CreateConfig

func CreateConfig(config *Config) (string, error)

CreateConfig creates a config file for the jail(8) command

func CreateJail

func CreateJail(ctx context.Context, confPath string) error

CreateJail wraps the jail(8) command to create a jail

func DestroyJail

func DestroyJail(ctx context.Context, confPath, jail string) error

DestroyJail wraps the jail(8) command to destroy a jail

func ExecEntrypoint

func ExecEntrypoint(id string, argv []string, env []string, consoleSocketPath string) error

ExecEntrypoint execs a runj-entrypoint process in order to start processes inside the jail.

Note: this API is unstable; expect it to change.

func IsRunning

func IsRunning(ctx context.Context, jail string, pid int) (bool, error)

IsRunning attempts to determine whether a given jail is running. This is accomplished by looking to see whether the jail's primary pid (passed as an argument) is still active and by whether there are any processes present in the jail. This function is best-effort, racy, and subject to change. It currently depends on the host's "ps" command.

func Kill

func Kill(ctx context.Context, jail string, pid int, signal unix.Signal) error

Kill sends a signal to a process in a jail

func KillAll

func KillAll(ctx context.Context, jail string, signal unix.Signal) error

KillAll sends a signal to all processes in a jail

func Mount

func Mount(ociConfig *runtimespec.Spec) error

Mount mounts the mounts

func SetupEntrypoint

func SetupEntrypoint(id string, init bool, argv []string, env []string, consoleSocketPath string) (*exec.Cmd, error)

SetupEntrypoint starts a runj-entrypoint process, which is used to start processes inside the jail.

When used to start the jail's init process, runj-entrypoint will later be signalled through `runj start` to run the specified program in the jail. This indirection is necessary so that the STDIO for `runj create` or the supplied console socket is directed to that process.

When used to start a secondary process inside the jail, the waiting step is skipped and runj-entrypoint will immediately proceed to create the process as soon as STDIO is configured.

Note: this API is unstable; expect it to change.

func Unmount

func Unmount(ociConfig *runtimespec.Spec) error

Unmount attempts to unmount all mounts present in the spec. If multiple errors occur, Unmount returns the first.

Types

type Config

type Config struct {
	Name          string
	Root          string
	Hostname      string
	IP4           string
	IP4Addr       []string
	VNet          string
	VNetInterface []string
}

Config is a limited subset of the parameters available in jail.conf(5) for use with jail(8).

type ID

type ID int32

ID identifies jails

type Jail

type Jail interface {
	// Attach attaches the current running process to the jail
	Attach() error
	// Remove destroys the jail
	Remove() error
}

Jail represents an existing jail

func FromName

func FromName(name string) (Jail, error)

FromName queries the OS for a jail with the specified name

Jump to

Keyboard shortcuts

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