Documentation
¶
Overview ¶
Package sandbox confines agent-selected commands with Landlock. The worker re-executes itself with a landlock-exec subcommand, which calls Restrict and then execs the real program, because Go cannot run code between fork and exec.
On macOS, Seatbelt (sandbox-exec) provides the equivalent confinement for the opt-in "seatbelt" execution isolation mode; see seatbelt.go.
Index ¶
- Constants
- func ABI() (int, error)
- func Restrict(runRoot string) error
- func RestrictWithPaths(runRoot string, readExecPaths, readWritePaths []string) error
- func RestrictWithReadExec(runRoot string, readExecPaths []string) error
- func RunExec(args []string) int
- func SeatbeltArgs(paths SeatbeltPaths, program string, args []string) ([]string, error)
- func SeatbeltAvailable() error
- type SeatbeltPaths
Constants ¶
const SeatbeltExecutable = "/usr/bin/sandbox-exec"
SeatbeltExecutable is the macOS tool that applies a Seatbelt profile and execs the confined program.
Variables ¶
This section is empty.
Functions ¶
func ABI ¶
ABI reports the Landlock ABI version of the running kernel, or 0 when the kernel does not support Landlock or it is disabled.
func Restrict ¶
Restrict confines the calling thread to the system toolchain paths plus full access under runRoot. It is irreversible and inherited across exec, so call it from the thread that will exec the confined program.
func RestrictWithPaths ¶
RestrictWithPaths additionally grants full access to operator-selected writable state directories. Both path lists must come from trusted runtime configuration, never agent-controlled command arguments.
func RestrictWithReadExec ¶
RestrictWithReadExec confines the calling thread like Restrict and grants read/execute access to operator-selected toolchain paths. The caller must derive these paths from the worker environment, never agent input.
func RunExec ¶ added in v0.13.16
runLandlockExec confines this process to the run root and replaces it with the requested program. The parent already prepared the environment.
func SeatbeltArgs ¶ added in v0.13.8
func SeatbeltArgs(paths SeatbeltPaths, program string, args []string) ([]string, error)
SeatbeltArgs returns sandbox-exec arguments that confine program to the given paths. The caller runs SeatbeltExecutable with these arguments.
func SeatbeltAvailable ¶ added in v0.13.8
func SeatbeltAvailable() error
SeatbeltAvailable fails off macOS: Seatbelt is a macOS mechanism.
Types ¶
type SeatbeltPaths ¶ added in v0.13.8
type SeatbeltPaths struct {
// Root receives full access, like the Landlock run root.
Root string
// ReadWrite are additional trusted state and cache directories.
ReadWrite []string
// DenyRead are directories the command must not read, such as secrets.
DenyRead []string
}
SeatbeltPaths are the trusted paths a Seatbelt-confined command may use. Every path must come from runtime configuration, never agent input.