Skip to content

fix(desktop): grant Windows sandbox access during installation - #46696

Merged
Hona merged 4 commits into
anomalyco:v2from
Hona:installer-permissions
Sep 2, 2026
Merged

fix(desktop): grant Windows sandbox access during installation#46696
Hona merged 4 commits into
anomalyco:v2from
Hona:installer-permissions

Conversation

@Hona

@Hona Hona commented Sep 2, 2026

Copy link
Copy Markdown
Member

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 customInstall hook that runs icacls to grant (OI)(CI)(RX) to S-1-15-2-2 for $INSTDIR.
  • Wire the hook into electron-builder via nsis.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[]) => {
@Hona

Hona commented Sep 2, 2026

Copy link
Copy Markdown
Member Author
  • Exercised the real V2 desktop from 1722728ce4 on Windows 11 x64 using a temporary app identity, URL scheme, and isolated profile. The NSIS permission hook was unchanged; automatic updates were disabled.
  • Fresh install, upgrade from test version 1 to 2, and reinstall completed successfully. The upgrade restored sandbox RX after removing the test installation's grant and adding an inherited synthetic AppContainer SID.
  • The real UI opened after installation. An unsubmitted draft survived reinstall, and its database was byte-identical across the installer run.
  • Uninstall removed the application and shortcuts. The runtime-created test URL registration needed separate cleanup; only the test-owned entry was removed. Recorded existing installation hashes, ACLs, protocol entries, and live service PIDs were unchanged.
  • Local artifacts were unsigned, so this does not cover release signing, SmartScreen, ARM64, or the automatic update feed.
Fresh Install Draft Restored After Reinstall
Temporary V2 desktop after fresh installation Unsubmitted test draft restored after reinstall

@Hona
Hona merged commit 0b77103 into anomalyco:v2 Sep 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants