Skip to content

refactor(sandbox): remove unreachable root-side identity and workspace code - #3979

Merged
matthewgrossman merged 2 commits into
mainfrom
podman-workdir/0-remove-dead-workspace-code
Sep 30, 2026
Merged

matthewgrossman merged 2 commits into
mainfrom
podman-workdir/0-remove-dead-workspace-code

Conversation

@matthewgrossman

@matthewgrossman matthewgrossman commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Remove sandbox code left over from the architecture before RFC 0012. These paths no longer run, but still show up in searches and reviews as if they handle image identity and workspace setup.

Why RFC 0012 made this code obsolete

Before RFC 0012, OpenShell's supervisor and the agent shared the image's filesystem. The supervisor started as root and prepared the environment before launching the agent: it resolved the image's USER, prepared workspace ownership, updated account files, and dropped privileges. Those operations also needed checks to prevent an unusual image layout—such as symlinks—from causing root to change the wrong files.

RFC 0012 separated the supervisor from the workload. The compute driver now resolves the workload identity, and the sandbox runs in the workload environment as that identity, without capabilities. Where a privileged bootstrap is necessary, a separate, limited bootstrap path prepares the environment and drops privileges before the sandbox accepts a supervisor connection.

The old root-side preparation code therefore has no production callers. Keeping it does not provide additional protection; it only makes the old architecture appear to still be in use.

This PR removes those unused paths. It keeps the checks that run today, including workload identity verification, capability checks, Landlock enforcement, and workspace validation performed as the workload user. The one live identity-wrapper call is replaced with the same UID/GID assignments it already performed.

Why this comes first in the stack

This is the first of four stacked PRs split out of #3801:

  1. This PR: remove obsolete root-side identity and workspace code.
  2. fix(podman): create managed workspace volumes owned by the workload identity #3981: fix Podman workspace volume ownership.
  3. feat(podman): honor OCI image working directories #3982: honor the image's OCI WORKDIR on Podman.
  4. test(oci): share OCI USER and WORKDIR checks across Docker and Podman #3931: share image USER/WORKDIR e2e tests across Docker and Podman.

Removing the obsolete code first makes those changes easier to reason about: reviewers can see which component actually resolves identity, prepares the workspace, and enforces access. The later fixes target those active paths, and the shared e2e tests run with the cleanup underneath them—not alongside unused code that looks like it still handles workspace setup.

Related Issue

No issue required: this removes unused implementation paths without changing supported sandbox runtime behavior. It was found while working on #2526 / #3801.

Changes

  • process.rs: remove prepare_filesystem* (the /sandbox and OCI workspace chown step), the root-side OCI workspace validation and its privilege-dropped subprocess, drop_privileges*, capability bounding-set clearing, validate_sandbox_user/group*, /etc/passwd and /etc/group rewriting, ResolvedProcessIdentity, and their tests.
  • main.rs: remove the hidden validate-workspace subcommand, which only that unused subprocess path invoked.
  • identity.rs: delete the sandbox-side image USER resolver. The drivers already resolve the identity.
  • boundary_server.rs: write the driver-resolved workload_identity UID/GID into policy.process.run_as_user/group directly instead of going through the removed resolver.
  • Unchanged: validate_oci_workspace_as_effective_identity, the workspace check that still runs inside the capability-free boundary (called from delegated.rs).

About 3,200 lines removed across five files in openshell-sandbox. This removes Rust exports from the runtime crate and the hidden validation command; no in-repository consumer depends on the removed exports, and no driver, script, or workflow invokes that command.

Testing

  • mise run pre-commit passes
  • cargo clippy -p openshell-sandbox --all-targets -D warnings is clean for aarch64-unknown-linux-gnu (cross-built with cargo-zigbuild) and on the macOS host.
  • Host unit tests pass. Linux-only unit tests run in CI.
  • Unit tests added/updated: tests for the removed code are removed with it; nothing new to test.
  • E2E: the shared oci-image suite at the top of this stack passes 4/4 on a local rootful Podman gateway with this change underneath.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable): not applicable

@copy-pr-bot

copy-pr-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

…e code

RFC 0012 moved the workload into its own capability-free container that
starts as the final sandbox identity. The sandbox no longer runs a root
supervisor that prepares the filesystem, rewrites account files, resolves
OCI USER entries, or drops privileges before launching the workload, so
that code had no production callers.

Remove the unreachable paths and their tests:

- prepare_filesystem / prepare_filesystem_with_identity, the /sandbox and
  OCI workspace chown preparation, and the root-side workspace validation
  (validate_oci_workspace and its privilege-dropped subprocess)
- the hidden validate-workspace subcommand
- drop_privileges / drop_privileges_with_identity, capability bounding set
  clearing, validate_sandbox_user/group, and /etc/passwd and /etc/group
  rewriting
- the sandbox-side OCI USER resolver (identity.rs) and
  ResolvedProcessIdentity; the boundary now writes the driver-resolved
  UID/GID into the policy directly

The workspace check that still runs inside the capability-free boundary
(validate_oci_workspace_as_effective_identity) is unchanged.

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
…ock comments

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
@matthewgrossman
matthewgrossman force-pushed the podman-workdir/0-remove-dead-workspace-code branch from 3d75d44 to 0124680 Compare September 30, 2026 19:54
@drew drew added the test:e2e Requires end-to-end coverage label Sep 30, 2026
@github-actions

Copy link
Copy Markdown

Label test:e2e applied for 0124680. Open the existing run and click Re-run all jobs to execute with the label set. The run will execute the standard E2E suite after building the required gateway, sandbox, and supervisor images once. The matching required CI gate status on this PR will flip green automatically once the run finishes.

@drew

drew commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

gator-agent

PR Review Status

This maintainer-authored cleanup is project-valid, and the initial code review found no blocking issues. The required E2E coverage has not started because test:e2e was applied after the existing Branch E2E run completed with the suite skipped.

Action required: a maintainer must open Branch E2E Checks run 36768946391 and choose Re-run all jobs so the standard E2E suite runs for this head.

Blocking findings:

  • No blocking code findings remain

Carried findings:

  • None

Non-blocking suggestions:

  • None
Gator metadata
  • Validation: Maintainer-authored, focused removal of obsolete sandbox implementation paths related to accepted workspace work
  • Docs: Not needed because this is an internal refactor with no supported user-facing behavior change
  • Checks: Current-head branch checks are running; required E2E has not been dispatched
  • E2E: test:e2e applied; existing Branch E2E run must be rerun with the label set
  • Head SHA: 0124680f8edef50675e961a3377dcd021a1e320e
  • Base SHA: 07a486d751876fdc2bb2ffde74c1ed3adc8b1421
  • Merge base SHA: 07a486d751876fdc2bb2ffde74c1ed3adc8b1421
  • Patch ID: 4d340a2294fac249f412bed67f7da788079bc844
  • Gator payload: 10
  • Review mode: initial
  • Previous reviewed SHA: none
  • Review budget exhausted: no
  • Maintainer decision required: no
  • Next state: gator:blocked
  • Blocked reason: test_dispatch_required

@drew drew added gator:blocked Gator is blocked by process or repository gates gator:watch-pipeline Gator is monitoring PR CI/CD status and removed gator:blocked Gator is blocked by process or repository gates labels Sep 30, 2026
@drew drew added gator:in-review Gator is reviewing or awaiting PR review feedback gator:watch-pipeline Gator is monitoring PR CI/CD status gator:merge-ready and removed gator:watch-pipeline Gator is monitoring PR CI/CD status gator:in-review Gator is reviewing or awaiting PR review feedback labels Sep 30, 2026
@matthewgrossman
matthewgrossman added this pull request to the merge queue Sep 30, 2026
Merged via the queue into main with commit 4784e79 Sep 30, 2026
268 of 277 checks passed
@matthewgrossman
matthewgrossman deleted the podman-workdir/0-remove-dead-workspace-code branch September 30, 2026 23:15
@drew

drew commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

gator-agent

Monitoring Complete

Monitoring is complete because this PR has merged.

Final status: Gator found no blocking code issues, required checks including E2E passed, and maintainer approval was present before merge.

I removed the active gator:* label because there is nothing left for gator to monitor on this PR.

Gator metadata
  • Head SHA: 0124680f8edef50675e961a3377dcd021a1e320e
  • Gator payload: 10
  • Final state: merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants