fix(paths): respect HERMES_HOME for protected .env write-deny path (#3840)

The write-deny list in file_operations.py hardcoded ~/.hermes/.env,
which misses the actual .env in custom HERMES_HOME or profile setups.
Use get_hermes_home() for profile-safe path resolution.

Salvaged from PR #3232 by @erhnysr.

Co-authored-by: Erhnysr <erhnysr@users.noreply.github.com>
This commit is contained in:
Teknium
2026-03-29 18:02:11 -07:00
committed by GitHub
parent d6b7836210
commit 59f2b228f7

View File

@@ -32,6 +32,7 @@ from abc import ABC, abstractmethod
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Optional, List, Dict, Any from typing import Optional, List, Dict, Any
from pathlib import Path from pathlib import Path
from hermes_constants import get_hermes_home
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -46,7 +47,7 @@ WRITE_DENIED_PATHS = {
os.path.join(_HOME, ".ssh", "id_rsa"), os.path.join(_HOME, ".ssh", "id_rsa"),
os.path.join(_HOME, ".ssh", "id_ed25519"), os.path.join(_HOME, ".ssh", "id_ed25519"),
os.path.join(_HOME, ".ssh", "config"), os.path.join(_HOME, ".ssh", "config"),
os.path.join(_HOME, ".hermes", ".env"), str(get_hermes_home() / ".env"),
os.path.join(_HOME, ".bashrc"), os.path.join(_HOME, ".bashrc"),
os.path.join(_HOME, ".zshrc"), os.path.join(_HOME, ".zshrc"),
os.path.join(_HOME, ".profile"), os.path.join(_HOME, ".profile"),