Repository navigation
fix(server): normalise process identity on policy update for custom-image sandboxes - #230
Merged
Merged
Conversation
johntmyers
force-pushed
the
fix-policy-set-process-identity/jm
branch
from
March 11, 2026 17:18
7af953f to
a95dbbc
Compare
drew
approved these changes
Mar 11, 2026
Replace the clear_process_identity + maybe_infer_sandbox_user workaround with strict enforcement: run_as_user and run_as_group must always be 'sandbox'. If omitted from YAML, they are defaulted server-side via ensure_sandbox_process_identity(). Any other value is rejected. This fixes 'policy set' failing with 'process policy cannot be changed on a live sandbox' for custom-image sandboxes, where the CLI was clearing identity fields but the YAML had 'sandbox' explicitly set. - Remove clear_process_identity() from CLI and TUI - Add ensure_sandbox_process_identity() to default missing fields - Rename RootProcessIdentity -> InvalidProcessIdentity - Replace maybe_infer_sandbox_user with validate_sandbox_user (fail-fast) - Update OPA test policies to use run_as_user: sandbox
johntmyers
force-pushed
the
fix-policy-set-process-identity/jm
branch
from
March 11, 2026 19:20
a95dbbc to
7f778d4
Compare
drew
approved these changes
Mar 11, 2026
drew
pushed a commit
that referenced
this pull request
Mar 16, 2026
Replace the clear_process_identity + maybe_infer_sandbox_user workaround with strict enforcement: run_as_user and run_as_group must always be 'sandbox'. If omitted from YAML, they are defaulted server-side via ensure_sandbox_process_identity(). Any other value is rejected. This fixes 'policy set' failing with 'process policy cannot be changed on a live sandbox' for custom-image sandboxes, where the CLI was clearing identity fields but the YAML had 'sandbox' explicitly set. - Remove clear_process_identity() from CLI and TUI - Add ensure_sandbox_process_identity() to default missing fields - Rename RootProcessIdentity -> InvalidProcessIdentity - Replace maybe_infer_sandbox_user with validate_sandbox_user (fail-fast) - Update OPA test policies to use run_as_user: sandbox
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
Enforce that
run_as_userandrun_as_groupmust always be"sandbox"in sandbox policies. If omitted from YAML, they are defaulted server-side. Any other value is rejected.This fixes
openshell policy setfailing with "process policy cannot be changed on a live sandbox" for sandboxes created with custom images (--from), where the CLI was clearing identity fields but the YAML hadsandboxexplicitly set, causing a mismatch the server rejected.Approach
Replace the previous
clear_process_identity()→maybe_infer_sandbox_user()roundtrip with strict enforcement:ensure_sandbox_process_identity()fills in"sandbox"for missing/emptyrun_as_user/run_as_groupin bothCreateSandboxandupdate_sandbox_policyvalidate_policy_safety()rejects any value that isn't"sandbox"(renamedRootProcessIdentity→InvalidProcessIdentity)validate_sandbox_user()replacesmaybe_infer_sandbox_user()— fails fast if thesandboxuser doesn't exist in/etc/passwdclear_process_identity()calls — no longer needed since the server handles defaultingChanges
crates/navigator-policy/src/lib.rsensure_sandbox_process_identity(), renamedRootProcessIdentity→InvalidProcessIdentity, updated validation to reject non-sandbox values, removedis_root_identity()andclear_process_identity()crates/navigator-server/src/grpc.rsensure_sandbox_process_identity()+validate_policy_safety()in bothCreateSandboxandupdate_sandbox_policycrates/navigator-cli/src/run.rsclear_process_identityblock for custom imagescrates/navigator-tui/src/lib.rsclear_process_identitycall for custom imagescrates/navigator-sandbox/src/lib.rsmaybe_infer_sandbox_userwithvalidate_sandbox_user(fail-fast)crates/navigator-sandbox/src/opa.rsrun_as_user: ""→run_as_user: sandboxTesting
cargo test --workspace)test_live_policy_update_and_logs,test_policy_validation(pending cluster redeploy)