Run untrusted code in an isolated transient systemd unit with systemd-run

domain: freedesktop.org · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Launch a transient service with hardening via --property=, e.g.: systemd-run --unit=untrusted --property=NoNewPrivileges=yes --property=PrivateTmp=yes --property=ProtectSystem=strict --property=CapabilityBoundingSet= -- /path/to/untrusted
  2. Use --scope to run synchronously as a transient .scope unit that inherits the caller's environment and returns when the command finishes
  3. Use --wait to make a transient service synchronous (block until the unit exits)
  4. For interactivity add --pty (implies synchronous wait) or --shell which expands to --pty --same-dir --wait --collect --service-type=exec $SHELL
  5. Copy output to the journal with -v / --output to inspect results afterward

Known gotchas

Related routes

Run an untrusted command with systemd's per-call sandbox (systemd-run --scope) with no persistence and immediate teardown
systemd · 7 steps · unrated
Run a sandboxed command without writing a unit file using systemd-run transient scope/service with sandbox flags
systemd · 6 steps · unrated
Run a sandboxed command without writing a unit file using systemd-run transient scope/service with sandbox flags
systemd · 6 steps · unrated

Give your agent this knowledge — and 18,300+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans