Repository navigation
Fix Windows PowerShell resource path authorization - #7943
danielhanchen merged 5 commits into
Conversation
|
I reproduced this on a real The root cause is confirmed, and the code path is the only oneSame file, same directory, only the spelling differs, Windows PowerShell 5.1.26100.33158:
And the verbatim spelling is not an edge case, it is what we always hand PowerShell in a release build. Using the real crate on the same runner: The chain is For the record on where it came from: #7819's whole What I changed1. Match the 2. Do not de-verbatimize past MAX_PATH. The verbatim form is the only one that addresses a path longer than 260 characters, so stripping the prefix there swapped an authorization error for a "path too long" one. Now those are left alone. 3. Resolve Verification
One thing worth fixing separatelyThe |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88abb327d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // Only the verbatim form addresses a path past MAX_PATH; stripping it there | ||
| // would trade an authorization error for a "path too long" one. | ||
| if normalized.len() > 260 { |
There was a problem hiding this comment.
Keep verbatim paths at the MAX_PATH boundary
When the normalized script path is exactly 260 UTF-16 code units, this strips the \\?\ prefix even though legacy Win32 MAX_PATH leaves room for only 259 path characters plus the terminating NUL. In that boundary case Windows PowerShell 5.1 receives an ordinary path it cannot open, so installations under a just-long-enough per-user path fail with a path error instead of preserving the verbatim spelling; the guard should treat >= 260 as too long.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in f4560c5. MAX_PATH is 260 counting the terminating NUL, so the longest legacy path string is 259 units, and the guard now rejects 260. Test pins both sides of the boundary: a 259 unit normalized path still strips, 260 and 300 stay verbatim.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…#7969) The windows-unit-tests leg added in #7943 pins powershell_script_path as a pure function. That cannot see the regression that actually shipped: #7819's entire install.rs diff was Bypass -> RemoteSigned, and dropping the powershell_script_path call from spawn_script leaves every existing assertion passing while first-run install is broken on every Windows bundle. Lift the argument vector into powershell_launch_args so the call site itself is testable, then run the real interpreter with those flags against a script addressed the way Tauri addresses it (fs::canonicalize, which resource resolution bottoms out in and which is documented to return extended-length syntax). The test asserts it reproduced a verbatim path before using it, so it cannot pass vacuously. A second test pins the flag set so a policy swap shows up as a diff. No behaviour change: the arguments spawn_script passes are byte for byte the ones it passed before.
Summary
RemoteSignedplusCREATE_NO_WINDOW)install.ps1to Windows PowerShell 5.1Root cause
Tauri can resolve the bundled script as
\\?\C:\...\install.ps1. Windows PowerShell 5.1'sRemoteSignedauthorization rejects that spelling withAuthorizationManager check failed/UnauthorizedAccess, even when the script's Authenticode signature is valid and it has noZone.Identifier. The equivalentC:\...\install.ps1path authorizes successfully.This keeps
RemoteSigned; it does not restore the-WindowStyle Hidden -ExecutionPolicy Bypasscommand shape that was removed because it matched a Microsoft Defender detection signature.Validation
rustfmt --edition 2021 --check studio/src-tauri/src/install.rsnpm ci --no-fund --no-audit && npm run buildinstudio/frontendcargo test powershell_script_path_normalizes_verbatim_filesystem_paths -- --nocaptureon Windows: 1 passedRemoteSignedreproducedAuthorizationManager/UnauthorizedAccessRemoteSignedauthorized the exact signed scriptThe runner validates the authorization fix while retaining the Defender-friendly command shape. Absence of consumer Defender notifications still requires final testing with the fully signed release installer.