fix(docker): require ARCHON_ALLOW_ROOT_FALLBACK opt-in for root-fallback when chown fails#1573
fix(docker): require ARCHON_ALLOW_ROOT_FALLBACK opt-in for root-fallback when chown fails#1573ztech-gthb wants to merge 1 commit intocoleam00:devfrom
Conversation
… as root on chown failure
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesPrivilege-Drop Initialization & Error Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Summary
docker-entrypoint.shexits with1on anychownfailure of/.archonor/home/appuser. On macOS VirtioFS bind-mounts this is the normal state — host UID 501 cannot be remapped to container appuser 1001 — so the container crash-loops on every start. Linux-host failures (SELinux/AppArmor, RO mounts) look identical to the macOS case from inside the container, so the entrypoint cannot distinguish them automatically.IS_SANDBOX=1(PR Non-fatal chown fallback for macOS bind mounts (complement to #1307) #1537), but that bypassed ClaudeProvider's UID-0 safety guard for any failure cause — security-adjacent on misconfigured Linux hosts.ARCHON_ALLOW_ROOT_FALLBACK=1. Without the opt-in, behavior is unchanged from feat(docker): persist /home/appuser by default + clarify ARCHON_HOME/ARCHON_DATA semantics #1518 (fail-loud, exit 1). With the opt-in, container starts as root and exportsIS_SANDBOX=1to allow ClaudeProvider to skip its UID-0 guard. Both chown blocks (/.archonand/home/appuser) share the same fallback path so users don't need to debug them separately.gosu) is unchanged. Linux hosts where chown succeeds see no behavior change. The new env var is opt-in only — never auto-enabled.UX Journey
Before (current origin/dev, post-#1518)
After (this PR)
Architecture Diagram
Before
After
Connection inventory:
2>/dev/null, now2>&1intochown_errIS_SANDBOX=1exportARCHON_ALLOW_ROOT_FALLBACKenv varexit 1with instructionsIS_SANDBOX=1to skip the guard/home/appuserchown/.archonLabel Snapshot
risk: lowsize: Sdockerdocker:entrypointChange Metadata
bugmulti(config + macOS UX)Linked Issue
Validation Evidence (required)
bash -n docker-entrypoint.sh # syntax OKEnd-to-end manual verification:
ERROR: refusing to run as root...followed byexit 1. Container crash-loops as in current state — but with a clear instruction message for the user.ARCHON_ALLOW_ROOT_FALLBACK=1(set via compose env): chown fails, both errors printed, thenWARNING: ARCHON_ALLOW_ROOT_FALLBACK=1 — continuing as root with IS_SANDBOX=1., container starts, ClaudeProvider passes its UID-0 guard. End-to-end functional.--read-onlyflag): same as macOS-without-opt-in — clear error, actionable instruction. No silent root-execution.Security Impact (required)
2>/dev/null), and refuses to bypass ClaudeProvider's UID-0 guard unless the operator has explicitly opted in. Linux misconfigurations (SELinux denials, broken volumes) now produce a loud error with the OS message instead of either a silent root-bypass (pre-feat(docker): persist /home/appuser by default + clarify ARCHON_HOME/ARCHON_DATA semantics #1518 Non-fatal chown fallback for macOS bind mounts (complement to #1307) #1537) or a generic "ownership... incompatible options" message (current origin/dev).Compatibility / Migration
ARCHON_ALLOW_ROOT_FALLBACK=1once, e.g. in theirdocker-compose.override.ymlenvironment:block or in.env.ARCHON_ALLOW_ROOT_FALLBACK). Default unset → behavior identical to current origin/dev.Human Verification (required)
Verified scenarios:
bash -n)docker exec ... env | grep IS_SANDBOX)/.archonand/home/appuser) tested independently — message accumulates per-path errorsEdge cases checked:
chown_errcapture works underset -ebecause theif ! cmd; thenguard suppresses the failing exit-status from triggering errexitprintf "%s" "$chown_errors"preserves embedded newlines correctlyARCHON_ALLOW_ROOT_FALLBACKis checked with:-0default so an unset var resolves to "0" (exit-loud) rather than triggering set-uWhat was not verified:
Side Effects / Blast Radius (required)
docker-entrypoint.sh. No TypeScript change, no schema change, no build-step change.Rollback Plan (required)
Risks and Mitigations
ARCHON_ALLOW_ROOT_FALLBACK) might clash with a future CI tool expecting it to mean something else.ARCHON_-prefixed, so unlikely collision with generic CI vars. Could be tightened further (ARCHON_DOCKER_ALLOW_ROOT, etc.) if reviewers prefer — happy to rename.chown_failed/chown_errorsaccumulator rather than introduce a new isolatedexit 1.Summary by CodeRabbit
Bug Fixes
New Features
ARCHON_ALLOW_ROOT_FALLBACKenvironment variable for cases where standard permission configurations fail.