Skip to content

The agent that grows with you

fix(desktop): a bundled install launches with the flags its sandbox probe passed

Teknium8f94d1f05957
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.py
index 072533d4ff2..c5d862664b0 100644
--- a/hermes_cli/main_desktop.py
+++ b/hermes_cli/main_desktop.py
@@ -1980,17 +1980,7 @@ def _launch_bundled_desktop(
print(" The install is damaged — reinstall Hermes from the website.")
sys.exit(1)
- from hermes_cli.main_desktop_apparmor import print_blocked_remedies
-
- launch_command = [str(layout.launcher)]
- if not _desktop_linux_sandbox_fixup(layout.launcher):
- if _desktop_linux_needs_no_sandbox() and _desktop_linux_sandbox_helper_is_regular_file(layout.launcher):
- print("⚠ Falling back to --no-sandbox because this Linux host restricts unprivileged user namespaces and the Electron sandbox helper could not be configured.")
- print_blocked_remedies(layout.launcher)
- launch_command.append("--no-sandbox")
- else:
- sys.exit(1)
-
+ launch_command = _packaged_desktop_launch_command(layout.launcher)
launch_command.extend(electron_flags)
launch_command.extend(_explicit_profile_args())
pid = launch_detached(launch_command, env=env, cwd=layout.app_root)
diff --git a/tests/hermes_cli/test_bundled_desktop_launch.py b/tests/hermes_cli/test_bundled_desktop_launch.py
index c8e86cc5fc4..3b3b1d233cd 100644
--- a/tests/hermes_cli/test_bundled_desktop_launch.py
+++ b/tests/hermes_cli/test_bundled_desktop_launch.py
@@ -226,7 +226,7 @@ class TestCmdGuiOnABundle:
return SimpleNamespace(**base)
@staticmethod
- def _run(monkeypatch, repo: Path, args, *, launcher_ok: bool = True):
+ def _run(monkeypatch, repo: Path, args, *, launcher_ok: bool = True, setuid_helper_unusable: bool = False):
"""Run cmd_gui against *repo*, recording builds and launches."""
builds: list[list[str]] = []
launches: list[list[str]] = []
@@ -249,6 +249,7 @@ class TestCmdGuiOnABundle:
monkeypatch.setattr(main_desktop, "_desktop_linux_sandbox_fixup", lambda *a, **k: launcher_ok)
monkeypatch.setattr(main_desktop, "_desktop_linux_needs_no_sandbox", lambda: not launcher_ok)
monkeypatch.setattr(main_desktop, "_desktop_linux_sandbox_helper_is_regular_file", lambda *a, **k: True)
+ monkeypatch.setattr(main_desktop, "_desktop_linux_needs_disable_setuid_sandbox", lambda *a: setuid_helper_unusable)
monkeypatch.setattr(main_desktop, "_detect_linux_password_store", lambda: None)
with patch("hermes_cli.bundled_app.subprocess.Popen", side_effect=record_popen), \
@@ -269,6 +270,14 @@ class TestCmdGuiOnABundle:
assert builds == []
assert launches == [[str(launcher)]]
+ def test_a_non_setuid_helper_beside_a_working_userns_sandbox_is_bypassed(self, tmp_path, monkeypatch):
+ """The probe passed with --disable-setuid-sandbox, so the real launch must carry it too."""
+ repo, launcher = _host_bundle(tmp_path)
+ code, _builds, launches = self._run(monkeypatch, repo, self._args(), setuid_helper_unusable=True)
+
+ assert code == 0
+ assert launches == [[str(launcher), "--disable-setuid-sandbox"]]
+
def test_explicit_profile_reaches_the_bundled_launcher(self, tmp_path, monkeypatch):
"""`hermes -p work desktop` on a bundle hands Electron --profile work."""
repo, launcher = _host_bundle(tmp_path / "app")