Repository navigation
fix(desktop): strip group/world write bits from Linux package files - #352
Merged
Merged
Conversation
Electron's Linux zips ship world-writable files (0777 binaries, 0666 paks), and electron-builder copies those modes verbatim into the .deb and AppImage. Register a Linux afterPack hook that walks the packed app with lstat, skips symlinks, and clears group/other write bits. Ports pingdotgg#28351 (bfa1ff6) without its compile-cache step. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Electron's Linux zips ship world-writable files (0777 binaries, 0666
.paks), and electron-builder copies those modes verbatim into the.deband AppImage. The current nightly.deb(v0.1.5-nightly.20261101.79, amd64) installs 14 world-writable files under/opt/S2Code (Nightly), including the main executable andchrome-sandbox.Ports upstream pingdotgg/t3code#28351 (bfa1ff6):
scripts/linux-after-pack.ts: an electron-builderafterPackhook that walksappOutDirwithlstat, skips symlinks (so it never follows a link out of the app folder), and runschmod(path, mode & 0o7755)on any entry with group/other write bits set.buildConfig.afterPackin the Linux branch ofscripts/build-desktop-artifact.ts.scripts/linux-after-pack.test.ts), which covers 0777, 0666, setuid 0o4777, and 0777 directories, and checks that a file reached through a symlinked directory outside the app keeps its mode.scriptsentries inknip.jsonc, since electron-builder loads it by path.Deviation from upstream: upstream's hook also calls
prepare-server-compile-cache.cjs. This fork doesn't have that file, so that call is left out.Verification
vp test run scripts/linux-after-pack.test.ts: 1 file, 1 test passed.vp run knip:check: passes. Plainvp run knipexits 1, but its findings are identical to unmodifiedHEAD(5bbc455) and none of them involvelinux-after-pack.vp run --filter t3 --filter @t3tools/contracts --filter @t3tools/shared --filter @t3tools/web --filter @t3tools/scripts typecheck: 5/5 successful.vp run check:changed: format, lint, knip 1/2 and 2/2, typecheck (40 packages), and tests (3 files, 68 tests) all pass.Packaging proof
build-desktop-artifact.tsrefuses to package Linux on a non-Linux host (LinuxBrowserSecretHostError: the libsecret helper must be built on Linux), so this was done on macOS against the published nightly instead. I extracteddata.tar.xzfromS2Code-0.1.5-nightly.20261101.79-amd64.debwith bsdtar (tar -xpf, which preserves modes) and ran the hook's default export withappOutDirset to the extractedopt/S2Code (Nightly)directory.find "$OPT" -perm -o+w ! -type llisted 14 files (chrome-sandbox,s2code-nightly,chrome_crashpad_handler,libffmpeg.so,libvk_swiftshader.so,libvulkan.so.1,resources.pak,chrome_100_percent.pak,chrome_200_percent.pak,locales/en-US.pak,LICENSES.chromium.html,snapshot_blob.bin,v8_context_snapshot.bin,vk_swiftshader_icd.json). These match the archive's owntar -tvflisting.findprints nothing (0 world-writable and 0 group-writable entries). The executables are now-rwxr-xr-xand the data files-rw-r--r--.Ported with Claude Opus via Cursor in T3 Code.