Documentation
¶
Overview ¶
Package sidecar starts an extension's sidecar (extension version 1.1, docs/reference/extensions.md in the console repository) in its sandbox: the agent runs `edgeweir-node sidecar-exec` (ChildCommand) with a Spec in the environment; the child moves itself into the sidecar's cgroup, sets the resource limits, switches to the sidecar user, sets no_new_privs and a seccomp filter, and executes the binary with only the Spec's environment.
Index ¶
Constants ¶
const CapabilityHandoff = "edgeweir-node:sidecar-capabilities-v1"
CapabilityHandoff is the local version query's promise that every entry point clears inherited sidecar capabilities before it can start other processes.
const ChildCommand = "sidecar-exec"
ChildCommand is the hidden subcommand of the sandbox helper.
const SpecEnv = "EDGEWEIR_SIDECAR_EXEC_SPEC"
SpecEnv carries the Spec (JSON) from the agent to the helper.
Variables ¶
var ErrUnsupported = errors.New("sidecars need Linux")
ErrUnsupported: this platform cannot isolate a sidecar.
Functions ¶
func CapabilityHandoffSupported ¶ added in v1.8.0
func CapabilityHandoffSupported() (supported bool)
CapabilityHandoffSupported excludes cgo builds, whose non-Go threads cannot participate in the process-wide removal of the temporary inheritable bits.
func ClearInheritedCapabilities ¶ added in v1.8.0
func ClearInheritedCapabilities() error
ClearInheritedCapabilities keeps the agent's effective/permitted privileges but removes the sidecar exec bridge before nginx or other helpers can inherit it.
func InheritCapabilities ¶ added in v1.8.0
InheritCapabilities carries only the caller's existing sidecar privileges across an internal agent or sandbox-helper exec without file capabilities. The target must call ClearInheritedCapabilities before starting any children.
Types ¶
type Spec ¶
type Spec struct {
Binary string `json:"binary"`
Args []string `json:"args"`
Env []string `json:"env"`
Dir string `json:"dir"`
UID int `json:"uid"`
GID int `json:"gid"`
// Cgroup is the sidecar's cgroup v2 directory ("": none; the limits
// then come from rlimits only).
Cgroup string `json:"cgroup,omitempty"`
// MemoryBytes and Tasks become RLIMIT_DATA and RLIMIT_NPROC without a
// cgroup (RLIMIT_NPROC counts the sidecar user's tasks).
MemoryBytes uint64 `json:"memory_bytes"`
Tasks uint64 `json:"tasks"`
}
Spec is how the helper starts one sidecar.