fix(environments): profile-aware snapshot store paths + owner-only perms on writes - #60317
fix(environments): profile-aware snapshot store paths + owner-only perms on writes#60317isheng-eqi wants to merge 3 commits into
Conversation
Duplicate of #60259 — same-author clean isolation of that stacked-branch PR's environments-only contribution: byte-identical |
|
Closing — #60259 (the referenced duplicate) was intentionally closed by me to create this clean replacement. Will re-submit to avoid bot false-positive. |
Summary
Two related fixes for snapshot store handling in terminal environments:
Profile-scoped snapshot store paths (modal.py, singularity.py): Module-level
_SNAPSHOT_STOREcapturedget_hermes_home()at import time, which is stale in long-lived multi-profile runtimes (Dashboard/TUI/cron). Replace with_snapshot_store_path()resolved at call time, matching the pattern from [Bug]: Profile-local skills are unavailable in Dashboard/TUI/Desktop GUI because child processes use the root HERMES_HOME #40677.Owner-only permissions on snapshot writes (base.py):
_save_json_store()wrote snapshot files with the process default umask. Wrap the write withumask(0o077)to restrict metadata files that may contain env-carried secrets. Also remove the redundant runtimeumask 077commands from the bootstrap and exec paths, now that the store-level write handles it.Changes
tools/environments/modal.py:_SNAPSHOT_STORE→_snapshot_store_path()call-time resolutiontools/environments/singularity.py:_SNAPSHOT_STORE→_snapshot_store_path()call-time resolutiontools/environments/base.py:_save_json_store()wraps write withumask(0o077); removes duplicateumask 077from bootstrap/execWhy this is correct and safe
umaskwrapping in_save_json_storeis the canonical single point — the twoumask 077in bootstrap/exec were redundant and inconsistently applied