mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-05 14:45:25 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
765aec33e5 |
@@ -6,7 +6,7 @@ import {
|
||||
validatePort,
|
||||
validateSshHost,
|
||||
} from "@getpaseo/protocol/ssh-transport";
|
||||
import { stripAppImageRuntimeEnv } from "@getpaseo/server/process";
|
||||
import { stripLinuxDesktopRuntimeEnv } from "@getpaseo/server/process";
|
||||
|
||||
export interface SshProxyTarget {
|
||||
host: string;
|
||||
@@ -59,7 +59,7 @@ export function buildSshSpawnEnv(
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): NodeJS.ProcessEnv {
|
||||
const env = { ...baseEnv };
|
||||
stripAppImageRuntimeEnv(env, { platform });
|
||||
stripLinuxDesktopRuntimeEnv(env, { platform });
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { existsSync as nodeExistsSync, readdirSync as nodeReaddirSync } from "no
|
||||
import { readFile } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path, { posix, win32 } from "node:path";
|
||||
import { stripAppImageRuntimeEnv } from "@getpaseo/server/process";
|
||||
import { stripLinuxDesktopRuntimeEnv } from "@getpaseo/server/process";
|
||||
import { app, shell } from "electron";
|
||||
|
||||
import type {
|
||||
@@ -53,7 +53,7 @@ function createExternalProcessEnv(
|
||||
for (const key of RUNTIME_CONTROL_ENV_KEYS) {
|
||||
delete env[key];
|
||||
}
|
||||
stripAppImageRuntimeEnv(env, { platform });
|
||||
stripLinuxDesktopRuntimeEnv(env, { platform });
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (value === undefined) {
|
||||
delete env[key];
|
||||
|
||||
@@ -7,7 +7,7 @@ import { spawnSync as defaultSpawnSync } from "node:child_process";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { userInfo as defaultUserInfo } from "node:os";
|
||||
import { basename } from "node:path";
|
||||
import { stripAppImageRuntimeEnv } from "@getpaseo/server/process";
|
||||
import { stripLinuxDesktopRuntimeEnv } from "@getpaseo/server/process";
|
||||
import defaultLog from "electron-log/main";
|
||||
|
||||
const DEFAULT_RESOLVE_TIMEOUT_MS = 30_000;
|
||||
@@ -410,7 +410,7 @@ function resolveShellEnv({ deps, timeoutMs }: ResolveShellEnvInput): ResolvedShe
|
||||
delete shellEnv.PASEO_NODE_ENV;
|
||||
delete shellEnv.PASEO_DESKTOP_MANAGED;
|
||||
delete shellEnv.PASEO_SUPERVISED;
|
||||
stripAppImageRuntimeEnv(shellEnv, { platform: deps.platform });
|
||||
stripLinuxDesktopRuntimeEnv(shellEnv, { platform: deps.platform });
|
||||
|
||||
deps.logger.info("[login-shell-env] start", {
|
||||
shell,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { daemonLaunchEnvironment } from "./config-environment.js";
|
||||
|
||||
describe("daemonLaunchEnvironment AppImage sanitization", () => {
|
||||
describe("daemonLaunchEnvironment", () => {
|
||||
const appDir = "/tmp/.mount_Paseo-abcdef";
|
||||
|
||||
test("strips AppImage runtime variables in both managed and deployment modes", () => {
|
||||
@@ -47,6 +47,40 @@ describe("daemonLaunchEnvironment AppImage sanitization", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test.each(["Paseo.desktop", "paseo-desktop.desktop"])(
|
||||
"keeps the desktop identity %s out of a Linux managed daemon",
|
||||
(identity) => {
|
||||
const inputEnv = {
|
||||
CHROME_DESKTOP: identity,
|
||||
PASEO_DESKTOP_SANDBOX_REASON: "user namespaces available",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
const result = daemonLaunchEnvironment({
|
||||
env: inputEnv,
|
||||
home: "/home/user/.paseo",
|
||||
mode: "managed",
|
||||
desktopManaged: true,
|
||||
platform: "linux",
|
||||
});
|
||||
|
||||
expect(result.CHROME_DESKTOP).toBeUndefined();
|
||||
expect(result.PASEO_DESKTOP_SANDBOX_REASON).toBeUndefined();
|
||||
expect(result.PATH).toBe("/usr/bin");
|
||||
expect(result.PASEO_DESKTOP_MANAGED).toBe("1");
|
||||
expect(inputEnv.CHROME_DESKTOP).toBe(identity);
|
||||
},
|
||||
);
|
||||
|
||||
test("preserves an unrelated Chromium desktop identity", () => {
|
||||
const result = daemonLaunchEnvironment({
|
||||
env: { CHROME_DESKTOP: "chromium.desktop" },
|
||||
home: "/home/user/.paseo",
|
||||
mode: "deployment",
|
||||
platform: "linux",
|
||||
});
|
||||
expect(result.CHROME_DESKTOP).toBe("chromium.desktop");
|
||||
});
|
||||
|
||||
test("preserves user ARGV0 without APPIMAGE or APPDIR", () => {
|
||||
const result = daemonLaunchEnvironment({
|
||||
env: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { stripAppImageRuntimeEnv } from "./paseo-env.js";
|
||||
import { stripLinuxDesktopRuntimeEnv } from "./paseo-env.js";
|
||||
|
||||
// Daemon configuration inputs. General provider credentials and executable/runtime
|
||||
// controls remain available to managed launches and their agent processes.
|
||||
@@ -90,7 +90,7 @@ export function daemonLaunchEnvironment(input: {
|
||||
}
|
||||
delete env.PASEO_HOST;
|
||||
delete env.PASEO_DESKTOP_MANAGED;
|
||||
stripAppImageRuntimeEnv(env, { platform: input.platform });
|
||||
stripLinuxDesktopRuntimeEnv(env, { platform: input.platform });
|
||||
env.PASEO_HOME = input.home;
|
||||
if (input.desktopManaged) env.PASEO_DESKTOP_MANAGED = "1";
|
||||
return env;
|
||||
|
||||
@@ -66,6 +66,15 @@ describe("paseo env contract", () => {
|
||||
expect(env.PATH).toBe("/custom/bin");
|
||||
});
|
||||
|
||||
test.runIf(process.platform === "linux")("strips Paseo desktop metadata after overlays", () => {
|
||||
const env = createExternalProcessEnv(baseEnv, {
|
||||
CHROME_DESKTOP: "Paseo.desktop",
|
||||
PASEO_DESKTOP_SANDBOX_REASON: "user namespaces available",
|
||||
});
|
||||
expect(env.CHROME_DESKTOP).toBeUndefined();
|
||||
expect(env.PASEO_DESKTOP_SANDBOX_REASON).toBeUndefined();
|
||||
});
|
||||
|
||||
test("applies non-control overlays to external process env", () => {
|
||||
const env = createExternalProcessEnv(baseEnv, { PATH: "/custom/bin" }, { CUSTOM: "value" });
|
||||
|
||||
|
||||
@@ -89,6 +89,21 @@ export function stripAppImageRuntimeEnv(
|
||||
}
|
||||
}
|
||||
|
||||
/** Keep Linux launcher metadata in the desktop process that owns it. */
|
||||
export function stripLinuxDesktopRuntimeEnv(
|
||||
env: ProcessEnvRecord,
|
||||
options?: { platform?: NodeJS.Platform },
|
||||
): void {
|
||||
const platform = options?.platform ?? process.platform;
|
||||
if (platform !== "linux") return;
|
||||
|
||||
if (env.CHROME_DESKTOP === "Paseo.desktop" || env.CHROME_DESKTOP === "paseo-desktop.desktop") {
|
||||
delete env.CHROME_DESKTOP;
|
||||
}
|
||||
delete env.PASEO_DESKTOP_SANDBOX_REASON;
|
||||
stripAppImageRuntimeEnv(env, { platform });
|
||||
}
|
||||
|
||||
function buildInternalProcessEnv<T extends ProcessEnvRecord>(baseEnv: T): T {
|
||||
return { ...baseEnv };
|
||||
}
|
||||
@@ -101,7 +116,7 @@ function buildExternalProcessEnv(
|
||||
for (const key of RUNTIME_CONTROL_ENV_KEYS) {
|
||||
delete sanitized[key];
|
||||
}
|
||||
stripAppImageRuntimeEnv(sanitized);
|
||||
stripLinuxDesktopRuntimeEnv(sanitized);
|
||||
for (const [key, value] of Object.entries(sanitized)) {
|
||||
if (value === undefined) {
|
||||
delete sanitized[key];
|
||||
|
||||
@@ -7,10 +7,11 @@ import {
|
||||
import {
|
||||
createExternalCommandProcessEnv,
|
||||
stripAppImageRuntimeEnv,
|
||||
stripLinuxDesktopRuntimeEnv,
|
||||
type ProcessEnvRecord,
|
||||
} from "../server/paseo-env.js";
|
||||
|
||||
export { stripAppImageRuntimeEnv };
|
||||
export { stripAppImageRuntimeEnv, stripLinuxDesktopRuntimeEnv };
|
||||
|
||||
interface ExternalEnvOptions {
|
||||
baseEnv?: ProcessEnvRecord;
|
||||
|
||||
Reference in New Issue
Block a user