WIP: fix(sandbox): Windows: a confined game writes the diagnostic folders the real environment names, as on Linux, and no wider #2847
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2847
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/mod-api-win-sandbox-diagnostics"
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
For #2822 (into
mod-api). On Windows a confined game cannot write the folders its diagnostic switches name:RX_VK_SHOTS(the renderer's shots, headless ones too),HOS_PROFILE_DIR,HOS_SHADER_DUMP,RX_VK_DUMP,RX_VK_HANG_DUMP. Unless such a folder is inside one the game already writes (diagnostics\logs\), the shots and dumps go nowhere: the folder is not even made. Linux's plan writes them (sandbox_linux.rsdiagnostic_dirs, docs/dev/reference/sandbox.md's Linux table).env_own.rssays the Windows plan grants what such a switch names, but the Windows plan had no grant for them.The builder's Windows plan now takes these five switches from the real environment and the command alone (
Env::realingather.rs), never from a file of switches:longshot_env.txttakes no path, andHOS_ENV_FILE's file may be one a confined run can write. Each folder is served as a written root, made first. It goes throughGrants::add's checks (no drive's root, no short name, nothing at or above the player's own folders or the grants' record's folder) and two checks of its own (Grants::add_diagnosticinplan.rs):.nup;bin\,mods\andromfs\, DLSS's runtime (DLLs the renderer loads), a file read whole.Inside a folder the game already writes, it is that folder's: nothing new. A refused folder is said in the log (
sandbox: not granted: ... (a diagnostic switch's folder at or above one of the game's or the player's)). docs/dev/reference/sandbox.md's Windows table gets the row.Not in this PR: Linux also writes the folders of seven diagnostic files (
RX_VK_FRAME_LOG,HOS_CHAIN...). On Windows those would need a folder granted for one file, a wider grant, so they are left out here.To see it on
mod-api: start the game confined (longshot-builder game) withRX_VK_SHOTSset to a folder outside the game folder's own: no shot is written.Read first:
Grants::add_diagnosticinbuilder/crates/build-core/src/sandbox_windows/plan.rs.Testing
Tested: Windows 11, RTX 5080, NVIDIA 621.40, the game confined, headless,
RX_VK_SHOTSset tobuild-windows\shots-diag-*, a folder beside the game folder (not in it, not above it), a shot every 10 frames, 20 s. The game and its runtime were the same for both runs; only the builder differs.mod-api): no grant for the folder, the folder not made, no shot written.sandbox: allowed write ...\build-windows\shots-diag-after (a diagnostic switch's folder (the real environment's)), served by the builder, then 135vk: present N written to ...\shots-diag-after\vk_...png.Both runs are on
mod-apiwith #2726's save-folder fix and its broker change applied locally, beneath this PR: on plainmod-apia confined Windows start with a profile stops at the save folder. The shots were deleted after.Checks, on Windows (
cargo test -p build-core --lib --target x86_64-pc-windows-gnullvmwith llvm-mingw):sandbox_windows::gather::tests::a_diagnostic_folder_the_environment_names_is_written_and_no_wider_one, throughplan_forwith a real command: each of the five set to a folder of its own is a written root;%USERPROFILE%andC:\are neither a root nor an ACL; a folder named only byHOS_ENV_FILE's file is not granted. It fails onmod-api(no root forRX_VK_SHOTS) and passes here.sandbox_windows::plan::tests::a_diagnostic_folder_is_written_alone_and_never_over_or_in_what_the_game_only_reads, on the launcher's layout the plan's tests use:C:\Dev\shotswritten, served, made first; the plan unchanged, and the refusal said, for the game folder, a folder above it,bin\shots,mods\shots,romfs\, the user folder, the.nup's folder, DLSS's runtime,%LOCALAPPDATA%\Longshot(the record's),%USERPROFILE%andC:\; and nothing new forlogs\shots, inside a written folder.build-core's library: 98 pass here, 96 onmod-api. The two that fail here fail the same way onmod-api:driver_caches::…the_caches_are_longshots_own_unless_one_is_named(#2834 fixes it) andfiles_windows::…the_cache_takes_files_folders_renames_and_removes.tests/test_sandbox_windows.pypasses: it readsgather.rsand checks it starts nothing (noCommand::new), so the gather test, which builds a command but never starts it, is ingather/tests.rs.cargo fmt --checkpasses.cargo clippy -p build-core --all-targets --no-deps -- -D warnings(Windows target) passes with #2830 beneath (alone,mod-api's ownchannel.rsandcontrol.rslints stop it first).mise run lintpasses.Still to test:
RX_VK_SHOTSand F12's shots, and aHOS_PROFILE_DIRprofiler run, into a folder of their own (by hand)cargo test -p build-core(CI; the new tests are Windows', the Linux plan is untouched)Measurements
Verdict: fixed. A confined game on Windows writes its diagnostic switches' folders, and none wider.
Baseline:
mod-api(#2822's head), the branch this PR goes into. Nothing to time: the plan gains up to five roots.c5e5b6761b3a92b2RX_VK_SHOTSbeside the game folder, 20 s, one per 10 framesa_diagnostic_folder_the_environment_names_is_written_and_no_wider_onea_diagnostic_folder_is_written_alone_and_never_over_or_in_what_the_game_only_readsRisks
The sandbox: this PR widens what a confined game may write on Windows, but only to the folders a developer's real environment names for these five switches. It keeps every refusal
Grants::addhas, and adds two: nothing at or above anything the plan gives, and nothing inside what the game only reads. A player'slongshot_env.txtcannot name them (it takes no path), and neither canHOS_ENV_FILE's file. Each folder is a root of the builder's file service, opened through its no-link walk like every other root; no ACL changes. Each refusal is pinned by a test that fails without it (above).Beside #2747, whose latest comment adds the test mode's folder (
--mod-tests,HOS_MOD_TESTS) to the same Windows plan from the command and environment: the two add separate roots, and whichever lands second may need a rebase ingather.rs.What a developer's environment points the switches at, the game can write: a folder of the developer's choosing, as on Linux. Up to five roots more. A revert is enough.
Checklist
Ready for review
mod-api(#2822's head); the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (The checks this change reaches pass, as above.mod-api's whole suite has failures on Windows that this PR doesn't change: #2825 and #2826 fix eight of them.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (It fails onmod-api, where the bug is.)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
On Linux the builder's plan writes the folders of the diagnostic switches the real environment sets (RX_VK_SHOTS, HOS_PROFILE_DIR, HOS_SHADER_DUMP, RX_VK_DUMP, RX_VK_HANG_DUMP: sandbox_linux.rs diagnostic_dirs), never the home, the root or a system folder. On Windows the plan gives none, so a confined game's headless shots, profiler runs and dumps fail to open ("PNG open failed (error 13)"). Through plan_for with a real command: each of the five set to a folder of its own is a written root; the player's own folder and a drive's root are neither a root nor an ACL; and a file of switches (HOS_ENV_FILE's, which a confined run may be able to write) names none. The first part fails on mod-api: no root for RX_VK_SHOTS. Assisted-by: Claude Code Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in the game: Windows 11, RTX 5080, NVIDIA 621.40, confined through
longshot-builder game, headless,RX_VK_SHOTSset to a folder beside the game folder (not in it, not above it), a shot every 10 frames, 20 s. The game and runtime were the same for both runs; only the builder differs. Both are onmod-apiwith #2726's save-folder fix and its broker change applied locally, beneath this PR.mod-api: no grant, the folder not made, no shot.sandbox: allowed write ...\build-windows\shots-diag-after (a diagnostic switch's folder (the real environment's)), served by the builder, then 135vk: present N written to ...\shots-diag-after\vk_...png.The shots were deleted after.
On hold. The direction for the confined game is that it writes nothing itself and everything goes through the broker, and the game's writes are getting an audit. This PR gives the game five more written roots (served by the builder, but still the game's writes), so it waits on that audit rather than going in as it is. If the diagnostics should come out through the broker instead (the game hands the shot or dump over, the builder writes it), this PR's refusals and tests are a starting point for which folders the builder may write to.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.