fix(sandbox): preserve NEKO_* env across sudo re-exec in start-browser.sh - #507
Merged
Merged
Conversation
…r.sh The sandbox image bakes NEKO_WEBRTC_ICESERVERS_* (TURN at 192.168.1.208:3478) into Config.Env so Neko can relay WebRTC media. When start-browser.sh runs as the agent (uid 1000), it re-execs through sudo; /etc/sudoers sets Defaults env_reset and does not include NEKO_* in env_keep, so sudo strips the TURN config. Neko falls back to Google STUN only, ICE has no relay, and the live view white-screens. Preserve the NEKO_* vars across the re-exec via a temp file the root branch sources back. NEKO_ENV_FILE is set on the sudo command line (not the inherited env), so it survives env_reset. Surfaced by PR #506 (auto-open browser preview) once the Browser panel started opening on its own and the agent-started browser path became user-visible. The backend's as_root=True path is unaffected. Requires rebuilding the cubeplex-sandbox image with a new tag and deploying it for the fix to land in running sandboxes.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When
start-browser.shruns as the agent (uid 1000), it re-execs throughsudoso the chown/lock/pidfile steps can touch/var/run. The sandboximage bakes
NEKO_WEBRTC_ICESERVERS_*(TURN atturn:192.168.1.208:3478)into
Config.Envso Neko can relay WebRTC media, but/etc/sudoerssetsDefaults env_resetand does not includeNEKO_*inenv_keep, so sudostrips the ICE config. Neko falls back to Google STUN only, the WebRTC
media path has no relay, and the live view white-screens.
Why
The agent path (browser skill telling the agent to run
/usr/local/bin/start-browser.shas the sandbox user) loses the TURNserver baked into the image. The backend's
start_browserflow usesas_root=Trueand was never affected; the bug only shows up when theagent starts the browser itself. Surfaced once PR #506
(
feat/2026-08-19-auto-open-browser-preview) started opening the Browserpanel automatically and the agent-driven path became user-visible.
How
Preserve the
NEKO_*vars across theexec sudoboundary via a temp filethe root branch sources back.
NEKO_ENV_FILEis set on the sudo commandline (not the inherited env) so it survives
env_resetand points there-exec'd root shell at the file.
start_browser(backend,as_root=True) takes the existing fast path andnever hits the preservation code, so behaviour for the live-view flow is
unchanged.
Test plan
After rebuilding the
cubeplex-sandboximage with a new tag and rollingit onto a node:
docker inspecton the new tag still bakesNEKO_WEBRTC_ICESERVERS_BACKEND/FRONTENDwithturn:192.168.1.208:3478.sudo -u cubeplex), run/usr/local/bin/start-browser.sh;confirm
/var/log/neko/neko.logshowsiceservers-backend=[{"urls":["turn:192.168.1.208:3478"],...}](notthe Google STUN default).
ICE relay still works through coturn on 208.
Requires rebuilding
cubeplex-sandbox(new tag) and deploying it for thefix to take effect;
sh -nand a code review suffice at the repo level.