fix(desktop): grant Windows sandbox access during installation - #46696
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The NSIS hook currently uses incorrect quoting for nsExec::ExecToLog and ignores icacls failure, which can prevent the permission fix from being applied reliably.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the Windows NSIS installer used by the Desktop app to grant the Chromium sandbox (“ALL RESTRICTED APPLICATION PACKAGES”, SID S-1-15-2-2) inheritable read/execute access to the installation directory, addressing the fresh-install startup crash tied to missing ACLs.
Changes:
- Add an NSIS
customInstallhook that runsicaclsto grant(OI)(CI)(RX)toS-1-15-2-2for$INSTDIR. - Wire the hook into
electron-builderviansis.include. - Add tests to validate the config includes the hook and (optionally) validate ACL behavior on Windows with a native NSIS toolchain.
File summaries
| File | Description |
|---|---|
| packages/desktop/scripts/windows-installer.test.ts | Adds a Windows-only integration test that exercises the NSIS hook and asserts ACL changes are scoped/idempotent. |
| packages/desktop/resources/windows/installer.nsh | Introduces the NSIS customInstall macro that runs icacls to grant sandbox read/execute permissions. |
| packages/desktop/electron-builder.config.ts | Configures electron-builder to include the new NSIS hook. |
| packages/desktop/electron-builder.config.test.ts | Adds a test asserting the Windows installer hook include is present for each release channel. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+4
to
+6
| nsExec::ExecToLog '"$SYSDIR\icacls.exe" "$INSTDIR" /grant "*S-1-15-2-2:(OI)(CI)(RX)"' | ||
| Pop $0 | ||
| !macroend |
Comment on lines
+21
to
+31
| test(`includes the Windows sandbox permission hook for ${channel.channel}`, async () => { | ||
| const previous = process.env.OPENCODE_CHANNEL | ||
| process.env.OPENCODE_CHANNEL = channel.channel | ||
| const config = (await import(`./electron-builder.config.ts?channel=${channel.channel}`)).default as Configuration | ||
| if (previous === undefined) delete process.env.OPENCODE_CHANNEL | ||
| else process.env.OPENCODE_CHANNEL = previous | ||
|
|
||
| const include = path.join(import.meta.dirname, "resources/windows/installer.nsh") | ||
| expect(config.nsis?.include).toBe(include) | ||
| expect(await Bun.file(include).exists()).toBe(true) | ||
| }) |
Comment on lines
+2
to
+12
| import { mkdtemp, rm } from "node:fs/promises" | ||
| import os from "node:os" | ||
| import path from "node:path" | ||
|
|
||
| // Set OPENCODE_NSIS_PATH to electron-builder's makensis.exe to run the native hook. | ||
| test.skipIf(process.platform !== "win32" || !process.env.OPENCODE_NSIS_PATH)( | ||
| "installer grants sandbox access without changing unrelated permissions", | ||
| async () => { | ||
| const dir = await mkdtemp(path.join(os.tmpdir(), "opencode-installer-")) | ||
| const config = (await import("../electron-builder.config")).default | ||
| const run = async (cmd: string[]) => { |
Member
Author
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.


ALL RESTRICTED APPLICATION PACKAGESinheritable read/execute access to$INSTDIRafter NSIS extraction, including updates, following Electron's installer guidance.