ubuntu not working. idk I'm just gonna use windows anyway
This commit is contained in:
@@ -60,6 +60,26 @@ function sanitizeElectronEnv(baseEnv = process.env) {
|
||||
return env;
|
||||
}
|
||||
|
||||
function linuxSandboxLaunchArgs({
|
||||
electronPath,
|
||||
platform = process.platform,
|
||||
statSync = fs.statSync,
|
||||
} = {}) {
|
||||
if (platform !== 'linux') return [];
|
||||
if (!electronPath) return ['--no-sandbox'];
|
||||
|
||||
const helperPath = path.join(path.dirname(electronPath), 'chrome-sandbox');
|
||||
try {
|
||||
const stat = statSync(helperPath);
|
||||
const ownedByRoot = stat.uid === 0;
|
||||
const hasSetuid = Boolean(stat.mode & 0o4000);
|
||||
if (ownedByRoot && hasSetuid) return [];
|
||||
} catch {
|
||||
// Missing or unreadable helper: fall back to the unsandboxed launcher.
|
||||
}
|
||||
return ['--no-sandbox'];
|
||||
}
|
||||
|
||||
function electronBinaryCandidates({ packageRoot, distDir, platform }) {
|
||||
const candidatePaths = [];
|
||||
const pathHint = packageRoot ? readElectronPathHint(packageRoot) : null;
|
||||
@@ -292,6 +312,7 @@ module.exports = {
|
||||
runNpmRebuild,
|
||||
runNpmInstall,
|
||||
sanitizeElectronEnv,
|
||||
linuxSandboxLaunchArgs,
|
||||
resolveElectronBinary,
|
||||
resolveElectronPackageRoot,
|
||||
platformBinaryCandidates,
|
||||
|
||||
@@ -46,8 +46,21 @@ fi
|
||||
cat > "$WORK_DIR/usr/bin/stepforge" <<'EOF'
|
||||
#!/usr/bin/env sh
|
||||
APP_DIR=/opt/stepforge
|
||||
ELECTRON="$APP_DIR/node_modules/.bin/electron"
|
||||
SANDBOX_HELPER="$APP_DIR/node_modules/electron/dist/chrome-sandbox"
|
||||
cd "$APP_DIR" || exit 1
|
||||
exec "$APP_DIR/node_modules/.bin/electron" "$APP_DIR" "$@"
|
||||
if command -v stat >/dev/null 2>&1 && [ -e "$SANDBOX_HELPER" ]; then
|
||||
helper_uid="$(stat -c '%u' "$SANDBOX_HELPER" 2>/dev/null || echo '')"
|
||||
helper_mode="$(stat -c '%a' "$SANDBOX_HELPER" 2>/dev/null || echo '')"
|
||||
if [ "$helper_uid" = "0" ] && [ -n "$helper_mode" ]; then
|
||||
helper_mode_num=$((8#$helper_mode))
|
||||
if [ $((helper_mode_num & 04000)) -ne 0 ]; then
|
||||
exec "$ELECTRON" "$APP_DIR" "$@"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
printf '%s\n' '[stepforge] Electron sandbox helper is not configured for this install; starting with --no-sandbox' >&2
|
||||
exec "$ELECTRON" --no-sandbox "$APP_DIR" "$@"
|
||||
EOF
|
||||
chmod 0755 "$WORK_DIR/usr/bin/stepforge"
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
|
||||
const { spawn } = require('node:child_process');
|
||||
|
||||
const { resolveElectronBinary, sanitizeElectronEnv } = require('./electron-launcher');
|
||||
const {
|
||||
linuxSandboxLaunchArgs,
|
||||
resolveElectronBinary,
|
||||
sanitizeElectronEnv,
|
||||
} = require('./electron-launcher');
|
||||
|
||||
let electronPath;
|
||||
try {
|
||||
@@ -13,11 +17,16 @@ try {
|
||||
process.exit(1);
|
||||
}
|
||||
const env = sanitizeElectronEnv();
|
||||
const sandboxArgs = linuxSandboxLaunchArgs({ electronPath });
|
||||
if (sandboxArgs.includes('--no-sandbox')) {
|
||||
console.warn('[stepforge] Electron sandbox helper is not configured for this install; starting with --no-sandbox');
|
||||
}
|
||||
|
||||
// On Linux/Wayland, enable PipeWire-based screen capture so desktopCapturer
|
||||
// can go through the XDG Desktop Portal when XWayland isn't the only option.
|
||||
// On Linux, prefer the native Ozone path when available and enable PipeWire-
|
||||
// based screen capture so desktopCapturer can go through the XDG Desktop
|
||||
// Portal on Wayland without affecting X11.
|
||||
const extraArgs = process.platform === 'linux'
|
||||
? ['--enable-features=WebRTCPipeWireCapturer']
|
||||
? ['--enable-features=WebRTCPipeWireCapturer', '--ozone-platform-hint=auto', ...sandboxArgs]
|
||||
: [];
|
||||
|
||||
const child = spawn(electronPath, [...extraArgs, '.'], {
|
||||
|
||||
Reference in New Issue
Block a user