GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #352 from shuv1337/fix/linux-deb-write-bits · shuv1337/s2code@2de863c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • knip.jsonc
  • scripts
    • build-desktop-artifact.ts
    • linux-after-pack.test.ts
    • linux-after-pack.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎knip.jsonc‎

Copy file name to clipboardExpand all lines: knip.jsonc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
// Knip loads its preprocessor through a CLI option; native verification and
2121
// worktree setup (from t3.json) run directly. release-desktop.yml bundles the
2222
// Windows verify script with esbuild through a path knip does not trace,
23-
// electron-builder loads the macOS signer by path, and mobile-e2e.ts runs
23+
// electron-builder loads the macOS signer and the Linux afterPack hook by path, and mobile-e2e.ts runs
2424
// agent-device's CLI by path, and mobile-behavior.ts spawns its runner by path.
2525
// release-desktop.yml runs the desktop launch check through xvfb-run, which knip
2626
// does not trace. release-smoke.ts runs the nightly resolver by path.
2727
"entry": [
2828
// These fixture scripts are injected into a browser page by path.
2929
"fixtures/*/*.js",
3030
"knip-schemas.ts",
31+
"linux-after-pack.ts",
3132
"mobile-behavior/run.ts",
3233
"mobile-native-client.ts",
3334
"resolve-nightly-release.ts",
Collapse file

‎scripts/build-desktop-artifact.ts‎

Copy file name to clipboardExpand all lines: scripts/build-desktop-artifact.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3188,6 +3188,7 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
31883188
buildConfig.toolsets = { appimage: "1.0.3" };
31893189
const path = yield* Path.Path;
31903190
const repoRoot = yield* RepoRoot;
3191+
buildConfig.afterPack = path.join(repoRoot, "scripts/linux-after-pack.ts");
31913192
buildConfig.linux = {
31923193
target: target === "AppImage" ? [target, "deb"] : [target],
31933194
executableName: identity.executableName,
Collapse file

‎scripts/linux-after-pack.test.ts‎

Copy file name to clipboard
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// @effect-diagnostics nodeBuiltinImport:off - Applies real file modes in a temporary app folder.
2+
import * as HostProcess from "@t3tools/shared/HostProcess";
3+
import * as NodeFSP from "node:fs/promises";
4+
import * as NodeOS from "node:os";
5+
import * as NodePath from "node:path";
6+
import { describe, expect, it } from "vite-plus/test";
7+
8+
import { removeSharedWriteAccess } from "./linux-after-pack.ts";
9+
10+
describe.skipIf(HostProcess.Platform.defaultValue() === "win32")("removeSharedWriteAccess", () => {
11+
it("removes group and other write access from the packed app only", async () => {
12+
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-after-pack-"));
13+
try {
14+
const appOutDir = NodePath.join(root, "app");
15+
const modes = {
16+
"app/t3code": [0o777, 0o755],
17+
"app/resources.pak": [0o666, 0o644],
18+
"app/chrome-sandbox": [0o4777, 0o4755],
19+
"app/resources/app.asar": [0o644, 0o644],
20+
"outside/file": [0o666, 0o666],
21+
} as const;
22+
await NodeFSP.mkdir(NodePath.join(appOutDir, "resources"), { recursive: true });
23+
await NodeFSP.mkdir(NodePath.join(root, "outside"));
24+
for (const [file, [before]] of Object.entries(modes)) {
25+
await NodeFSP.writeFile(NodePath.join(root, file), "");
26+
await NodeFSP.chmod(NodePath.join(root, file), before);
27+
}
28+
await NodeFSP.chmod(NodePath.join(appOutDir, "resources"), 0o777);
29+
await NodeFSP.symlink("../outside", NodePath.join(appOutDir, "linked-dir"));
30+
31+
await removeSharedWriteAccess(appOutDir);
32+
33+
for (const [file, [, after]] of Object.entries(modes)) {
34+
const { mode } = await NodeFSP.stat(NodePath.join(root, file));
35+
expect([file, mode & 0o7777]).toEqual([file, after]);
36+
}
37+
const { mode: resourcesMode } = await NodeFSP.stat(NodePath.join(appOutDir, "resources"));
38+
expect(resourcesMode & 0o7777).toBe(0o755);
39+
} finally {
40+
await NodeFSP.rm(root, { recursive: true, force: true });
41+
}
42+
});
43+
});
Collapse file

‎scripts/linux-after-pack.ts‎

Copy file name to clipboard
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @effect-diagnostics nodeBuiltinImport:off
2+
import * as NodeFSP from "node:fs/promises";
3+
import * as NodePath from "node:path";
4+
5+
interface AfterPackContext {
6+
readonly appOutDir: string;
7+
}
8+
9+
// Electron's Linux zips can ship world-writable files (44.10.0 has 0777 binaries), and
10+
// electron-builder copies zip modes verbatim into the .deb and AppImage.
11+
export default async function afterPack(context: AfterPackContext): Promise<void> {
12+
await removeSharedWriteAccess(context.appOutDir);
13+
}
14+
15+
// Walks by hand: recursive readdir follows directory symlinks out of the app folder.
16+
export async function removeSharedWriteAccess(path: string): Promise<void> {
17+
const stats = await NodeFSP.lstat(path);
18+
if (stats.isSymbolicLink()) return;
19+
if (stats.mode & 0o022) await NodeFSP.chmod(path, stats.mode & 0o7755);
20+
if (!stats.isDirectory()) return;
21+
for (const entry of await NodeFSP.readdir(path)) {
22+
await removeSharedWriteAccess(NodePath.join(path, entry));
23+
}
24+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.