dsh-plugin-wsl-env 0.26.3 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +142 -0
- package/CONTRIBUTING.md +32 -25
- package/CONTRIBUTING.zh.md +3 -2
- package/README.md +1 -1
- package/SECURITY.md +21 -7
- package/SECURITY.zh.md +18 -5
- package/SUPPORT.md +2 -2
- package/SUPPORT.zh.md +2 -2
- package/client.js +351 -48
- package/cordis.patch.yml +26 -10
- package/docs/AGENT-PROTOCOL-V7.md +4 -2
- package/docs/API.md +3 -1
- package/docs/API.zh.md +3 -1
- package/docs/ARCHITECTURE.md +22 -4
- package/docs/ARCHITECTURE.zh.md +18 -4
- package/docs/CONFIGURATION.md +117 -17
- package/docs/CONFIGURATION.zh.md +97 -11
- package/docs/DIAGNOSTICS.md +22 -11
- package/docs/DIAGNOSTICS.zh.md +17 -9
- package/docs/LIMITATIONS.md +27 -4
- package/docs/LIMITATIONS.zh.md +20 -3
- package/docs/MIGRATION.md +2 -2
- package/docs/MIGRATION.zh.md +2 -2
- package/docs/PARITY.md +3 -1
- package/docs/QUICKSTART.md +31 -20
- package/docs/QUICKSTART.zh.md +16 -9
- package/docs/README.zh.md +1 -1
- package/docs/RELEASING.md +25 -3
- package/docs/REQUIREMENTS.zh.md +7 -6
- package/docs/ROADMAP-1.0.md +11 -7
- package/lib/agent-confined.d.ts +9 -1
- package/lib/agent-confined.js +3 -3
- package/lib/agent.d.ts +54 -18
- package/lib/agent.js +86 -19
- package/lib/bwrap.d.ts +16 -0
- package/lib/bwrap.js +9 -0
- package/lib/fs-routing.d.ts +6 -0
- package/lib/fs-routing.js +7 -0
- package/lib/fs-substrate.d.ts +1 -1
- package/lib/fs-substrate.js +10 -18
- package/lib/fsio-agent.d.ts +4 -0
- package/lib/fsio-agent.js +37 -10
- package/lib/listing.d.ts +2 -2
- package/lib/listing.js +5 -4
- package/lib/messages.d.ts +70 -0
- package/lib/messages.js +80 -0
- package/lib/open-in-app.js +12 -9
- package/lib/picker.d.ts +4 -1
- package/lib/picker.js +35 -11
- package/lib/plugin-update.d.ts +212 -0
- package/lib/plugin-update.js +283 -0
- package/lib/ports.js +8 -1
- package/lib/provider-common.d.ts +22 -0
- package/lib/provider-common.js +18 -0
- package/lib/provider-marker.d.ts +23 -0
- package/lib/provider-marker.js +21 -0
- package/lib/sandbox-core.d.ts +2 -0
- package/lib/sandbox-core.js +5 -3
- package/lib/session-runtime.d.ts +10 -1
- package/lib/session-runtime.js +3 -1
- package/lib/shell-env.js +1 -1
- package/lib/socket-isolation.d.ts +103 -0
- package/lib/socket-isolation.js +166 -0
- package/lib/status.d.ts +21 -8
- package/lib/status.js +61 -23
- package/lib/subprocess.d.ts +3 -0
- package/lib/subprocess.js +5 -0
- package/lib/takeover-report.js +4 -11
- package/lib/update-check.d.ts +49 -9
- package/lib/update-check.js +81 -28
- package/lib/watcher.d.ts +1 -1
- package/lib/watcher.js +1 -1
- package/lib/wsl-doctor-command.d.ts +6 -2
- package/lib/wsl-doctor-command.js +24 -15
- package/lib/wsl-doctor-tool.js +2 -0
- package/lib/wsl-filesystem.d.ts +53 -12
- package/lib/wsl-filesystem.js +90 -31
- package/lib/wsl-shell.d.ts +109 -40
- package/lib/wsl-shell.js +128 -54
- package/package.json +8 -3
- package/scripts/doctor.mjs +199 -3
- package/scripts/profile-preset.mjs +10 -2
package/scripts/doctor.mjs
CHANGED
|
@@ -72,6 +72,8 @@ import { fileURLToPath } from "node:url";
|
|
|
72
72
|
import { parseDistroList } from "../lib/wsl.js";
|
|
73
73
|
import { AGENT_NAME, PROTOCOL_VERSION, encodeExecFrame, encodeFsbFrame, parseAgentLine } from "../lib/agent-protocol.js";
|
|
74
74
|
import { bwrapArgvPrefix } from "../lib/bwrap.js";
|
|
75
|
+
import { validateWritableRootsConfig, writableRootsCheckArgv } from "../lib/writable-roots.js";
|
|
76
|
+
import { parseSocketIsolationFacts, socketIsolationProbeScript, socketMaskPaths } from "../lib/socket-isolation.js";
|
|
75
77
|
import { sessionScopeSweepScript } from "../lib/session-scope.js";
|
|
76
78
|
import { parseListeningPorts, procNetScript } from "../lib/ports.js";
|
|
77
79
|
|
|
@@ -347,6 +349,9 @@ const QUICK_SECTIONS = ["host", "session", "sandbox"];
|
|
|
347
349
|
* @property {string} sandbox - the fs-routing confinement stance.
|
|
348
350
|
* @property {string} maskWindowsDrive - the drive-masking stance (when `interopVisibility` is unset).
|
|
349
351
|
* @property {string} interopVisibility - the one-key stance (`""` unset, `visible`, `masked` or `disabled`); when set it takes precedence over `maskWindowsDrive`.
|
|
352
|
+
* @property {string[]} writableRoots - the `wsl-shell` row's extra `workspace-write` grants (the command plane).
|
|
353
|
+
* @property {string[]} writableRootsFs - the `wsl-fs` row's grants; the two rows must agree.
|
|
354
|
+
* @property {string} socketIsolation - the command/write rows' socket stance (`off`, `session-bus` or `strict`).
|
|
350
355
|
* @property {string} source - where the values came from.
|
|
351
356
|
* @property {string[]} overrides - the profile layers that changed keys, "`<name>`: `<keys>`".
|
|
352
357
|
*/
|
|
@@ -547,6 +552,48 @@ export function rowKey(block, key) {
|
|
|
547
552
|
return (/** @type {RegExpExecArray} */ (match)[1] ?? "").trim().replace(/^['"]|['"]$/g, "");
|
|
548
553
|
}
|
|
549
554
|
|
|
555
|
+
/**
|
|
556
|
+
* The list one key sets inside a row block, accepting the two YAML spellings
|
|
557
|
+
* the documentation uses: a flow list (`writableRoots: ['~/.npm', '~/.cache']`)
|
|
558
|
+
* or a block list (the key line, then indented `- value` lines). Anything else
|
|
559
|
+
* is a scalar and is returned as a one-item list, so a mistaken single value
|
|
560
|
+
* still reaches the validation rather than disappearing.
|
|
561
|
+
* @param {string} block - the row block's text.
|
|
562
|
+
* @param {string} key - the YAML key.
|
|
563
|
+
* @returns {string[] | undefined} the items (`[]` for an empty list), or undefined when unset.
|
|
564
|
+
*/
|
|
565
|
+
export function rowList(block, key) {
|
|
566
|
+
const lines = block.split(/\r?\n/);
|
|
567
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
568
|
+
const match = new RegExp(`^(\\s*)${key}:\\s*(.*)$`).exec(/** @type {string} */ (lines[index]));
|
|
569
|
+
if (match === null) continue;
|
|
570
|
+
const indent = (match[1] ?? "").length;
|
|
571
|
+
const value = (match[2] ?? "").replace(/\s+#.*$/u, "").trim();
|
|
572
|
+
if (value.startsWith("[")) {
|
|
573
|
+
const inner = value.slice(1, value.endsWith("]") ? -1 : undefined);
|
|
574
|
+
/** @type {string[]} */
|
|
575
|
+
const items = [];
|
|
576
|
+
for (const item of inner.matchAll(/'([^']*)'|"([^"]*)"|([^,\s][^,]*)/gu)) {
|
|
577
|
+
const raw = (item[1] ?? item[2] ?? item[3] ?? "").trim();
|
|
578
|
+
if (raw.length > 0) items.push(raw.replace(/^['"]|['"]$/g, ""));
|
|
579
|
+
}
|
|
580
|
+
return items;
|
|
581
|
+
}
|
|
582
|
+
if (value.length > 0) return [value.replace(/^['"]|['"]$/g, "")];
|
|
583
|
+
/** @type {string[]} */
|
|
584
|
+
const items = [];
|
|
585
|
+
for (let next = index + 1; next < lines.length; next += 1) {
|
|
586
|
+
const line = /** @type {string} */ (lines[next]);
|
|
587
|
+
if (line.trim().length === 0 || line.trim().startsWith("#")) continue;
|
|
588
|
+
const item = /^(\s*)-\s+(.*)$/.exec(line);
|
|
589
|
+
if (item === null || (item[1] ?? "").length <= indent) break;
|
|
590
|
+
items.push((item[2] ?? "").trim().replace(/^['"]|['"]$/g, ""));
|
|
591
|
+
}
|
|
592
|
+
return items;
|
|
593
|
+
}
|
|
594
|
+
return undefined;
|
|
595
|
+
}
|
|
596
|
+
|
|
550
597
|
/**
|
|
551
598
|
* Read the configuration the blocking verdict must answer under: the shipped
|
|
552
599
|
* preset's values, overlaid by every profile layer under `$DSH_HOME/profiles/*`
|
|
@@ -561,11 +608,13 @@ export function rowKey(block, key) {
|
|
|
561
608
|
*/
|
|
562
609
|
export function effectiveConfig(dshHome, root) {
|
|
563
610
|
/** @type {EffectiveConfig} */
|
|
564
|
-
let config = { distro: "auto", sessionSandbox: "true", agentBackend: "auto", sandbox: "true", maskWindowsDrive: "false", interopVisibility: "", source: "the shipped preset", overrides: [] };
|
|
611
|
+
let config = { distro: "auto", sessionSandbox: "true", agentBackend: "auto", sandbox: "true", maskWindowsDrive: "false", interopVisibility: "", writableRoots: [], writableRootsFs: [], socketIsolation: "off", source: "the shipped preset", overrides: [] };
|
|
565
612
|
let recognized = false;
|
|
566
613
|
const shipped = readFileSync(join(root, "cordis.patch.yml"), "utf8");
|
|
567
614
|
const preset = rowBlock(shipped, "preset-wsl");
|
|
568
615
|
const routing = rowBlock(shipped, "fs-routing");
|
|
616
|
+
config.writableRoots = rowList(rowBlock(preset, "wsl-shell"), "writableRoots") ?? [];
|
|
617
|
+
config.writableRootsFs = rowList(rowBlock(preset, "wsl-fs"), "writableRoots") ?? [];
|
|
569
618
|
const distro = rowKey(preset, "distro");
|
|
570
619
|
const sessionSandbox = rowKey(preset, "sessionSandbox");
|
|
571
620
|
const agentBackend = rowKey(preset, "agentBackend");
|
|
@@ -587,6 +636,9 @@ export function effectiveConfig(dshHome, root) {
|
|
|
587
636
|
sandbox: sandbox ?? "true",
|
|
588
637
|
maskWindowsDrive: maskWindowsDrive ?? "false",
|
|
589
638
|
interopVisibility: rowKey(routing, "interopVisibility") ?? "",
|
|
639
|
+
writableRoots: config.writableRoots,
|
|
640
|
+
writableRootsFs: config.writableRootsFs,
|
|
641
|
+
socketIsolation: rowKey(preset, "socketIsolation") ?? rowKey(routing, "socketIsolation") ?? "off",
|
|
590
642
|
source: "the shipped preset",
|
|
591
643
|
overrides: [],
|
|
592
644
|
};
|
|
@@ -603,10 +655,20 @@ export function effectiveConfig(dshHome, root) {
|
|
|
603
655
|
const next = { ...config };
|
|
604
656
|
const layerPreset = rowBlock(text, "preset-wsl");
|
|
605
657
|
const layerRouting = rowBlock(text, "fs-routing");
|
|
606
|
-
|
|
658
|
+
const layerShellRoots = rowList(rowBlock(layerPreset, "wsl-shell"), "writableRoots");
|
|
659
|
+
const layerFsRoots = rowList(rowBlock(layerPreset, "wsl-fs"), "writableRoots");
|
|
660
|
+
if (layerShellRoots !== undefined && JSON.stringify(layerShellRoots) !== JSON.stringify(next.writableRoots)) {
|
|
661
|
+
next.writableRoots = layerShellRoots;
|
|
662
|
+
changed.push("writableRoots");
|
|
663
|
+
}
|
|
664
|
+
if (layerFsRoots !== undefined && JSON.stringify(layerFsRoots) !== JSON.stringify(next.writableRootsFs)) {
|
|
665
|
+
next.writableRootsFs = layerFsRoots;
|
|
666
|
+
changed.push("writableRoots (wsl-fs)");
|
|
667
|
+
}
|
|
668
|
+
for (const [block, keys] of [[layerPreset, ["distro", "sessionSandbox", "agentBackend", "sandbox", "socketIsolation"]], [layerRouting, ["sandbox", "maskWindowsDrive", "socketIsolation"]]]) {
|
|
607
669
|
const source = /** @type {string} */ (block);
|
|
608
670
|
/** The scalar keys the overlay may change; `source`/`overrides` are bookkeeping, not overlay inputs. */
|
|
609
|
-
const scalar = /** @type {const} */ (["distro", "sessionSandbox", "agentBackend", "sandbox", "maskWindowsDrive", "interopVisibility"]);
|
|
671
|
+
const scalar = /** @type {const} */ (["distro", "sessionSandbox", "agentBackend", "sandbox", "maskWindowsDrive", "interopVisibility", "socketIsolation"]);
|
|
610
672
|
for (const key of /** @type {string[]} */ (keys)) {
|
|
611
673
|
const value = rowKey(source, key);
|
|
612
674
|
if (value === undefined || value === next[/** @type {keyof EffectiveConfig} */ (key)]) continue;
|
|
@@ -1334,6 +1396,140 @@ async function main(options) {
|
|
|
1334
1396
|
}
|
|
1335
1397
|
}
|
|
1336
1398
|
|
|
1399
|
+
// ---- writable roots ------------------------------------------------------
|
|
1400
|
+
// `workspace-write` grants the workspace and the temp areas; the toolchain
|
|
1401
|
+
// caches under `$HOME` need `writableRoots`. The bwrap rows above prove the
|
|
1402
|
+
// fence can run; this row names the extra roots the fence will bind and the
|
|
1403
|
+
// physical-path problems the runtime's one-time check refuses. It reads the
|
|
1404
|
+
// effective profile rows and runs one in-distro stat: it writes nothing and
|
|
1405
|
+
// creates no directory.
|
|
1406
|
+
if (!want("sandbox")) {
|
|
1407
|
+
// sandbox section out of scope
|
|
1408
|
+
} else if (sandboxDisabled) {
|
|
1409
|
+
check("sandbox.grants", "skipped", "Writable roots", "skipped: the sandbox is disabled; no extra roots are bound");
|
|
1410
|
+
} else {
|
|
1411
|
+
const shellRoots = effective.writableRoots;
|
|
1412
|
+
const fsRoots = effective.writableRootsFs;
|
|
1413
|
+
const mismatch = JSON.stringify([...shellRoots].sort()) !== JSON.stringify([...fsRoots].sort());
|
|
1414
|
+
/** @type {string[]} */
|
|
1415
|
+
const configured = [...new Set([...shellRoots, ...fsRoots])];
|
|
1416
|
+
/** Normalize one Linux path the way the runtime's resolver does.
|
|
1417
|
+
* @param {string} root - the raw path.
|
|
1418
|
+
* @returns {string} the absolute normalized path. */
|
|
1419
|
+
const normalize = (root) => {
|
|
1420
|
+
/** @type {string[]} */
|
|
1421
|
+
const parts = [];
|
|
1422
|
+
for (const part of root.split("/")) {
|
|
1423
|
+
if (part.length === 0 || part === ".") continue;
|
|
1424
|
+
if (part === "..") parts.pop();
|
|
1425
|
+
else parts.push(part);
|
|
1426
|
+
}
|
|
1427
|
+
return `/${parts.join("/")}`;
|
|
1428
|
+
};
|
|
1429
|
+
if (configured.length === 0) {
|
|
1430
|
+
check("sandbox.grants", "ok", "Writable roots", "none configured — workspace, /tmp and /dev/shm only; toolchain caches under $HOME need writableRoots");
|
|
1431
|
+
} else {
|
|
1432
|
+
/** @type {string | undefined} */
|
|
1433
|
+
let failure;
|
|
1434
|
+
/** @type {string | undefined} */
|
|
1435
|
+
let remedy;
|
|
1436
|
+
try {
|
|
1437
|
+
validateWritableRootsConfig(shellRoots);
|
|
1438
|
+
validateWritableRootsConfig(fsRoots);
|
|
1439
|
+
} catch (error) {
|
|
1440
|
+
failure = error instanceof Error ? error.message : String(error);
|
|
1441
|
+
remedy = "fix the writableRoots entry on both rows — an absolute Linux path or ~/...; see docs/CONFIGURATION.md#toolchain-caches-and-extra-writable-roots";
|
|
1442
|
+
}
|
|
1443
|
+
/** @type {string[]} */
|
|
1444
|
+
let roots = [];
|
|
1445
|
+
if (failure === undefined) {
|
|
1446
|
+
/** @type {string} */
|
|
1447
|
+
let home = "";
|
|
1448
|
+
if (configured.some((root) => root === "~" || root.startsWith("~/"))) {
|
|
1449
|
+
const homeAnswer = await probe('printf %s "$HOME"');
|
|
1450
|
+
if (homeAnswer.ok) home = homeAnswer.stdout.trim();
|
|
1451
|
+
if (home.length === 0 || !home.startsWith("/")) {
|
|
1452
|
+
failure = "the distro home did not answer, so ~ in writableRoots cannot be resolved";
|
|
1453
|
+
remedy = `run "wsl.exe -d ${target} --exec sh -c 'printf %s \\"$HOME\\"'" and retry`;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
if (failure === undefined) {
|
|
1457
|
+
roots = configured.map((root) => normalize(root === "~" ? home : root.startsWith("~/") ? `${home}/${root.slice(2)}` : root));
|
|
1458
|
+
const answer = await run(writableRootsCheckArgv(WSL, target, roots));
|
|
1459
|
+
if (!answer.ok) {
|
|
1460
|
+
const match = /(\d+)\|(missing|unreadable|symlink)(?: -> (.*))?/u.exec(`${answer.stdout}\n${answer.stderr}`);
|
|
1461
|
+
const index = match === null ? -1 : Number(match[1] ?? -1);
|
|
1462
|
+
const root = roots[index];
|
|
1463
|
+
if (root === undefined) {
|
|
1464
|
+
const first = answer.stderr.trim().split(/\r?\n/u)[0] ?? "";
|
|
1465
|
+
failure = `the writable-root check did not answer${first.length > 0 ? `: ${first.slice(0, 120)}` : ""}`;
|
|
1466
|
+
remedy = "rerun the doctor; if it persists, check that wsl.exe can run a command in the distro";
|
|
1467
|
+
} else {
|
|
1468
|
+
const reason = match?.[2];
|
|
1469
|
+
failure = reason === "missing"
|
|
1470
|
+
? `${root} is missing`
|
|
1471
|
+
: reason === "unreadable"
|
|
1472
|
+
? `${root} is unreadable`
|
|
1473
|
+
: `${root} is a symlink to ${match?.[3] ?? "another path"}`;
|
|
1474
|
+
remedy = reason === "missing"
|
|
1475
|
+
? `create the directory inside "${target}" (mkdir -p ${root}) or remove it from writableRoots`
|
|
1476
|
+
: reason === "unreadable"
|
|
1477
|
+
? `make ${root} readable and physically inside "${target}", or remove it from writableRoots`
|
|
1478
|
+
: `use the physical path ${match?.[3] ?? ""} in writableRoots; symlinked grants are not supported`;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
const listed = roots.length === configured.length ? roots : configured;
|
|
1484
|
+
const detail = mismatch
|
|
1485
|
+
? `wsl-shell: ${shellRoots.length === 0 ? "(none)" : shellRoots.join(", ")}; wsl-fs: ${fsRoots.length === 0 ? "(none)" : fsRoots.join(", ")}`
|
|
1486
|
+
: `${listed.length} root(s): ${listed.join(", ")}`;
|
|
1487
|
+
if (failure !== undefined) {
|
|
1488
|
+
check("sandbox.grants", "warn", "Writable roots", `${detail} — ${failure}`, remedy);
|
|
1489
|
+
} else if (mismatch) {
|
|
1490
|
+
check("sandbox.grants", "warn", "Writable roots", `${detail} — the command and write rows bind different roots`, "put the same writableRoots list on wsl-shell and wsl-fs; see docs/CONFIGURATION.md#toolchain-caches-and-extra-writable-roots");
|
|
1491
|
+
} else {
|
|
1492
|
+
check("sandbox.grants", "ok", "Writable roots", `${detail} — all usable`);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
// ---- socket isolation ----------------------------------------------------
|
|
1498
|
+
// The mount profile does not govern process authority. This row names the
|
|
1499
|
+
// surface the command/write rows' socket stance covers and the escape
|
|
1500
|
+
// paths it leaves to the distro-level closure; the masks themselves are
|
|
1501
|
+
// verified by `pnpm run probe:sandbox`.
|
|
1502
|
+
if (!want("sandbox")) {
|
|
1503
|
+
// sandbox section out of scope
|
|
1504
|
+
} else if (sandboxDisabled) {
|
|
1505
|
+
check("sandbox.isolation", "skipped", "Socket isolation", "skipped: the sandbox is disabled; no socket masks are applied");
|
|
1506
|
+
} else {
|
|
1507
|
+
const stance = effective.socketIsolation;
|
|
1508
|
+
const answer = await probe(socketIsolationProbeScript());
|
|
1509
|
+
if (!answer.ok && answer.flaked) {
|
|
1510
|
+
flakeCheck("sandbox.isolation", "Socket isolation", answer);
|
|
1511
|
+
} else if (!answer.ok) {
|
|
1512
|
+
check("sandbox.isolation", "unknown", "Socket isolation", "the socket-facts probe did not answer", "rerun the doctor; if it persists, check that wsl.exe can run a command in the distro");
|
|
1513
|
+
} else {
|
|
1514
|
+
const valid = stance === "off" || stance === "session-bus" || stance === "strict";
|
|
1515
|
+
if (!valid) {
|
|
1516
|
+
check("sandbox.isolation", "warn", "Socket isolation", `unknown stance ${JSON.stringify(stance)} in the effective configuration`, "use off, session-bus or strict on the confined rows");
|
|
1517
|
+
} else {
|
|
1518
|
+
const facts = parseSocketIsolationFacts(answer.stdout);
|
|
1519
|
+
const masks = socketMaskPaths(stance, facts);
|
|
1520
|
+
const detected = [...facts.userSockets, ...facts.strictSockets];
|
|
1521
|
+
const surfaceText = detected.length === 0 ? "no matching socket detected" : detected.join(", ");
|
|
1522
|
+
if (stance === "off") {
|
|
1523
|
+
check("sandbox.isolation", "info", "Socket isolation", `off — confined commands can reach the user manager, system bus, container sockets and the interop transport; detected: ${surfaceText}`, "set socketIsolation: session-bus or strict on the confined rows (and fs-routing) to mask the sockets");
|
|
1524
|
+
} else if (stance === "session-bus") {
|
|
1525
|
+
check("sandbox.isolation", "ok", "Socket isolation", `session-bus — masks ${masks.length === 0 ? "no user-manager socket (none detected)" : masks.join(", ")}; the system bus, container sockets and the interop transport remain; enforcement stays partial`, "use strict to mask the system bus and reachable container sockets; close interop at the distro level");
|
|
1526
|
+
} else {
|
|
1527
|
+
check("sandbox.isolation", "ok", "Socket isolation", `strict — masks ${masks.length === 0 ? "no socket (none detected)" : masks.join(", ")}; the WSL interop transport is masked by the profile; same-user /proc remains; enforcement stays partial`, "the distro-level [interop] enabled=false still closes interop for the rest of the distro; same-user /proc is outside the mount profile");
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1337
1533
|
// ---- session sandbox prerequisites --------------------------------------
|
|
1338
1534
|
// The statuses are config-aware: the scope is only *required* under
|
|
1339
1535
|
// `sessionSandbox: true` (the shipped default); `auto` falls back to the
|
|
@@ -111,7 +111,7 @@ function setKey(lines, id, key, value) {
|
|
|
111
111
|
/**
|
|
112
112
|
* Apply the supported edits to a preset block.
|
|
113
113
|
* @param {string} block - the block from {@link presetBlock}.
|
|
114
|
-
* @param {{ distro?: string, sessionSandbox?: boolean | "auto", sandbox?: boolean, maskWindowsDrive?: boolean, agentBackend?: string, writableRoots?: string[] }} edits - the edits.
|
|
114
|
+
* @param {{ distro?: string, sessionSandbox?: boolean | "auto", sandbox?: boolean, maskWindowsDrive?: boolean, agentBackend?: string, writableRoots?: string[], socketIsolation?: "off" | "session-bus" | "strict" }} edits - the edits.
|
|
115
115
|
* @returns {string} the edited block.
|
|
116
116
|
*/
|
|
117
117
|
export function applyEdits(block, edits) {
|
|
@@ -121,6 +121,7 @@ export function applyEdits(block, edits) {
|
|
|
121
121
|
["sessionSandbox", edits.sessionSandbox === undefined ? undefined : String(edits.sessionSandbox)],
|
|
122
122
|
["sandbox", edits.sandbox === undefined ? undefined : String(edits.sandbox)],
|
|
123
123
|
["maskWindowsDrive", edits.maskWindowsDrive === undefined ? undefined : String(edits.maskWindowsDrive)],
|
|
124
|
+
["socketIsolation", edits.socketIsolation],
|
|
124
125
|
]);
|
|
125
126
|
for (const [key, value] of both) {
|
|
126
127
|
if (value === undefined) continue;
|
|
@@ -161,6 +162,13 @@ function parseArgs(argv) {
|
|
|
161
162
|
else if (flag === "--agent-backend") {
|
|
162
163
|
if (!["auto", "native", "shell"].includes(value)) throw new Error(`profile-preset: --agent-backend must be auto, native or shell (got "${value}")`);
|
|
163
164
|
edits.agentBackend = value;
|
|
165
|
+
} else if (flag === "--socket-isolation") {
|
|
166
|
+
if (!["off", "session-bus", "strict"].includes(value)) throw new Error(`profile-preset: --socket-isolation must be off, session-bus or strict (got "${value}")`);
|
|
167
|
+
edits.socketIsolation = value;
|
|
168
|
+
} else if (flag === "--strict") {
|
|
169
|
+
edits.socketIsolation = "strict";
|
|
170
|
+
edits.maskWindowsDrive = true;
|
|
171
|
+
i -= 1;
|
|
164
172
|
} else if (flag === "--writable-roots") {
|
|
165
173
|
const roots = value.split(",").map((root) => root.trim()).filter((root) => root.length > 0);
|
|
166
174
|
if (roots.length === 0) throw new Error("profile-preset: --writable-roots needs a comma-separated list of distro paths");
|
|
@@ -171,7 +179,7 @@ function parseArgs(argv) {
|
|
|
171
179
|
options.force = true;
|
|
172
180
|
i -= 1;
|
|
173
181
|
} else if (flag === "--help" || flag === "-h") {
|
|
174
|
-
console.log("node scripts/profile-preset.mjs [--distro NAME] [--session-sandbox true|false|auto] [--sandbox true|false] [--mask-windows-drive true|false] [--agent-backend auto|native|shell] [--writable-roots 'PATH,...'] [--out FILE] [--check FILE] [--force]");
|
|
182
|
+
console.log("node scripts/profile-preset.mjs [--distro NAME] [--session-sandbox true|false|auto] [--sandbox true|false] [--mask-windows-drive true|false] [--socket-isolation off|session-bus|strict] [--strict] [--agent-backend auto|native|shell] [--writable-roots 'PATH,...'] [--out FILE] [--check FILE] [--force]");
|
|
175
183
|
process.exit(0);
|
|
176
184
|
} else throw new Error(`profile-preset: unknown option "${arg}"`);
|
|
177
185
|
}
|