7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
fix(desktop): ship chrome-sandbox mode 4755 in Linux .deb (#1240)
rome-xif4f5e977953e
diff --git a/desktop/electron-builder.yml b/desktop/electron-builder.ymlindex e17960a4..c192b125 100644--- a/desktop/electron-builder.yml+++ b/desktop/electron-builder.yml@@ -19,6 +19,9 @@ publish:owner: tashfeenahmedrepo: freellmapiasar: true+# Linux chrome-sandbox must be mode 4755 (setuid) in the .deb; otherwise+# Electron aborts at launch (#1229). Path is relative to desktop/.+afterPack: ./scripts/after-pack-linux-sandbox.mjsasarUnpack:- "**/node_modules/better-sqlite3/**/*.node"- "**/node_modules/better-sqlite3/build/Release/**"diff --git a/desktop/scripts/after-pack-linux-sandbox.mjs b/desktop/scripts/after-pack-linux-sandbox.mjsnew file mode 100644index 00000000..f2bddbbe--- /dev/null+++ b/desktop/scripts/after-pack-linux-sandbox.mjs@@ -0,0 +1,21 @@+// electron-builder copies chrome-sandbox into appOutDir as 0755. Electron then+// refuses to start on Linux unless that helper is root-owned mode 4755+// (setuid). afterPack runs after the files are staged and before fpm/deb, so+// chmod here is what the installed /opt/FreeLLMAPI/chrome-sandbox inherits.+// See #1229. Do not "fix" this with --no-sandbox.+import { chmodSync, existsSync } from 'node:fs';+import { join } from 'node:path';++export const LINUX_SANDBOX_NAME = 'chrome-sandbox';+export const LINUX_SANDBOX_MODE = 0o4755;++export function chmodLinuxChromeSandbox(appOutDir) {+ const sandbox = join(appOutDir, LINUX_SANDBOX_NAME);+ if (!existsSync(sandbox)) return;+ chmodSync(sandbox, LINUX_SANDBOX_MODE);+}++export default async function afterPack(context) {+ if (context.electronPlatformName !== 'linux') return;+ chmodLinuxChromeSandbox(context.appOutDir);+}diff --git a/desktop/src/__tests__/linux-chrome-sandbox-packaging.test.ts b/desktop/src/__tests__/linux-chrome-sandbox-packaging.test.tsnew file mode 100644index 00000000..92d4be12--- /dev/null+++ b/desktop/src/__tests__/linux-chrome-sandbox-packaging.test.ts@@ -0,0 +1,77 @@+import { chmodSync, existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';+import { createRequire } from 'node:module';+import { tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath, pathToFileURL } from 'node:url';+import { afterEach, describe, expect, it } from 'vitest';++// #1229: the Linux .deb ships chrome-sandbox as 755. Electron then aborts:+// "The SUID sandbox helper binary was found, but is not configured correctly.+// You need to make sure that /opt/FreeLLMAPI/chrome-sandbox is owned by root+// and has mode 4755." afterPack chmod's the helper before fpm packs the deb.++const yaml = createRequire(import.meta.url)('js-yaml');+const here = dirname(fileURLToPath(import.meta.url));+const desktopRoot = resolve(here, '../..');+const builderConfigPath = join(desktopRoot, 'electron-builder.yml');+const afterPackRel = './scripts/after-pack-linux-sandbox.mjs';+const afterPackPath = resolve(desktopRoot, afterPackRel);++describe('linux chrome-sandbox packaging (#1229)', () => {+ it('wires afterPack to a script that sets chrome-sandbox mode 4755', () => {+ const config = yaml.load(readFileSync(builderConfigPath, 'utf8')) as {+ afterPack?: string;+ linux?: { target?: Array<{ target?: string }> };+ };+ const linuxTargets = (config.linux?.target ?? []).map((entry) => entry.target);+ expect(linuxTargets).toContain('deb');+ expect(config.afterPack).toBe(afterPackRel);+ expect(existsSync(afterPackPath)).toBe(true);++ const source = readFileSync(afterPackPath, 'utf8');+ expect(source).toMatch(/chrome-sandbox/);+ expect(source).toMatch(/0o4755/);+ });++ describe('afterPack helper', () => {+ let directory: string;++ afterEach(() => {+ if (directory) rmSync(directory, { recursive: true, force: true });+ });++ async function loadHelper() {+ return import(pathToFileURL(afterPackPath).href) as Promise<{+ chmodLinuxChromeSandbox: (appOutDir: string) => void;+ default: (context: { electronPlatformName: string; appOutDir: string }) => Promise<void>;+ }>;+ }++ // Windows chmod/stat does not preserve Unix mode bits (0o755 → 0o666).+ it.skipIf(process.platform !== 'linux')('chmodSyncs a 0755 chrome-sandbox to 0o4755 on linux', async () => {+ const { chmodLinuxChromeSandbox, default: afterPack } = await loadHelper();+ directory = mkdtempSync(join(tmpdir(), 'linux-sandbox-'));+ const sandbox = join(directory, 'chrome-sandbox');+ writeFileSync(sandbox, 'fake-sandbox');+ // 0o755 — the mode electron-builder leaves the helper at today.+ chmodSync(sandbox, 0o755);+ expect(statSync(sandbox).mode & 0o7777).toBe(0o755);++ chmodLinuxChromeSandbox(directory);+ expect(statSync(sandbox).mode & 0o7777).toBe(0o4755);++ // Default hook is the electron-builder afterPack entry: linux only.+ chmodSync(sandbox, 0o755);+ await afterPack({ electronPlatformName: 'darwin', appOutDir: directory });+ expect(statSync(sandbox).mode & 0o7777).toBe(0o755);+ await afterPack({ electronPlatformName: 'linux', appOutDir: directory });+ expect(statSync(sandbox).mode & 0o7777).toBe(0o4755);+ });++ it('is a no-op when chrome-sandbox is absent', async () => {+ const { chmodLinuxChromeSandbox } = await loadHelper();+ directory = mkdtempSync(join(tmpdir(), 'linux-sandbox-missing-'));+ expect(() => chmodLinuxChromeSandbox(directory)).not.toThrow();+ });+ });+});