@ai-ecoverse/slicc-kernel 1.196.3 → 1.196.4
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 +187 -64
- package/dist/cloudflare.js.map +3 -3
- package/dist/kernel-worker.js +187 -64
- 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 +187 -64
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/commands.d.ts +4 -2
- package/dist/types/launcher.d.ts +3 -0
- package/dist/types/sudo-files.d.ts +7 -2
- package/dist/types/sudo.d.ts +1 -0
- package/dist/types/sudoers.d.ts +3 -2
- package/package.json +2 -2
package/dist/kernel-worker.js
CHANGED
|
@@ -9493,7 +9493,7 @@ function satisfies(version, range2) {
|
|
|
9493
9493
|
}
|
|
9494
9494
|
|
|
9495
9495
|
// src/version.ts
|
|
9496
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
9496
|
+
var KERNEL_VERSION = true ? "1.196.4" : "0.0.0-dev";
|
|
9497
9497
|
var OS_RELEASE = "6.0.0-slicc";
|
|
9498
9498
|
function procVersion() {
|
|
9499
9499
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -9820,8 +9820,20 @@ function winners(tier) {
|
|
|
9820
9820
|
}
|
|
9821
9821
|
return out;
|
|
9822
9822
|
}
|
|
9823
|
-
|
|
9823
|
+
function providerInputs(inputs, tier, global) {
|
|
9824
|
+
for (const { pkg, name: name2, commands } of tier) {
|
|
9825
|
+
const root = pkg.slice(0, -(name2.length + 1));
|
|
9826
|
+
for (const command of commands) {
|
|
9827
|
+
const paths = inputs.get(command.name) ?? /* @__PURE__ */ new Set();
|
|
9828
|
+
paths.add(`${pkg}/package.json`);
|
|
9829
|
+
if (global.has(root)) paths.add(`${root.slice(0, root.lastIndexOf("/"))}/package.json`);
|
|
9830
|
+
inputs.set(command.name, paths);
|
|
9831
|
+
}
|
|
9832
|
+
}
|
|
9833
|
+
}
|
|
9834
|
+
async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION, refused5, global = /* @__PURE__ */ new Set(), provenance = false) {
|
|
9824
9835
|
const found = /* @__PURE__ */ new Map();
|
|
9836
|
+
const inputs = /* @__PURE__ */ new Map();
|
|
9825
9837
|
const physical = physicalResolver(fs);
|
|
9826
9838
|
const tiers = (typeof modules === "string" ? [modules] : modules).map(
|
|
9827
9839
|
(tier) => typeof tier === "string" ? [tier] : tier
|
|
@@ -9834,11 +9846,20 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, ke
|
|
|
9834
9846
|
const dependencies = [];
|
|
9835
9847
|
for (const [index2, roots] of tiers.entries()) {
|
|
9836
9848
|
const tier = await tierPackages(fs, physical, roots, index2 >= binsFrom, kernel, global);
|
|
9849
|
+
if (provenance) providerInputs(inputs, tier, global);
|
|
9837
9850
|
if (refused5) refused5.push(...tier.flatMap((entry) => entry.commands.filter((c) => c.refused)));
|
|
9838
9851
|
await take(tier.filter((entry) => !entry.dependency));
|
|
9839
9852
|
dependencies.push(tier.filter((entry) => entry.dependency));
|
|
9840
9853
|
}
|
|
9841
9854
|
for (const tier of dependencies) await take(tier);
|
|
9855
|
+
if (provenance) {
|
|
9856
|
+
const shared2 = /* @__PURE__ */ new Map();
|
|
9857
|
+
for (const command of [...found.values(), ...refused5 ?? []]) {
|
|
9858
|
+
const paths = shared2.get(command.name) ?? [...inputs.get(command.name)];
|
|
9859
|
+
shared2.set(command.name, paths);
|
|
9860
|
+
command.manifests = paths;
|
|
9861
|
+
}
|
|
9862
|
+
}
|
|
9842
9863
|
if (!found.has("sh") && found.has("bash")) {
|
|
9843
9864
|
found.set("sh", { ...found.get("bash"), name: "sh", argv0: "sh" });
|
|
9844
9865
|
}
|
|
@@ -9902,7 +9923,7 @@ function binfmtEntry(pkg, key, value2) {
|
|
|
9902
9923
|
return { name: key, pkg, command: value2, preserveArgv0: false };
|
|
9903
9924
|
}
|
|
9904
9925
|
async function scanBinfmts(fs, modules, warn = () => {
|
|
9905
|
-
}) {
|
|
9926
|
+
}, declarations) {
|
|
9906
9927
|
const found = /* @__PURE__ */ new Map();
|
|
9907
9928
|
for (const pkg of await packagesIn(fs, modules)) {
|
|
9908
9929
|
let manifest;
|
|
@@ -9916,6 +9937,7 @@ async function scanBinfmts(fs, modules, warn = () => {
|
|
|
9916
9937
|
for (const [key, value2] of Object.entries(declared2)) {
|
|
9917
9938
|
const rule = binfmtEntry(pkg, key, value2);
|
|
9918
9939
|
if (!rule) continue;
|
|
9940
|
+
declarations?.push(rule);
|
|
9919
9941
|
const had = found.get(key);
|
|
9920
9942
|
if (had === void 0) found.set(key, rule);
|
|
9921
9943
|
else if (had.command !== rule.command)
|
|
@@ -9926,6 +9948,19 @@ async function scanBinfmts(fs, modules, warn = () => {
|
|
|
9926
9948
|
}
|
|
9927
9949
|
return [...found.values()];
|
|
9928
9950
|
}
|
|
9951
|
+
function binfmtInputs(declarations, path, head) {
|
|
9952
|
+
const name2 = path.slice(path.lastIndexOf("/") + 1);
|
|
9953
|
+
const keys2 = new Set(
|
|
9954
|
+
declarations.filter(
|
|
9955
|
+
(rule) => rule.magic ? head && magicMatches(rule, head) : name2.length > rule.name.length && name2.endsWith(rule.name)
|
|
9956
|
+
).map((rule) => rule.name)
|
|
9957
|
+
);
|
|
9958
|
+
return [
|
|
9959
|
+
...new Set(
|
|
9960
|
+
declarations.filter((rule) => keys2.has(rule.name)).map((rule) => `${rule.pkg}/package.json`)
|
|
9961
|
+
)
|
|
9962
|
+
];
|
|
9963
|
+
}
|
|
9929
9964
|
function binfmtFor(rules, path, head) {
|
|
9930
9965
|
const magic = head && rules.find((rule) => magicMatches(rule, head));
|
|
9931
9966
|
if (magic) return magic;
|
|
@@ -22171,8 +22206,9 @@ var SudoReads = class {
|
|
|
22171
22206
|
reads = /* @__PURE__ */ new Map();
|
|
22172
22207
|
names = /* @__PURE__ */ new Map();
|
|
22173
22208
|
documents = /* @__PURE__ */ new Map();
|
|
22174
|
-
|
|
22175
|
-
|
|
22209
|
+
texts = /* @__PURE__ */ new Map();
|
|
22210
|
+
relevant = /* @__PURE__ */ new Set();
|
|
22211
|
+
verified = /* @__PURE__ */ new Set();
|
|
22176
22212
|
interpreters = [];
|
|
22177
22213
|
chainSha256;
|
|
22178
22214
|
operandsFromEnd = /* @__PURE__ */ new Map();
|
|
@@ -22189,6 +22225,26 @@ var SudoReads = class {
|
|
|
22189
22225
|
}
|
|
22190
22226
|
return read;
|
|
22191
22227
|
}
|
|
22228
|
+
resetSelection() {
|
|
22229
|
+
this.relevant.clear();
|
|
22230
|
+
this.interpreters.length = 0;
|
|
22231
|
+
delete this.chainSha256;
|
|
22232
|
+
this.operandsFromEnd.clear();
|
|
22233
|
+
}
|
|
22234
|
+
include(paths) {
|
|
22235
|
+
for (const path of paths ?? []) if (this.verified.has(path)) this.relevant.add(path);
|
|
22236
|
+
}
|
|
22237
|
+
async digest(path) {
|
|
22238
|
+
const real = await this.access.real(path);
|
|
22239
|
+
this.saw(path, real);
|
|
22240
|
+
return (await this.bytes(real))?.hash;
|
|
22241
|
+
}
|
|
22242
|
+
async text(path) {
|
|
22243
|
+
const real = await this.access.real(path);
|
|
22244
|
+
this.saw(path, real);
|
|
22245
|
+
const result = await this.document(real, (at) => this.raw(at)).catch(() => void 0);
|
|
22246
|
+
return result?.text;
|
|
22247
|
+
}
|
|
22192
22248
|
raw(real) {
|
|
22193
22249
|
const saved = this.snapshots.get(real);
|
|
22194
22250
|
return saved ? Promise.resolve(saved) : this.access.read(real);
|
|
@@ -22205,19 +22261,19 @@ var SudoReads = class {
|
|
|
22205
22261
|
const real = await this.access.real(path);
|
|
22206
22262
|
this.saw(path, real);
|
|
22207
22263
|
const { text, read } = await this.document(real, raw2);
|
|
22208
|
-
this.observed.add(path);
|
|
22209
22264
|
await verify(real, read.hash);
|
|
22265
|
+
this.verified.add(path);
|
|
22210
22266
|
return text;
|
|
22211
22267
|
}
|
|
22212
22268
|
document(real, raw2) {
|
|
22213
|
-
let found = this.
|
|
22269
|
+
let found = this.texts.get(real);
|
|
22214
22270
|
if (!found) {
|
|
22215
22271
|
const saved = this.snapshots.get(real);
|
|
22216
22272
|
found = (saved ? Promise.resolve(saved) : raw2(real)).then(async (data) => {
|
|
22217
22273
|
const bytes = new Uint8Array(data);
|
|
22218
22274
|
return { text: new TextDecoder().decode(bytes), read: await fingerprint(bytes) };
|
|
22219
22275
|
});
|
|
22220
|
-
this.
|
|
22276
|
+
this.texts.set(real, found);
|
|
22221
22277
|
const earlier = this.reads.get(real);
|
|
22222
22278
|
this.reads.set(
|
|
22223
22279
|
real,
|
|
@@ -22244,7 +22300,7 @@ var SudoReads = class {
|
|
|
22244
22300
|
*inputs(paths) {
|
|
22245
22301
|
const primary = new Set(paths);
|
|
22246
22302
|
yield* primary;
|
|
22247
|
-
for (const path of this.
|
|
22303
|
+
for (const path of this.relevant) if (!primary.has(path)) yield path;
|
|
22248
22304
|
}
|
|
22249
22305
|
async bind(paths) {
|
|
22250
22306
|
const hashes = {};
|
|
@@ -22354,7 +22410,7 @@ var SUDOERS_D = "/etc/sudoers.d";
|
|
|
22354
22410
|
var NAME4 = /^[a-z_][a-z0-9_.-]*$/;
|
|
22355
22411
|
var WORD = String.raw`(?:'[^']*'|"(?:[^"\\]|\\[\s\S])*"|\\[\s\S]|[^\s'"\\])+`;
|
|
22356
22412
|
var KERNEL_FORM = new RegExp(
|
|
22357
|
-
String.raw`^(NOPASSWD\s+)?(\S+)\s+(?:\(([^()]*)\)\s+)?(?:Cwd\s+(${WORD})\s+)?(?:Stdin\s+(\S+)\s+)?(?:RouteSha256\s+([a-f0-9]{64})\s+)?((?:Sha256\s+${WORD}\s+)*)Cmnd(?:\s+(.*))?$`
|
|
22413
|
+
String.raw`^(NOPASSWD\s+)?(\S+)\s+(?:\(([^()]*)\)\s+)?(?:Cwd\s+(${WORD})\s+)?(?:Stdin\s+(\S+)\s+)?(?:ChainSha256\s+([a-f0-9]{64})\s+)?(?:RouteSha256\s+([a-f0-9]{64})\s+)?((?:Sha256\s+${WORD}\s+)*)Cmnd(?:\s+(.*))?$`
|
|
22358
22414
|
);
|
|
22359
22415
|
var SHA256_CLAUSE = new RegExp(String.raw`Sha256\s+(${WORD})`, "g");
|
|
22360
22416
|
var HEX2 = /^[0-9a-f]{64}$/;
|
|
@@ -22366,7 +22422,7 @@ var PLAIN2 = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
|
22366
22422
|
var CONTROL2 = /[\p{Cc}\u2028\u2029]/u;
|
|
22367
22423
|
var CONTROLS = /[\p{Cc}\u2028\u2029]/gu;
|
|
22368
22424
|
var SHOWN_MAX = 60;
|
|
22369
|
-
var KERNEL_SYNTAX = "[NOPASSWD] <user|%group|ALL> [(<target>)] [Cwd <dir>] [Stdin none] [RouteSha256 <sha256>] [Sha256
|
|
22425
|
+
var KERNEL_SYNTAX = "[NOPASSWD] <user|%group|ALL> [(<target>)] [Cwd <dir>] [Stdin none] [ChainSha256 <sha256>] [RouteSha256 <sha256>] [Sha256 none|<file>=<sha256>\u2026] Cmnd <command\u2026|*>";
|
|
22370
22426
|
var SUDOERS_SYNTAX = "<user|%group|ALL> ALL=[(<target>[,<target>\u2026])] [NOPASSWD:] <command\u2026|ALL>";
|
|
22371
22427
|
var EXPECTED = `expected '${KERNEL_SYNTAX}' or '${SUDOERS_SYNTAX}'`;
|
|
22372
22428
|
var TIMESTAMP_TIMEOUT = 5;
|
|
@@ -22534,6 +22590,7 @@ function commandOf2(text, after) {
|
|
|
22534
22590
|
return args.length === 0 ? { path } : { path, args };
|
|
22535
22591
|
}
|
|
22536
22592
|
function sha256Of(clauses) {
|
|
22593
|
+
if (/^Sha256\s+none\s*$/.test(clauses)) return {};
|
|
22537
22594
|
const files = {};
|
|
22538
22595
|
for (const [, word = ""] of clauses.matchAll(SHA256_CLAUSE)) {
|
|
22539
22596
|
const [text = ""] = splitWords(word) ?? [];
|
|
@@ -22547,9 +22604,11 @@ function sha256Of(clauses) {
|
|
|
22547
22604
|
}
|
|
22548
22605
|
return files;
|
|
22549
22606
|
}
|
|
22550
|
-
function sha256Text(files, routeSha256) {
|
|
22607
|
+
function sha256Text(files, routeSha256, chainSha256) {
|
|
22608
|
+
const chain2 = chainSha256 ? `ChainSha256 ${chainSha256} ` : "";
|
|
22609
|
+
if (!Object.keys(files).length) return `${chain2}Sha256 none `;
|
|
22551
22610
|
const route2 = routeSha256 ? `RouteSha256 ${routeSha256} ` : "";
|
|
22552
|
-
return route2 + Object.entries(files).map(([path, hex4]) => `Sha256 ${quoteWord(`${path}=${hex4}`)} `).join("");
|
|
22611
|
+
return chain2 + route2 + Object.entries(files).map(([path, hex4]) => `Sha256 ${quoteWord(`${path}=${hex4}`)} `).join("");
|
|
22553
22612
|
}
|
|
22554
22613
|
function targetError(list) {
|
|
22555
22614
|
if (list.includes(",")) {
|
|
@@ -22558,16 +22617,28 @@ function targetError(list) {
|
|
|
22558
22617
|
return `expected one user name or ALL in (\u2026), not ${shown(`(${list})`)}`;
|
|
22559
22618
|
}
|
|
22560
22619
|
function kernelRules(m) {
|
|
22561
|
-
const [
|
|
22620
|
+
const [
|
|
22621
|
+
,
|
|
22622
|
+
nopasswd,
|
|
22623
|
+
who = "",
|
|
22624
|
+
target = "root",
|
|
22625
|
+
dir,
|
|
22626
|
+
stdin,
|
|
22627
|
+
chainSha256,
|
|
22628
|
+
routeSha256,
|
|
22629
|
+
sums = "",
|
|
22630
|
+
rest2 = ""
|
|
22631
|
+
] = m;
|
|
22562
22632
|
const bad = whoError(who);
|
|
22563
22633
|
if (bad !== void 0) return bad;
|
|
22564
22634
|
if (target !== "ALL" && !NAME4.test(target)) return targetError(target);
|
|
22565
22635
|
const cwd = dir === void 0 ? void 0 : cwdOf(dir);
|
|
22566
22636
|
if (cwd === "") return `Cwd expects one absolute directory, not ${shown(dir)}`;
|
|
22567
22637
|
if (stdin !== void 0 && stdin !== "none") return `Stdin takes none, not ${shown(stdin)}`;
|
|
22568
|
-
if (routeSha256 && !sums) return "RouteSha256 requires Sha256";
|
|
22569
22638
|
const sha2564 = sha256Of(sums);
|
|
22570
22639
|
if (typeof sha2564 === "string") return sha2564;
|
|
22640
|
+
if (routeSha256 && !Object.keys(sha2564).length) return "RouteSha256 requires Sha256";
|
|
22641
|
+
if (chainSha256 && !sums) return "ChainSha256 requires Sha256";
|
|
22571
22642
|
const rule = {
|
|
22572
22643
|
nopasswd: !!nopasswd,
|
|
22573
22644
|
who,
|
|
@@ -22575,7 +22646,8 @@ function kernelRules(m) {
|
|
|
22575
22646
|
...cwd !== void 0 ? { cwd } : {},
|
|
22576
22647
|
...stdin === "none" ? { stdin: "none" } : {},
|
|
22577
22648
|
...sums === "" ? {} : { sha256: sha2564 },
|
|
22578
|
-
...routeSha256 ? { routeSha256 } : {}
|
|
22649
|
+
...routeSha256 ? { routeSha256 } : {},
|
|
22650
|
+
...chainSha256 ? { chainSha256 } : {}
|
|
22579
22651
|
};
|
|
22580
22652
|
const text = rest2.trim();
|
|
22581
22653
|
if (text === "*") return [{ ...rule, cmnd: "*" }];
|
|
@@ -22954,8 +23026,21 @@ function changedFile(approved, now) {
|
|
|
22954
23026
|
const files = /* @__PURE__ */ new Set([...Object.keys(approved), ...Object.keys(now)]);
|
|
22955
23027
|
return [...files].find((file) => approved[file] !== now[file]);
|
|
22956
23028
|
}
|
|
22957
|
-
function pinned(rule, hashes,
|
|
22958
|
-
return rule.sha256 === void 0 || rule.routeSha256 === routeSha256 && changedFile(rule.sha256, hashes) === void 0;
|
|
23029
|
+
function pinned(rule, hashes, proof) {
|
|
23030
|
+
return rule.sha256 === void 0 || rule.routeSha256 === proof.routeSha256 && (rule.chainSha256 === void 0 || rule.chainSha256 === proof.chainSha256) && changedFile(rule.sha256, hashes) === void 0;
|
|
23031
|
+
}
|
|
23032
|
+
function changedManifests(rules, bound3) {
|
|
23033
|
+
const changed2 = /* @__PURE__ */ new Set();
|
|
23034
|
+
for (const { sha256: hashes } of rules) {
|
|
23035
|
+
if (!hashes) continue;
|
|
23036
|
+
for (const [asked, real] of Object.entries(bound3.routes)) {
|
|
23037
|
+
if (asked.endsWith("/package.json") && hashes[real] !== bound3.hashes[real]) changed2.add(real);
|
|
23038
|
+
}
|
|
23039
|
+
for (const path of Object.keys(hashes)) {
|
|
23040
|
+
if (path.endsWith("/package.json") && !Object.hasOwn(bound3.hashes, path)) changed2.add(path);
|
|
23041
|
+
}
|
|
23042
|
+
}
|
|
23043
|
+
return changed2.size ? { changedManifests: [...changed2].sort() } : {};
|
|
22959
23044
|
}
|
|
22960
23045
|
function proofOf({ routeSha256, chainSha256 }) {
|
|
22961
23046
|
return { ...routeSha256 ? { routeSha256 } : {}, ...chainSha256 ? { chainSha256 } : {} };
|
|
@@ -23176,10 +23261,12 @@ function described(rule, writable3) {
|
|
|
23176
23261
|
const cmnd = rule.cmnd === "*" ? "ALL" : commandText(rule.cmnd);
|
|
23177
23262
|
const cwd = rule.cwd === void 0 ? "" : `CWD=${quoteWord(rule.cwd)} `;
|
|
23178
23263
|
const stdin = rule.stdin === void 0 ? "" : "STDIN=none ";
|
|
23264
|
+
const chain2 = rule.chainSha256 ? `CHAIN_SHA256=${rule.chainSha256} ` : "";
|
|
23265
|
+
const empty = rule.sha256 && !Object.keys(rule.sha256).length ? "SHA256=none " : "";
|
|
23179
23266
|
const sums = Object.entries(rule.sha256 ?? {}).map(([path, hex4]) => `SHA256=${quoteWord(path)}:${hex4} `).join("");
|
|
23180
23267
|
const route2 = rule.routeSha256 ? `ROUTE_SHA256=${rule.routeSha256} ` : "";
|
|
23181
23268
|
const flag = writable3 ? " # user-writable command" : "";
|
|
23182
|
-
return ` (${rule.target}) ${cwd}${stdin}${route2}${sums}${rule.nopasswd ? "NOPASSWD: " : ""}${cmnd}${flag}`;
|
|
23269
|
+
return ` (${rule.target}) ${cwd}${stdin}${chain2}${route2}${empty}${sums}${rule.nopasswd ? "NOPASSWD: " : ""}${cmnd}${flag}`;
|
|
23183
23270
|
}
|
|
23184
23271
|
var Sudo = class {
|
|
23185
23272
|
o;
|
|
@@ -23430,10 +23517,11 @@ var Sudo = class {
|
|
|
23430
23517
|
const bound3 = files && await reads.bind([path, asked, ...files]);
|
|
23431
23518
|
return bound3 && !Object.values(bound3.hashes).includes("") && (bound3.routes[asked] ?? path) === path ? bound3 : void 0;
|
|
23432
23519
|
}
|
|
23433
|
-
async writable(rule, pid) {
|
|
23520
|
+
async writable(rule, pid, reads) {
|
|
23434
23521
|
if (rule.cmnd === "*") return false;
|
|
23435
23522
|
const { path } = rule.cmnd;
|
|
23436
|
-
|
|
23523
|
+
reads.resetSelection();
|
|
23524
|
+
const bound3 = await this.bound(path, "/", path, pid, reads);
|
|
23437
23525
|
if (bound3) return Object.keys(bound3.hashes).length > 0;
|
|
23438
23526
|
return !await this.trusted(await this.existing(path));
|
|
23439
23527
|
}
|
|
@@ -23571,7 +23659,7 @@ ${SCRIPT_HELP}
|
|
|
23571
23659
|
const { rules } = await this.policyRules({ cred, pid: 0, stdin: r.stdin });
|
|
23572
23660
|
const applies = await this.applies(self, cred);
|
|
23573
23661
|
return rules.some(
|
|
23574
|
-
(rule) => applies(rule.who) && (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === r.cwd) && stdinMatches(rule, r.stdin) && commandMatches(rule.cmnd, argv) && pinned(rule, r.bound, r
|
|
23662
|
+
(rule) => applies(rule.who) && (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === r.cwd) && stdinMatches(rule, r.stdin) && commandMatches(rule.cmnd, argv) && pinned(rule, r.bound, r)
|
|
23575
23663
|
);
|
|
23576
23664
|
}
|
|
23577
23665
|
async command(s, root, mine, call) {
|
|
@@ -23591,9 +23679,10 @@ ${SCRIPT_HELP}
|
|
|
23591
23679
|
if (!located || !bound3) return failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
23592
23680
|
const { path, asked } = located;
|
|
23593
23681
|
const argv = [path, ...args];
|
|
23594
|
-
const
|
|
23595
|
-
(rule) => (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === cwd) && stdinMatches(rule, caller.stdin) && commandMatches(rule.cmnd, argv)
|
|
23682
|
+
const applicable = mine.filter(
|
|
23683
|
+
(rule) => (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === cwd) && stdinMatches(rule, caller.stdin) && commandMatches(rule.cmnd, argv)
|
|
23596
23684
|
);
|
|
23685
|
+
const matching = applicable.filter((rule) => pinned(rule, bound3.hashes, bound3));
|
|
23597
23686
|
const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept, asked);
|
|
23598
23687
|
if (root || matching.some((rule) => rule.nopasswd)) return grant();
|
|
23599
23688
|
const quoted = argv.map(quoteWord).join(" ");
|
|
@@ -23616,6 +23705,10 @@ ${SCRIPT_HELP}
|
|
|
23616
23705
|
path,
|
|
23617
23706
|
cwd,
|
|
23618
23707
|
bound: bound3.hashes,
|
|
23708
|
+
...changedManifests(
|
|
23709
|
+
applicable.filter((rule) => !matching.includes(rule)),
|
|
23710
|
+
bound3
|
|
23711
|
+
),
|
|
23619
23712
|
...proof
|
|
23620
23713
|
});
|
|
23621
23714
|
if ("error" in answer2) return answer2;
|
|
@@ -23704,7 +23797,8 @@ ${SCRIPT_HELP}
|
|
|
23704
23797
|
return failed2("EPERM", `User ${self.name} is not allowed to run sudo on ${host}.`);
|
|
23705
23798
|
}
|
|
23706
23799
|
const shown2 = [];
|
|
23707
|
-
|
|
23800
|
+
const reads = this.reads();
|
|
23801
|
+
for (const rule of rules) shown2.push(described(rule, await this.writable(rule, pid, reads)));
|
|
23708
23802
|
const lines3 = shown2.join("\n");
|
|
23709
23803
|
const params = defaults2.flatMap((d) => d.params).join(", ");
|
|
23710
23804
|
const matching = params === "" ? "" : `Matching Defaults entries for ${self.name} on ${host}:
|
|
@@ -23744,6 +23838,7 @@ ${lines3}
|
|
|
23744
23838
|
stdin: caller.stdin,
|
|
23745
23839
|
rootOnly: asked.validate ? {} : await this.rootOnly(cwd, argv.slice(1)),
|
|
23746
23840
|
...userWritable(asked.bound),
|
|
23841
|
+
...asked.changedManifests ? { changedManifests: asked.changedManifests } : {},
|
|
23747
23842
|
...proofOf(asked),
|
|
23748
23843
|
...asked.validate ? { validate: true } : {},
|
|
23749
23844
|
timestamp: true
|
|
@@ -23764,12 +23859,7 @@ ${lines3}
|
|
|
23764
23859
|
requester.removeEventListener("abort", withdraw);
|
|
23765
23860
|
}
|
|
23766
23861
|
}
|
|
23767
|
-
async remember(self, target, {
|
|
23768
|
-
cwd,
|
|
23769
|
-
argv,
|
|
23770
|
-
bound: bound3,
|
|
23771
|
-
routeSha256
|
|
23772
|
-
}) {
|
|
23862
|
+
async remember(self, target, { cwd, argv, bound: bound3, routeSha256, chainSha256 }) {
|
|
23773
23863
|
const { fs } = this.o;
|
|
23774
23864
|
const path = `${SUDOERS_D}/${self.name}`;
|
|
23775
23865
|
if (!NAME4.test(self.name)) return false;
|
|
@@ -23780,7 +23870,7 @@ ${lines3}
|
|
|
23780
23870
|
if (st && !await this.trusted(path)) return false;
|
|
23781
23871
|
const old = st ? await fs.readFile(path) : "";
|
|
23782
23872
|
const words3 = recordedCommand(argv);
|
|
23783
|
-
const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Stdin none ${sha256Text(bound3, routeSha256)}Cmnd ${words3}
|
|
23873
|
+
const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Stdin none ${sha256Text(bound3, routeSha256, chainSha256)}Cmnd ${words3}
|
|
23784
23874
|
`;
|
|
23785
23875
|
const text = old === "" || old.endsWith("\n") ? `${old}${line}` : `${old}
|
|
23786
23876
|
${line}`;
|
|
@@ -37302,6 +37392,7 @@ function refusing(command) {
|
|
|
37302
37392
|
argv0: command.name,
|
|
37303
37393
|
args: [`${command.name}: ${command.refused}`],
|
|
37304
37394
|
refused: command.refused,
|
|
37395
|
+
...command.manifests ? { manifests: command.manifests } : {},
|
|
37305
37396
|
shows: command.script ?? command.wasm,
|
|
37306
37397
|
origin: {
|
|
37307
37398
|
abi: command.abi,
|
|
@@ -37885,7 +37976,8 @@ function expandDefaults(defaults2, env) {
|
|
|
37885
37976
|
}
|
|
37886
37977
|
return out;
|
|
37887
37978
|
}
|
|
37888
|
-
function targetOf(command) {
|
|
37979
|
+
function targetOf(command, reads) {
|
|
37980
|
+
reads?.include(command.manifests);
|
|
37889
37981
|
return {
|
|
37890
37982
|
abi: command.abi,
|
|
37891
37983
|
command: command.name,
|
|
@@ -37969,6 +38061,7 @@ var CatalogCache = class {
|
|
|
37969
38061
|
commands = /* @__PURE__ */ new Map();
|
|
37970
38062
|
own = /* @__PURE__ */ new Map();
|
|
37971
38063
|
rules = /* @__PURE__ */ new Map();
|
|
38064
|
+
declarations = /* @__PURE__ */ new Map();
|
|
37972
38065
|
fs;
|
|
37973
38066
|
};
|
|
37974
38067
|
var Launcher = class {
|
|
@@ -38395,7 +38488,8 @@ var Launcher = class {
|
|
|
38395
38488
|
tiers.length - appended2.length,
|
|
38396
38489
|
void 0,
|
|
38397
38490
|
refused5,
|
|
38398
|
-
await this.globalRoots(scope)
|
|
38491
|
+
await this.globalRoots(scope),
|
|
38492
|
+
reads !== void 0
|
|
38399
38493
|
);
|
|
38400
38494
|
this.refusedOf.set(commands, refused5.map(refusing));
|
|
38401
38495
|
return commands;
|
|
@@ -38457,11 +38551,18 @@ var Launcher = class {
|
|
|
38457
38551
|
return found;
|
|
38458
38552
|
}
|
|
38459
38553
|
async scanInterpreters(scope, reads) {
|
|
38460
|
-
|
|
38461
|
-
|
|
38462
|
-
|
|
38463
|
-
|
|
38464
|
-
|
|
38554
|
+
const declarations = reads && [];
|
|
38555
|
+
if (declarations) this.catalogOf(reads).declarations.set(scope, declarations);
|
|
38556
|
+
return scanBinfmts(
|
|
38557
|
+
this.scanFs(reads),
|
|
38558
|
+
await this.roots(scope),
|
|
38559
|
+
(message3) => {
|
|
38560
|
+
if (this.warned.has(message3)) return;
|
|
38561
|
+
this.warned.add(message3);
|
|
38562
|
+
console.warn(message3);
|
|
38563
|
+
},
|
|
38564
|
+
declarations
|
|
38565
|
+
);
|
|
38465
38566
|
}
|
|
38466
38567
|
async tiers(scope = "", appended2) {
|
|
38467
38568
|
const system = [
|
|
@@ -38568,7 +38669,7 @@ var Launcher = class {
|
|
|
38568
38669
|
async resolve(file, argv0, cwd, scope = "", reads) {
|
|
38569
38670
|
if (!file.includes("/") || COMMAND2.test(file)) {
|
|
38570
38671
|
const command = await this.commandAt(file, scope, reads);
|
|
38571
|
-
return command && !command.script ? targetOf(command) : void 0;
|
|
38672
|
+
return command && !command.script ? targetOf(command, reads) : void 0;
|
|
38572
38673
|
}
|
|
38573
38674
|
const path = this.fs.resolvePath(cwd, file);
|
|
38574
38675
|
const glue = await this.followCommand(path, reads);
|
|
@@ -38581,12 +38682,12 @@ var Launcher = class {
|
|
|
38581
38682
|
return target && byPath ? { ...target, argv0: path } : target;
|
|
38582
38683
|
}
|
|
38583
38684
|
const own = await this.ownOrRefused(glue, baseName3(file), scope, reads);
|
|
38584
|
-
if (own) return own.script ? void 0 : { ...targetOf(own), ...asked };
|
|
38685
|
+
if (own) return own.script ? void 0 : { ...targetOf(own, reads), ...asked };
|
|
38585
38686
|
const head = await this.head(glue, reads);
|
|
38586
38687
|
if (!head) return void 0;
|
|
38587
38688
|
if (isWasm(head)) {
|
|
38588
38689
|
const owner2 = await this.wasmOwner(glue, baseName3(file).replace(/\.wasm$/, ""), scope, reads);
|
|
38589
|
-
if (owner2) return { ...targetOf(owner2), ...asked };
|
|
38690
|
+
if (owner2) return { ...targetOf(owner2, reads), ...asked };
|
|
38590
38691
|
return {
|
|
38591
38692
|
abi: "wasi",
|
|
38592
38693
|
glue,
|
|
@@ -38604,9 +38705,9 @@ var Launcher = class {
|
|
|
38604
38705
|
const owner = await this.glueOwner(glue, baseName3(file), scope, reads);
|
|
38605
38706
|
if (!owner) {
|
|
38606
38707
|
const shim = await this.shimOwner(glue, baseName3(file), scope, reads);
|
|
38607
|
-
return shim && { ...targetOf(shim), ...asked, shim: glue };
|
|
38708
|
+
return shim && { ...targetOf(shim, reads), ...asked, shim: glue };
|
|
38608
38709
|
}
|
|
38609
|
-
return { ...targetOf(owner), ...asked, ...owner.glue === glue ? {} : { copy: glue } };
|
|
38710
|
+
return { ...targetOf(owner, reads), ...asked, ...owner.glue === glue ? {} : { copy: glue } };
|
|
38610
38711
|
}
|
|
38611
38712
|
async ownOrRefused(path, name2, scope, reads) {
|
|
38612
38713
|
return await this.commandAt(path, scope, reads) ?? await this.refusedAt(path, name2, scope, reads);
|
|
@@ -38629,22 +38730,23 @@ var Launcher = class {
|
|
|
38629
38730
|
}
|
|
38630
38731
|
const stem = name2.replace(/\.wasm$/, "");
|
|
38631
38732
|
const named = owners.find((c) => c.name === name2) ?? owners.find((c) => c.name === stem);
|
|
38632
|
-
return named ?? owners[0] ?? await this.refusedCopy(real, name2, refused5);
|
|
38733
|
+
return named ?? owners[0] ?? await this.refusedCopy(real, name2, refused5, reads);
|
|
38633
38734
|
}
|
|
38634
|
-
async refusedCopy(real, name2, refused5) {
|
|
38735
|
+
async refusedCopy(real, name2, refused5, reads) {
|
|
38635
38736
|
const dir = real.slice(0, real.lastIndexOf("/"));
|
|
38636
38737
|
for (const c of refused5) {
|
|
38637
38738
|
const origin = c.origin;
|
|
38638
38739
|
if (origin.abi !== "emscripten" || origin.script || c.name !== name2) continue;
|
|
38639
38740
|
const own = await physicalPathAsync(this.base, origin.glue).catch(() => origin.glue);
|
|
38640
|
-
if (own.slice(0, own.lastIndexOf("/")) === dir && await this.sameFile(real, own))
|
|
38741
|
+
if (own.slice(0, own.lastIndexOf("/")) === dir && await this.sameFile(real, own, reads))
|
|
38742
|
+
return c;
|
|
38641
38743
|
}
|
|
38642
38744
|
return void 0;
|
|
38643
38745
|
}
|
|
38644
38746
|
async shimOwner(script, name2, scope, reads) {
|
|
38645
38747
|
const command = (await this.commands(scope, reads)).get(name2);
|
|
38646
38748
|
if (!command || command.script || command.origin?.script) return void 0;
|
|
38647
|
-
const target = await this.shimTarget(script);
|
|
38749
|
+
const target = await this.shimTarget(script, reads);
|
|
38648
38750
|
if (target === void 0) return void 0;
|
|
38649
38751
|
const pkg = await this.installedPackage(await physicalPathAsync(this.base, target), scope);
|
|
38650
38752
|
if (!pkg) return void 0;
|
|
@@ -38652,10 +38754,10 @@ var Launcher = class {
|
|
|
38652
38754
|
const own = await physicalPathAsync(this.base, glue).catch(() => void 0);
|
|
38653
38755
|
return own?.startsWith(`${pkg}/`) ? command : void 0;
|
|
38654
38756
|
}
|
|
38655
|
-
async shimTarget(script) {
|
|
38757
|
+
async shimTarget(script, reads) {
|
|
38656
38758
|
const st = await this.base.stat(script).catch(() => void 0);
|
|
38657
38759
|
if (!st?.isFile || st.size > SHIM_MAX) return void 0;
|
|
38658
|
-
const text = await this.base.readFile(script).catch(() => "");
|
|
38760
|
+
const text = reads ? await reads.text(script) ?? "" : await this.base.readFile(script).catch(() => "");
|
|
38659
38761
|
const marker = [...text.matchAll(SHIM_MARKER)].at(-1)?.[1];
|
|
38660
38762
|
if (marker === void 0) return void 0;
|
|
38661
38763
|
let target;
|
|
@@ -38688,12 +38790,16 @@ var Launcher = class {
|
|
|
38688
38790
|
if (c.abi !== "emscripten" || c.script || c.name !== leaf) continue;
|
|
38689
38791
|
const own = await physicalPathAsync(this.base, c.glue).catch(() => c.glue);
|
|
38690
38792
|
if (own.slice(0, own.lastIndexOf("/")) !== dir) continue;
|
|
38691
|
-
if (await this.sameFile(glue, own)) return c;
|
|
38793
|
+
if (await this.sameFile(glue, own, reads)) return c;
|
|
38692
38794
|
}
|
|
38693
38795
|
return void 0;
|
|
38694
38796
|
}
|
|
38695
38797
|
sameFiles = /* @__PURE__ */ new Map();
|
|
38696
|
-
async sameFile(a, b) {
|
|
38798
|
+
async sameFile(a, b, reads) {
|
|
38799
|
+
if (reads) {
|
|
38800
|
+
const [left, right] = await Promise.all([reads.digest(a), reads.digest(b)]);
|
|
38801
|
+
return left !== void 0 && left === right;
|
|
38802
|
+
}
|
|
38697
38803
|
const [x, y] = await Promise.all([this.base.stat(a), this.base.stat(b)]).catch(() => []);
|
|
38698
38804
|
if (!x?.isFile || !y?.isFile || x.size !== y.size) return false;
|
|
38699
38805
|
const stamp = [x, y].map((st) => `${st.size}:${st.mtime.getTime()}:${st.ino}`).join("|");
|
|
@@ -38732,7 +38838,9 @@ var Launcher = class {
|
|
|
38732
38838
|
const direct = !file.includes("/") || COMMAND2.test(file);
|
|
38733
38839
|
const at = direct ? file : await this.followCommand(this.fs.resolvePath(cwd, file), reads);
|
|
38734
38840
|
const command = await this.commandAt(at, scope, reads);
|
|
38735
|
-
|
|
38841
|
+
if (!command?.script) return void 0;
|
|
38842
|
+
reads?.include(command.manifests);
|
|
38843
|
+
return command;
|
|
38736
38844
|
}
|
|
38737
38845
|
async mayRead(reader, path, reads) {
|
|
38738
38846
|
if (!reader || !this.dac) return true;
|
|
@@ -38740,7 +38848,10 @@ var Launcher = class {
|
|
|
38740
38848
|
}
|
|
38741
38849
|
async binfmtOf(path, head, scope, reader, reads) {
|
|
38742
38850
|
const shown2 = await this.mayRead(reader, path, reads) ? head : void 0;
|
|
38743
|
-
|
|
38851
|
+
const rules = await this.interpreters(scope, reads);
|
|
38852
|
+
if (reads)
|
|
38853
|
+
reads.include(binfmtInputs(this.catalogOf(reads).declarations.get(scope) ?? [], path, shown2));
|
|
38854
|
+
return binfmtFor(rules, path, shown2);
|
|
38744
38855
|
}
|
|
38745
38856
|
async interpreterWords(head, script, who) {
|
|
38746
38857
|
const bang = shebang(head);
|
|
@@ -38846,7 +38957,9 @@ var Launcher = class {
|
|
|
38846
38957
|
if (direct) {
|
|
38847
38958
|
const shim = direct.shim ? { sources: [direct.shim], asked: direct.asked ? { [direct.shim]: direct.asked } : {} } : {};
|
|
38848
38959
|
const args = [...direct.prefix ?? [], ...argv.slice(1)];
|
|
38849
|
-
|
|
38960
|
+
const planned = { target: direct, args, ...shim };
|
|
38961
|
+
await this.stampDirect(reads, planned);
|
|
38962
|
+
return { planned };
|
|
38850
38963
|
}
|
|
38851
38964
|
const command = await this.scriptCommand(file, cwd, scope, reads);
|
|
38852
38965
|
if (catalogOnly && !command) return {};
|
|
@@ -38854,14 +38967,17 @@ var Launcher = class {
|
|
|
38854
38967
|
const given = typeof argv0 === "string" ? { argv0 } : {};
|
|
38855
38968
|
const who = { scope, reader, reads, pid, ...given };
|
|
38856
38969
|
const script = await this.interpreted(file, argv, cwd, who, command);
|
|
38857
|
-
if (reads && script)
|
|
38858
|
-
reads.chainSha256 = await sha256(
|
|
38859
|
-
new TextEncoder().encode(
|
|
38860
|
-
JSON.stringify([reads.interpreters, script.binfmts, script.target])
|
|
38861
|
-
)
|
|
38862
|
-
);
|
|
38970
|
+
if (reads && script) await this.stampChain(reads, script);
|
|
38863
38971
|
return { planned: script && { ...script, script: true }, ...examined };
|
|
38864
38972
|
}
|
|
38973
|
+
async stampDirect(reads, plan) {
|
|
38974
|
+
if (reads && plan.target.command) await this.stampChain(reads, plan);
|
|
38975
|
+
}
|
|
38976
|
+
async stampChain(reads, plan) {
|
|
38977
|
+
reads.chainSha256 = await sha256(
|
|
38978
|
+
new TextEncoder().encode(JSON.stringify([reads.interpreters, plan.binfmts, plan.target]))
|
|
38979
|
+
);
|
|
38980
|
+
}
|
|
38865
38981
|
async mayExec(cred, req, { planned, examined }, reads) {
|
|
38866
38982
|
const { dac } = this;
|
|
38867
38983
|
if (!dac) return;
|
|
@@ -38922,12 +39038,18 @@ var Launcher = class {
|
|
|
38922
39038
|
});
|
|
38923
39039
|
await this.mayExec(cred, { ...req, file, pid: ppid }, plan, reads).catch(refused5);
|
|
38924
39040
|
if (plan.planned) return reads ? { ...plan.planned, reads } : plan.planned;
|
|
38925
|
-
if (grant?.files)
|
|
39041
|
+
if (grant?.files) await this.checkFailedPlan(file, req, scope, grant);
|
|
39042
|
+
if (catalogOnly) throw new SpawnError("ENOENT");
|
|
39043
|
+
throw new SpawnError(await this.unrunnable(file, req.cwd, scope, cred));
|
|
39044
|
+
}
|
|
39045
|
+
async checkFailedPlan(file, req, scope, grant) {
|
|
39046
|
+
const reads = this.sudoer.reads();
|
|
39047
|
+
const { planned } = await this.plan(file, req.argv, req.cwd, scope, { reads });
|
|
39048
|
+
if (!planned) {
|
|
38926
39049
|
const gone = await this.sudoer.missingBacking(grant.files.hashes) ?? file;
|
|
38927
39050
|
throw new ChangedError(changedText(gone), gone);
|
|
38928
39051
|
}
|
|
38929
|
-
|
|
38930
|
-
throw new SpawnError(await this.unrunnable(file, req.cwd, scope, cred));
|
|
39052
|
+
await this.unchanged({ ...planned, reads }, file, req.cwd, grant);
|
|
38931
39053
|
}
|
|
38932
39054
|
async enterable(g, cwd) {
|
|
38933
39055
|
if (!g) return;
|
|
@@ -41168,6 +41290,7 @@ var Launcher = class {
|
|
|
41168
41290
|
const name2 = system ?? path.slice(slash + 1);
|
|
41169
41291
|
const command = scope === void 0 ? void 0 : (await this.commands(scope, reads)).get(name2);
|
|
41170
41292
|
const owner = scope ? scopes.owners?.get(scope) : void 0;
|
|
41293
|
+
reads?.include(command?.manifests);
|
|
41171
41294
|
const target = command && (command.shows ?? command.script ?? command.wasm);
|
|
41172
41295
|
return target === void 0 ? void 0 : { path: target, ...owner ? { owner } : {} };
|
|
41173
41296
|
}
|