WIP: fix(sandbox): Windows: a confined game reads a profile past 260 characters: the file layer takes the extended-length prefix #2838
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2838
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/mod-api-win-long-paths"
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 whose profile's path passes 260 characters reads nothing of the profile from its Rust side. It logs:the settings file …\settings\settings.toml could not be read (Access is denied. (os error 5)): every setting at its default, and nothing saved this runprofile.json is not a list of mods (Access is denied …)with no mod in itThe C side reads the same profile fine.
The game reaches the player's files through its file layer,
host/hos_file_windows.c, which hands an open to the builder only whenwhole_utf8finds a drive's (C:\…) or a share's (\\server\…) path. Rust's std gives a path pastMAX_PATHWindows' extended-length prefix (\\?\C:\…), andGetFullPathNameWleaves that form as it is. So those opens stayed native calls, which the AppContainer refuses.whole_utf8now also takes\\?\C:\…and\\?\UNC\server\share\…, and hands them on in their plain form, which the builder's rules take (files_rules). A device's path (\\.\…,\\?\Volume{…}), a pipe and the console are still never the builder's.To see it on
mod-api: Windows, a profile at a path longer than 260 characters,longshot-builder game(confined). The log has the warnings above, and the profile's mods don't start.Read first:
whole_utf8inhost/hos_file_windows.c.Testing
Tested: Windows 11, RTX 5080, NVIDIA 621.40, confined through
longshot-builder game, with a profile copied to a folder 285 characters deep (given as a plainC:\…path), holding three script mods and a development mod.options: the settings file is …\settings\settings.toml, the profile's three mods started, and the development mod was found (it waits for its permission prompt, as with a short path). No access-denied line.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. A profile path with spaces and non-ASCII letters (modapi run é ü) was also run, and it works the same before and after.Checks:
tests/test_file_layer_long_paths.py(Windows; skipped on Linux) cutswhole_utf8from the source, compiles it with the PC's clang and gives it each path form. It fails onmod-api@eaf4a48b(the two prefixed forms "never the builder's") and passes here.tests/test_sandbox_windows.pyandtests/test_builder_files_wine.pypass (the latter needs Wine, which this PC lacks, so it was skipped here).host/hos_file_windows.ccompiles with-Wall -Wextra -Werror(llvm-mingw clang) before and after.build-coretestfiles_rules::tests::the_extended_length_form_keeps_every_refusalchecks the builder's rules on what the layer now hands them. Every name Windows reads differently under\\?\stays refused in that form:..,., a trailing dot or space, a stream's:, a device's name,*. So does a\\?\path that is not a drive's or a share's: a volume's,GLOBALROOT, a pipe. It passes onmod-apiand here, on Windows and Linux (it pins what the change relies on).mise run lintpasses.Still to test:
Measurements
Verdict: fixed. A confined Windows game reads a profile past 260 characters.
Baseline:
mod-api(#2822's head), the branch this PR goes into: the bug is there, not onmain. The in-game runs are both onmod-apiwith #2726's save-folder fix and broker change applied locally, beneath this PR.Setup: Windows 11, RTX 5080, NVIDIA 621.40, the game confined, the same 285-character profile. The log's lines, and the check.
eaf4a48b56668d15settings.tomlprofile.json's listtests/test_file_layer_long_paths.pyRisks
Only the file layer's choice of what the builder serves changes: opens with the prefix now reach the builder's rules, which decide as for the plain path.
The sandbox keeps every guarantee. The builder decides each such open by its own rules (
files_rules::norm,decide), which already took the\\?\form and strip it before checking. The names that mean something else under the prefix are refused in either form (the test above), and the builder still checks an opened file's final path under its root and refuses links. No grant, root or right changes: a file outside the player's roots is refused as before, now by the builder instead of by Windows. A revert is enough. Players on Windows with a profile in a deep folder get their settings and mods.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.mod-api's whole suite has failures on Windows that this PR doesn't change.)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
host/hos_file_windows.c's whole_utf8 cut and compiled with the PC's C compiler, given each path form: \?\C:\... and \?\UNC\server\share\... must be the builder's, in their plain form, as C:\... and \server\... are; a device's path, a pipe and the console never. It fails on mod-api: the prefixed forms are never the builder's, so in a profile past 260 characters the confined game's Rust read nothing of it ("settings.toml could not be read (Access is denied. (os error 5))", "profile.json is not a list of mods (Access is denied ...)"). Windows only (RUN_ALL_SKIP on Linux). 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 gamewith a profile copied to a folder 285 characters deep (on mod-api with #2726's save-folder fix and its broker change applied locally, beneath this PR). Before:settings.toml could not be read (Access is denied. (os error 5)),profile.json is not a list of mods (Access is denied ...), the development mod's folderwith no mod in it, no profile mod started. After: the settings file read, the profile's 3 mods started, the development mod found; no access-denied line.Possibly related, for context:
Pushed a refusal test (
1e810390): the builder's file rules refuse, in the ?\ form too, every name Windows reads differently under that prefix (.., ., a trailing dot or space, a stream, a device's name), and a ?\ path that is not a drive's or a share's. It passes on mod-api and here, on Windows and Linux. Risks now says how the change keeps the sandbox's guarantees.1e810390877d780aeebcRebased onto mod-api's newest (
4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.7d780aeebcfd685a47fdRebased onto
mod-api@816d2354(#2837, headless shots of the mods' UI), nowfd685a47. No conflict, and the diff is the same as before (samegit patch-id). #2837 touches none of this PR's files.fd685a47fd4c9fe205204c9fe2052056668d15e4Rebased onto
mod-api@c5e5b676: it was re-squashed onto main @46291934(#2833) twice today (cdbb8551, thenc5e5b676), which made this PR show main's and the whole mod API's diff. Now56668d15, the same diff as before (samegit patch-id), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.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.