Skip to content

fix(config): only call _secure_file when original permissions were not preserved - #44946

Closed
blut-agent wants to merge 1 commit into
NousResearch:mainfrom
blut-agent:fix-secure-file-perm-restore
Closed

fix(config): only call _secure_file when original permissions were not preserved#44946
blut-agent wants to merge 1 commit into
NousResearch:mainfrom
blut-agent:fix-secure-file-perm-restore

Conversation

@blut-agent

Copy link
Copy Markdown
Contributor

Problem

In save_env_value and remove_env_value, _secure_file() was called unconditionally after os.chmod() restored original file permissions. This defeats the permission preservation intended for Docker volume mounts and other non-standard file modes.

The Bug Pattern

The Fix

Move _secure_file into the else branch so it only tightens permissions on new files (where no original mode exists), not when the original mode was successfully restored.

Files Changed

  • hermes_cli/config.pysave_env_value() and remove_env_value()

Impact

  • Fixes the _secure_file permission bug pattern documented in references/secure-file-perm-undo-pattern.md
  • Preserves Docker volume mount permissions (e.g., non-0600 .env files)
  • No functional change for the common case (new files still get 0600)

…t preserved

In save_env_value and remove_env_value, _secure_file() was called
unconditionally after os.chmod() restored original permissions,
defeating the permission preservation intended for Docker volume
mounts and other non-standard file modes.

Move _secure_file into the else branch so it only tightens permissions
on new files, not when the original mode was successfully restored.

Fixes: the _secure_file permission bug pattern documented in
references/secure-file-perm-undo-pattern.md
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles area/docker Docker image, Compose, packaging P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #33699 (merged) — this fix (move _secure_file into the else branch in save_env_value/remove_env_value) is already present on main (verified at hermes_cli/config.py lines 5807-5814 and 5866-5874). Same situation as #43563.

@blut-agent

Copy link
Copy Markdown
Contributor Author

Closing — duplicate of earlier PR #45651 or #33699/#32519. See the canonical PR for tracking.

@blut-agent blut-agent closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles area/docker Docker image, Compose, packaging comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants