improve native isolation

This commit is contained in:
olcxja 2026-10-07 08:26:57 +02:00
commit 9748b98163
15 changed files with 341 additions and 95 deletions

View file

@ -38,6 +38,8 @@ function loadGames() {
g[k] = usePrefix && isPrefixRel(g[k]) ? path.join(usePrefix, g[k]) : resolvePortablePath(g[k])
}
if (g.iconSource) g.iconSource = resolvePortablePath(g.iconSource)
// an entry written by an older launcher keeps its meaning
if (g.isolation !== undefined) g.isolation = isolationMode(g.isolation)
const ps = readPlaySeconds(g.id)
if (ps != null) g.playSeconds = ps
}
@ -114,17 +116,26 @@ function isLinuxGame(game) {
return !!game && game.kind === 'linux'
}
const ISOLATION_MODES = ['auto', 'off', 'require']
// none = plain run, relaxed = bwrap + the whole host filesystem mounted rw,
// isolated = bwrap + handed documents copied in, auto = relaxed where bwrap
// works and none where it does not.
const ISOLATION_MODES = ['auto', 'none', 'relaxed', 'isolated']
// Modes written by launcher 0.5.x: `off` was the plain run, `require` was
// "bwrap or refuse" - which is exactly what the strictest level means now.
const LEGACY_ISOLATION_MODES = { off: 'none', require: 'isolated' }
// One known mode, always: an unknown value would otherwise reach the runner
// and pick something nobody asked for.
function isolationMode(value) {
const mode = LEGACY_ISOLATION_MODES[value] || value
return ISOLATION_MODES.includes(mode) ? mode : 'auto'
}
// Only known values reach the registry; anything else falls back to the safe
// default (a typo must not silently disable the sandbox).
function sanitizeLinuxPatch(patch) {
if (!patch) return patch
const out = { ...patch }
if (out.kind !== undefined) out.kind = out.kind === 'linux' ? 'linux' : 'windows'
if (out.isolation !== undefined) {
out.isolation = ISOLATION_MODES.includes(out.isolation) ? out.isolation : 'auto'
}
if (out.isolation !== undefined) out.isolation = isolationMode(out.isolation)
if (out.forceX11 !== undefined) out.forceX11 = !!out.forceX11
return out
}
@ -211,7 +222,7 @@ function newGame({ id, name, exePath, workdir, mode, kind }) {
dllOverrides: [],
// Proton-only: UMU by default, or the build's steam.exe launcher
disableUmu: false,
// Linux-only: how hard to try the bwrap sandbox before falling back
// Linux-only: none, relaxed, isolated, or auto (relaxed where bwrap works)
isolation: 'auto',
// Linux-only: force XWayland, where a window can still carry its icon
forceX11: false,