feat: add optional securityContext for supervised services - #8
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
securityContext(runAsUser,runAsGroup,capabilities) to service definitions; privilege drop + ambient caps applied at spawn inservice.rs/ newsecurity.rs(completely disabled on Android).microinit describewith live process identity (Running asfrom/proc) and configuredSecuritycontext; add-o jsonto dump the raw service object from its source drop-in/config file.SecurityContextin 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_daemonis a pre-existing flake on this host)cargo clippy --all-targets -- -D warningsgo test ./...undergo/securityContext.runAsUser=nobodyand confirmdescribeshows matching uid/gidmicroinit describe -o json <name>prints valid JSON of the source object; path on stderr--no-default-featuresbuild still compiles (securityContext field absent)Made with Cursor