fix(login): tolerate read-only CODEWITH_HOME in auth profile dir setup#284
Merged
Conversation
Auth-profile directory setup unconditionally chmod'd every ensured directory to 0o700, so any auth-profile operation on a read-only CODEWITH_HOME (sandboxed/bind-mounted config used by OpenLoops preflight and bounded auth-profile health runs) failed with EROFS even when the directory was already private. `create_private_dir_all` now skips the chmod when the permission bits already match 0o700 (the common case, so a read-only mount never sees a needless write), and tolerates a read-only-filesystem error only when the directory is already private (no group/other access); otherwise the failure is surfaced so credentials are never silently left world-accessible. This mirrors the JS shim fix (c30b6dc) at the Rust layer. Adds regression coverage for the already-private early-return, the tighten-when-writable path, and the read-only error classifier. Refs: BUG-PA14 (2d9d931b)
andrei-hasna
force-pushed
the
fix/auth-profile
branch
from
July 20, 2026 13:56
a7b939e to
0e827ef
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What
Harden auth-profile config-directory setup in
codex-loginso it no longerfails when
CODEWITH_HOME(~/.codewith) is on a read-only mount.create_private_dir_allpreviously ranfs::set_permissions(dir, 0o700)unconditionally on every ensured directory. On a read-only / bind-mounted
CODEWITH_HOME(as used by OpenLoops auth-profile preflight and boundedauth-profile health runs) that chmod fails with
EROFSeven when thedirectory is already private and no write is actually required.
The new
ensure_private_dir_mode:0o700(the common case), so a read-only filesystem never sees a needless write;
error only when the directory is already private (no group/other access) —
otherwise the error is surfaced so credentials are never silently left
world-accessible.
This mirrors, at the Rust layer, the JS shim fix already on
main(
c30b6dc5c"fix(cli): tolerate read-only codewith home chmod"), whichhandles the
CODEWITH_HOMEroot but not the auth-profile subdirectoriesensured inside
codex-login.Why
BUG-PA14 (
2d9d931b): "auth profile preflight chmod fails on read-onlyCODEWITH_HOME". OpenLoops
loops doctor/loops workflows validate --preflightinvoke the codewith CLI, which chmods~/.codewith; on aread-only worker sandbox this raised
EROFSand blocked preflight eventhough config was already safely private.
Tests
Adds
codex-loginregression coverage:ensure_private_dir_mode_leaves_already_private_dir_untouched— thealready-
0o700early-return path (the read-only-safe case).ensure_private_dir_mode_tightens_permissions_when_writable— stilllocks down an over-permissive dir when the FS is writable.
read_only_fs_errors_are_classified_for_tolerance— theread-only/permission error classifier.
Verification
E2B (fresh
codewith-pr-drainbox):check-fastforcodex-login+codex-core→ PASS (exit 0). Test-mode compilation reached the linkstage successfully; full unit-test execution was blocked by a disk-full
sandbox (environmental, "No space left on device") and runs in CI.
Notes on the related task
BUG-CW-AUTH-ACCOUNT004 (
94343851, "auth profile health loop hits usagelimit") is not addressed by this PR: its acceptance is OpenLoops-side
(skip/cooldown a usage-limited profile in the provider/account pool before
bounded health loops burn scheduled runs). The in-repo detection primitive
already exists —
codewith usage --jsonreportsExhausted+resets_atwithout burning a model turn, and interactive auto-switch already reroutes
on a usage limit — so the remaining work belongs in the OpenLoops loop
scheduler, out of this repo.
codewith bug-fix fleet