@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/node.js
CHANGED
|
@@ -7648,7 +7648,7 @@ function satisfies(version, range2) {
|
|
|
7648
7648
|
}
|
|
7649
7649
|
|
|
7650
7650
|
// src/version.ts
|
|
7651
|
-
var KERNEL_VERSION = true ? "1.195.
|
|
7651
|
+
var KERNEL_VERSION = true ? "1.195.31" : "0.0.0-dev";
|
|
7652
7652
|
var OS_RELEASE = "6.0.0-slicc";
|
|
7653
7653
|
function procVersion() {
|
|
7654
7654
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -8057,12 +8057,12 @@ function binfmtEntry(pkg, key, value2) {
|
|
|
8057
8057
|
return { name: key, pkg, command: value2, preserveArgv0: false };
|
|
8058
8058
|
}
|
|
8059
8059
|
async function scanBinfmts(fs, modules, warn = () => {
|
|
8060
|
-
}
|
|
8060
|
+
}) {
|
|
8061
8061
|
const found = /* @__PURE__ */ new Map();
|
|
8062
8062
|
for (const pkg of await packagesIn(fs, modules)) {
|
|
8063
8063
|
let manifest;
|
|
8064
8064
|
try {
|
|
8065
|
-
manifest = JSON.parse(await
|
|
8065
|
+
manifest = JSON.parse(await fs.readFile(`${pkg}/package.json`));
|
|
8066
8066
|
} catch {
|
|
8067
8067
|
continue;
|
|
8068
8068
|
}
|
|
@@ -11512,6 +11512,10 @@ var Integrity = class {
|
|
|
11512
11512
|
const found = await this.real(path, asked, real);
|
|
11513
11513
|
if (found) await this.verify(found.name, bytes, caller, EXEC_OPS);
|
|
11514
11514
|
}
|
|
11515
|
+
async checkManifest(path, real, hash, caller) {
|
|
11516
|
+
const found = await this.real(path, void 0, real);
|
|
11517
|
+
if (found) await this.checkHash(found.name, hash, caller, EXEC_OPS);
|
|
11518
|
+
}
|
|
11515
11519
|
get readsChecked() {
|
|
11516
11520
|
return this.sources.length > 0;
|
|
11517
11521
|
}
|
|
@@ -11554,7 +11558,9 @@ var Integrity = class {
|
|
|
11554
11558
|
return st?.isFile && ((st.mode ?? 0) & 73) !== 0 ? found : void 0;
|
|
11555
11559
|
}
|
|
11556
11560
|
async verify(name2, bytes, caller, ops) {
|
|
11557
|
-
|
|
11561
|
+
return this.checkHash(name2, await sha2562(bytes), caller, ops);
|
|
11562
|
+
}
|
|
11563
|
+
async checkHash(name2, actual, caller, ops) {
|
|
11558
11564
|
const denial = { pid: caller.pid, uid: caller.uid, path: name2, actual };
|
|
11559
11565
|
const tagged = caller.tag !== void 0 ? { tag: caller.tag } : {};
|
|
11560
11566
|
let expected;
|
|
@@ -18557,6 +18563,11 @@ var SudoReads = class {
|
|
|
18557
18563
|
access;
|
|
18558
18564
|
reads = /* @__PURE__ */ new Map();
|
|
18559
18565
|
names = /* @__PURE__ */ new Map();
|
|
18566
|
+
documents = /* @__PURE__ */ new Map();
|
|
18567
|
+
manifestFiles = /* @__PURE__ */ new Map();
|
|
18568
|
+
observed = /* @__PURE__ */ new Set();
|
|
18569
|
+
interpreters = [];
|
|
18570
|
+
chainSha256;
|
|
18560
18571
|
operandsFromEnd = /* @__PURE__ */ new Map();
|
|
18561
18572
|
snapshots;
|
|
18562
18573
|
constructor(access2, snapshots = /* @__PURE__ */ new Map()) {
|
|
@@ -18575,16 +18586,41 @@ var SudoReads = class {
|
|
|
18575
18586
|
const saved = this.snapshots.get(real);
|
|
18576
18587
|
return saved ? Promise.resolve(saved) : this.access.read(real);
|
|
18577
18588
|
}
|
|
18578
|
-
|
|
18589
|
+
manifest(path, verify, raw2) {
|
|
18590
|
+
let found = this.documents.get(path);
|
|
18591
|
+
if (!found) {
|
|
18592
|
+
found = this.readManifest(path, verify, raw2);
|
|
18593
|
+
this.documents.set(path, found);
|
|
18594
|
+
}
|
|
18595
|
+
return found;
|
|
18596
|
+
}
|
|
18597
|
+
async readManifest(path, verify, raw2) {
|
|
18579
18598
|
const real = await this.access.real(path);
|
|
18580
18599
|
this.saw(path, real);
|
|
18581
|
-
const
|
|
18582
|
-
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18600
|
+
const { text, read } = await this.document(real, raw2);
|
|
18601
|
+
this.observed.add(path);
|
|
18602
|
+
await verify(real, read.hash);
|
|
18603
|
+
return text;
|
|
18604
|
+
}
|
|
18605
|
+
document(real, raw2) {
|
|
18606
|
+
let found = this.manifestFiles.get(real);
|
|
18607
|
+
if (!found) {
|
|
18608
|
+
const saved = this.snapshots.get(real);
|
|
18609
|
+
found = (saved ? Promise.resolve(saved) : raw2(real)).then(async (data) => {
|
|
18610
|
+
const bytes = new Uint8Array(data);
|
|
18611
|
+
return { text: new TextDecoder().decode(bytes), read: await fingerprint(bytes) };
|
|
18612
|
+
});
|
|
18613
|
+
this.manifestFiles.set(real, found);
|
|
18614
|
+
const earlier = this.reads.get(real);
|
|
18615
|
+
this.reads.set(
|
|
18616
|
+
real,
|
|
18617
|
+
found.then(
|
|
18618
|
+
async ({ read }) => !earlier || (await earlier)?.hash === read.hash ? read : void 0,
|
|
18619
|
+
() => void 0
|
|
18620
|
+
)
|
|
18621
|
+
);
|
|
18622
|
+
}
|
|
18623
|
+
return found;
|
|
18588
18624
|
}
|
|
18589
18625
|
saw(path, real) {
|
|
18590
18626
|
const seen = this.names.get(path);
|
|
@@ -18598,10 +18634,15 @@ var SudoReads = class {
|
|
|
18598
18634
|
this.saw(path, real);
|
|
18599
18635
|
return (await this.bytes(real))?.head;
|
|
18600
18636
|
}
|
|
18637
|
+
*inputs(paths) {
|
|
18638
|
+
const primary = new Set(paths);
|
|
18639
|
+
yield* primary;
|
|
18640
|
+
for (const path of this.observed) if (!primary.has(path)) yield path;
|
|
18641
|
+
}
|
|
18601
18642
|
async bind(paths) {
|
|
18602
18643
|
const hashes = {};
|
|
18603
18644
|
const routes = {};
|
|
18604
|
-
for (const path of
|
|
18645
|
+
for (const path of this.inputs(paths)) {
|
|
18605
18646
|
if (await this.access.trusted(path)) continue;
|
|
18606
18647
|
const real = await this.access.real(path);
|
|
18607
18648
|
routes[path] = real;
|
|
@@ -18612,7 +18653,12 @@ var SudoReads = class {
|
|
|
18612
18653
|
const scripts = [...new Set(this.operandsFromEnd.values())].filter(
|
|
18613
18654
|
(path) => Object.hasOwn(routes, path)
|
|
18614
18655
|
);
|
|
18615
|
-
const binding = {
|
|
18656
|
+
const binding = {
|
|
18657
|
+
hashes,
|
|
18658
|
+
routes,
|
|
18659
|
+
...scripts.length ? { scripts } : {},
|
|
18660
|
+
...this.chainSha256 ? { chainSha256: this.chainSha256 } : {}
|
|
18661
|
+
};
|
|
18616
18662
|
if (!Object.keys(routes).some((path) => path !== routes[path])) return binding;
|
|
18617
18663
|
const pairs = Object.keys(routes).sort().map((path) => [path, routes[path]]);
|
|
18618
18664
|
const routeSha256 = await sha2562(new TextEncoder().encode(JSON.stringify(pairs)));
|
|
@@ -19679,8 +19725,14 @@ function changedFile(approved, now) {
|
|
|
19679
19725
|
function pinned(rule2, hashes, routeSha256) {
|
|
19680
19726
|
return rule2.sha256 === void 0 || rule2.routeSha256 === routeSha256 && changedFile(rule2.sha256, hashes) === void 0;
|
|
19681
19727
|
}
|
|
19682
|
-
function
|
|
19683
|
-
return routeSha256 ? {
|
|
19728
|
+
function proofOf({ routeSha256, chainSha256 }) {
|
|
19729
|
+
return { ...routeSha256 ? { routeSha256 } : {}, ...chainSha256 ? { chainSha256 } : {} };
|
|
19730
|
+
}
|
|
19731
|
+
function changedDecision(hashes, proof, now, path) {
|
|
19732
|
+
return changedFile(hashes, now.hashes) ?? (proof.routeSha256 !== now.routeSha256 || proof.chainSha256 !== now.chainSha256 ? path : void 0);
|
|
19733
|
+
}
|
|
19734
|
+
function stampOf(files) {
|
|
19735
|
+
return Object.keys(files.hashes).length ? { ...files.hashes, ...proofOf(files) } : files.hashes;
|
|
19684
19736
|
}
|
|
19685
19737
|
var REPLAY_ID = /^[!-~]{1,256}$/;
|
|
19686
19738
|
var REPLAY_TAGS_MAX = 64;
|
|
@@ -19695,13 +19747,23 @@ function words(value2) {
|
|
|
19695
19747
|
const bytes = value2.reduce((n, s) => n + s.length + 1, 0);
|
|
19696
19748
|
return bytes <= REPLAY_BYTES_MAX && !value2.some((s) => s.includes("\0"));
|
|
19697
19749
|
}
|
|
19750
|
+
var FACT_OVERHEAD = 66;
|
|
19751
|
+
function factsFit(files) {
|
|
19752
|
+
let budget = REPLAY_BYTES_MAX;
|
|
19753
|
+
for (const path of Object.keys(files))
|
|
19754
|
+
if ((budget -= storedSize(path) + FACT_OVERHEAD) < 0) return false;
|
|
19755
|
+
return true;
|
|
19756
|
+
}
|
|
19698
19757
|
function filesOf(value2) {
|
|
19699
19758
|
if (value2 === void 0) return {};
|
|
19700
|
-
if (!Array.isArray(value2) || value2.length >
|
|
19759
|
+
if (!Array.isArray(value2) || value2.length * FACT_OVERHEAD > REPLAY_BYTES_MAX) return void 0;
|
|
19701
19760
|
const files = {};
|
|
19761
|
+
let budget = REPLAY_BYTES_MAX;
|
|
19702
19762
|
for (const file of value2) {
|
|
19703
19763
|
const { path, sha256: hex4 } = file ?? {};
|
|
19704
|
-
if (typeof path !== "string" || typeof hex4 !== "string"
|
|
19764
|
+
if (typeof path !== "string" || !path.startsWith("/") || typeof hex4 !== "string" || !/^[0-9a-f]{64}$/.test(hex4))
|
|
19765
|
+
return void 0;
|
|
19766
|
+
if (path.length > budget || (budget -= storedSize(path) + FACT_OVERHEAD) < 0) return void 0;
|
|
19705
19767
|
files[path] = hex4;
|
|
19706
19768
|
}
|
|
19707
19769
|
return files;
|
|
@@ -19724,9 +19786,9 @@ function replayOf(value2) {
|
|
|
19724
19786
|
const { id: id2, user, uid, target, argv, path, cwd, stdin, tag, tags } = r;
|
|
19725
19787
|
const rootOnly = flagsOf(r.rootOnly);
|
|
19726
19788
|
const bound3 = filesOf(r.userWritable);
|
|
19727
|
-
const { routeSha256 } = r;
|
|
19728
|
-
|
|
19729
|
-
|
|
19789
|
+
const { routeSha256, chainSha256 } = r;
|
|
19790
|
+
const digest = (v) => v === void 0 || typeof v === "string" && /^[0-9a-f]{64}$/.test(v);
|
|
19791
|
+
if (!digest(routeSha256) || !digest(chainSha256)) return failed2("EINVAL", NOT_A_REQUEST);
|
|
19730
19792
|
const named = (s) => typeof s === "string" && s !== "";
|
|
19731
19793
|
const absolute2 = (s) => typeof s === "string" && s.startsWith("/") && s.length <= PATH_MAX2 && !s.includes("\0");
|
|
19732
19794
|
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;
|
|
@@ -19744,6 +19806,7 @@ function replayOf(value2) {
|
|
|
19744
19806
|
rootOnly,
|
|
19745
19807
|
bound: bound3,
|
|
19746
19808
|
...routeSha256 === void 0 ? {} : { routeSha256 },
|
|
19809
|
+
...chainSha256 === void 0 ? {} : { chainSha256 },
|
|
19747
19810
|
tags: [...new Set(all)]
|
|
19748
19811
|
};
|
|
19749
19812
|
}
|
|
@@ -19921,8 +19984,7 @@ var Sudo = class {
|
|
|
19921
19984
|
}
|
|
19922
19985
|
return true;
|
|
19923
19986
|
}
|
|
19924
|
-
async trustedThrough(path, destination) {
|
|
19925
|
-
const { fs } = this.o;
|
|
19987
|
+
async trustedThrough(path, destination, fs = this.o.fs) {
|
|
19926
19988
|
if (!heldByRoot(await fs.lstat("/").catch(() => void 0))) return false;
|
|
19927
19989
|
const queue = path.split("/").filter(Boolean);
|
|
19928
19990
|
const done4 = [];
|
|
@@ -20111,18 +20173,26 @@ var Sudo = class {
|
|
|
20111
20173
|
}
|
|
20112
20174
|
return void 0;
|
|
20113
20175
|
}
|
|
20176
|
+
async missingBacking(hashes, except) {
|
|
20177
|
+
for (const path of Object.keys(hashes)) {
|
|
20178
|
+
if (path !== except && !(await this.o.fs.stat(path).catch(() => void 0))?.isFile)
|
|
20179
|
+
return path;
|
|
20180
|
+
}
|
|
20181
|
+
return void 0;
|
|
20182
|
+
}
|
|
20114
20183
|
reads(snapshots) {
|
|
20115
|
-
|
|
20184
|
+
const reads = new SudoReads(
|
|
20116
20185
|
{
|
|
20117
20186
|
real: (at) => this.real(at),
|
|
20118
|
-
trusted: (at) => this.trustedThrough(at),
|
|
20119
|
-
read: (at) =>
|
|
20187
|
+
trusted: (at) => this.trustedThrough(at, void 0, fs),
|
|
20188
|
+
read: (at) => fs.readFileBuffer(at)
|
|
20120
20189
|
},
|
|
20121
20190
|
snapshots
|
|
20122
20191
|
);
|
|
20192
|
+
const fs = this.o.planFs?.(reads) ?? this.o.fs;
|
|
20193
|
+
return reads;
|
|
20123
20194
|
}
|
|
20124
|
-
async bound(path, cwd, asked = path, pid) {
|
|
20125
|
-
const reads = this.reads();
|
|
20195
|
+
async bound(path, cwd, asked = path, pid, reads = this.reads()) {
|
|
20126
20196
|
const files = this.o.backing ? await this.o.backing(path, cwd, reads, pid) : [];
|
|
20127
20197
|
const bound3 = files && await reads.bind([path, asked, ...files]);
|
|
20128
20198
|
return bound3 && !Object.values(bound3.hashes).includes("") && (bound3.routes[asked] ?? path) === path ? bound3 : void 0;
|
|
@@ -20134,8 +20204,8 @@ var Sudo = class {
|
|
|
20134
20204
|
if (bound3) return Object.keys(bound3.hashes).length > 0;
|
|
20135
20205
|
return !await this.trusted(await this.existing(path));
|
|
20136
20206
|
}
|
|
20137
|
-
async locate(word, cwd) {
|
|
20138
|
-
const
|
|
20207
|
+
async locate(word, cwd, reads) {
|
|
20208
|
+
const fs = this.o.planFs?.(reads) ?? this.o.fs;
|
|
20139
20209
|
const candidates = word.includes("/") ? [fs.resolvePath(cwd, word)] : SECURE_PATH.split(":").map((dir) => `${dir}/${word}`);
|
|
20140
20210
|
for (const path of candidates) {
|
|
20141
20211
|
const st = await fs.stat(path).catch(() => void 0);
|
|
@@ -20226,13 +20296,17 @@ var Sudo = class {
|
|
|
20226
20296
|
`sudo: cannot run in ${r.cwd}: it isn't a directory ${self.name} can enter`
|
|
20227
20297
|
);
|
|
20228
20298
|
}
|
|
20229
|
-
const
|
|
20230
|
-
|
|
20299
|
+
const reads = this.reads();
|
|
20300
|
+
const located = await this.locate(word, r.cwd, reads);
|
|
20301
|
+
if (!located) {
|
|
20302
|
+
const gone = await this.missingBacking(r.bound, r.path);
|
|
20303
|
+
return gone ? failed2("EPERM", requestedText(gone)) : failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
20304
|
+
}
|
|
20231
20305
|
const { path, asked } = located;
|
|
20232
20306
|
if (path !== r.path) return failed2("EPERM", `sudo: ${word} now runs ${path}, not ${r.path}`);
|
|
20233
|
-
const bound3 = await this.bound(path, r.cwd, asked);
|
|
20234
|
-
if (!bound3) return failed2("
|
|
20235
|
-
const changed2 =
|
|
20307
|
+
const bound3 = await this.bound(path, r.cwd, asked, void 0, reads);
|
|
20308
|
+
if (!bound3) return failed2("EPERM", requestedText(await this.missingBacking(r.bound) ?? path));
|
|
20309
|
+
const changed2 = changedDecision(r.bound, r, bound3, path);
|
|
20236
20310
|
if (changed2 !== void 0) return failed2("EPERM", requestedText(changed2));
|
|
20237
20311
|
const now = await this.rootOnly(r.cwd, args);
|
|
20238
20312
|
const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
|
|
@@ -20274,8 +20348,9 @@ var Sudo = class {
|
|
|
20274
20348
|
`sudo: cannot run in ${call.cwd}: it isn't a directory you can enter`
|
|
20275
20349
|
);
|
|
20276
20350
|
}
|
|
20277
|
-
const
|
|
20278
|
-
const
|
|
20351
|
+
const reads = this.reads();
|
|
20352
|
+
const located = await this.locate(word, cwd, reads);
|
|
20353
|
+
const bound3 = located && await this.bound(located.path, cwd, located.asked, caller.pid, reads);
|
|
20279
20354
|
if (!located || !bound3) return failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
20280
20355
|
const { path, asked } = located;
|
|
20281
20356
|
const argv = [path, ...args];
|
|
@@ -20298,13 +20373,13 @@ var Sudo = class {
|
|
|
20298
20373
|
}
|
|
20299
20374
|
if (parsed3.nonInteractive) return failed2("EPERM", "sudo: a password is required");
|
|
20300
20375
|
return this.pendingFor(cred.ruid, async () => {
|
|
20301
|
-
const
|
|
20376
|
+
const proof = proofOf(bound3);
|
|
20302
20377
|
const answer2 = await this.ask(s, {
|
|
20303
20378
|
argv: parsed3.command,
|
|
20304
20379
|
path,
|
|
20305
20380
|
cwd,
|
|
20306
20381
|
bound: bound3.hashes,
|
|
20307
|
-
...
|
|
20382
|
+
...proof
|
|
20308
20383
|
});
|
|
20309
20384
|
if ("error" in answer2) return answer2;
|
|
20310
20385
|
if (await this.canonical(call.cwd) !== cwd || !await this.reachable(cred, cwd)) {
|
|
@@ -20312,14 +20387,17 @@ var Sudo = class {
|
|
|
20312
20387
|
}
|
|
20313
20388
|
const moved2 = await this.moved(bound3);
|
|
20314
20389
|
if (moved2 !== void 0) return failed2("EPERM", changedText(moved2));
|
|
20390
|
+
if (answer2.answer === "once" && !answer2.person) return grant();
|
|
20315
20391
|
const now = await this.bound(path, cwd, asked, caller.pid);
|
|
20316
|
-
if (!now)
|
|
20392
|
+
if (!now)
|
|
20393
|
+
return failed2("EPERM", changedText(await this.missingBacking(bound3.hashes) ?? path));
|
|
20394
|
+
const changed2 = changedDecision(bound3.hashes, bound3, now, path);
|
|
20395
|
+
if (changed2 !== void 0) return failed2("EPERM", changedText(changed2));
|
|
20317
20396
|
const shown2 = recordable(cwd, [...parsed3.command, ...Object.keys(bound3.hashes)]);
|
|
20318
20397
|
const result = answer2.answer === "once" ? grant() : await this.always(
|
|
20319
20398
|
self,
|
|
20320
20399
|
target,
|
|
20321
|
-
{ cwd, argv, bound: bound3.hashes, ...
|
|
20322
|
-
now,
|
|
20400
|
+
{ cwd, argv, bound: bound3.hashes, ...proof },
|
|
20323
20401
|
shown2,
|
|
20324
20402
|
grant
|
|
20325
20403
|
);
|
|
@@ -20369,11 +20447,8 @@ var Sudo = class {
|
|
|
20369
20447
|
`sudo: ${self.name} : TTY=${tty} ; PWD=${quoteWord(cwd)} ; USER=${target.name} ; TIMESTAMP=${type} ; COMMAND=${command}`
|
|
20370
20448
|
);
|
|
20371
20449
|
}
|
|
20372
|
-
async always(self, target, line,
|
|
20373
|
-
|
|
20374
|
-
if (!shown2 || !recordable(cwd, argv)) return { ...grant(), notice: RAN_ONCE };
|
|
20375
|
-
const changed2 = changedFile(bound3, now.hashes) ?? (line.routeSha256 !== now.routeSha256 ? argv[0] : void 0);
|
|
20376
|
-
if (changed2 !== void 0) return failed2("EPERM", changedText(changed2));
|
|
20450
|
+
async always(self, target, line, shown2, grant) {
|
|
20451
|
+
if (!shown2 || !recordable(line.cwd, line.argv)) return { ...grant(), notice: RAN_ONCE };
|
|
20377
20452
|
if (!await this.remember(self, target, line)) {
|
|
20378
20453
|
return failed2("EIO", "sudo: the rule could not be recorded");
|
|
20379
20454
|
}
|
|
@@ -20408,6 +20483,8 @@ ${lines3}
|
|
|
20408
20483
|
async ask(s, asked) {
|
|
20409
20484
|
const { caller, self, target, signal: requester } = s;
|
|
20410
20485
|
const { argv, path, cwd } = asked;
|
|
20486
|
+
if (!factsFit(asked.bound))
|
|
20487
|
+
return failed2("E2BIG", "sudo: too many user-writable file facts for an approval request");
|
|
20411
20488
|
const { approve } = this.o;
|
|
20412
20489
|
if (!approve || requester.aborted) return failed2("EACCES", DENIED2);
|
|
20413
20490
|
const createdAt = Date.now();
|
|
@@ -20430,7 +20507,7 @@ ${lines3}
|
|
|
20430
20507
|
stdin: caller.stdin,
|
|
20431
20508
|
rootOnly: asked.validate ? {} : await this.rootOnly(cwd, argv.slice(1)),
|
|
20432
20509
|
...userWritable(asked.bound),
|
|
20433
|
-
...asked
|
|
20510
|
+
...proofOf(asked),
|
|
20434
20511
|
...asked.validate ? { validate: true } : {},
|
|
20435
20512
|
timestamp: true
|
|
20436
20513
|
};
|
|
@@ -37057,6 +37134,12 @@ function addTimes(into, pid, t) {
|
|
|
37057
37134
|
function locksForPackages(options) {
|
|
37058
37135
|
return new PackageLocks(options.packageLocks ?? META_DB, options.leaseImage ? null : void 0);
|
|
37059
37136
|
}
|
|
37137
|
+
var CatalogCache = class {
|
|
37138
|
+
commands = /* @__PURE__ */ new Map();
|
|
37139
|
+
own = /* @__PURE__ */ new Map();
|
|
37140
|
+
rules = /* @__PURE__ */ new Map();
|
|
37141
|
+
fs;
|
|
37142
|
+
};
|
|
37060
37143
|
var Launcher = class {
|
|
37061
37144
|
emscripten;
|
|
37062
37145
|
admit;
|
|
@@ -37083,9 +37166,8 @@ var Launcher = class {
|
|
|
37083
37166
|
appended;
|
|
37084
37167
|
reportedRoots = /* @__PURE__ */ new Set();
|
|
37085
37168
|
env;
|
|
37086
|
-
|
|
37087
|
-
|
|
37088
|
-
binfmts = /* @__PURE__ */ new Map();
|
|
37169
|
+
catalog = new CatalogCache();
|
|
37170
|
+
planCatalogs = /* @__PURE__ */ new WeakMap();
|
|
37089
37171
|
scopes;
|
|
37090
37172
|
unwatchScopes = () => void 0;
|
|
37091
37173
|
warned = /* @__PURE__ */ new Set();
|
|
@@ -37363,6 +37445,7 @@ var Launcher = class {
|
|
|
37363
37445
|
env: () => this.env,
|
|
37364
37446
|
pnpmHome: this.pnpmHome,
|
|
37365
37447
|
backing: (path, cwd, reads, pid) => this.backing(path, cwd, reads, pid),
|
|
37448
|
+
planFs: (reads) => this.sudoFs(reads),
|
|
37366
37449
|
approve: options.approve,
|
|
37367
37450
|
timeoutMs: options.sudoTimeoutMs,
|
|
37368
37451
|
now: sudoClock ? () => sudoClock.now() : void 0
|
|
@@ -37436,14 +37519,44 @@ var Launcher = class {
|
|
|
37436
37519
|
for (const listener of [...this.traitsListeners]) listener();
|
|
37437
37520
|
return true;
|
|
37438
37521
|
}
|
|
37439
|
-
|
|
37440
|
-
|
|
37522
|
+
catalogOf(reads) {
|
|
37523
|
+
if (!reads) return this.catalog;
|
|
37524
|
+
let cache = this.planCatalogs.get(reads);
|
|
37525
|
+
if (!cache) {
|
|
37526
|
+
cache = new CatalogCache();
|
|
37527
|
+
this.planCatalogs.set(reads, cache);
|
|
37528
|
+
}
|
|
37529
|
+
return cache;
|
|
37530
|
+
}
|
|
37531
|
+
scanFs(reads) {
|
|
37532
|
+
if (!reads) return this.scanned;
|
|
37533
|
+
return Object.assign(Object.create(this.scanned), {
|
|
37534
|
+
readFile: (path) => reads.manifest(
|
|
37535
|
+
path,
|
|
37536
|
+
async (real, hash) => {
|
|
37537
|
+
await this.integrity?.checkManifest(path, real, hash, KERNEL_CALLER);
|
|
37538
|
+
},
|
|
37539
|
+
(real) => this.base.readFileBuffer(real)
|
|
37540
|
+
)
|
|
37541
|
+
});
|
|
37542
|
+
}
|
|
37543
|
+
sudoFs(reads) {
|
|
37544
|
+
const cache = this.catalogOf(reads);
|
|
37545
|
+
return cache.fs ??= this.processView(
|
|
37546
|
+
this.commandFs(this.base, reads),
|
|
37547
|
+
this.nodes,
|
|
37548
|
+
this.unlinked
|
|
37549
|
+
);
|
|
37550
|
+
}
|
|
37551
|
+
commands(scope = "", reads) {
|
|
37552
|
+
const cache = this.catalogOf(reads).commands;
|
|
37553
|
+
let found = cache.get(scope);
|
|
37441
37554
|
if (!found) {
|
|
37442
37555
|
found = this.swaps.settled().then(() => this.trustedAppended()).then(async (appended2) => {
|
|
37443
37556
|
const tiers = await this.tiers(scope, appended2);
|
|
37444
37557
|
const refused5 = [];
|
|
37445
37558
|
const commands = await scanCommands(
|
|
37446
|
-
this.
|
|
37559
|
+
this.scanFs(reads),
|
|
37447
37560
|
tiers,
|
|
37448
37561
|
tiers.length - appended2.length,
|
|
37449
37562
|
void 0,
|
|
@@ -37455,7 +37568,7 @@ var Launcher = class {
|
|
|
37455
37568
|
}).then(
|
|
37456
37569
|
(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)
|
|
37457
37570
|
);
|
|
37458
|
-
|
|
37571
|
+
cache.set(scope, found);
|
|
37459
37572
|
}
|
|
37460
37573
|
return found;
|
|
37461
37574
|
}
|
|
@@ -37470,25 +37583,26 @@ var Launcher = class {
|
|
|
37470
37583
|
}
|
|
37471
37584
|
return commands;
|
|
37472
37585
|
}
|
|
37473
|
-
ownCommands(scope) {
|
|
37474
|
-
|
|
37586
|
+
ownCommands(scope, reads) {
|
|
37587
|
+
const cache = this.catalogOf(reads).own;
|
|
37588
|
+
let found = cache.get(scope);
|
|
37475
37589
|
if (!found) {
|
|
37476
|
-
found = this.ownCatalog(scope);
|
|
37477
|
-
|
|
37590
|
+
found = this.ownCatalog(scope, reads);
|
|
37591
|
+
cache.set(scope, found);
|
|
37478
37592
|
}
|
|
37479
37593
|
return found;
|
|
37480
37594
|
}
|
|
37481
|
-
async ownCatalog(scope) {
|
|
37595
|
+
async ownCatalog(scope, reads) {
|
|
37482
37596
|
const roots = await pnpmGlobalRoots(this.base, scope);
|
|
37483
37597
|
const own = await scanCommands(
|
|
37484
|
-
this.
|
|
37598
|
+
this.scanFs(reads),
|
|
37485
37599
|
roots,
|
|
37486
37600
|
void 0,
|
|
37487
37601
|
void 0,
|
|
37488
37602
|
void 0,
|
|
37489
37603
|
new Set(roots)
|
|
37490
37604
|
);
|
|
37491
|
-
const system = await this.commands();
|
|
37605
|
+
const system = await this.commands("", reads);
|
|
37492
37606
|
return new Set(
|
|
37493
37607
|
[...own.values()].filter((command) => !command.dependency || !system.has(command.name)).map((command) => command.name)
|
|
37494
37608
|
);
|
|
@@ -37500,28 +37614,20 @@ var Launcher = class {
|
|
|
37500
37614
|
}
|
|
37501
37615
|
interpreters(scope = "", reads) {
|
|
37502
37616
|
if (this.leaseImage) return Promise.resolve([]);
|
|
37503
|
-
|
|
37504
|
-
let found =
|
|
37617
|
+
const cache = this.catalogOf(reads).rules;
|
|
37618
|
+
let found = cache.get(scope);
|
|
37505
37619
|
if (!found) {
|
|
37506
|
-
found = this.scanInterpreters(scope);
|
|
37507
|
-
|
|
37620
|
+
found = this.scanInterpreters(scope, reads);
|
|
37621
|
+
cache.set(scope, found);
|
|
37508
37622
|
}
|
|
37509
37623
|
return found;
|
|
37510
37624
|
}
|
|
37511
37625
|
async scanInterpreters(scope, reads) {
|
|
37512
|
-
|
|
37513
|
-
|
|
37514
|
-
|
|
37515
|
-
|
|
37516
|
-
|
|
37517
|
-
await this.roots(scope),
|
|
37518
|
-
(message3) => {
|
|
37519
|
-
if (this.warned.has(message3)) return;
|
|
37520
|
-
this.warned.add(message3);
|
|
37521
|
-
console.warn(message3);
|
|
37522
|
-
},
|
|
37523
|
-
read
|
|
37524
|
-
);
|
|
37626
|
+
return scanBinfmts(this.scanFs(reads), await this.roots(scope), (message3) => {
|
|
37627
|
+
if (this.warned.has(message3)) return;
|
|
37628
|
+
this.warned.add(message3);
|
|
37629
|
+
console.warn(message3);
|
|
37630
|
+
});
|
|
37525
37631
|
}
|
|
37526
37632
|
async tiers(scope = "", appended2) {
|
|
37527
37633
|
const system = [
|
|
@@ -37579,9 +37685,7 @@ var Launcher = class {
|
|
|
37579
37685
|
);
|
|
37580
37686
|
}
|
|
37581
37687
|
resetCatalogs() {
|
|
37582
|
-
this.
|
|
37583
|
-
this.ownCatalogs.clear();
|
|
37584
|
-
this.binfmts.clear();
|
|
37688
|
+
this.catalog = new CatalogCache();
|
|
37585
37689
|
}
|
|
37586
37690
|
userScopes() {
|
|
37587
37691
|
this.scopes ??= this.users.list().then(
|
|
@@ -37604,27 +37708,27 @@ var Launcher = class {
|
|
|
37604
37708
|
);
|
|
37605
37709
|
return this.scopes;
|
|
37606
37710
|
}
|
|
37607
|
-
async userCommandDir(dir) {
|
|
37711
|
+
async userCommandDir(dir, reads) {
|
|
37608
37712
|
const scope = (await this.userScopes()).byBin.get(dir);
|
|
37609
|
-
return scope === void 0 ? void 0 : this.ownCommands(scope);
|
|
37713
|
+
return scope === void 0 ? void 0 : this.ownCommands(scope, reads);
|
|
37610
37714
|
}
|
|
37611
37715
|
async scopeOf(uid) {
|
|
37612
37716
|
return (await this.userScopes()).byUid.get(uid) ?? "";
|
|
37613
37717
|
}
|
|
37614
|
-
async commandAt(file, scope) {
|
|
37718
|
+
async commandAt(file, scope, reads) {
|
|
37615
37719
|
const system = COMMAND2.exec(file)?.[1];
|
|
37616
|
-
if (system !== void 0) return (await this.commands()).get(system);
|
|
37617
|
-
if (!file.includes("/")) return (await this.commands(scope)).get(file);
|
|
37720
|
+
if (system !== void 0) return (await this.commands("", reads)).get(system);
|
|
37721
|
+
if (!file.includes("/")) return (await this.commands(scope, reads)).get(file);
|
|
37618
37722
|
const slash = file.lastIndexOf("/");
|
|
37619
37723
|
const owner = (await this.userScopes()).byBin.get(file.slice(0, slash));
|
|
37620
|
-
if (owner === void 0 || !(await this.ownCommands(owner)).has(file.slice(slash + 1))) {
|
|
37724
|
+
if (owner === void 0 || !(await this.ownCommands(owner, reads)).has(file.slice(slash + 1))) {
|
|
37621
37725
|
return void 0;
|
|
37622
37726
|
}
|
|
37623
|
-
return (await this.commands(owner)).get(file.slice(slash + 1));
|
|
37727
|
+
return (await this.commands(owner, reads)).get(file.slice(slash + 1));
|
|
37624
37728
|
}
|
|
37625
37729
|
async resolve(file, argv0, cwd, scope = "", reads) {
|
|
37626
37730
|
if (!file.includes("/") || COMMAND2.test(file)) {
|
|
37627
|
-
const command = await this.commandAt(file, scope);
|
|
37731
|
+
const command = await this.commandAt(file, scope, reads);
|
|
37628
37732
|
return command && !command.script ? targetOf(command) : void 0;
|
|
37629
37733
|
}
|
|
37630
37734
|
const path = this.fs.resolvePath(cwd, file);
|
|
@@ -37634,15 +37738,15 @@ var Launcher = class {
|
|
|
37634
37738
|
if (linked2 !== void 0) {
|
|
37635
37739
|
const found = await this.resolve(`/bin/${linked2}`, argv0, cwd, "", reads);
|
|
37636
37740
|
const target = found && { ...found, ...asked };
|
|
37637
|
-
const byPath = !COMMAND2.test(path) && (await this.commands()).get(linked2)?.argv0Path === true;
|
|
37741
|
+
const byPath = !COMMAND2.test(path) && (await this.commands("", reads)).get(linked2)?.argv0Path === true;
|
|
37638
37742
|
return target && byPath ? { ...target, argv0: path } : target;
|
|
37639
37743
|
}
|
|
37640
|
-
const own = await this.ownOrRefused(glue, baseName3(file), scope);
|
|
37744
|
+
const own = await this.ownOrRefused(glue, baseName3(file), scope, reads);
|
|
37641
37745
|
if (own) return own.script ? void 0 : { ...targetOf(own), ...asked };
|
|
37642
37746
|
const head = await this.head(glue, reads);
|
|
37643
37747
|
if (!head) return void 0;
|
|
37644
37748
|
if (isWasm(head)) {
|
|
37645
|
-
const owner2 = await this.wasmOwner(glue, baseName3(file).replace(/\.wasm$/, ""), scope);
|
|
37749
|
+
const owner2 = await this.wasmOwner(glue, baseName3(file).replace(/\.wasm$/, ""), scope, reads);
|
|
37646
37750
|
if (owner2) return { ...targetOf(owner2), ...asked };
|
|
37647
37751
|
return {
|
|
37648
37752
|
abi: "wasi",
|
|
@@ -37658,18 +37762,18 @@ var Launcher = class {
|
|
|
37658
37762
|
if (await this.base.exists(wasm)) {
|
|
37659
37763
|
return { abi: "emscripten", glue, wasm, argv0: baseName3(argv0 || file), ...asked };
|
|
37660
37764
|
}
|
|
37661
|
-
const owner = await this.glueOwner(glue, baseName3(file), scope);
|
|
37765
|
+
const owner = await this.glueOwner(glue, baseName3(file), scope, reads);
|
|
37662
37766
|
if (!owner) {
|
|
37663
|
-
const shim = await this.shimOwner(glue, baseName3(file), scope);
|
|
37767
|
+
const shim = await this.shimOwner(glue, baseName3(file), scope, reads);
|
|
37664
37768
|
return shim && { ...targetOf(shim), ...asked, shim: glue };
|
|
37665
37769
|
}
|
|
37666
37770
|
return { ...targetOf(owner), ...asked, ...owner.glue === glue ? {} : { copy: glue } };
|
|
37667
37771
|
}
|
|
37668
|
-
async ownOrRefused(path, name2, scope) {
|
|
37669
|
-
return await this.commandAt(path, scope) ?? await this.refusedAt(path, name2, scope);
|
|
37772
|
+
async ownOrRefused(path, name2, scope, reads) {
|
|
37773
|
+
return await this.commandAt(path, scope, reads) ?? await this.refusedAt(path, name2, scope, reads);
|
|
37670
37774
|
}
|
|
37671
|
-
async refusedAt(path, name2, scope) {
|
|
37672
|
-
const refused5 = this.refusedOf.get(await this.commands(scope)) ?? [];
|
|
37775
|
+
async refusedAt(path, name2, scope, reads) {
|
|
37776
|
+
const refused5 = this.refusedOf.get(await this.commands(scope, reads)) ?? [];
|
|
37673
37777
|
if (refused5.length === 0) return void 0;
|
|
37674
37778
|
const st = await this.base.stat(path).catch(() => void 0);
|
|
37675
37779
|
if (!st?.isFile) return void 0;
|
|
@@ -37698,8 +37802,8 @@ var Launcher = class {
|
|
|
37698
37802
|
}
|
|
37699
37803
|
return void 0;
|
|
37700
37804
|
}
|
|
37701
|
-
async shimOwner(script, name2, scope) {
|
|
37702
|
-
const command = (await this.commands(scope)).get(name2);
|
|
37805
|
+
async shimOwner(script, name2, scope, reads) {
|
|
37806
|
+
const command = (await this.commands(scope, reads)).get(name2);
|
|
37703
37807
|
if (!command || command.script || command.origin?.script) return void 0;
|
|
37704
37808
|
const target = await this.shimTarget(script);
|
|
37705
37809
|
if (target === void 0) return void 0;
|
|
@@ -37735,8 +37839,8 @@ var Launcher = class {
|
|
|
37735
37839
|
}
|
|
37736
37840
|
return void 0;
|
|
37737
37841
|
}
|
|
37738
|
-
async glueOwner(glue, name2, scope) {
|
|
37739
|
-
const commands = [...(await this.commands(scope)).values()];
|
|
37842
|
+
async glueOwner(glue, name2, scope, reads) {
|
|
37843
|
+
const commands = [...(await this.commands(scope, reads)).values()];
|
|
37740
37844
|
const owners = commands.filter((c) => c.abi === "emscripten" && !c.script && c.glue === glue);
|
|
37741
37845
|
if (owners.length > 0) return owners.find((c) => c.name === name2) ?? owners[0];
|
|
37742
37846
|
const leaf = baseName3(glue);
|
|
@@ -37761,11 +37865,11 @@ var Launcher = class {
|
|
|
37761
37865
|
this.sameFiles.set(`${a}|${b}`, { stamp, same: same2 });
|
|
37762
37866
|
return same2;
|
|
37763
37867
|
}
|
|
37764
|
-
async wasmOwner(wasm, name2, scope) {
|
|
37868
|
+
async wasmOwner(wasm, name2, scope, reads) {
|
|
37765
37869
|
const leaf = baseName3(wasm);
|
|
37766
37870
|
const real = await physicalPathAsync(this.base, wasm);
|
|
37767
37871
|
const owners = [];
|
|
37768
|
-
for (const command of (await this.commands(scope)).values()) {
|
|
37872
|
+
for (const command of (await this.commands(scope, reads)).values()) {
|
|
37769
37873
|
if (command.abi !== "wasi" || command.script || baseName3(command.wasm) !== leaf) continue;
|
|
37770
37874
|
if (command.wasm === wasm || await physicalPathAsync(this.base, command.wasm) === real)
|
|
37771
37875
|
owners.push(command);
|
|
@@ -37788,15 +37892,15 @@ var Launcher = class {
|
|
|
37788
37892
|
async scriptCommand(file, cwd, scope, reads) {
|
|
37789
37893
|
const direct = !file.includes("/") || COMMAND2.test(file);
|
|
37790
37894
|
const at = direct ? file : await this.followCommand(this.fs.resolvePath(cwd, file), reads);
|
|
37791
|
-
const command = await this.commandAt(at, scope);
|
|
37895
|
+
const command = await this.commandAt(at, scope, reads);
|
|
37792
37896
|
return command?.script ? command : void 0;
|
|
37793
37897
|
}
|
|
37794
|
-
async mayRead(reader, path) {
|
|
37898
|
+
async mayRead(reader, path, reads) {
|
|
37795
37899
|
if (!reader || !this.dac) return true;
|
|
37796
|
-
return (await access(this.fs, reader, path, R_OK)).denied === void 0;
|
|
37900
|
+
return (await access(reads ? this.sudoFs(reads) : this.fs, reader, path, R_OK)).denied === void 0;
|
|
37797
37901
|
}
|
|
37798
37902
|
async binfmtOf(path, head, scope, reader, reads) {
|
|
37799
|
-
const shown2 = await this.mayRead(reader, path) ? head : void 0;
|
|
37903
|
+
const shown2 = await this.mayRead(reader, path, reads) ? head : void 0;
|
|
37800
37904
|
return binfmtFor(await this.interpreters(scope, reads), path, shown2);
|
|
37801
37905
|
}
|
|
37802
37906
|
async interpreterWords(head, script, who) {
|
|
@@ -37834,6 +37938,7 @@ var Launcher = class {
|
|
|
37834
37938
|
const passed = [...args, command ? script : file, ...words3.kept, ...argv.slice(1)];
|
|
37835
37939
|
if (!interp) return void 0;
|
|
37836
37940
|
who.reads?.operandsFromEnd.set(passed.length - args.length, script);
|
|
37941
|
+
who.reads?.interpreters.push([script, ...words3.words, String(words3.kept.length)]);
|
|
37837
37942
|
const found = await this.resolve(interp, interp, cwd, scope, who.reads);
|
|
37838
37943
|
if (!found) {
|
|
37839
37944
|
const next3 = depth < MAX_INTERPRETERS ? await this.scriptCommand(interp, cwd, scope, who.reads) : void 0;
|
|
@@ -37895,13 +38000,19 @@ var Launcher = class {
|
|
|
37895
38000
|
const given = typeof argv0 === "string" ? { argv0 } : {};
|
|
37896
38001
|
const who = { scope, reader, reads, ...given };
|
|
37897
38002
|
const script = await this.interpreted(file, argv, cwd, who, command);
|
|
38003
|
+
if (reads && script)
|
|
38004
|
+
reads.chainSha256 = await sha2562(
|
|
38005
|
+
new TextEncoder().encode(
|
|
38006
|
+
JSON.stringify([reads.interpreters, script.binfmts, script.target])
|
|
38007
|
+
)
|
|
38008
|
+
);
|
|
37898
38009
|
return { planned: script && { ...script, script: true }, ...examined };
|
|
37899
38010
|
}
|
|
37900
|
-
async mayExec(cred, req, { planned, examined }) {
|
|
38011
|
+
async mayExec(cred, req, { planned, examined }, reads) {
|
|
37901
38012
|
const { dac } = this;
|
|
37902
38013
|
if (!dac) return;
|
|
37903
38014
|
const g = {
|
|
37904
|
-
fs: this.fs,
|
|
38015
|
+
fs: reads ? this.sudoFs(reads) : this.fs,
|
|
37905
38016
|
cred,
|
|
37906
38017
|
pid: req.pid,
|
|
37907
38018
|
dac,
|
|
@@ -37928,10 +38039,11 @@ var Launcher = class {
|
|
|
37928
38039
|
throw err;
|
|
37929
38040
|
}
|
|
37930
38041
|
}
|
|
37931
|
-
planOrSearch(req, ctx) {
|
|
38042
|
+
async planOrSearch(req, ctx) {
|
|
38043
|
+
const reads = ctx.grant?.files && await this.scriptReads(ctx.grant.files, ctx.cred, ctx.ppid);
|
|
37932
38044
|
return planOrSearch(req, {
|
|
37933
|
-
listed: (file) => this.commandAt(file, ctx.scope),
|
|
37934
|
-
plan: (candidate, catalogOnly) => this.planOne(candidate, ctx, catalogOnly),
|
|
38045
|
+
listed: (file) => this.commandAt(file, ctx.scope, reads),
|
|
38046
|
+
plan: (candidate, catalogOnly) => this.planOne(candidate, ctx, catalogOnly, reads),
|
|
37935
38047
|
searchable: (dir) => this.execDirectory(
|
|
37936
38048
|
dir.startsWith("/") ? dir : `${req.cwd}/${dir}`,
|
|
37937
38049
|
this.execGuard(ctx.cred, ctx.ppid),
|
|
@@ -37939,22 +38051,26 @@ var Launcher = class {
|
|
|
37939
38051
|
)
|
|
37940
38052
|
});
|
|
37941
38053
|
}
|
|
37942
|
-
async planOne(req, { ppid, cred, scope, grant }, catalogOnly = false) {
|
|
38054
|
+
async planOne(req, { ppid, cred, scope, grant }, catalogOnly = false, prepared) {
|
|
37943
38055
|
const refused5 = (err) => {
|
|
37944
38056
|
throw codeOf9(err) === "EACCES" ? new SpawnError("EACCES") : err;
|
|
37945
38057
|
};
|
|
37946
38058
|
const file = await this.execFile(req.file, req.cwd, this.execGuard(cred, ppid), ppid).catch(
|
|
37947
38059
|
refused5
|
|
37948
38060
|
);
|
|
37949
|
-
const reads = grant?.files && await this.scriptReads(grant.files, cred, ppid);
|
|
38061
|
+
const reads = prepared ?? (grant?.files && await this.scriptReads(grant.files, cred, ppid));
|
|
37950
38062
|
const plan = await this.plan(file, req.argv, req.cwd, scope, {
|
|
37951
38063
|
argv0: req.argv0,
|
|
37952
38064
|
catalogOnly,
|
|
37953
38065
|
reader: cred,
|
|
37954
38066
|
reads
|
|
37955
38067
|
});
|
|
37956
|
-
await this.mayExec(cred, { ...req, file, pid: ppid }, plan).catch(refused5);
|
|
38068
|
+
await this.mayExec(cred, { ...req, file, pid: ppid }, plan, reads).catch(refused5);
|
|
37957
38069
|
if (plan.planned) return reads ? { ...plan.planned, reads } : plan.planned;
|
|
38070
|
+
if (grant?.files) {
|
|
38071
|
+
const gone = await this.sudoer.missingBacking(grant.files.hashes) ?? file;
|
|
38072
|
+
throw new ChangedError(changedText(gone), gone);
|
|
38073
|
+
}
|
|
37958
38074
|
if (catalogOnly) throw new SpawnError("ENOENT");
|
|
37959
38075
|
throw new SpawnError(await this.unrunnable(file, req.cwd, scope, cred));
|
|
37960
38076
|
}
|
|
@@ -38099,6 +38215,7 @@ var Launcher = class {
|
|
|
38099
38215
|
const now = await planned.reads.bind([file, grant.asked ?? file, ...files]);
|
|
38100
38216
|
refuseChanged(approved.hashes, now.hashes);
|
|
38101
38217
|
refuseChanged(approved.routes, now.routes);
|
|
38218
|
+
if (now.chainSha256 !== approved.chainSha256) throw new ChangedError(changedText(file), file);
|
|
38102
38219
|
return { pinned: approved };
|
|
38103
38220
|
}
|
|
38104
38221
|
approvedChain(planned, file, cwd, grant) {
|
|
@@ -38112,7 +38229,8 @@ var Launcher = class {
|
|
|
38112
38229
|
async scriptReads(files, cred, pid) {
|
|
38113
38230
|
await this.checkRoutes(files, false);
|
|
38114
38231
|
const snapshots = /* @__PURE__ */ new Map();
|
|
38115
|
-
const
|
|
38232
|
+
const reads = this.sudoer.reads(snapshots);
|
|
38233
|
+
const guard2 = { fs: this.sudoFs(reads), dac: this.dac, cred, pid, links: cred.euid };
|
|
38116
38234
|
for (const path of files.scripts ?? []) {
|
|
38117
38235
|
const real = files.routes[path];
|
|
38118
38236
|
const walked2 = await need(guard2, "open", path, R_OK, { directory: false });
|
|
@@ -38120,7 +38238,7 @@ var Launcher = class {
|
|
|
38120
38238
|
if (!snapshots.has(real))
|
|
38121
38239
|
snapshots.set(real, new Uint8Array(await this.noLinksFs.readFileBuffer(real)));
|
|
38122
38240
|
}
|
|
38123
|
-
return
|
|
38241
|
+
return reads;
|
|
38124
38242
|
}
|
|
38125
38243
|
scriptArgs(planned, files, fds) {
|
|
38126
38244
|
const reads = planned.reads;
|
|
@@ -40126,14 +40244,14 @@ var Launcher = class {
|
|
|
40126
40244
|
const watched = this.watchers.wrap(mounted);
|
|
40127
40245
|
return this.owners ? this.freshModules.wrap(watched) : watched;
|
|
40128
40246
|
}
|
|
40129
|
-
commandFs(root) {
|
|
40247
|
+
commandFs(root, reads) {
|
|
40130
40248
|
return withCommandDirs(
|
|
40131
40249
|
withEtcFiles(root, /* @__PURE__ */ new Map([[HOSTNAME_PATH, () => `${this.hostname}
|
|
40132
40250
|
`]])),
|
|
40133
|
-
async () => this.commandNames(await this.commands()),
|
|
40134
|
-
(dir) => this.userCommandDir(dir),
|
|
40251
|
+
async () => this.commandNames(await this.commands("", reads)),
|
|
40252
|
+
(dir) => this.userCommandDir(dir, reads),
|
|
40135
40253
|
this.owners,
|
|
40136
|
-
(path) => this.entryTarget(path)
|
|
40254
|
+
(path) => this.entryTarget(path, reads)
|
|
40137
40255
|
);
|
|
40138
40256
|
}
|
|
40139
40257
|
named = /* @__PURE__ */ new WeakMap();
|
|
@@ -40145,13 +40263,13 @@ var Launcher = class {
|
|
|
40145
40263
|
}
|
|
40146
40264
|
return names2;
|
|
40147
40265
|
}
|
|
40148
|
-
async entryTarget(path) {
|
|
40266
|
+
async entryTarget(path, reads) {
|
|
40149
40267
|
const system = COMMAND2.exec(path)?.[1];
|
|
40150
40268
|
const slash = path.lastIndexOf("/");
|
|
40151
40269
|
const scopes = await this.userScopes();
|
|
40152
40270
|
const scope = system === void 0 ? scopes.byBin.get(path.slice(0, slash)) : "";
|
|
40153
40271
|
const name2 = system ?? path.slice(slash + 1);
|
|
40154
|
-
const command = scope === void 0 ? void 0 : (await this.commands(scope)).get(name2);
|
|
40272
|
+
const command = scope === void 0 ? void 0 : (await this.commands(scope, reads)).get(name2);
|
|
40155
40273
|
const owner = scope ? scopes.owners?.get(scope) : void 0;
|
|
40156
40274
|
const target = command && (command.shows ?? command.script ?? command.wasm);
|
|
40157
40275
|
return target === void 0 ? void 0 : { path: target, ...owner ? { owner } : {} };
|
|
@@ -40173,6 +40291,9 @@ var Launcher = class {
|
|
|
40173
40291
|
nodes.changed = (path) => this.changes.publish(path);
|
|
40174
40292
|
nodes.movedAway = (from, to) => this.moved(from, to, nodes);
|
|
40175
40293
|
nodes.dirtied = (delta) => this.changes.dirtied(delta);
|
|
40294
|
+
return this.processView(fs, nodes, unlinked);
|
|
40295
|
+
}
|
|
40296
|
+
processView(fs, nodes, unlinked) {
|
|
40176
40297
|
const kept = keepingOpen(fs, nodes, (path) => this.changes.publish(path));
|
|
40177
40298
|
return this.textBusy.view(this.swaps.wrap(unlinked.wrap(kept)));
|
|
40178
40299
|
}
|