@ai-ecoverse/slicc-kernel 1.195.30 → 1.195.31
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/README.md +4 -4
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +246 -125
- package/dist/cloudflare.js.map +3 -3
- package/dist/index.js.map +1 -1
- package/dist/kernel-worker.js +246 -125
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +246 -125
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/commands.d.ts +1 -1
- package/dist/types/fs/integrity.d.ts +2 -0
- package/dist/types/launcher.d.ts +7 -4
- package/dist/types/sudo-files.d.ts +10 -1
- package/dist/types/sudo.d.ts +5 -2
- package/package.json +1 -1
package/dist/kernel-worker.js
CHANGED
|
@@ -898,6 +898,10 @@ var Integrity = class {
|
|
|
898
898
|
const found = await this.real(path, asked, real);
|
|
899
899
|
if (found) await this.verify(found.name, bytes, caller, EXEC_OPS);
|
|
900
900
|
}
|
|
901
|
+
async checkManifest(path, real, hash, caller) {
|
|
902
|
+
const found = await this.real(path, void 0, real);
|
|
903
|
+
if (found) await this.checkHash(found.name, hash, caller, EXEC_OPS);
|
|
904
|
+
}
|
|
901
905
|
get readsChecked() {
|
|
902
906
|
return this.sources.length > 0;
|
|
903
907
|
}
|
|
@@ -940,7 +944,9 @@ var Integrity = class {
|
|
|
940
944
|
return st?.isFile && ((st.mode ?? 0) & 73) !== 0 ? found : void 0;
|
|
941
945
|
}
|
|
942
946
|
async verify(name2, bytes, caller, ops) {
|
|
943
|
-
|
|
947
|
+
return this.checkHash(name2, await sha256(bytes), caller, ops);
|
|
948
|
+
}
|
|
949
|
+
async checkHash(name2, actual, caller, ops) {
|
|
944
950
|
const denial = { pid: caller.pid, uid: caller.uid, path: name2, actual };
|
|
945
951
|
const tagged = caller.tag !== void 0 ? { tag: caller.tag } : {};
|
|
946
952
|
let expected;
|
|
@@ -9370,7 +9376,7 @@ function satisfies(version, range2) {
|
|
|
9370
9376
|
}
|
|
9371
9377
|
|
|
9372
9378
|
// src/version.ts
|
|
9373
|
-
var KERNEL_VERSION = true ? "1.195.
|
|
9379
|
+
var KERNEL_VERSION = true ? "1.195.31" : "0.0.0-dev";
|
|
9374
9380
|
var OS_RELEASE = "6.0.0-slicc";
|
|
9375
9381
|
function procVersion() {
|
|
9376
9382
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -9779,12 +9785,12 @@ function binfmtEntry(pkg, key, value2) {
|
|
|
9779
9785
|
return { name: key, pkg, command: value2, preserveArgv0: false };
|
|
9780
9786
|
}
|
|
9781
9787
|
async function scanBinfmts(fs, modules, warn = () => {
|
|
9782
|
-
}
|
|
9788
|
+
}) {
|
|
9783
9789
|
const found = /* @__PURE__ */ new Map();
|
|
9784
9790
|
for (const pkg of await packagesIn(fs, modules)) {
|
|
9785
9791
|
let manifest;
|
|
9786
9792
|
try {
|
|
9787
|
-
manifest = JSON.parse(await
|
|
9793
|
+
manifest = JSON.parse(await fs.readFile(`${pkg}/package.json`));
|
|
9788
9794
|
} catch {
|
|
9789
9795
|
continue;
|
|
9790
9796
|
}
|
|
@@ -21750,6 +21756,11 @@ var SudoReads = class {
|
|
|
21750
21756
|
access;
|
|
21751
21757
|
reads = /* @__PURE__ */ new Map();
|
|
21752
21758
|
names = /* @__PURE__ */ new Map();
|
|
21759
|
+
documents = /* @__PURE__ */ new Map();
|
|
21760
|
+
manifestFiles = /* @__PURE__ */ new Map();
|
|
21761
|
+
observed = /* @__PURE__ */ new Set();
|
|
21762
|
+
interpreters = [];
|
|
21763
|
+
chainSha256;
|
|
21753
21764
|
operandsFromEnd = /* @__PURE__ */ new Map();
|
|
21754
21765
|
snapshots;
|
|
21755
21766
|
constructor(access2, snapshots = /* @__PURE__ */ new Map()) {
|
|
@@ -21768,16 +21779,41 @@ var SudoReads = class {
|
|
|
21768
21779
|
const saved = this.snapshots.get(real);
|
|
21769
21780
|
return saved ? Promise.resolve(saved) : this.access.read(real);
|
|
21770
21781
|
}
|
|
21771
|
-
|
|
21782
|
+
manifest(path, verify, raw2) {
|
|
21783
|
+
let found = this.documents.get(path);
|
|
21784
|
+
if (!found) {
|
|
21785
|
+
found = this.readManifest(path, verify, raw2);
|
|
21786
|
+
this.documents.set(path, found);
|
|
21787
|
+
}
|
|
21788
|
+
return found;
|
|
21789
|
+
}
|
|
21790
|
+
async readManifest(path, verify, raw2) {
|
|
21772
21791
|
const real = await this.access.real(path);
|
|
21773
21792
|
this.saw(path, real);
|
|
21774
|
-
const
|
|
21775
|
-
|
|
21776
|
-
|
|
21777
|
-
|
|
21778
|
-
|
|
21779
|
-
|
|
21780
|
-
|
|
21793
|
+
const { text, read } = await this.document(real, raw2);
|
|
21794
|
+
this.observed.add(path);
|
|
21795
|
+
await verify(real, read.hash);
|
|
21796
|
+
return text;
|
|
21797
|
+
}
|
|
21798
|
+
document(real, raw2) {
|
|
21799
|
+
let found = this.manifestFiles.get(real);
|
|
21800
|
+
if (!found) {
|
|
21801
|
+
const saved = this.snapshots.get(real);
|
|
21802
|
+
found = (saved ? Promise.resolve(saved) : raw2(real)).then(async (data) => {
|
|
21803
|
+
const bytes = new Uint8Array(data);
|
|
21804
|
+
return { text: new TextDecoder().decode(bytes), read: await fingerprint(bytes) };
|
|
21805
|
+
});
|
|
21806
|
+
this.manifestFiles.set(real, found);
|
|
21807
|
+
const earlier = this.reads.get(real);
|
|
21808
|
+
this.reads.set(
|
|
21809
|
+
real,
|
|
21810
|
+
found.then(
|
|
21811
|
+
async ({ read }) => !earlier || (await earlier)?.hash === read.hash ? read : void 0,
|
|
21812
|
+
() => void 0
|
|
21813
|
+
)
|
|
21814
|
+
);
|
|
21815
|
+
}
|
|
21816
|
+
return found;
|
|
21781
21817
|
}
|
|
21782
21818
|
saw(path, real) {
|
|
21783
21819
|
const seen = this.names.get(path);
|
|
@@ -21791,10 +21827,15 @@ var SudoReads = class {
|
|
|
21791
21827
|
this.saw(path, real);
|
|
21792
21828
|
return (await this.bytes(real))?.head;
|
|
21793
21829
|
}
|
|
21830
|
+
*inputs(paths) {
|
|
21831
|
+
const primary = new Set(paths);
|
|
21832
|
+
yield* primary;
|
|
21833
|
+
for (const path of this.observed) if (!primary.has(path)) yield path;
|
|
21834
|
+
}
|
|
21794
21835
|
async bind(paths) {
|
|
21795
21836
|
const hashes = {};
|
|
21796
21837
|
const routes = {};
|
|
21797
|
-
for (const path of
|
|
21838
|
+
for (const path of this.inputs(paths)) {
|
|
21798
21839
|
if (await this.access.trusted(path)) continue;
|
|
21799
21840
|
const real = await this.access.real(path);
|
|
21800
21841
|
routes[path] = real;
|
|
@@ -21805,7 +21846,12 @@ var SudoReads = class {
|
|
|
21805
21846
|
const scripts = [...new Set(this.operandsFromEnd.values())].filter(
|
|
21806
21847
|
(path) => Object.hasOwn(routes, path)
|
|
21807
21848
|
);
|
|
21808
|
-
const binding = {
|
|
21849
|
+
const binding = {
|
|
21850
|
+
hashes,
|
|
21851
|
+
routes,
|
|
21852
|
+
...scripts.length ? { scripts } : {},
|
|
21853
|
+
...this.chainSha256 ? { chainSha256: this.chainSha256 } : {}
|
|
21854
|
+
};
|
|
21809
21855
|
if (!Object.keys(routes).some((path) => path !== routes[path])) return binding;
|
|
21810
21856
|
const pairs = Object.keys(routes).sort().map((path) => [path, routes[path]]);
|
|
21811
21857
|
const routeSha256 = await sha256(new TextEncoder().encode(JSON.stringify(pairs)));
|
|
@@ -22495,8 +22541,14 @@ function changedFile(approved, now) {
|
|
|
22495
22541
|
function pinned(rule, hashes, routeSha256) {
|
|
22496
22542
|
return rule.sha256 === void 0 || rule.routeSha256 === routeSha256 && changedFile(rule.sha256, hashes) === void 0;
|
|
22497
22543
|
}
|
|
22498
|
-
function
|
|
22499
|
-
return routeSha256 ? {
|
|
22544
|
+
function proofOf({ routeSha256, chainSha256 }) {
|
|
22545
|
+
return { ...routeSha256 ? { routeSha256 } : {}, ...chainSha256 ? { chainSha256 } : {} };
|
|
22546
|
+
}
|
|
22547
|
+
function changedDecision(hashes, proof, now, path) {
|
|
22548
|
+
return changedFile(hashes, now.hashes) ?? (proof.routeSha256 !== now.routeSha256 || proof.chainSha256 !== now.chainSha256 ? path : void 0);
|
|
22549
|
+
}
|
|
22550
|
+
function stampOf(files) {
|
|
22551
|
+
return Object.keys(files.hashes).length ? { ...files.hashes, ...proofOf(files) } : files.hashes;
|
|
22500
22552
|
}
|
|
22501
22553
|
var REPLAY_ID = /^[!-~]{1,256}$/;
|
|
22502
22554
|
var REPLAY_TAGS_MAX = 64;
|
|
@@ -22511,13 +22563,23 @@ function words(value2) {
|
|
|
22511
22563
|
const bytes = value2.reduce((n, s) => n + s.length + 1, 0);
|
|
22512
22564
|
return bytes <= REPLAY_BYTES_MAX && !value2.some((s) => s.includes("\0"));
|
|
22513
22565
|
}
|
|
22566
|
+
var FACT_OVERHEAD = 66;
|
|
22567
|
+
function factsFit(files) {
|
|
22568
|
+
let budget = REPLAY_BYTES_MAX;
|
|
22569
|
+
for (const path of Object.keys(files))
|
|
22570
|
+
if ((budget -= storedSize(path) + FACT_OVERHEAD) < 0) return false;
|
|
22571
|
+
return true;
|
|
22572
|
+
}
|
|
22514
22573
|
function filesOf(value2) {
|
|
22515
22574
|
if (value2 === void 0) return {};
|
|
22516
|
-
if (!Array.isArray(value2) || value2.length >
|
|
22575
|
+
if (!Array.isArray(value2) || value2.length * FACT_OVERHEAD > REPLAY_BYTES_MAX) return void 0;
|
|
22517
22576
|
const files = {};
|
|
22577
|
+
let budget = REPLAY_BYTES_MAX;
|
|
22518
22578
|
for (const file of value2) {
|
|
22519
22579
|
const { path, sha256: hex4 } = file ?? {};
|
|
22520
|
-
if (typeof path !== "string" || typeof hex4 !== "string"
|
|
22580
|
+
if (typeof path !== "string" || !path.startsWith("/") || typeof hex4 !== "string" || !/^[0-9a-f]{64}$/.test(hex4))
|
|
22581
|
+
return void 0;
|
|
22582
|
+
if (path.length > budget || (budget -= storedSize(path) + FACT_OVERHEAD) < 0) return void 0;
|
|
22521
22583
|
files[path] = hex4;
|
|
22522
22584
|
}
|
|
22523
22585
|
return files;
|
|
@@ -22540,9 +22602,9 @@ function replayOf(value2) {
|
|
|
22540
22602
|
const { id: id2, user, uid, target, argv, path, cwd, stdin, tag, tags } = r;
|
|
22541
22603
|
const rootOnly = flagsOf(r.rootOnly);
|
|
22542
22604
|
const bound3 = filesOf(r.userWritable);
|
|
22543
|
-
const { routeSha256 } = r;
|
|
22544
|
-
|
|
22545
|
-
|
|
22605
|
+
const { routeSha256, chainSha256 } = r;
|
|
22606
|
+
const digest2 = (v) => v === void 0 || typeof v === "string" && /^[0-9a-f]{64}$/.test(v);
|
|
22607
|
+
if (!digest2(routeSha256) || !digest2(chainSha256)) return failed2("EINVAL", NOT_A_REQUEST);
|
|
22546
22608
|
const named = (s) => typeof s === "string" && s !== "";
|
|
22547
22609
|
const absolute2 = (s) => typeof s === "string" && s.startsWith("/") && s.length <= PATH_MAX2 && !s.includes("\0");
|
|
22548
22610
|
const valid2 = typeof id2 === "string" && REPLAY_ID.test(id2) && named(user) && named(target) && Number.isInteger(uid) && uid >= 0 && words(argv) && absolute2(path) && absolute2(cwd) && (stdin === "tty" || stdin === "none") && (tag === void 0 || typeof tag === "string") && (tags === void 0 || strings2(tags, REPLAY_TAGS_MAX)) && rootOnly !== void 0 && bound3 !== void 0;
|
|
@@ -22560,6 +22622,7 @@ function replayOf(value2) {
|
|
|
22560
22622
|
rootOnly,
|
|
22561
22623
|
bound: bound3,
|
|
22562
22624
|
...routeSha256 === void 0 ? {} : { routeSha256 },
|
|
22625
|
+
...chainSha256 === void 0 ? {} : { chainSha256 },
|
|
22563
22626
|
tags: [...new Set(all)]
|
|
22564
22627
|
};
|
|
22565
22628
|
}
|
|
@@ -22737,8 +22800,7 @@ var Sudo = class {
|
|
|
22737
22800
|
}
|
|
22738
22801
|
return true;
|
|
22739
22802
|
}
|
|
22740
|
-
async trustedThrough(path, destination) {
|
|
22741
|
-
const { fs } = this.o;
|
|
22803
|
+
async trustedThrough(path, destination, fs = this.o.fs) {
|
|
22742
22804
|
if (!heldByRoot(await fs.lstat("/").catch(() => void 0))) return false;
|
|
22743
22805
|
const queue = path.split("/").filter(Boolean);
|
|
22744
22806
|
const done5 = [];
|
|
@@ -22927,18 +22989,26 @@ var Sudo = class {
|
|
|
22927
22989
|
}
|
|
22928
22990
|
return void 0;
|
|
22929
22991
|
}
|
|
22992
|
+
async missingBacking(hashes, except) {
|
|
22993
|
+
for (const path of Object.keys(hashes)) {
|
|
22994
|
+
if (path !== except && !(await this.o.fs.stat(path).catch(() => void 0))?.isFile)
|
|
22995
|
+
return path;
|
|
22996
|
+
}
|
|
22997
|
+
return void 0;
|
|
22998
|
+
}
|
|
22930
22999
|
reads(snapshots) {
|
|
22931
|
-
|
|
23000
|
+
const reads = new SudoReads(
|
|
22932
23001
|
{
|
|
22933
23002
|
real: (at) => this.real(at),
|
|
22934
|
-
trusted: (at) => this.trustedThrough(at),
|
|
22935
|
-
read: (at) =>
|
|
23003
|
+
trusted: (at) => this.trustedThrough(at, void 0, fs),
|
|
23004
|
+
read: (at) => fs.readFileBuffer(at)
|
|
22936
23005
|
},
|
|
22937
23006
|
snapshots
|
|
22938
23007
|
);
|
|
23008
|
+
const fs = this.o.planFs?.(reads) ?? this.o.fs;
|
|
23009
|
+
return reads;
|
|
22939
23010
|
}
|
|
22940
|
-
async bound(path, cwd, asked = path, pid) {
|
|
22941
|
-
const reads = this.reads();
|
|
23011
|
+
async bound(path, cwd, asked = path, pid, reads = this.reads()) {
|
|
22942
23012
|
const files = this.o.backing ? await this.o.backing(path, cwd, reads, pid) : [];
|
|
22943
23013
|
const bound3 = files && await reads.bind([path, asked, ...files]);
|
|
22944
23014
|
return bound3 && !Object.values(bound3.hashes).includes("") && (bound3.routes[asked] ?? path) === path ? bound3 : void 0;
|
|
@@ -22950,8 +23020,8 @@ var Sudo = class {
|
|
|
22950
23020
|
if (bound3) return Object.keys(bound3.hashes).length > 0;
|
|
22951
23021
|
return !await this.trusted(await this.existing(path));
|
|
22952
23022
|
}
|
|
22953
|
-
async locate(word, cwd) {
|
|
22954
|
-
const
|
|
23023
|
+
async locate(word, cwd, reads) {
|
|
23024
|
+
const fs = this.o.planFs?.(reads) ?? this.o.fs;
|
|
22955
23025
|
const candidates = word.includes("/") ? [fs.resolvePath(cwd, word)] : SECURE_PATH.split(":").map((dir) => `${dir}/${word}`);
|
|
22956
23026
|
for (const path of candidates) {
|
|
22957
23027
|
const st = await fs.stat(path).catch(() => void 0);
|
|
@@ -23042,13 +23112,17 @@ var Sudo = class {
|
|
|
23042
23112
|
`sudo: cannot run in ${r.cwd}: it isn't a directory ${self.name} can enter`
|
|
23043
23113
|
);
|
|
23044
23114
|
}
|
|
23045
|
-
const
|
|
23046
|
-
|
|
23115
|
+
const reads = this.reads();
|
|
23116
|
+
const located = await this.locate(word, r.cwd, reads);
|
|
23117
|
+
if (!located) {
|
|
23118
|
+
const gone = await this.missingBacking(r.bound, r.path);
|
|
23119
|
+
return gone ? failed2("EPERM", requestedText(gone)) : failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
23120
|
+
}
|
|
23047
23121
|
const { path, asked } = located;
|
|
23048
23122
|
if (path !== r.path) return failed2("EPERM", `sudo: ${word} now runs ${path}, not ${r.path}`);
|
|
23049
|
-
const bound3 = await this.bound(path, r.cwd, asked);
|
|
23050
|
-
if (!bound3) return failed2("
|
|
23051
|
-
const changed2 =
|
|
23123
|
+
const bound3 = await this.bound(path, r.cwd, asked, void 0, reads);
|
|
23124
|
+
if (!bound3) return failed2("EPERM", requestedText(await this.missingBacking(r.bound) ?? path));
|
|
23125
|
+
const changed2 = changedDecision(r.bound, r, bound3, path);
|
|
23052
23126
|
if (changed2 !== void 0) return failed2("EPERM", requestedText(changed2));
|
|
23053
23127
|
const now = await this.rootOnly(r.cwd, args);
|
|
23054
23128
|
const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
|
|
@@ -23090,8 +23164,9 @@ var Sudo = class {
|
|
|
23090
23164
|
`sudo: cannot run in ${call.cwd}: it isn't a directory you can enter`
|
|
23091
23165
|
);
|
|
23092
23166
|
}
|
|
23093
|
-
const
|
|
23094
|
-
const
|
|
23167
|
+
const reads = this.reads();
|
|
23168
|
+
const located = await this.locate(word, cwd, reads);
|
|
23169
|
+
const bound3 = located && await this.bound(located.path, cwd, located.asked, caller.pid, reads);
|
|
23095
23170
|
if (!located || !bound3) return failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
23096
23171
|
const { path, asked } = located;
|
|
23097
23172
|
const argv = [path, ...args];
|
|
@@ -23114,13 +23189,13 @@ var Sudo = class {
|
|
|
23114
23189
|
}
|
|
23115
23190
|
if (parsed3.nonInteractive) return failed2("EPERM", "sudo: a password is required");
|
|
23116
23191
|
return this.pendingFor(cred.ruid, async () => {
|
|
23117
|
-
const
|
|
23192
|
+
const proof = proofOf(bound3);
|
|
23118
23193
|
const answer2 = await this.ask(s, {
|
|
23119
23194
|
argv: parsed3.command,
|
|
23120
23195
|
path,
|
|
23121
23196
|
cwd,
|
|
23122
23197
|
bound: bound3.hashes,
|
|
23123
|
-
...
|
|
23198
|
+
...proof
|
|
23124
23199
|
});
|
|
23125
23200
|
if ("error" in answer2) return answer2;
|
|
23126
23201
|
if (await this.canonical(call.cwd) !== cwd || !await this.reachable(cred, cwd)) {
|
|
@@ -23128,14 +23203,17 @@ var Sudo = class {
|
|
|
23128
23203
|
}
|
|
23129
23204
|
const moved2 = await this.moved(bound3);
|
|
23130
23205
|
if (moved2 !== void 0) return failed2("EPERM", changedText(moved2));
|
|
23206
|
+
if (answer2.answer === "once" && !answer2.person) return grant();
|
|
23131
23207
|
const now = await this.bound(path, cwd, asked, caller.pid);
|
|
23132
|
-
if (!now)
|
|
23208
|
+
if (!now)
|
|
23209
|
+
return failed2("EPERM", changedText(await this.missingBacking(bound3.hashes) ?? path));
|
|
23210
|
+
const changed2 = changedDecision(bound3.hashes, bound3, now, path);
|
|
23211
|
+
if (changed2 !== void 0) return failed2("EPERM", changedText(changed2));
|
|
23133
23212
|
const shown2 = recordable(cwd, [...parsed3.command, ...Object.keys(bound3.hashes)]);
|
|
23134
23213
|
const result = answer2.answer === "once" ? grant() : await this.always(
|
|
23135
23214
|
self,
|
|
23136
23215
|
target,
|
|
23137
|
-
{ cwd, argv, bound: bound3.hashes, ...
|
|
23138
|
-
now,
|
|
23216
|
+
{ cwd, argv, bound: bound3.hashes, ...proof },
|
|
23139
23217
|
shown2,
|
|
23140
23218
|
grant
|
|
23141
23219
|
);
|
|
@@ -23185,11 +23263,8 @@ var Sudo = class {
|
|
|
23185
23263
|
`sudo: ${self.name} : TTY=${tty} ; PWD=${quoteWord(cwd)} ; USER=${target.name} ; TIMESTAMP=${type} ; COMMAND=${command}`
|
|
23186
23264
|
);
|
|
23187
23265
|
}
|
|
23188
|
-
async always(self, target, line,
|
|
23189
|
-
|
|
23190
|
-
if (!shown2 || !recordable(cwd, argv)) return { ...grant(), notice: RAN_ONCE };
|
|
23191
|
-
const changed2 = changedFile(bound3, now.hashes) ?? (line.routeSha256 !== now.routeSha256 ? argv[0] : void 0);
|
|
23192
|
-
if (changed2 !== void 0) return failed2("EPERM", changedText(changed2));
|
|
23266
|
+
async always(self, target, line, shown2, grant) {
|
|
23267
|
+
if (!shown2 || !recordable(line.cwd, line.argv)) return { ...grant(), notice: RAN_ONCE };
|
|
23193
23268
|
if (!await this.remember(self, target, line)) {
|
|
23194
23269
|
return failed2("EIO", "sudo: the rule could not be recorded");
|
|
23195
23270
|
}
|
|
@@ -23224,6 +23299,8 @@ ${lines3}
|
|
|
23224
23299
|
async ask(s, asked) {
|
|
23225
23300
|
const { caller, self, target, signal: requester } = s;
|
|
23226
23301
|
const { argv, path, cwd } = asked;
|
|
23302
|
+
if (!factsFit(asked.bound))
|
|
23303
|
+
return failed2("E2BIG", "sudo: too many user-writable file facts for an approval request");
|
|
23227
23304
|
const { approve } = this.o;
|
|
23228
23305
|
if (!approve || requester.aborted) return failed2("EACCES", DENIED2);
|
|
23229
23306
|
const createdAt = Date.now();
|
|
@@ -23246,7 +23323,7 @@ ${lines3}
|
|
|
23246
23323
|
stdin: caller.stdin,
|
|
23247
23324
|
rootOnly: asked.validate ? {} : await this.rootOnly(cwd, argv.slice(1)),
|
|
23248
23325
|
...userWritable(asked.bound),
|
|
23249
|
-
...asked
|
|
23326
|
+
...proofOf(asked),
|
|
23250
23327
|
...asked.validate ? { validate: true } : {},
|
|
23251
23328
|
timestamp: true
|
|
23252
23329
|
};
|
|
@@ -37108,6 +37185,12 @@ function addTimes(into, pid, t) {
|
|
|
37108
37185
|
function locksForPackages(options) {
|
|
37109
37186
|
return new PackageLocks(options.packageLocks ?? META_DB, options.leaseImage ? null : void 0);
|
|
37110
37187
|
}
|
|
37188
|
+
var CatalogCache = class {
|
|
37189
|
+
commands = /* @__PURE__ */ new Map();
|
|
37190
|
+
own = /* @__PURE__ */ new Map();
|
|
37191
|
+
rules = /* @__PURE__ */ new Map();
|
|
37192
|
+
fs;
|
|
37193
|
+
};
|
|
37111
37194
|
var Launcher = class {
|
|
37112
37195
|
emscripten;
|
|
37113
37196
|
admit;
|
|
@@ -37134,9 +37217,8 @@ var Launcher = class {
|
|
|
37134
37217
|
appended;
|
|
37135
37218
|
reportedRoots = /* @__PURE__ */ new Set();
|
|
37136
37219
|
env;
|
|
37137
|
-
|
|
37138
|
-
|
|
37139
|
-
binfmts = /* @__PURE__ */ new Map();
|
|
37220
|
+
catalog = new CatalogCache();
|
|
37221
|
+
planCatalogs = /* @__PURE__ */ new WeakMap();
|
|
37140
37222
|
scopes;
|
|
37141
37223
|
unwatchScopes = () => void 0;
|
|
37142
37224
|
warned = /* @__PURE__ */ new Set();
|
|
@@ -37414,6 +37496,7 @@ var Launcher = class {
|
|
|
37414
37496
|
env: () => this.env,
|
|
37415
37497
|
pnpmHome: this.pnpmHome,
|
|
37416
37498
|
backing: (path, cwd, reads, pid) => this.backing(path, cwd, reads, pid),
|
|
37499
|
+
planFs: (reads) => this.sudoFs(reads),
|
|
37417
37500
|
approve: options.approve,
|
|
37418
37501
|
timeoutMs: options.sudoTimeoutMs,
|
|
37419
37502
|
now: sudoClock ? () => sudoClock.now() : void 0
|
|
@@ -37487,14 +37570,44 @@ var Launcher = class {
|
|
|
37487
37570
|
for (const listener of [...this.traitsListeners]) listener();
|
|
37488
37571
|
return true;
|
|
37489
37572
|
}
|
|
37490
|
-
|
|
37491
|
-
|
|
37573
|
+
catalogOf(reads) {
|
|
37574
|
+
if (!reads) return this.catalog;
|
|
37575
|
+
let cache = this.planCatalogs.get(reads);
|
|
37576
|
+
if (!cache) {
|
|
37577
|
+
cache = new CatalogCache();
|
|
37578
|
+
this.planCatalogs.set(reads, cache);
|
|
37579
|
+
}
|
|
37580
|
+
return cache;
|
|
37581
|
+
}
|
|
37582
|
+
scanFs(reads) {
|
|
37583
|
+
if (!reads) return this.scanned;
|
|
37584
|
+
return Object.assign(Object.create(this.scanned), {
|
|
37585
|
+
readFile: (path) => reads.manifest(
|
|
37586
|
+
path,
|
|
37587
|
+
async (real, hash) => {
|
|
37588
|
+
await this.integrity?.checkManifest(path, real, hash, KERNEL_CALLER);
|
|
37589
|
+
},
|
|
37590
|
+
(real) => this.base.readFileBuffer(real)
|
|
37591
|
+
)
|
|
37592
|
+
});
|
|
37593
|
+
}
|
|
37594
|
+
sudoFs(reads) {
|
|
37595
|
+
const cache = this.catalogOf(reads);
|
|
37596
|
+
return cache.fs ??= this.processView(
|
|
37597
|
+
this.commandFs(this.base, reads),
|
|
37598
|
+
this.nodes,
|
|
37599
|
+
this.unlinked
|
|
37600
|
+
);
|
|
37601
|
+
}
|
|
37602
|
+
commands(scope = "", reads) {
|
|
37603
|
+
const cache = this.catalogOf(reads).commands;
|
|
37604
|
+
let found = cache.get(scope);
|
|
37492
37605
|
if (!found) {
|
|
37493
37606
|
found = this.swaps.settled().then(() => this.trustedAppended()).then(async (appended2) => {
|
|
37494
37607
|
const tiers = await this.tiers(scope, appended2);
|
|
37495
37608
|
const refused5 = [];
|
|
37496
37609
|
const commands = await scanCommands(
|
|
37497
|
-
this.
|
|
37610
|
+
this.scanFs(reads),
|
|
37498
37611
|
tiers,
|
|
37499
37612
|
tiers.length - appended2.length,
|
|
37500
37613
|
void 0,
|
|
@@ -37506,7 +37619,7 @@ var Launcher = class {
|
|
|
37506
37619
|
}).then(
|
|
37507
37620
|
(commands) => this.refusals(commands).set(SUDO_COMMAND.name, SUDO_COMMAND).set(VISUDO_COMMAND.name, VISUDO_COMMAND).set(CRONTAB_COMMAND.name, CRONTAB_COMMAND).set(SEALED_COMMAND.name, SEALED_COMMAND)
|
|
37508
37621
|
);
|
|
37509
|
-
|
|
37622
|
+
cache.set(scope, found);
|
|
37510
37623
|
}
|
|
37511
37624
|
return found;
|
|
37512
37625
|
}
|
|
@@ -37521,25 +37634,26 @@ var Launcher = class {
|
|
|
37521
37634
|
}
|
|
37522
37635
|
return commands;
|
|
37523
37636
|
}
|
|
37524
|
-
ownCommands(scope) {
|
|
37525
|
-
|
|
37637
|
+
ownCommands(scope, reads) {
|
|
37638
|
+
const cache = this.catalogOf(reads).own;
|
|
37639
|
+
let found = cache.get(scope);
|
|
37526
37640
|
if (!found) {
|
|
37527
|
-
found = this.ownCatalog(scope);
|
|
37528
|
-
|
|
37641
|
+
found = this.ownCatalog(scope, reads);
|
|
37642
|
+
cache.set(scope, found);
|
|
37529
37643
|
}
|
|
37530
37644
|
return found;
|
|
37531
37645
|
}
|
|
37532
|
-
async ownCatalog(scope) {
|
|
37646
|
+
async ownCatalog(scope, reads) {
|
|
37533
37647
|
const roots = await pnpmGlobalRoots(this.base, scope);
|
|
37534
37648
|
const own = await scanCommands(
|
|
37535
|
-
this.
|
|
37649
|
+
this.scanFs(reads),
|
|
37536
37650
|
roots,
|
|
37537
37651
|
void 0,
|
|
37538
37652
|
void 0,
|
|
37539
37653
|
void 0,
|
|
37540
37654
|
new Set(roots)
|
|
37541
37655
|
);
|
|
37542
|
-
const system = await this.commands();
|
|
37656
|
+
const system = await this.commands("", reads);
|
|
37543
37657
|
return new Set(
|
|
37544
37658
|
[...own.values()].filter((command) => !command.dependency || !system.has(command.name)).map((command) => command.name)
|
|
37545
37659
|
);
|
|
@@ -37551,28 +37665,20 @@ var Launcher = class {
|
|
|
37551
37665
|
}
|
|
37552
37666
|
interpreters(scope = "", reads) {
|
|
37553
37667
|
if (this.leaseImage) return Promise.resolve([]);
|
|
37554
|
-
|
|
37555
|
-
let found =
|
|
37668
|
+
const cache = this.catalogOf(reads).rules;
|
|
37669
|
+
let found = cache.get(scope);
|
|
37556
37670
|
if (!found) {
|
|
37557
|
-
found = this.scanInterpreters(scope);
|
|
37558
|
-
|
|
37671
|
+
found = this.scanInterpreters(scope, reads);
|
|
37672
|
+
cache.set(scope, found);
|
|
37559
37673
|
}
|
|
37560
37674
|
return found;
|
|
37561
37675
|
}
|
|
37562
37676
|
async scanInterpreters(scope, reads) {
|
|
37563
|
-
|
|
37564
|
-
|
|
37565
|
-
|
|
37566
|
-
|
|
37567
|
-
|
|
37568
|
-
await this.roots(scope),
|
|
37569
|
-
(message3) => {
|
|
37570
|
-
if (this.warned.has(message3)) return;
|
|
37571
|
-
this.warned.add(message3);
|
|
37572
|
-
console.warn(message3);
|
|
37573
|
-
},
|
|
37574
|
-
read
|
|
37575
|
-
);
|
|
37677
|
+
return scanBinfmts(this.scanFs(reads), await this.roots(scope), (message3) => {
|
|
37678
|
+
if (this.warned.has(message3)) return;
|
|
37679
|
+
this.warned.add(message3);
|
|
37680
|
+
console.warn(message3);
|
|
37681
|
+
});
|
|
37576
37682
|
}
|
|
37577
37683
|
async tiers(scope = "", appended2) {
|
|
37578
37684
|
const system = [
|
|
@@ -37630,9 +37736,7 @@ var Launcher = class {
|
|
|
37630
37736
|
);
|
|
37631
37737
|
}
|
|
37632
37738
|
resetCatalogs() {
|
|
37633
|
-
this.
|
|
37634
|
-
this.ownCatalogs.clear();
|
|
37635
|
-
this.binfmts.clear();
|
|
37739
|
+
this.catalog = new CatalogCache();
|
|
37636
37740
|
}
|
|
37637
37741
|
userScopes() {
|
|
37638
37742
|
this.scopes ??= this.users.list().then(
|
|
@@ -37655,27 +37759,27 @@ var Launcher = class {
|
|
|
37655
37759
|
);
|
|
37656
37760
|
return this.scopes;
|
|
37657
37761
|
}
|
|
37658
|
-
async userCommandDir(dir) {
|
|
37762
|
+
async userCommandDir(dir, reads) {
|
|
37659
37763
|
const scope = (await this.userScopes()).byBin.get(dir);
|
|
37660
|
-
return scope === void 0 ? void 0 : this.ownCommands(scope);
|
|
37764
|
+
return scope === void 0 ? void 0 : this.ownCommands(scope, reads);
|
|
37661
37765
|
}
|
|
37662
37766
|
async scopeOf(uid) {
|
|
37663
37767
|
return (await this.userScopes()).byUid.get(uid) ?? "";
|
|
37664
37768
|
}
|
|
37665
|
-
async commandAt(file, scope) {
|
|
37769
|
+
async commandAt(file, scope, reads) {
|
|
37666
37770
|
const system = COMMAND2.exec(file)?.[1];
|
|
37667
|
-
if (system !== void 0) return (await this.commands()).get(system);
|
|
37668
|
-
if (!file.includes("/")) return (await this.commands(scope)).get(file);
|
|
37771
|
+
if (system !== void 0) return (await this.commands("", reads)).get(system);
|
|
37772
|
+
if (!file.includes("/")) return (await this.commands(scope, reads)).get(file);
|
|
37669
37773
|
const slash = file.lastIndexOf("/");
|
|
37670
37774
|
const owner = (await this.userScopes()).byBin.get(file.slice(0, slash));
|
|
37671
|
-
if (owner === void 0 || !(await this.ownCommands(owner)).has(file.slice(slash + 1))) {
|
|
37775
|
+
if (owner === void 0 || !(await this.ownCommands(owner, reads)).has(file.slice(slash + 1))) {
|
|
37672
37776
|
return void 0;
|
|
37673
37777
|
}
|
|
37674
|
-
return (await this.commands(owner)).get(file.slice(slash + 1));
|
|
37778
|
+
return (await this.commands(owner, reads)).get(file.slice(slash + 1));
|
|
37675
37779
|
}
|
|
37676
37780
|
async resolve(file, argv0, cwd, scope = "", reads) {
|
|
37677
37781
|
if (!file.includes("/") || COMMAND2.test(file)) {
|
|
37678
|
-
const command = await this.commandAt(file, scope);
|
|
37782
|
+
const command = await this.commandAt(file, scope, reads);
|
|
37679
37783
|
return command && !command.script ? targetOf(command) : void 0;
|
|
37680
37784
|
}
|
|
37681
37785
|
const path = this.fs.resolvePath(cwd, file);
|
|
@@ -37685,15 +37789,15 @@ var Launcher = class {
|
|
|
37685
37789
|
if (linked2 !== void 0) {
|
|
37686
37790
|
const found = await this.resolve(`/bin/${linked2}`, argv0, cwd, "", reads);
|
|
37687
37791
|
const target = found && { ...found, ...asked };
|
|
37688
|
-
const byPath = !COMMAND2.test(path) && (await this.commands()).get(linked2)?.argv0Path === true;
|
|
37792
|
+
const byPath = !COMMAND2.test(path) && (await this.commands("", reads)).get(linked2)?.argv0Path === true;
|
|
37689
37793
|
return target && byPath ? { ...target, argv0: path } : target;
|
|
37690
37794
|
}
|
|
37691
|
-
const own = await this.ownOrRefused(glue, baseName3(file), scope);
|
|
37795
|
+
const own = await this.ownOrRefused(glue, baseName3(file), scope, reads);
|
|
37692
37796
|
if (own) return own.script ? void 0 : { ...targetOf(own), ...asked };
|
|
37693
37797
|
const head = await this.head(glue, reads);
|
|
37694
37798
|
if (!head) return void 0;
|
|
37695
37799
|
if (isWasm(head)) {
|
|
37696
|
-
const owner2 = await this.wasmOwner(glue, baseName3(file).replace(/\.wasm$/, ""), scope);
|
|
37800
|
+
const owner2 = await this.wasmOwner(glue, baseName3(file).replace(/\.wasm$/, ""), scope, reads);
|
|
37697
37801
|
if (owner2) return { ...targetOf(owner2), ...asked };
|
|
37698
37802
|
return {
|
|
37699
37803
|
abi: "wasi",
|
|
@@ -37709,18 +37813,18 @@ var Launcher = class {
|
|
|
37709
37813
|
if (await this.base.exists(wasm)) {
|
|
37710
37814
|
return { abi: "emscripten", glue, wasm, argv0: baseName3(argv0 || file), ...asked };
|
|
37711
37815
|
}
|
|
37712
|
-
const owner = await this.glueOwner(glue, baseName3(file), scope);
|
|
37816
|
+
const owner = await this.glueOwner(glue, baseName3(file), scope, reads);
|
|
37713
37817
|
if (!owner) {
|
|
37714
|
-
const shim = await this.shimOwner(glue, baseName3(file), scope);
|
|
37818
|
+
const shim = await this.shimOwner(glue, baseName3(file), scope, reads);
|
|
37715
37819
|
return shim && { ...targetOf(shim), ...asked, shim: glue };
|
|
37716
37820
|
}
|
|
37717
37821
|
return { ...targetOf(owner), ...asked, ...owner.glue === glue ? {} : { copy: glue } };
|
|
37718
37822
|
}
|
|
37719
|
-
async ownOrRefused(path, name2, scope) {
|
|
37720
|
-
return await this.commandAt(path, scope) ?? await this.refusedAt(path, name2, scope);
|
|
37823
|
+
async ownOrRefused(path, name2, scope, reads) {
|
|
37824
|
+
return await this.commandAt(path, scope, reads) ?? await this.refusedAt(path, name2, scope, reads);
|
|
37721
37825
|
}
|
|
37722
|
-
async refusedAt(path, name2, scope) {
|
|
37723
|
-
const refused5 = this.refusedOf.get(await this.commands(scope)) ?? [];
|
|
37826
|
+
async refusedAt(path, name2, scope, reads) {
|
|
37827
|
+
const refused5 = this.refusedOf.get(await this.commands(scope, reads)) ?? [];
|
|
37724
37828
|
if (refused5.length === 0) return void 0;
|
|
37725
37829
|
const st = await this.base.stat(path).catch(() => void 0);
|
|
37726
37830
|
if (!st?.isFile) return void 0;
|
|
@@ -37749,8 +37853,8 @@ var Launcher = class {
|
|
|
37749
37853
|
}
|
|
37750
37854
|
return void 0;
|
|
37751
37855
|
}
|
|
37752
|
-
async shimOwner(script, name2, scope) {
|
|
37753
|
-
const command = (await this.commands(scope)).get(name2);
|
|
37856
|
+
async shimOwner(script, name2, scope, reads) {
|
|
37857
|
+
const command = (await this.commands(scope, reads)).get(name2);
|
|
37754
37858
|
if (!command || command.script || command.origin?.script) return void 0;
|
|
37755
37859
|
const target = await this.shimTarget(script);
|
|
37756
37860
|
if (target === void 0) return void 0;
|
|
@@ -37786,8 +37890,8 @@ var Launcher = class {
|
|
|
37786
37890
|
}
|
|
37787
37891
|
return void 0;
|
|
37788
37892
|
}
|
|
37789
|
-
async glueOwner(glue, name2, scope) {
|
|
37790
|
-
const commands = [...(await this.commands(scope)).values()];
|
|
37893
|
+
async glueOwner(glue, name2, scope, reads) {
|
|
37894
|
+
const commands = [...(await this.commands(scope, reads)).values()];
|
|
37791
37895
|
const owners = commands.filter((c) => c.abi === "emscripten" && !c.script && c.glue === glue);
|
|
37792
37896
|
if (owners.length > 0) return owners.find((c) => c.name === name2) ?? owners[0];
|
|
37793
37897
|
const leaf = baseName3(glue);
|
|
@@ -37812,11 +37916,11 @@ var Launcher = class {
|
|
|
37812
37916
|
this.sameFiles.set(`${a}|${b}`, { stamp, same: same3 });
|
|
37813
37917
|
return same3;
|
|
37814
37918
|
}
|
|
37815
|
-
async wasmOwner(wasm, name2, scope) {
|
|
37919
|
+
async wasmOwner(wasm, name2, scope, reads) {
|
|
37816
37920
|
const leaf = baseName3(wasm);
|
|
37817
37921
|
const real = await physicalPathAsync(this.base, wasm);
|
|
37818
37922
|
const owners = [];
|
|
37819
|
-
for (const command of (await this.commands(scope)).values()) {
|
|
37923
|
+
for (const command of (await this.commands(scope, reads)).values()) {
|
|
37820
37924
|
if (command.abi !== "wasi" || command.script || baseName3(command.wasm) !== leaf) continue;
|
|
37821
37925
|
if (command.wasm === wasm || await physicalPathAsync(this.base, command.wasm) === real)
|
|
37822
37926
|
owners.push(command);
|
|
@@ -37839,15 +37943,15 @@ var Launcher = class {
|
|
|
37839
37943
|
async scriptCommand(file, cwd, scope, reads) {
|
|
37840
37944
|
const direct = !file.includes("/") || COMMAND2.test(file);
|
|
37841
37945
|
const at = direct ? file : await this.followCommand(this.fs.resolvePath(cwd, file), reads);
|
|
37842
|
-
const command = await this.commandAt(at, scope);
|
|
37946
|
+
const command = await this.commandAt(at, scope, reads);
|
|
37843
37947
|
return command?.script ? command : void 0;
|
|
37844
37948
|
}
|
|
37845
|
-
async mayRead(reader, path) {
|
|
37949
|
+
async mayRead(reader, path, reads) {
|
|
37846
37950
|
if (!reader || !this.dac) return true;
|
|
37847
|
-
return (await access(this.fs, reader, path, R_OK)).denied === void 0;
|
|
37951
|
+
return (await access(reads ? this.sudoFs(reads) : this.fs, reader, path, R_OK)).denied === void 0;
|
|
37848
37952
|
}
|
|
37849
37953
|
async binfmtOf(path, head, scope, reader, reads) {
|
|
37850
|
-
const shown2 = await this.mayRead(reader, path) ? head : void 0;
|
|
37954
|
+
const shown2 = await this.mayRead(reader, path, reads) ? head : void 0;
|
|
37851
37955
|
return binfmtFor(await this.interpreters(scope, reads), path, shown2);
|
|
37852
37956
|
}
|
|
37853
37957
|
async interpreterWords(head, script, who) {
|
|
@@ -37885,6 +37989,7 @@ var Launcher = class {
|
|
|
37885
37989
|
const passed = [...args, command ? script : file, ...words3.kept, ...argv.slice(1)];
|
|
37886
37990
|
if (!interp) return void 0;
|
|
37887
37991
|
who.reads?.operandsFromEnd.set(passed.length - args.length, script);
|
|
37992
|
+
who.reads?.interpreters.push([script, ...words3.words, String(words3.kept.length)]);
|
|
37888
37993
|
const found = await this.resolve(interp, interp, cwd, scope, who.reads);
|
|
37889
37994
|
if (!found) {
|
|
37890
37995
|
const next3 = depth < MAX_INTERPRETERS ? await this.scriptCommand(interp, cwd, scope, who.reads) : void 0;
|
|
@@ -37946,13 +38051,19 @@ var Launcher = class {
|
|
|
37946
38051
|
const given = typeof argv0 === "string" ? { argv0 } : {};
|
|
37947
38052
|
const who = { scope, reader, reads, ...given };
|
|
37948
38053
|
const script = await this.interpreted(file, argv, cwd, who, command);
|
|
38054
|
+
if (reads && script)
|
|
38055
|
+
reads.chainSha256 = await sha256(
|
|
38056
|
+
new TextEncoder().encode(
|
|
38057
|
+
JSON.stringify([reads.interpreters, script.binfmts, script.target])
|
|
38058
|
+
)
|
|
38059
|
+
);
|
|
37949
38060
|
return { planned: script && { ...script, script: true }, ...examined };
|
|
37950
38061
|
}
|
|
37951
|
-
async mayExec(cred, req, { planned, examined }) {
|
|
38062
|
+
async mayExec(cred, req, { planned, examined }, reads) {
|
|
37952
38063
|
const { dac } = this;
|
|
37953
38064
|
if (!dac) return;
|
|
37954
38065
|
const g = {
|
|
37955
|
-
fs: this.fs,
|
|
38066
|
+
fs: reads ? this.sudoFs(reads) : this.fs,
|
|
37956
38067
|
cred,
|
|
37957
38068
|
pid: req.pid,
|
|
37958
38069
|
dac,
|
|
@@ -37979,10 +38090,11 @@ var Launcher = class {
|
|
|
37979
38090
|
throw err;
|
|
37980
38091
|
}
|
|
37981
38092
|
}
|
|
37982
|
-
planOrSearch(req, ctx) {
|
|
38093
|
+
async planOrSearch(req, ctx) {
|
|
38094
|
+
const reads = ctx.grant?.files && await this.scriptReads(ctx.grant.files, ctx.cred, ctx.ppid);
|
|
37983
38095
|
return planOrSearch(req, {
|
|
37984
|
-
listed: (file) => this.commandAt(file, ctx.scope),
|
|
37985
|
-
plan: (candidate, catalogOnly) => this.planOne(candidate, ctx, catalogOnly),
|
|
38096
|
+
listed: (file) => this.commandAt(file, ctx.scope, reads),
|
|
38097
|
+
plan: (candidate, catalogOnly) => this.planOne(candidate, ctx, catalogOnly, reads),
|
|
37986
38098
|
searchable: (dir) => this.execDirectory(
|
|
37987
38099
|
dir.startsWith("/") ? dir : `${req.cwd}/${dir}`,
|
|
37988
38100
|
this.execGuard(ctx.cred, ctx.ppid),
|
|
@@ -37990,22 +38102,26 @@ var Launcher = class {
|
|
|
37990
38102
|
)
|
|
37991
38103
|
});
|
|
37992
38104
|
}
|
|
37993
|
-
async planOne(req, { ppid, cred, scope, grant }, catalogOnly = false) {
|
|
38105
|
+
async planOne(req, { ppid, cred, scope, grant }, catalogOnly = false, prepared) {
|
|
37994
38106
|
const refused5 = (err) => {
|
|
37995
38107
|
throw codeOf9(err) === "EACCES" ? new SpawnError("EACCES") : err;
|
|
37996
38108
|
};
|
|
37997
38109
|
const file = await this.execFile(req.file, req.cwd, this.execGuard(cred, ppid), ppid).catch(
|
|
37998
38110
|
refused5
|
|
37999
38111
|
);
|
|
38000
|
-
const reads = grant?.files && await this.scriptReads(grant.files, cred, ppid);
|
|
38112
|
+
const reads = prepared ?? (grant?.files && await this.scriptReads(grant.files, cred, ppid));
|
|
38001
38113
|
const plan = await this.plan(file, req.argv, req.cwd, scope, {
|
|
38002
38114
|
argv0: req.argv0,
|
|
38003
38115
|
catalogOnly,
|
|
38004
38116
|
reader: cred,
|
|
38005
38117
|
reads
|
|
38006
38118
|
});
|
|
38007
|
-
await this.mayExec(cred, { ...req, file, pid: ppid }, plan).catch(refused5);
|
|
38119
|
+
await this.mayExec(cred, { ...req, file, pid: ppid }, plan, reads).catch(refused5);
|
|
38008
38120
|
if (plan.planned) return reads ? { ...plan.planned, reads } : plan.planned;
|
|
38121
|
+
if (grant?.files) {
|
|
38122
|
+
const gone = await this.sudoer.missingBacking(grant.files.hashes) ?? file;
|
|
38123
|
+
throw new ChangedError(changedText(gone), gone);
|
|
38124
|
+
}
|
|
38009
38125
|
if (catalogOnly) throw new SpawnError("ENOENT");
|
|
38010
38126
|
throw new SpawnError(await this.unrunnable(file, req.cwd, scope, cred));
|
|
38011
38127
|
}
|
|
@@ -38150,6 +38266,7 @@ var Launcher = class {
|
|
|
38150
38266
|
const now = await planned.reads.bind([file, grant.asked ?? file, ...files]);
|
|
38151
38267
|
refuseChanged(approved.hashes, now.hashes);
|
|
38152
38268
|
refuseChanged(approved.routes, now.routes);
|
|
38269
|
+
if (now.chainSha256 !== approved.chainSha256) throw new ChangedError(changedText(file), file);
|
|
38153
38270
|
return { pinned: approved };
|
|
38154
38271
|
}
|
|
38155
38272
|
approvedChain(planned, file, cwd, grant) {
|
|
@@ -38163,7 +38280,8 @@ var Launcher = class {
|
|
|
38163
38280
|
async scriptReads(files, cred, pid) {
|
|
38164
38281
|
await this.checkRoutes(files, false);
|
|
38165
38282
|
const snapshots = /* @__PURE__ */ new Map();
|
|
38166
|
-
const
|
|
38283
|
+
const reads = this.sudoer.reads(snapshots);
|
|
38284
|
+
const guard2 = { fs: this.sudoFs(reads), dac: this.dac, cred, pid, links: cred.euid };
|
|
38167
38285
|
for (const path of files.scripts ?? []) {
|
|
38168
38286
|
const real = files.routes[path];
|
|
38169
38287
|
const walked2 = await need(guard2, "open", path, R_OK, { directory: false });
|
|
@@ -38171,7 +38289,7 @@ var Launcher = class {
|
|
|
38171
38289
|
if (!snapshots.has(real))
|
|
38172
38290
|
snapshots.set(real, new Uint8Array(await this.noLinksFs.readFileBuffer(real)));
|
|
38173
38291
|
}
|
|
38174
|
-
return
|
|
38292
|
+
return reads;
|
|
38175
38293
|
}
|
|
38176
38294
|
scriptArgs(planned, files, fds) {
|
|
38177
38295
|
const reads = planned.reads;
|
|
@@ -40177,14 +40295,14 @@ var Launcher = class {
|
|
|
40177
40295
|
const watched = this.watchers.wrap(mounted);
|
|
40178
40296
|
return this.owners ? this.freshModules.wrap(watched) : watched;
|
|
40179
40297
|
}
|
|
40180
|
-
commandFs(root) {
|
|
40298
|
+
commandFs(root, reads) {
|
|
40181
40299
|
return withCommandDirs(
|
|
40182
40300
|
withEtcFiles(root, /* @__PURE__ */ new Map([[HOSTNAME_PATH, () => `${this.hostname}
|
|
40183
40301
|
`]])),
|
|
40184
|
-
async () => this.commandNames(await this.commands()),
|
|
40185
|
-
(dir) => this.userCommandDir(dir),
|
|
40302
|
+
async () => this.commandNames(await this.commands("", reads)),
|
|
40303
|
+
(dir) => this.userCommandDir(dir, reads),
|
|
40186
40304
|
this.owners,
|
|
40187
|
-
(path) => this.entryTarget(path)
|
|
40305
|
+
(path) => this.entryTarget(path, reads)
|
|
40188
40306
|
);
|
|
40189
40307
|
}
|
|
40190
40308
|
named = /* @__PURE__ */ new WeakMap();
|
|
@@ -40196,13 +40314,13 @@ var Launcher = class {
|
|
|
40196
40314
|
}
|
|
40197
40315
|
return names2;
|
|
40198
40316
|
}
|
|
40199
|
-
async entryTarget(path) {
|
|
40317
|
+
async entryTarget(path, reads) {
|
|
40200
40318
|
const system = COMMAND2.exec(path)?.[1];
|
|
40201
40319
|
const slash = path.lastIndexOf("/");
|
|
40202
40320
|
const scopes = await this.userScopes();
|
|
40203
40321
|
const scope = system === void 0 ? scopes.byBin.get(path.slice(0, slash)) : "";
|
|
40204
40322
|
const name2 = system ?? path.slice(slash + 1);
|
|
40205
|
-
const command = scope === void 0 ? void 0 : (await this.commands(scope)).get(name2);
|
|
40323
|
+
const command = scope === void 0 ? void 0 : (await this.commands(scope, reads)).get(name2);
|
|
40206
40324
|
const owner = scope ? scopes.owners?.get(scope) : void 0;
|
|
40207
40325
|
const target = command && (command.shows ?? command.script ?? command.wasm);
|
|
40208
40326
|
return target === void 0 ? void 0 : { path: target, ...owner ? { owner } : {} };
|
|
@@ -40224,6 +40342,9 @@ var Launcher = class {
|
|
|
40224
40342
|
nodes.changed = (path) => this.changes.publish(path);
|
|
40225
40343
|
nodes.movedAway = (from, to) => this.moved(from, to, nodes);
|
|
40226
40344
|
nodes.dirtied = (delta) => this.changes.dirtied(delta);
|
|
40345
|
+
return this.processView(fs, nodes, unlinked);
|
|
40346
|
+
}
|
|
40347
|
+
processView(fs, nodes, unlinked) {
|
|
40227
40348
|
const kept = keepingOpen(fs, nodes, (path) => this.changes.publish(path));
|
|
40228
40349
|
return this.textBusy.view(this.swaps.wrap(unlinked.wrap(kept)));
|
|
40229
40350
|
}
|