Skip to content

fog_volumes: publish output with the bits of a plain open(), not the staging file's 0600 - #7623

Open
best2135 wants to merge 1 commit into
ItsNotRexed:mainfrom
best2135:hunt/fog-volumes-mode
Open

best2135 wants to merge 1 commit into
ItsNotRexed:mainfrom
best2135:hunt/fog-volumes-mode

Conversation

@best2135

Copy link
Copy Markdown

Claimed in the coordination issue (claim).

_write_json_atomic in tools/fog_volumes.py stages its output in a private temporary file (tempfile creates it 0600) and os.replace()s it into place without restoring the mode. So:

  • a new output comes out 0600 instead of what a plain open() gives under the umask (0644 under umask 022);
  • a re-run resets a file the user made 0640 (or 0644) to 0600.

tools/file_mode.py exists for exactly this and is used by the other staged writers (#1082). This calls os.chmod(tmp, published_mode(dest)) before the replace, as they do.

Test: two new tests in tests/test_fog_volumes.py, both built by hand (no game data): a new output gets file_mode.new_file_mode(dir), and a replaced 0640 output stays 0640. Both fail on main (384 != 420 / 384 != 416) and pass with this change.

Ran (Linux, Python 3.14.8, CPU only):

  • python -I tests/test_fog_volumes.py: pass
  • python -m compileall -q make_game.py tools tests: pass
  • python -I scripts/check_no_game_data.py on the changed files: pass

Skipped on Windows (os.name == "nt"), where the POSIX bits don't apply. Same bug class as the timecycle_pairs (#7572) and shader_disasm (#7573) PRs, but in different files, so the PRs don't overlap.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…mkstemp's 0600

_write_json_atomic stages the JSON through tempfile.mkstemp, which creates the
file 0600, and os.replace()s it into place without restoring the mode. A new
report came out 0600 instead of the umask's bits, and a re-run reset a 0640
report to 0600. Give the staged file file_mode.published_mode(out) before the
replace, as the other staged writers do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant