Skip to content

Fix #34 regressions and gaps (#35) - #36

Merged
thorwhalen merged 2 commits into
masterfrom
fix-35-regressions
Oct 12, 2026
Merged

thorwhalen merged 2 commits into
masterfrom
fix-35-regressions

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #35 (all five points). Refs #33, #34.

  1. Import no longer crashes on a read-only / not-owned folder. New tighten_mode: chmod only when the mode differs, warn instead of raising. Used by secure_makedirs and the managed-folder re-tightening.
  2. Values are UTF-8 again. SecureTextFiles encodes the value to UTF-8 before opening (so an unencodable value no longer leaves an emptied file) and writes bytes through secure_open.
  3. Old 0o644 secrets are tightened. In a config2py-managed configs folder (marker .config2py), regular files lose group/other bits. Symlinks are not followed; unmanaged folders untouched.
  4. Configs alias is now SecureTextFiles.
  5. KeyError contract kept. Key validation via the inner persister's validate_key, other failures re-raised as KeyError, as dol's TextFiles does.

Also: secure_open is now the builtin open with an owner_only_opener, so it honors encoding, newline and binary modes (O_BINARY on Windows, addressing the plausible CR-doubling note).

Tests (written failing first, in config2py/tests/test_secure_io.py): chmod-raising folder at import (subprocess), no chmod when already tight, LC_ALL=C + PYTHONUTF8=0 non-ASCII round trip and no truncation on failure, pre-existing 0o644 files (incl. nested, symlink, unmanaged), Configs alias, KeyError contract.

Adversarial review (fresh Opus subagent, read the diff and #35): ship-after-fixes, none blocking. All five points confirmed fixed with scripts (incl. a real read-only bind mount of HOME under unshare, and LC_ALL=C). Addressed in the second commit:

Dependents gate (branch on PYTHONPATH, one suite at a time, 10-min timeout): py2store 85 passed, xdol 4 passed, mood 8 passed, oa 41 passed / 3 failed, the same 3 as on master (need a real OpenAI key).

https://claude.ai/code/session_01Ea4y3nEMhgmrx3XUpcUTMi

…old files, secure Configs alias, KeyError contract (#35)

- tighten_mode: chmod only when the mode differs, warn instead of raising (import no longer crashes on a read-only or not-owned folder)
- SecureTextFiles writes UTF-8 bytes, encoded before the file is truncated; keeps dol's key validation and KeyError contract
- a managed configs folder's existing files lose group/other bits (symlinks not followed)
- Configs alias is SecureTextFiles
- secure_open is the builtin open with an owner_only_opener (honors encoding, O_BINARY)

Claude-Session: https://claude.ai/code/session_01Ea4y3nEMhgmrx3XUpcUTMi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regressions from #34: import crashes on a read-only config folder; values no longer written as UTF-8

1 participant