fix(desktop): keep Windows SSH runtime at machine root

This commit is contained in:
Cad from Arca 2026-08-01 12:00:20 +00:00 committed by Teknium
parent 6d3cb23d24
commit 5cb19d7af5
2 changed files with 16 additions and 3 deletions

View File

@ -10,7 +10,7 @@ import sys
from pathlib import Path
from typing import Any
from hermes_constants import get_hermes_home
from hermes_constants import get_default_hermes_root
_HEX32 = re.compile(r"[0-9a-f]{32}\Z")
_HEX16 = re.compile(r"[0-9a-f]{16}\Z")
@ -49,7 +49,11 @@ def _nonce(value: str) -> str:
def _root() -> Path:
return get_hermes_home() / "desktop-ssh"
# The helper uploads the token before the child applies `--profile`, while
# read_token() runs after profile activation. Anchor both processes to the
# machine root so a named profile cannot move the reader away from the
# helper's token, including custom HERMES_HOME layouts.
return get_default_hermes_root() / "desktop-ssh"
def _directory(ownership_id: str) -> Path:
@ -452,7 +456,7 @@ def dispatch(argv: list[str]) -> Any:
operation = argv[0]
if operation == "probe":
import platform
return {"os": "Windows", "arch": platform.machine(), "hermesHome": str(get_hermes_home()), "python": sys.executable}
return {"os": "Windows", "arch": platform.machine(), "hermesHome": str(get_default_hermes_root()), "python": sys.executable}
if operation == "upload-token" and len(argv) == 3:
return upload_token(argv[1], argv[2], sys.stdin.buffer.read(65))
if operation == "read-lock" and len(argv) == 2:

View File

@ -138,3 +138,12 @@ def test_token_file_rejects_parent_escape(tmp_path, monkeypatch):
assert escaped.exists()
finally:
reset_hermes_home_override(override)
def test_windows_runtime_root_stays_at_machine_root_for_named_profile(tmp_path, monkeypatch):
from hermes_cli import windows_ssh_runtime
machine_root = tmp_path / "custom-hermes-root"
monkeypatch.setenv("HERMES_HOME", str(machine_root / "profiles" / "writer_2"))
assert windows_ssh_runtime._root() == machine_root / "desktop-ssh"