Skip to content

fix(desktop): configure Linux Electron sandbox helper - #37691

Merged
ethernet8023 merged 1 commit into
mainfrom
fix/linux-desktop-sandbox-v2
Jun 3, 2026
Merged

fix(desktop): configure Linux Electron sandbox helper#37691
ethernet8023 merged 1 commit into
mainfrom
fix/linux-desktop-sandbox-v2

Conversation

@ethernet8023

Copy link
Copy Markdown
Collaborator

Why

Electron's chrome-sandbox helper must be root:root 4755 on Linux or the sandboxed renderer aborts before the desktop app starts. The existing installer only searched for macOS .app bundles, so a successful Linux build was reported as missing.

This is a salvage of #37529 (by @Jgracier) — rebased onto current main to resolve merge conflicts, and addresses the two issues raised by Copilot's review:

  1. Symlink safety — the original used stat() which follows symlinks; chown/chmod on a symlink target would set SUID on an arbitrary path. This version uses lstat() + S_ISREG() to reject non-regular-file sandbox helpers.
  2. install.sh error handling — the original silently ignored chown/chmod failures. This version returns non-zero on failure.

What changed

  • hermes_cli/main.py: Add _desktop_linux_sandbox_fixup() using lstat() + S_ISREG() to reject symlinks before sudo chown/sudo chmod. Wired into cmd_gui() before launch.
  • scripts/install.sh: Recognize Linux unpacked artifacts (linux-unpacked/Hermes or hermes). Configure chrome-sandbox with ! -L symlink guard and proper error handling on chown/chmod failure.
  • tests/hermes_cli/test_gui_command.py: Three new tests:
    • test_gui_linux_configures_sandbox_before_launch — verifies sudo chown/sudo chmod are called before launch
    • test_gui_linux_rejects_symlink_sandbox — verifies symlinked chrome-sandbox is rejected without calling sudo
    • test_gui_linux_skips_fixup_when_already_configured — verifies no-op when sandbox is already root:root 4755

Verification

  • bash -n scripts/install.sh
  • python -m pytest tests/hermes_cli/test_gui_command.py -q — 19 passed ✅
  • python -m pytest tests/test_install_sh_*.py -q — 10 passed ✅

Closes #37529

Electron's chrome-sandbox helper must be root:root 4755 on Linux or the
sandboxed renderer aborts before the desktop app starts. The existing
installer only searched for macOS .app bundles, so a successful Linux
build was reported as missing.

Changes:
- Add _desktop_linux_sandbox_fixup() to hermes_cli/main.py, called
  before launching a packaged desktop app on Linux.
- Use lstat() + S_ISREG check to reject symlinks — chown/chmod on a
  symlink target would set SUID on an arbitrary path.
- Update install.sh to recognize Linux unpacked artifacts and configure
  chrome-sandbox with proper error handling (the original PR silently
  ignored chown/chmod failures).
- Add regression tests: normal fixup flow, symlink rejection, and
  already-configured skip path.

Closes #37529 (rebased, merge conflicts resolved, copilot review
feedback addressed).
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/linux-desktop-sandbox-v2 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9682 on HEAD, 9682 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5016 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@Jgracier

Jgracier commented Jun 2, 2026

Copy link
Copy Markdown

Thank you @ethernet8023, I appreciate the review and proper implementation of this! My fix made it work on my machine but you likely have a more experienced eye for this! Excited for Hermes Desktop app!

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels Jun 2, 2026
@simpolism

Copy link
Copy Markdown
Contributor

@ethernet8023 confirmed working, good to merge. cc @alt-glitch

@ethernet8023
ethernet8023 merged commit 46e513e into main Jun 3, 2026
30 of 31 checks passed
@ethernet8023
ethernet8023 deleted the fix/linux-desktop-sandbox-v2 branch June 3, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants