The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): find the probe switch in the unpacked main bundle electron-builder ships
Teknium8b53c88ef167
diff --git a/hermes_cli/main_desktop_apparmor.py b/hermes_cli/main_desktop_apparmor.pyindex d0a17b60300..460bfa164fd 100644--- a/hermes_cli/main_desktop_apparmor.py+++ b/hermes_cli/main_desktop_apparmor.py@@ -37,14 +37,19 @@ def _build_answers_probe(packaged_executable: Path) -> bool:"""True when this packaged build's entry point honours the probe switch.A build from before the switch would start the whole app instead of exiting, so the probe is- only sent to a build whose ``app.asar`` carries the switch literal.+ only sent to a build whose main bundle carries the switch literal. electron-builder unpacks+ ``dist/`` beside the asar; a fully packed asar holds the bundle verbatim."""- asar = packaged_executable.parent / "resources" / "app.asar"- try:- with asar.open("rb") as handle, mmap.mmap(handle.fileno(), 0, access=mmap.ACCESS_READ) as data:- return data.find(SANDBOX_PROBE_SWITCH.encode()) != -1- except (OSError, ValueError):- return False+ resources = packaged_executable.parent / "resources"+ needle = SANDBOX_PROBE_SWITCH.encode()+ for bundle in (resources / "app.asar.unpacked" / "dist" / "electron-main.mjs", resources / "app.asar"):+ try:+ with bundle.open("rb") as handle, mmap.mmap(handle.fileno(), 0, access=mmap.ACCESS_READ) as data:+ if data.find(needle) != -1:+ return True+ except (OSError, ValueError):+ continue+ return Falsedef chromium_userns_sandbox_verdict(packaged_executable: Path) -> Optional[bool]:diff --git a/tests/hermes_cli/test_desktop_apparmor_sandbox.py b/tests/hermes_cli/test_desktop_apparmor_sandbox.pyindex 33bcc110859..1c39ba5dfb1 100644--- a/tests/hermes_cli/test_desktop_apparmor_sandbox.py+++ b/tests/hermes_cli/test_desktop_apparmor_sandbox.py@@ -24,10 +24,13 @@ _ALLOWED = "#!/bin/sh\nexit 0\n"def _packaged_app(tmp_path, script: str):unpacked = tmp_path / "linux-unpacked"- (unpacked / "resources").mkdir(parents=True)- # The bundled entry point carries the probe switch, so the launcher knows this build answers it.- (unpacked / "resources" / "app.asar").write_bytes(- b"\0asar\0" + main_desktop_apparmor.SANDBOX_PROBE_SWITCH.encode() + b"\0")+ # electron-builder's layout: dist/ unpacked beside the asar. The main bundle carries the probe+ # switch, so the launcher knows this build answers it.+ dist = unpacked / "resources" / "app.asar.unpacked" / "dist"+ dist.mkdir(parents=True)+ (dist / "electron-main.mjs").write_text(+ f"if (process.argv.includes('{main_desktop_apparmor.SANDBOX_PROBE_SWITCH}')) process.exit(0)\n",+ encoding="utf-8")exe = unpacked / "Hermes"exe.write_text(script, encoding="utf-8")exe.chmod(0o755)