Skip to content

feat: add optional securityContext for supervised services - #8

Merged
keskad merged 2 commits into
mainfrom
feat/security-context
Aug 5, 2026
Merged

feat: add optional securityContext for supervised services#8
keskad merged 2 commits into
mainfrom
feat/security-context

Conversation

@keskad

@keskad keskad commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add optional securityContext (runAsUser, runAsGroup, capabilities) to service definitions; privilege drop + ambient caps applied at spawn in service.rs / new security.rs (completely disabled on Android).
  • Extend microinit describe with live process identity (Running as from /proc) and configured Security context; add -o json to dump the raw service object from its source drop-in/config file.
  • Mirror SecurityContext in the Go SDK; document usage in operator guide, man pages, and example config.

Test plan

  • cargo test --tests --lib (note: shutdown_wait_secs_stops_tracked_daemon is a pre-existing flake on this host)
  • cargo clippy --all-targets -- -D warnings
  • go test ./... under go/
  • As root: start a service with securityContext.runAsUser=nobody and confirm describe shows matching uid/gid
  • microinit describe -o json <name> prints valid JSON of the source object; path on stderr
  • Android / --no-default-features build still compiles (securityContext field absent)

Made with Cursor

keskad and others added 2 commits August 5, 2026 10:47
Allow per-service runAsUser/runAsGroup and Linux capabilities, applied
at spawn via pre_exec. Extend describe with live identity and config,
plus -o json to dump the raw source-file service object. Disabled on
Android builds.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cache resolved identities at config load so spawn/liveness skip NSS.
Read /proc identity outside the runtimes lock. Fail closed on setgroups
when dropping uid/gid; shrink bounding set (best-effort), set
NO_NEW_PRIVS, and inject HOME/USER/LOGNAME. Reject securityContext on
Android at validate; require runAsGroup for numeric uids without passwd.
Unify the capability allowlist and document exclusive caps.

Co-authored-by: Cursor <cursoragent@cursor.com>
@keskad
keskad merged commit b9d4203 into main Aug 5, 2026
9 checks passed
@keskad
keskad deleted the feat/security-context branch August 5, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant