fix(server): scrub AppImage XDG_DATA_DIRS and GSETTINGS_SCHEMA_DIR from terminals (#5075)
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
1 parent
37ae1abbe9
commit
c30a6d9b99
2 files changed
+20
-4
No files matched your search
@@ -1400,6 +1400,8 @@ it.layer(
|
||||
OWD: "/home/user/project",
|
||||
PATH: `${appDir}/usr/bin:${appDir}:/usr/local/bin:/usr/bin:/bin`,
|
||||
LD_LIBRARY_PATH: `${appDir}/usr/lib:/home/user/.local/lib`,
|
||||
XDG_DATA_DIRS: `${appDir}/usr/share:/usr/local/share:/usr/share`,
|
||||
GSETTINGS_SCHEMA_DIR: `${appDir}/usr/share/glib-2.0/schemas`,
|
||||
TEST_TERMINAL_KEEP: "keep-me",
|
||||
},
|
||||
});
|
||||
@@ -1419,6 +1421,11 @@ it.layer(
|
||||
// mount segments that the runtime prepended.
|
||||
expect(spawnInput.env.PATH).toBe("/usr/local/bin:/usr/bin:/bin");
|
||||
expect(spawnInput.env.LD_LIBRARY_PATH).toBe("/home/user/.local/lib");
|
||||
// XDG_DATA_DIRS keeps the host entries but drops the AppImage share dir.
|
||||
expect(spawnInput.env.XDG_DATA_DIRS).toBe("/usr/local/share:/usr/share");
|
||||
// GSETTINGS_SCHEMA_DIR pointed only at the mount, so it is removed and
|
||||
// gsettings falls back to the host schema location.
|
||||
expect(spawnInput.env.GSETTINGS_SCHEMA_DIR).toBeUndefined();
|
||||
// Unrelated host vars still pass through untouched.
|
||||
expect(spawnInput.env.TEST_TERMINAL_KEEP).toBe("keep-me");
|
||||
}),
|
||||
|
||||
@@ -1097,10 +1097,19 @@ function shouldExcludeTerminalEnvKey(key: string): boolean {
|
||||
// They describe the AppImage itself, not the user's session, so terminals must
|
||||
// not inherit them.
|
||||
const APPIMAGE_RUNTIME_ENV_KEYS = ["APPIMAGE", "APPDIR", "ARGV0", "OWD"] as const;
|
||||
// PATH-style variables the AppImage runtime prepends with its temporary mount
|
||||
// (e.g. /tmp/.mount_T3-XXXX/usr/bin). Only the mount segments are dropped; the
|
||||
// user's real entries are preserved.
|
||||
const APPIMAGE_PATH_LIKE_ENV_KEYS = ["PATH", "LD_LIBRARY_PATH"] as const;
|
||||
// Colon-separated search-path variables the AppImage runtime points at its
|
||||
// temporary mount (e.g. /tmp/.mount_T3-XXXX/usr/bin, the bundled glib schemas,
|
||||
// and an $APPDIR/usr/share XDG data entry). Only the mount segments are
|
||||
// dropped; the user's real entries are preserved. When nothing but mount
|
||||
// segments remain the variable is removed entirely so consumers fall back to
|
||||
// their platform default (e.g. gsettings finds the host schemas instead of
|
||||
// reporting "No schemas installed"). See issues #1699 and #5059.
|
||||
const APPIMAGE_PATH_LIKE_ENV_KEYS = [
|
||||
"PATH",
|
||||
"LD_LIBRARY_PATH",
|
||||
"XDG_DATA_DIRS",
|
||||
"GSETTINGS_SCHEMA_DIR",
|
||||
] as const;
|
||||
|
||||
function isPathSegmentUnderAppDir(segment: string, appDir: string): boolean {
|
||||
return segment === appDir || segment.startsWith(`${appDir}/`);
|
||||
|
||||
Reference in new issue
Block a user