WIP: fix(control): a game the sandbox confined serves its pipe in its AppContainer's namespace, and the client finds it #2742
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2742
Loading…
Reference in a new issue
No description provided.
Delete branch "ChloeNow/Longshot:fix/control-pipe-appcontainer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On Windows the control bridge never served a game the sandbox confined (the default since #2434): a process in an
AppContainer may make named pipes only in its own namespace, so the game's
CreateNamedPipeof\\.\pipe\<HOS_CONTROL>was refused with error 5, and the log said
control: off.dev.py game-tests(and anylongshot_bridgesession)then never saw the game ready: a sandboxed test run ended "the game did not start: game exited 0 before ready=present",
exit 2, even when its tests passed and wrote
results.json. #544 let the container connect to the pipe; nothing letit make one.
host/control.c: in an AppContainer (pipe_securityalready reads its SID), the pipe is made as\\.\pipe\LOCAL\<name>, and the log names the path a client outside opens:\\.\pipe\Sessions\<n>\AppContainerNamedObjects\<the container's SID>\<name>. A name already in a namespace(
LOCAL\,Sessions\) is taken as it is. Outside a container nothing changes.scripts/longshot_bridge.py: a pipe its plain name does not find is tried at that path, for the sandbox'scontainer,
Longshot.Game(its SID derived ashost/sandbox_windows.cderives it; this session's number).docs/dev/reference/control-bridge.md: the Security section says so.On mod-api, to see it: Windows,
dev.py game-tests <a mod with an in-game test>(sandboxed, the default): thegame's log says
control: \\.\pipe\longshot-control-...: 5andcontrol: off, and game-tests says the game did notstart. A sandboxed start with a profile also needs #2726 to reach play at all.
Read first:
host/control.ctransport_open,scripts/longshot_bridge.pyBridge.__init__andcontainer_pipe.Testing
Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24.
tests/test_control_appcontainer.py(new, Windows only):tests/control_test.c(the bridge over a fake game, astests/test_control.pybuilds it) serving inside a realLongshot.GameAppContainer with no capabilities, as thesandbox starts the game, and
longshot_bridge.Bridgeoutside askingstatusandquit. On mod-api: the confinedbridge exits 3, its pipe not made. Here: passes. With the client half undone: "no client reached the confined
bridge in 30 s ... cannot find the file specified", so both halves are needed.
tests/test_control.pyandtests/test_control_pipe_security.pypass (Windows, clang).dev.py game-testsof a mod with an in-game test, sandboxed with its profile, on this branch merged with #2726 (whicha sandboxed profile start needs to reach play; a local merge, not pushed). The game's log:
control: in an AppContainer: served as \\.\pipe\LOCAL\longshot-control-..., which a client outside opens as \\.\pipe\Sessions\1\AppContainerNamedObjects\S-1-15-2-...\longshot-control-...,control: listening on ...,control: state boot -> intro,intro -> menu. game-tests:ok - test/main.test.ts: ..., "1 passed, 0 failed,4 skipped (in the game)", exit 0. On #2726 alone the same run's game log says
control: off, and game-tests "the gamedid not start: game exited 0 before ready=present", exit 2.
Still to test:
tests/test_control.pyin CI.longshot_ctl.pysession (shot, press, teleport) against a sandboxed game (by hand).Measurements
Nothing to measure: the pipe's name and a client's second try, at connect only.
Risks
Longshot.Game's SID, this session): noother app's pipes are tried.
HOS_CONTROLalready of a namespace keeps it as it is.Checklist
Ready for review
mod-api; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24: dev.py game-tests of a mod with an in-game test, sandboxed with its profile, on this branch merged locally with #2726. The game's log: 'control: in an AppContainer: served as .\pipe\LOCAL\longshot-control-...', 'control: listening on ...', its states boot, intro, menu followed; game-tests: '1 passed, 0 failed, 4 skipped (in the game)', exit 0. On #2726 alone: 'control: off' and 'the game did not start ... before ready=present', exit 2.
ChloeNow referenced this pull request2026-11-28 16:17:35 +00:00
ChloeNow referenced this pull request2026-11-28 16:56:19 +00:00
ChloeNow referenced this pull request2026-11-28 17:31:53 +00:00
@review
Recommendation: Request changes. The sandboxed bridge works in the reported game run, but a client can connect to a different game when confined and unconfined games use the same pipe name. Explicit LOCAL names also remain unreachable through the client.
The change lets a sandboxed Windows game serve its control bridge and lets the Python client discover it. It fixes the reported game-tests failure, at the cost of introducing ambiguity between identically named pipes in different namespaces.
Blocking (1): must change before merging.
scripts/longshot_bridge.py:191: Trying the global pipe first can connect a session to the wrong game because the same name can now exist in both namespaces. (more on the line) Do: Carry the intended game's namespace or identity to the client and select or verify the pipe against that identity before sending commands. Add a test with both namespaces occupied.Should fix (2): not blocking, but worth doing before merging.
scripts/longshot_bridge.py:94: The client refuses to translate an explicit LOCAL pipe name, although the server accepts that name in the container. (more on the line) Do: Translate LOCAL-prefixed names to the container's external path after stripping LOCAL, and test an explicit LOCAL name end to end.tests/test_control_appcontainer.py:103: The new test ignores CC and can silently skip despite a configured Windows compiler. (more on the line) Do: Honor the configured compiler, including the test runner's compiler argument, and make a missing required compiler visible to the Windows test run.@fixcan do L1, L2 and L3.More: does it help, other systems, switches, what was read
Does it help: Yes. On Windows 11, the author reports that the sandboxed in-game test changed from control being off and game-tests exiting 2 to one test passing and exit 0, with #2726 included on both sides.
Other systems: The changed transport and discovery paths are Windows-only; Linux continues to use Unix sockets. The reported Windows run used NVIDIA hardware. Explicit pipe names, simultaneous confined and unconfined games, and a manual longshot_ctl session need coverage.
Switches: No switches added, changed, or removed.
Reviewed:
7ffc7313a0against4266ba68cc: Read the diff, both commit messages, repository rules, PR template, the new test, changed transport and client code, and relevant callers and security tests. The large host/control.c and scripts/longshot_bridge.py outputs were truncated, so their unchanged portions were not read in full. The requested review checklist and adjacent Tooling AGENTS.md were absent. No generated files or recorded runs were changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code, scripts, builds, or tests were run. The PR remains WIP and reports a dependency on #2726 for sandboxed profile starts.
Overlaps and merge order: #2726 is needed for the reported sandboxed profile start; the reported game comparison includes it on both sides.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -87,0 +91,4 @@"""The path a client outside opens for the pipe a process in the AppContainer `sid` serves as \\\\.\\pipe\\LOCAL\\<leaf>(host/control.c: a confined game's); None for a name already in some namespace (LOCAL\\, Sessions\\)"""leaf = name[len("\\\\.\\pipe\\"):] if name.startswith("\\\\.\\pipe\\") else nameif not leaf or leaf.lower().startswith(("local\\", "sessions\\")):L2 (should fix): The client refuses to translate an explicit LOCAL pipe name, although the server accepts that name in the container.
When: With HOS_CONTROL set to LOCAL\foo, the confined server creates its container-local pipe, but an outside Bridge tries its own LOCAL namespace and then returns None instead of trying the container's external Sessions path. It therefore cannot reach the running game.
Do: Translate LOCAL-prefixed names to the container's external path after stripping LOCAL, and test an explicit LOCAL name end to end.
@ -144,2 +189,3 @@self.sock = Noneself.pipe = open_windows_pipe(name, timeout)try:self.pipe = open_windows_pipe(name, timeout)L1 (blocking): Trying the global pipe first can connect a session to the wrong game because the same name can now exist in both namespaces.
When: If an unconfined game and a sandboxed game both use the same explicit HOS_CONTROL name, both pipes can be created. A client for the sandboxed game opens the unconfined pipe successfully and sends its commands there; a quit or write can affect the wrong game.
Do: Carry the intended game's namespace or identity to the client and select or verify the pipe against that identity before sending commands. Add a test with both namespaces occupied.
@ -0,0 +100,4 @@print("SKIP: Windows only (AppContainers)")returnmingw = os.environ.get("LONGSHOT_MINGW")cc = a.cc or (str(Path(mingw, "bin", "clang.exe")) if mingw else shutil.which("clang"))L3 (should fix): The new test ignores CC and can silently skip despite a configured Windows compiler.
When: On a Windows test host with CC set to a suitable compiler but no clang on PATH and no LONGSHOT_MINGW, the test reports SKIP and exits successfully without exercising either half of the fix.
Do: Honor the configured compiler, including the test runner's compiler argument, and make a missing required compiler visible to the Windows test run.
Marked as a stopgap: the plan is for the control connection to go through the builder's broker, and then the game serves no pipe of its own and this goes. Until that lands, it is what keeps sandboxed test runs working on Windows.
Superseded by the builder broker on mod-api (
eaf4a48b9): the builder now listens on the control pipe and hands the confined game its clients, so the game serves no pipe of its own. Verified on Windows: a sandboxed dev.py game-tests run connected through the builder and passed. Closing.Pull request closed