Expand description
Sandbox setup and exec for Cantainer.
plan completes a policy with what the executable needs to start (its ELF interpreter,
shared libraries and a small runtime base), filters the environment and builds argv.
exec then makes the kernel enforce the plan and replaces the current process with the
program:
- create writable command-line files that do not exist yet (so they have an inode),
- Landlock: deny by default, allow each grant (also sets
no_new_privs), - seccomp: baseline deny list plus the socket families the policy does not allow,
execve.
There is no supervisor process: exit status, signals and the terminal belong to the program, exactly as if it had been run directly. Restrictions are inherited by everything it starts and cannot be lifted.
Linux only. On other systems every entry point returns LaunchError::Unsupported, so the
workspace still builds on macOS for editing.
Modules§
- netns
- Can this system make a user + network namespace? (Phase 6.2; docs/NETWORK-ALLOWLIST.md
§10.) Host allowlists need one: the can gets a network with only
lo, and a filtering proxy outside is its only way out (Phase 6.4). Until then this only reports:cant checkand--explainsay whether host enforcement will be possible here, and if not, the step that failed and the fix.
Structs§
- CanStart
- How to start a can’s program: through the can’s own ELF loader, with the can’s own libraries, and nothing resolved from the host.
- Kernel
Support - Facts about the running kernel, for
cant check. - Plan
- Everything needed to start a cant.
- Resolved
- What an executable needs from the filesystem to start.
Enums§
- ElfError
- Errors reading an executable.
- Launch
Error - Errors from planning or launching.
Constants§
- DYNAMIC_
LOADERS - The system’s dynamic loaders. A cant that may execute files in a directory (cargo’s build
scripts in
$CWD) gets these, because the kernel needs execute access to a program’s loader to start it, andcantcan’t know in advance which files will run. Programs whose librariescantresolves get their own loader anyway. - MIN_ABI
- Below ABI 3,
truncate(2)is not controlled, so a read-only grant would not stop a cant from emptying a file. We refuse to run rather than pretend. - NETWORK_
READ - What name resolution reads, granted (read-only) to every cant with
network = true: without them a program may reach the network but can’t look up a host name. They hold no secrets. A symlinked/etc/resolv.conf(systemd-resolved) resolves to its target. - POLICY_
ENV - Name of the environment variable carrying the effective policy into a cant, so that a
nested
cantcan explain and pre-check attenuation. It is informational: the kernel enforces the real restrictions, and a forged value cannot widen them. - RUNTIME_
READ - Files every program may need to read: the loader cache, locale, time zone, terminfo, the CA trust store and a few devices.
- RUNTIME_
READ_ WRITE - Devices every program may read and write.
Functions§
- exec
- Enforces
planand replaces the current process with the program. Returns only on failure.warnreceives non-fatal notices (printed by the CLI). - flush_
coverage - Does nothing outside coverage builds.
- in_
merged_ usr - The path under a merged-
/usrroot of an absolute path as a program names it:/lib/ld-linux-aarch64.so.1is<root>/usr/lib/ld-linux-aarch64.so.1. - plan
- Completes
builtinto a launch plan. - probe_
kernel - Probes kernel support. On Linux this applies a no-op Landlock ruleset to the calling
process (the only way to learn the ABI through the
landlockcrate), so call it only from a process that is about to exit, such ascant check. - proxy_
environment - The environment a program behind the namespace’s proxy gets, whatever
[env] passsays (docs/NETWORK-ALLOWLIST.md §10.3: Go and Python read the upper- or lowercase variables; Node’sfetchneedsNODE_USE_ENV_PROXY). - resolve_
libraries - Resolves the interpreter and all shared libraries of
binary. - resolve_
libraries_ in - Like
resolve, but only insideroot, a sysroot laid out like Debian’s merged/usr(cant buildunpacks pinned packages there): nothing is looked up on this machine. The interpreter is found at<root>/usr/lib/…for a/lib/…PT_INTERP, andinterpreter_literalstays as written in the program. Files that resolve outsideroot(a symlink pointing out) count as missing.