main
main
¶
The parent supervisor — run_supervisor(container_id, sidecar_path).
Once a single asyncio loop composing every service, the supervisor is
now a supervisor of processes: it
launch_childs one
hardened child per service and owns only their lifecycle. Each child
(run_child) hardens
itself, rebuilds its one service from the sidecar, and runs it until the
parent signals stop — so a bug in the desktop notifier can no longer
touch the address space that holds the vault's session key.
The five children, in launch order:
verdict—VerdictServer, the varlink helper that execsterok-shield allow|deny.clearance—ClearanceHubplus the desktopEventSubscriber/ notifier it feeds.gate— the git gate (only when the sidecar wired it).vault—VaultProxy.signer— the token-gated SSH-agent (start_ssh_signer).
The parent awaits podman wait <container_id>; when the container
exits (or every child dies first) it terminates the children in reverse
launch order and returns.
Hidden from main user help; invoked by the OCI hook chain only.
run_supervisor(container_id, sidecar_path, container_pid=None)
async
¶
Launch, monitor, and tear down the per-container child processes.
container_pid is the container's init host-PID, handed down from the
createRuntime OCI hook. When present it is the authoritative
container-death signal: the supervisor watches it directly (via
pidfd), so it tears down the instant the container exits even where
nested podman wait is blind (crun handing the hook the container's
env). None (older hook, or a runtime that didn't supply it) falls
back to the podman wait watch alone.
Lifecycle:
- Load the sidecar JSON from sidecar_path; bail with exit code 2 on parse / missing.
- Launch one hardened child per service (skipping the git gate when the sidecar didn't wire it). A child that never spawns is logged and skipped; when no child spawns, exit code 3 hands the wrapper its retry.
- Install SIGTERM / SIGINT handlers so a host-side
terok-sandbox supervisorinvocation stops cleanly with Ctrl-C. - Await
podman wait <container_id>racing the children's own liveness and the stop signal. On any of them, terminate the children in reverse launch order and return.
The function is the sole parent entry point; the CLI verb
terok-sandbox supervisor invokes it via asyncio.run. The
per-service work now lives in
run_child, one
process each.