Skip to content

Commit 1d9bd91

Browse files
fix(desktop): AppImage relaunch helper ignores BASH_ENV and exported functions
An exported exec function could hijack the plain bash -c helper, and BASH_ENV ran before inherited descriptors were closed. bash -p skips both in the helper; the relaunched AppImage still receives them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b6a2818 commit 1d9bd91

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎apps/desktop/src/electron/ElectronUpdater.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type SpawnLog = (cmd: string, args?: Array<string>, ...rest: Array<unknown>) =>
1212
// Electron holds the AppImage runtime's keepalive pipe and some files without O_CLOEXEC; a
1313
// relaunched AppImage inherits them, so old runtimes and FUSE mounts never exit. bash (AppRun
1414
// already needs it; dash cannot close multi-digit fds) closes them before exec'ing the AppImage.
15+
// -p skips BASH_ENV and exported functions in the helper only; the AppImage still receives both.
1516
const CLOSE_INHERITED_FDS_THEN_EXEC =
1617
'for fd in /proc/self/fd/*; do fd=${fd##*/}; case $fd in *[!0-9]*|[012]) ;; *) eval "exec $fd>&-" ;; esac; done; exec "$@"';
1718

@@ -21,7 +22,7 @@ const relaunchWithoutInheritedDescriptors = (updater: AppImageUpdater) => {
2122
return spawnLog.call(
2223
this,
2324
"bash",
24-
["-c", CLOSE_INHERITED_FDS_THEN_EXEC, cmd, cmd, ...args],
25+
["-p", "-c", CLOSE_INHERITED_FDS_THEN_EXEC, cmd, cmd, ...args],
2526
...rest,
2627
);
2728
};

0 commit comments

Comments
 (0)