fix: fall back to no-sandbox for desktop launch on restricted Linux hosts

This commit is contained in:
Rafael Millan 2026-06-08 11:43:40 -04:00 committed by Teknium
parent 97640fd9ad
commit 54ea059919
3 changed files with 84 additions and 3 deletions

View file

@ -222,6 +222,41 @@ def test_gui_linux_skips_fixup_when_already_configured(tmp_path, monkeypatch):
assert mock_run.call_args.args[0] == [str(packaged_exe)]
def test_gui_linux_falls_back_to_no_sandbox_when_userns_is_restricted(tmp_path, monkeypatch):
root = _make_desktop_tree(tmp_path)
monkeypatch.setattr(cli_main, "PROJECT_ROOT", root)
packaged_exe = _make_packaged_executable(root, monkeypatch, platform="linux")
sandbox = packaged_exe.parent / "chrome-sandbox"
sandbox.write_text("", encoding="utf-8")
launch_ok = subprocess.CompletedProcess([str(packaged_exe), "--no-sandbox"], 0)
with patch("hermes_cli.main._desktop_linux_sandbox_fixup", return_value=False), \
patch("hermes_cli.main._desktop_linux_needs_no_sandbox", return_value=True), \
patch("hermes_cli.main.subprocess.run", return_value=launch_ok) as mock_run, \
pytest.raises(SystemExit) as exc:
cli_main.cmd_gui(_ns(skip_build=True))
assert exc.value.code == 0
mock_run.assert_called_once()
assert mock_run.call_args.args[0] == [str(packaged_exe), "--no-sandbox"]
def test_gui_linux_exits_when_sandbox_fixup_fails_without_safe_fallback(tmp_path, monkeypatch):
root = _make_desktop_tree(tmp_path)
monkeypatch.setattr(cli_main, "PROJECT_ROOT", root)
_make_packaged_executable(root, monkeypatch, platform="linux")
with patch("hermes_cli.main._desktop_linux_sandbox_fixup", return_value=False), \
patch("hermes_cli.main._desktop_linux_needs_no_sandbox", return_value=False), \
patch("hermes_cli.main.subprocess.run") as mock_run, \
pytest.raises(SystemExit) as exc:
cli_main.cmd_gui(_ns(skip_build=True))
assert exc.value.code == 1
mock_run.assert_not_called()
def test_gui_source_mode_uses_renderer_build_and_electron(tmp_path, monkeypatch):
root = _make_desktop_tree(tmp_path)
desktop_dir = root / "apps" / "desktop"