Repository navigation
fix(docker): ship /etc/passwd and /etc/group as regular files - #1347
Conversation
|
This change is part of the following stack:
Change managed by git-spice. |
📝 WalkthroughSummary by CodeRabbit
WalkthroughRematerialize ChangesDocker Image
Sequence Diagram(s)sequenceDiagram
participant BuildEnv
participant FakeRootCommands
participant ImageFS
BuildEnv->>ImageFS: earlier flow produced /etc symlinks into /nix/store
FakeRootCommands->>ImageFS: detect /etc symlink, copy contents and rematerialize /etc as directory
FakeRootCommands->>ImageFS: write /etc/passwd (regular file with root + ncps uids)
FakeRootCommands->>ImageFS: write /etc/group (regular file with root + ncps gids)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Code Review
This pull request resolves an issue where /etc/passwd and /etc/group are created as absolute symlinks in the built Docker image, causing container creation failures on strict runtimes like containerd. The changes materialize these files as regular files via fakeRootCommands and introduce a regression check to verify their file types. The review feedback highlights two important improvements: first, a safety concern in the shell script where an empty readlink output could lead to copying the entire root filesystem; second, a recommendation to filter and sort the files in the regression check to prevent running tar on non-tar files and to ensure deterministic behavior.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@nix/checks/flake-module.nix`:
- Around line 271-285: The current check collects all file listings then uses
`find img -type f` + `tail -1` to decide the final state of /etc/passwd and
/etc/group, which ignores layer ordering and whiteouts; change the logic to read
`manifest.json`'s `Layers` array and process each listed layer in manifest
order, parsing each layer tar in turn and applying whiteout semantics (e.g.,
files like `etc/.wh.passwd` or `etc/.wh.*` remove prior entries) to build the
effective final entry for /etc/passwd and /etc/group instead of using the
aggregated `listings.txt` + `tail -1`; update the code points that
create/consume `listings.txt` and the `for name in passwd group` block to
consult the computed final state (honoring whiteouts) and then assert
regular-file vs missing accordingly.
In `@openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/design.md`:
- Around line 20-33: The design doc mentions using extraCommands but the actual
implementation in nix/packages/docker.nix uses fakeRootCommands; update the
documentation in
openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/design.md to match the
implementation (or alternatively change the implementation to use
extraCommands), and explicitly reference the symbol used in code
(fakeRootCommands) and why it was chosen (effects on file materialization /
securejoin) so future readers/editors are not confused.
In `@openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/proposal.md`:
- Around line 14-16: Update the proposal text to use the actual hook name
fakeRootCommands instead of extraCommands: state that nix/packages/docker.nix
now materializes /etc/passwd and /etc/group via the
dockerTools.buildLayeredImage fakeRootCommands hook (which writes the files
directly) rather than placing them into the buildEnv contents (which would
create store symlinks); also keep the notes about identical content (root + ncps
uid/gid 1000) and the disallowedRequisites guard, and mention adding the
packaging regression check asserting the files are regular (non-symlink) files
with the expected entries.
- Around line 5-8: The fenced code block in proposal.md containing the error
snippet starting with "failed to create containerd container: mount callback
failed on …: openat etc/passwd: path escapes from parent" is missing a fence
language and triggers MD040; update that code block to include a language tag
such as `text` (e.g., change ``` to ```text) so markdownlint no longer flags it.
Ensure you modify the fenced block where that exact error string appears in
openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/proposal.md.
In `@openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/tasks.md`:
- Around line 9-10: Update the task description to reflect that `/etc/passwd`
and `/etc/group` are materialized via fakeRootCommands rather than
extraCommands: edit the entry referencing dockerTools.buildLayeredImage in the
archived task so it mentions fakeRootCommands (as implemented in
nix/packages/docker.nix) and retains the rest of the details (here-doc, create
`etc/` first, keep `root` + `ncps` uid/gid 1000 and the rebuilt-image
assertion).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6de48cd2-e056-4431-b914-0eeb2a9d6b6b
📒 Files selected for processing (8)
nix/checks/flake-module.nixnix/packages/docker.nixopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/.openspec.yamlopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/design.mdopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/proposal.mdopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/specs/container-image-etc-files/spec.mdopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/tasks.mdopenspec/specs/container-image-etc-files/spec.md
03c55ce to
7c713f8
Compare
Address PR #1347 review: - docker.nix (gemini): copy through the /etc symlink (cp -a etc/. etc.tmp/) instead of readlink -f, so a failed readlink can never expand to 'cp -a /. etc/' (copying the sandbox root). - flake checks (coderabbit/gemini): replay layers in manifest.json order and apply whiteout semantics (etc/.wh.*) to compute the effective final state of /etc/passwd & /etc/group, instead of aggregating all listings + tail -1 (which ignored layer order/whiteouts and was non-deterministic). - archived fix-docker-etc-passwd docs: correct extraCommands -> fakeRootCommands (the implemented hook) and add a 'text' fence language. Threads: PRRT_kwDONV6tZs6HofUb, PRRT_kwDONV6tZs6HofUf, PRRT_kwDONV6tZs6HogAS, PRRT_kwDONV6tZs6HogAT, PRRT_kwDONV6tZs6HogAU, PRRT_kwDONV6tZs6HogAW, PRRT_kwDONV6tZs6HogAX Co-Authored-By: Claude Opus 4.8 <[email protected]>
d510e49 to
3d06e81
Compare
The image added /etc/passwd and /etc/group via a buildEnv, which makes them absolute symlinks into the nix store (/etc/passwd -> /nix/store/...-passwd/etc/passwd). Recent containerd securejoins etc/passwd during container creation and rejects the absolute symlink as escaping the rootfs, so EVERY ncps pod fails to start: 'failed to create containerd container: ... openat etc/passwd: path escapes from parent'. This is a latent production failure on recent k8s/containerd, and it blocked the entire k8s-tests Kind suite. Materialize /etc/passwd and /etc/group as real files in fakeRootCommands (re-materializing the read-only store-symlinked /etc as a writable real directory first), with identical content. Add a checks.docker-image-etc-files regression guard that asserts both are regular files (not symlinks). Verified on Kind: the old (symlinked) image fails with the exact error; the fixed image starts and runs to Completed. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…etc-passwd Co-Authored-By: Claude Opus 4.8 <[email protected]>
Address PR #1347 review: - docker.nix (gemini): copy through the /etc symlink (cp -a etc/. etc.tmp/) instead of readlink -f, so a failed readlink can never expand to 'cp -a /. etc/' (copying the sandbox root). - flake checks (coderabbit/gemini): replay layers in manifest.json order and apply whiteout semantics (etc/.wh.*) to compute the effective final state of /etc/passwd & /etc/group, instead of aggregating all listings + tail -1 (which ignored layer order/whiteouts and was non-deterministic). - archived fix-docker-etc-passwd docs: correct extraCommands -> fakeRootCommands (the implemented hook) and add a 'text' fence language. Threads: PRRT_kwDONV6tZs6HofUb, PRRT_kwDONV6tZs6HofUf, PRRT_kwDONV6tZs6HogAS, PRRT_kwDONV6tZs6HogAT, PRRT_kwDONV6tZs6HogAU, PRRT_kwDONV6tZs6HogAW, PRRT_kwDONV6tZs6HogAX Co-Authored-By: Claude Opus 4.8 <[email protected]>
3d06e81 to
f61201e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/proposal.md`:
- Line 15: The proposal text overstates the packaging regression check: update
proposal.md to remove or rephrase "with the expected entries" so it only claims
the files are regular, OR extend the actual check in flake-module.nix to also
verify contents by adding assertions that /etc/passwd and /etc/group contain the
expected entries (e.g., grep/regex checks for the required user/group lines) in
addition to the existing regular-file type assertion; locate the current
assertions for /etc/passwd and /etc/group in flake-module.nix and either change
the prose in proposal.md or add content-matching assertions next to those
checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8b61a6fd-752c-4558-8567-03231065f462
📒 Files selected for processing (8)
nix/checks/flake-module.nixnix/packages/docker.nixopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/.openspec.yamlopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/design.mdopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/proposal.mdopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/specs/container-image-etc-files/spec.mdopenspec/changes/archive/2026-06-06-fix-docker-etc-passwd/tasks.mdopenspec/specs/container-image-etc-files/spec.md
✅ Files skipped from review due to trivial changes (5)
- openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/.openspec.yaml
- openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/tasks.md
- openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/specs/container-image-etc-files/spec.md
- openspec/specs/container-image-etc-files/spec.md
- openspec/changes/archive/2026-06-06-fix-docker-etc-passwd/design.md
🚧 Files skipped from review as they are similar to previous changes (1)
- nix/packages/docker.nix
## Summary The `[Unreleased]` section was populated in #1309 but skewed toward the recent CDC-drain, in-flight-staging, and Ent-migration work, omitting several user-facing features and fixes that also landed since v0.9.4. This backfills the missing notable changes, each cross-referenced by PR. **Added** - `ncps fsck` command + Helm fsck CronJob (#975, #996, #998, #999, #1000, #1004, #1006, #1176) - Closure pinning HTTP endpoints `POST`/`DELETE /pin/{hash}.narinfo`, `GET /pins` (#1108) - pprof server via `--pprof-addr` (#1063) - CDC lazy chunking as a feature + `--cache-cdc-lazy-cleanup-schedule` + recovery cron (#1082, #1083, #1089, #1096) - Helm: auto `GOMEMLIMIT` (#1061), configurable temp volume / `volumeClaimTemplate` (#1074, #1077), SQLite `Recreate` strategy (#1012) - Startup storage reporting + deprecated-narinfo warning (#959, #961) - `docker-dev` image (#1097) **Fixed** - `store/tmp` no longer wiped on startup (#1313) - `nix-hash` NAR verification (#1101) - Prometheus counters primed at startup (#1337, #1343) - 404 on un-reassemblable chunked NARs (#1319), purged narinfo no longer 500 (#1318), fail-fast tmp validation (#1086) - Further CDC/cache reliability fixes (#1317, #1346, #1341, #1342, #1331, #1347) **Changed** - CDC config now persisted in the DB config table (#971) Dependency bumps, CI/test-only changes, and the internal Ent-conversion PRs are intentionally excluded; the existing Ent-migration entry already covers that work. ## Test plan - [x] `nix fmt` reports no changes (docs-only edit) - [x] CHANGELOG section structure intact (Added/Fixed/Changed/Removed/Migration/CI)
Summary
The image added
/etc/passwdand/etc/groupvia abuildEnv, which makes them absolute symlinks into the nix store (/etc/passwd -> /nix/store/…-passwd/etc/passwd). Recent containerd securejoinsetc/passwdduring container creation and rejects the absolute symlink as escaping the rootfs, so every ncps pod fails to start:This is a latent production failure on recent k8s/containerd (reproduced on
kindest/node:v1.35.0), and it blocked the entirek8s-testsKind suite.Fix
Materialize
/etc/passwdand/etc/groupas real files infakeRootCommands(re-materializing the read-only store-symlinked/etcas a writable real directory first), with identical content (root+ncpsuid/gid 1000). Adds achecks.docker-image-etc-filesregression guard asserting both are regular files (not symlinks).OpenSpec change:
fix-docker-etc-passwd(new capabilitycontainer-image-etc-files).Test plan
checks.docker-image-etc-filesbuilds green (both are regular files)CreateContainerErrorwith the exact error; fixed image → podCompleteddisallowedRequisites(no shell/coreutils) still holds;task fmt/lintclean