@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/cloudflare.js
CHANGED
|
@@ -5214,7 +5214,7 @@ function satisfies(version, range2) {
|
|
|
5214
5214
|
}
|
|
5215
5215
|
|
|
5216
5216
|
// src/version.ts
|
|
5217
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
5217
|
+
var KERNEL_VERSION = true ? "1.196.4" : "0.0.0-dev";
|
|
5218
5218
|
var OS_RELEASE = "6.0.0-slicc";
|
|
5219
5219
|
function procVersion() {
|
|
5220
5220
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -5541,8 +5541,20 @@ function winners(tier) {
|
|
|
5541
5541
|
}
|
|
5542
5542
|
return out;
|
|
5543
5543
|
}
|
|
5544
|
-
|
|
5544
|
+
function providerInputs(inputs, tier, global) {
|
|
5545
|
+
for (const { pkg, name: name2, commands } of tier) {
|
|
5546
|
+
const root = pkg.slice(0, -(name2.length + 1));
|
|
5547
|
+
for (const command of commands) {
|
|
5548
|
+
const paths = inputs.get(command.name) ?? /* @__PURE__ */ new Set();
|
|
5549
|
+
paths.add(`${pkg}/package.json`);
|
|
5550
|
+
if (global.has(root)) paths.add(`${root.slice(0, root.lastIndexOf("/"))}/package.json`);
|
|
5551
|
+
inputs.set(command.name, paths);
|
|
5552
|
+
}
|
|
5553
|
+
}
|
|
5554
|
+
}
|
|
5555
|
+
async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, kernel = KERNEL_VERSION, refused5, global = /* @__PURE__ */ new Set(), provenance = false) {
|
|
5545
5556
|
const found = /* @__PURE__ */ new Map();
|
|
5557
|
+
const inputs = /* @__PURE__ */ new Map();
|
|
5546
5558
|
const physical = physicalResolver(fs);
|
|
5547
5559
|
const tiers = (typeof modules === "string" ? [modules] : modules).map(
|
|
5548
5560
|
(tier) => typeof tier === "string" ? [tier] : tier
|
|
@@ -5555,11 +5567,20 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, ke
|
|
|
5555
5567
|
const dependencies = [];
|
|
5556
5568
|
for (const [index2, roots] of tiers.entries()) {
|
|
5557
5569
|
const tier = await tierPackages(fs, physical, roots, index2 >= binsFrom, kernel, global);
|
|
5570
|
+
if (provenance) providerInputs(inputs, tier, global);
|
|
5558
5571
|
if (refused5) refused5.push(...tier.flatMap((entry) => entry.commands.filter((c) => c.refused)));
|
|
5559
5572
|
await take(tier.filter((entry) => !entry.dependency));
|
|
5560
5573
|
dependencies.push(tier.filter((entry) => entry.dependency));
|
|
5561
5574
|
}
|
|
5562
5575
|
for (const tier of dependencies) await take(tier);
|
|
5576
|
+
if (provenance) {
|
|
5577
|
+
const shared2 = /* @__PURE__ */ new Map();
|
|
5578
|
+
for (const command of [...found.values(), ...refused5 ?? []]) {
|
|
5579
|
+
const paths = shared2.get(command.name) ?? [...inputs.get(command.name)];
|
|
5580
|
+
shared2.set(command.name, paths);
|
|
5581
|
+
command.manifests = paths;
|
|
5582
|
+
}
|
|
5583
|
+
}
|
|
5563
5584
|
if (!found.has("sh") && found.has("bash")) {
|
|
5564
5585
|
found.set("sh", { ...found.get("bash"), name: "sh", argv0: "sh" });
|
|
5565
5586
|
}
|
|
@@ -5623,7 +5644,7 @@ function binfmtEntry(pkg, key, value2) {
|
|
|
5623
5644
|
return { name: key, pkg, command: value2, preserveArgv0: false };
|
|
5624
5645
|
}
|
|
5625
5646
|
async function scanBinfmts(fs, modules, warn = () => {
|
|
5626
|
-
}) {
|
|
5647
|
+
}, declarations) {
|
|
5627
5648
|
const found = /* @__PURE__ */ new Map();
|
|
5628
5649
|
for (const pkg of await packagesIn(fs, modules)) {
|
|
5629
5650
|
let manifest;
|
|
@@ -5637,6 +5658,7 @@ async function scanBinfmts(fs, modules, warn = () => {
|
|
|
5637
5658
|
for (const [key, value2] of Object.entries(declared2)) {
|
|
5638
5659
|
const rule2 = binfmtEntry(pkg, key, value2);
|
|
5639
5660
|
if (!rule2) continue;
|
|
5661
|
+
declarations?.push(rule2);
|
|
5640
5662
|
const had = found.get(key);
|
|
5641
5663
|
if (had === void 0) found.set(key, rule2);
|
|
5642
5664
|
else if (had.command !== rule2.command)
|
|
@@ -5647,6 +5669,19 @@ async function scanBinfmts(fs, modules, warn = () => {
|
|
|
5647
5669
|
}
|
|
5648
5670
|
return [...found.values()];
|
|
5649
5671
|
}
|
|
5672
|
+
function binfmtInputs(declarations, path, head) {
|
|
5673
|
+
const name2 = path.slice(path.lastIndexOf("/") + 1);
|
|
5674
|
+
const keys2 = new Set(
|
|
5675
|
+
declarations.filter(
|
|
5676
|
+
(rule2) => rule2.magic ? head && magicMatches(rule2, head) : name2.length > rule2.name.length && name2.endsWith(rule2.name)
|
|
5677
|
+
).map((rule2) => rule2.name)
|
|
5678
|
+
);
|
|
5679
|
+
return [
|
|
5680
|
+
...new Set(
|
|
5681
|
+
declarations.filter((rule2) => keys2.has(rule2.name)).map((rule2) => `${rule2.pkg}/package.json`)
|
|
5682
|
+
)
|
|
5683
|
+
];
|
|
5684
|
+
}
|
|
5650
5685
|
function binfmtFor(rules, path, head) {
|
|
5651
5686
|
const magic = head && rules.find((rule2) => magicMatches(rule2, head));
|
|
5652
5687
|
if (magic) return magic;
|
|
@@ -18602,8 +18637,9 @@ var SudoReads = class {
|
|
|
18602
18637
|
reads = /* @__PURE__ */ new Map();
|
|
18603
18638
|
names = /* @__PURE__ */ new Map();
|
|
18604
18639
|
documents = /* @__PURE__ */ new Map();
|
|
18605
|
-
|
|
18606
|
-
|
|
18640
|
+
texts = /* @__PURE__ */ new Map();
|
|
18641
|
+
relevant = /* @__PURE__ */ new Set();
|
|
18642
|
+
verified = /* @__PURE__ */ new Set();
|
|
18607
18643
|
interpreters = [];
|
|
18608
18644
|
chainSha256;
|
|
18609
18645
|
operandsFromEnd = /* @__PURE__ */ new Map();
|
|
@@ -18620,6 +18656,26 @@ var SudoReads = class {
|
|
|
18620
18656
|
}
|
|
18621
18657
|
return read;
|
|
18622
18658
|
}
|
|
18659
|
+
resetSelection() {
|
|
18660
|
+
this.relevant.clear();
|
|
18661
|
+
this.interpreters.length = 0;
|
|
18662
|
+
delete this.chainSha256;
|
|
18663
|
+
this.operandsFromEnd.clear();
|
|
18664
|
+
}
|
|
18665
|
+
include(paths) {
|
|
18666
|
+
for (const path of paths ?? []) if (this.verified.has(path)) this.relevant.add(path);
|
|
18667
|
+
}
|
|
18668
|
+
async digest(path) {
|
|
18669
|
+
const real2 = await this.access.real(path);
|
|
18670
|
+
this.saw(path, real2);
|
|
18671
|
+
return (await this.bytes(real2))?.hash;
|
|
18672
|
+
}
|
|
18673
|
+
async text(path) {
|
|
18674
|
+
const real2 = await this.access.real(path);
|
|
18675
|
+
this.saw(path, real2);
|
|
18676
|
+
const result = await this.document(real2, (at) => this.raw(at)).catch(() => void 0);
|
|
18677
|
+
return result?.text;
|
|
18678
|
+
}
|
|
18623
18679
|
raw(real2) {
|
|
18624
18680
|
const saved = this.snapshots.get(real2);
|
|
18625
18681
|
return saved ? Promise.resolve(saved) : this.access.read(real2);
|
|
@@ -18636,19 +18692,19 @@ var SudoReads = class {
|
|
|
18636
18692
|
const real2 = await this.access.real(path);
|
|
18637
18693
|
this.saw(path, real2);
|
|
18638
18694
|
const { text, read } = await this.document(real2, raw2);
|
|
18639
|
-
this.observed.add(path);
|
|
18640
18695
|
await verify(real2, read.hash);
|
|
18696
|
+
this.verified.add(path);
|
|
18641
18697
|
return text;
|
|
18642
18698
|
}
|
|
18643
18699
|
document(real2, raw2) {
|
|
18644
|
-
let found = this.
|
|
18700
|
+
let found = this.texts.get(real2);
|
|
18645
18701
|
if (!found) {
|
|
18646
18702
|
const saved = this.snapshots.get(real2);
|
|
18647
18703
|
found = (saved ? Promise.resolve(saved) : raw2(real2)).then(async (data) => {
|
|
18648
18704
|
const bytes = new Uint8Array(data);
|
|
18649
18705
|
return { text: new TextDecoder().decode(bytes), read: await fingerprint(bytes) };
|
|
18650
18706
|
});
|
|
18651
|
-
this.
|
|
18707
|
+
this.texts.set(real2, found);
|
|
18652
18708
|
const earlier = this.reads.get(real2);
|
|
18653
18709
|
this.reads.set(
|
|
18654
18710
|
real2,
|
|
@@ -18675,7 +18731,7 @@ var SudoReads = class {
|
|
|
18675
18731
|
*inputs(paths) {
|
|
18676
18732
|
const primary = new Set(paths);
|
|
18677
18733
|
yield* primary;
|
|
18678
|
-
for (const path of this.
|
|
18734
|
+
for (const path of this.relevant) if (!primary.has(path)) yield path;
|
|
18679
18735
|
}
|
|
18680
18736
|
async bind(paths) {
|
|
18681
18737
|
const hashes = {};
|
|
@@ -18785,7 +18841,7 @@ var SUDOERS_D = "/etc/sudoers.d";
|
|
|
18785
18841
|
var NAME3 = /^[a-z_][a-z0-9_.-]*$/;
|
|
18786
18842
|
var WORD = String.raw`(?:'[^']*'|"(?:[^"\\]|\\[\s\S])*"|\\[\s\S]|[^\s'"\\])+`;
|
|
18787
18843
|
var KERNEL_FORM = new RegExp(
|
|
18788
|
-
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+(.*))?$`
|
|
18844
|
+
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+(.*))?$`
|
|
18789
18845
|
);
|
|
18790
18846
|
var SHA256_CLAUSE = new RegExp(String.raw`Sha256\s+(${WORD})`, "g");
|
|
18791
18847
|
var HEX2 = /^[0-9a-f]{64}$/;
|
|
@@ -18797,7 +18853,7 @@ var PLAIN = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
|
18797
18853
|
var CONTROL2 = /[\p{Cc}\u2028\u2029]/u;
|
|
18798
18854
|
var CONTROLS = /[\p{Cc}\u2028\u2029]/gu;
|
|
18799
18855
|
var SHOWN_MAX = 60;
|
|
18800
|
-
var KERNEL_SYNTAX = "[NOPASSWD] <user|%group|ALL> [(<target>)] [Cwd <dir>] [Stdin none] [RouteSha256 <sha256>] [Sha256
|
|
18856
|
+
var KERNEL_SYNTAX = "[NOPASSWD] <user|%group|ALL> [(<target>)] [Cwd <dir>] [Stdin none] [ChainSha256 <sha256>] [RouteSha256 <sha256>] [Sha256 none|<file>=<sha256>\u2026] Cmnd <command\u2026|*>";
|
|
18801
18857
|
var SUDOERS_SYNTAX = "<user|%group|ALL> ALL=[(<target>[,<target>\u2026])] [NOPASSWD:] <command\u2026|ALL>";
|
|
18802
18858
|
var EXPECTED = `expected '${KERNEL_SYNTAX}' or '${SUDOERS_SYNTAX}'`;
|
|
18803
18859
|
var TIMESTAMP_TIMEOUT = 5;
|
|
@@ -18965,6 +19021,7 @@ function commandOf2(text, after) {
|
|
|
18965
19021
|
return args.length === 0 ? { path } : { path, args };
|
|
18966
19022
|
}
|
|
18967
19023
|
function sha256Of(clauses) {
|
|
19024
|
+
if (/^Sha256\s+none\s*$/.test(clauses)) return {};
|
|
18968
19025
|
const files = {};
|
|
18969
19026
|
for (const [, word = ""] of clauses.matchAll(SHA256_CLAUSE)) {
|
|
18970
19027
|
const [text = ""] = splitWords(word) ?? [];
|
|
@@ -18978,9 +19035,11 @@ function sha256Of(clauses) {
|
|
|
18978
19035
|
}
|
|
18979
19036
|
return files;
|
|
18980
19037
|
}
|
|
18981
|
-
function sha256Text(files, routeSha256) {
|
|
19038
|
+
function sha256Text(files, routeSha256, chainSha256) {
|
|
19039
|
+
const chain2 = chainSha256 ? `ChainSha256 ${chainSha256} ` : "";
|
|
19040
|
+
if (!Object.keys(files).length) return `${chain2}Sha256 none `;
|
|
18982
19041
|
const route2 = routeSha256 ? `RouteSha256 ${routeSha256} ` : "";
|
|
18983
|
-
return route2 + Object.entries(files).map(([path, hex5]) => `Sha256 ${quoteWord(`${path}=${hex5}`)} `).join("");
|
|
19042
|
+
return chain2 + route2 + Object.entries(files).map(([path, hex5]) => `Sha256 ${quoteWord(`${path}=${hex5}`)} `).join("");
|
|
18984
19043
|
}
|
|
18985
19044
|
function targetError(list) {
|
|
18986
19045
|
if (list.includes(",")) {
|
|
@@ -18989,16 +19048,28 @@ function targetError(list) {
|
|
|
18989
19048
|
return `expected one user name or ALL in (\u2026), not ${shown(`(${list})`)}`;
|
|
18990
19049
|
}
|
|
18991
19050
|
function kernelRules(m) {
|
|
18992
|
-
const [
|
|
19051
|
+
const [
|
|
19052
|
+
,
|
|
19053
|
+
nopasswd,
|
|
19054
|
+
who = "",
|
|
19055
|
+
target = "root",
|
|
19056
|
+
dir,
|
|
19057
|
+
stdin,
|
|
19058
|
+
chainSha256,
|
|
19059
|
+
routeSha256,
|
|
19060
|
+
sums = "",
|
|
19061
|
+
rest2 = ""
|
|
19062
|
+
] = m;
|
|
18993
19063
|
const bad = whoError(who);
|
|
18994
19064
|
if (bad !== void 0) return bad;
|
|
18995
19065
|
if (target !== "ALL" && !NAME3.test(target)) return targetError(target);
|
|
18996
19066
|
const cwd = dir === void 0 ? void 0 : cwdOf(dir);
|
|
18997
19067
|
if (cwd === "") return `Cwd expects one absolute directory, not ${shown(dir)}`;
|
|
18998
19068
|
if (stdin !== void 0 && stdin !== "none") return `Stdin takes none, not ${shown(stdin)}`;
|
|
18999
|
-
if (routeSha256 && !sums) return "RouteSha256 requires Sha256";
|
|
19000
19069
|
const sha2564 = sha256Of(sums);
|
|
19001
19070
|
if (typeof sha2564 === "string") return sha2564;
|
|
19071
|
+
if (routeSha256 && !Object.keys(sha2564).length) return "RouteSha256 requires Sha256";
|
|
19072
|
+
if (chainSha256 && !sums) return "ChainSha256 requires Sha256";
|
|
19002
19073
|
const rule2 = {
|
|
19003
19074
|
nopasswd: !!nopasswd,
|
|
19004
19075
|
who,
|
|
@@ -19006,7 +19077,8 @@ function kernelRules(m) {
|
|
|
19006
19077
|
...cwd !== void 0 ? { cwd } : {},
|
|
19007
19078
|
...stdin === "none" ? { stdin: "none" } : {},
|
|
19008
19079
|
...sums === "" ? {} : { sha256: sha2564 },
|
|
19009
|
-
...routeSha256 ? { routeSha256 } : {}
|
|
19080
|
+
...routeSha256 ? { routeSha256 } : {},
|
|
19081
|
+
...chainSha256 ? { chainSha256 } : {}
|
|
19010
19082
|
};
|
|
19011
19083
|
const text = rest2.trim();
|
|
19012
19084
|
if (text === "*") return [{ ...rule2, cmnd: "*" }];
|
|
@@ -19762,8 +19834,21 @@ function changedFile(approved, now) {
|
|
|
19762
19834
|
const files = /* @__PURE__ */ new Set([...Object.keys(approved), ...Object.keys(now)]);
|
|
19763
19835
|
return [...files].find((file) => approved[file] !== now[file]);
|
|
19764
19836
|
}
|
|
19765
|
-
function pinned(rule2, hashes,
|
|
19766
|
-
return rule2.sha256 === void 0 || rule2.routeSha256 === routeSha256 && changedFile(rule2.sha256, hashes) === void 0;
|
|
19837
|
+
function pinned(rule2, hashes, proof) {
|
|
19838
|
+
return rule2.sha256 === void 0 || rule2.routeSha256 === proof.routeSha256 && (rule2.chainSha256 === void 0 || rule2.chainSha256 === proof.chainSha256) && changedFile(rule2.sha256, hashes) === void 0;
|
|
19839
|
+
}
|
|
19840
|
+
function changedManifests(rules, bound3) {
|
|
19841
|
+
const changed2 = /* @__PURE__ */ new Set();
|
|
19842
|
+
for (const { sha256: hashes } of rules) {
|
|
19843
|
+
if (!hashes) continue;
|
|
19844
|
+
for (const [asked, real2] of Object.entries(bound3.routes)) {
|
|
19845
|
+
if (asked.endsWith("/package.json") && hashes[real2] !== bound3.hashes[real2]) changed2.add(real2);
|
|
19846
|
+
}
|
|
19847
|
+
for (const path of Object.keys(hashes)) {
|
|
19848
|
+
if (path.endsWith("/package.json") && !Object.hasOwn(bound3.hashes, path)) changed2.add(path);
|
|
19849
|
+
}
|
|
19850
|
+
}
|
|
19851
|
+
return changed2.size ? { changedManifests: [...changed2].sort() } : {};
|
|
19767
19852
|
}
|
|
19768
19853
|
function proofOf({ routeSha256, chainSha256 }) {
|
|
19769
19854
|
return { ...routeSha256 ? { routeSha256 } : {}, ...chainSha256 ? { chainSha256 } : {} };
|
|
@@ -19984,10 +20069,12 @@ function described(rule2, writable3) {
|
|
|
19984
20069
|
const cmnd = rule2.cmnd === "*" ? "ALL" : commandText(rule2.cmnd);
|
|
19985
20070
|
const cwd = rule2.cwd === void 0 ? "" : `CWD=${quoteWord(rule2.cwd)} `;
|
|
19986
20071
|
const stdin = rule2.stdin === void 0 ? "" : "STDIN=none ";
|
|
20072
|
+
const chain2 = rule2.chainSha256 ? `CHAIN_SHA256=${rule2.chainSha256} ` : "";
|
|
20073
|
+
const empty = rule2.sha256 && !Object.keys(rule2.sha256).length ? "SHA256=none " : "";
|
|
19987
20074
|
const sums = Object.entries(rule2.sha256 ?? {}).map(([path, hex5]) => `SHA256=${quoteWord(path)}:${hex5} `).join("");
|
|
19988
20075
|
const route2 = rule2.routeSha256 ? `ROUTE_SHA256=${rule2.routeSha256} ` : "";
|
|
19989
20076
|
const flag = writable3 ? " # user-writable command" : "";
|
|
19990
|
-
return ` (${rule2.target}) ${cwd}${stdin}${route2}${sums}${rule2.nopasswd ? "NOPASSWD: " : ""}${cmnd}${flag}`;
|
|
20077
|
+
return ` (${rule2.target}) ${cwd}${stdin}${chain2}${route2}${empty}${sums}${rule2.nopasswd ? "NOPASSWD: " : ""}${cmnd}${flag}`;
|
|
19991
20078
|
}
|
|
19992
20079
|
var Sudo = class {
|
|
19993
20080
|
o;
|
|
@@ -20238,10 +20325,11 @@ var Sudo = class {
|
|
|
20238
20325
|
const bound3 = files && await reads.bind([path, asked, ...files]);
|
|
20239
20326
|
return bound3 && !Object.values(bound3.hashes).includes("") && (bound3.routes[asked] ?? path) === path ? bound3 : void 0;
|
|
20240
20327
|
}
|
|
20241
|
-
async writable(rule2, pid) {
|
|
20328
|
+
async writable(rule2, pid, reads) {
|
|
20242
20329
|
if (rule2.cmnd === "*") return false;
|
|
20243
20330
|
const { path } = rule2.cmnd;
|
|
20244
|
-
|
|
20331
|
+
reads.resetSelection();
|
|
20332
|
+
const bound3 = await this.bound(path, "/", path, pid, reads);
|
|
20245
20333
|
if (bound3) return Object.keys(bound3.hashes).length > 0;
|
|
20246
20334
|
return !await this.trusted(await this.existing(path));
|
|
20247
20335
|
}
|
|
@@ -20379,7 +20467,7 @@ ${SCRIPT_HELP}
|
|
|
20379
20467
|
const { rules } = await this.policyRules({ cred, pid: 0, stdin: r.stdin });
|
|
20380
20468
|
const applies = await this.applies(self, cred);
|
|
20381
20469
|
return rules.some(
|
|
20382
|
-
(rule2) => applies(rule2.who) && (rule2.target === "ALL" || rule2.target === target.name) && (rule2.cwd === void 0 || rule2.cwd === r.cwd) && stdinMatches(rule2, r.stdin) && commandMatches(rule2.cmnd, argv) && pinned(rule2, r.bound, r
|
|
20470
|
+
(rule2) => applies(rule2.who) && (rule2.target === "ALL" || rule2.target === target.name) && (rule2.cwd === void 0 || rule2.cwd === r.cwd) && stdinMatches(rule2, r.stdin) && commandMatches(rule2.cmnd, argv) && pinned(rule2, r.bound, r)
|
|
20383
20471
|
);
|
|
20384
20472
|
}
|
|
20385
20473
|
async command(s, root, mine, call) {
|
|
@@ -20399,9 +20487,10 @@ ${SCRIPT_HELP}
|
|
|
20399
20487
|
if (!located || !bound3) return failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
20400
20488
|
const { path, asked } = located;
|
|
20401
20489
|
const argv = [path, ...args];
|
|
20402
|
-
const
|
|
20403
|
-
(rule2) => (rule2.target === "ALL" || rule2.target === target.name) && (rule2.cwd === void 0 || rule2.cwd === cwd) && stdinMatches(rule2, caller.stdin) && commandMatches(rule2.cmnd, argv)
|
|
20490
|
+
const applicable = mine.filter(
|
|
20491
|
+
(rule2) => (rule2.target === "ALL" || rule2.target === target.name) && (rule2.cwd === void 0 || rule2.cwd === cwd) && stdinMatches(rule2, caller.stdin) && commandMatches(rule2.cmnd, argv)
|
|
20404
20492
|
);
|
|
20493
|
+
const matching = applicable.filter((rule2) => pinned(rule2, bound3.hashes, bound3));
|
|
20405
20494
|
const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept, asked);
|
|
20406
20495
|
if (root || matching.some((rule2) => rule2.nopasswd)) return grant();
|
|
20407
20496
|
const quoted = argv.map(quoteWord).join(" ");
|
|
@@ -20424,6 +20513,10 @@ ${SCRIPT_HELP}
|
|
|
20424
20513
|
path,
|
|
20425
20514
|
cwd,
|
|
20426
20515
|
bound: bound3.hashes,
|
|
20516
|
+
...changedManifests(
|
|
20517
|
+
applicable.filter((rule2) => !matching.includes(rule2)),
|
|
20518
|
+
bound3
|
|
20519
|
+
),
|
|
20427
20520
|
...proof
|
|
20428
20521
|
});
|
|
20429
20522
|
if ("error" in answer2) return answer2;
|
|
@@ -20512,7 +20605,8 @@ ${SCRIPT_HELP}
|
|
|
20512
20605
|
return failed2("EPERM", `User ${self.name} is not allowed to run sudo on ${host}.`);
|
|
20513
20606
|
}
|
|
20514
20607
|
const shown2 = [];
|
|
20515
|
-
|
|
20608
|
+
const reads = this.reads();
|
|
20609
|
+
for (const rule2 of rules) shown2.push(described(rule2, await this.writable(rule2, pid, reads)));
|
|
20516
20610
|
const lines3 = shown2.join("\n");
|
|
20517
20611
|
const params = defaults2.flatMap((d) => d.params).join(", ");
|
|
20518
20612
|
const matching = params === "" ? "" : `Matching Defaults entries for ${self.name} on ${host}:
|
|
@@ -20552,6 +20646,7 @@ ${lines3}
|
|
|
20552
20646
|
stdin: caller.stdin,
|
|
20553
20647
|
rootOnly: asked.validate ? {} : await this.rootOnly(cwd, argv.slice(1)),
|
|
20554
20648
|
...userWritable(asked.bound),
|
|
20649
|
+
...asked.changedManifests ? { changedManifests: asked.changedManifests } : {},
|
|
20555
20650
|
...proofOf(asked),
|
|
20556
20651
|
...asked.validate ? { validate: true } : {},
|
|
20557
20652
|
timestamp: true
|
|
@@ -20572,12 +20667,7 @@ ${lines3}
|
|
|
20572
20667
|
requester.removeEventListener("abort", withdraw);
|
|
20573
20668
|
}
|
|
20574
20669
|
}
|
|
20575
|
-
async remember(self, target, {
|
|
20576
|
-
cwd,
|
|
20577
|
-
argv,
|
|
20578
|
-
bound: bound3,
|
|
20579
|
-
routeSha256
|
|
20580
|
-
}) {
|
|
20670
|
+
async remember(self, target, { cwd, argv, bound: bound3, routeSha256, chainSha256 }) {
|
|
20581
20671
|
const { fs } = this.o;
|
|
20582
20672
|
const path = `${SUDOERS_D}/${self.name}`;
|
|
20583
20673
|
if (!NAME3.test(self.name)) return false;
|
|
@@ -20588,7 +20678,7 @@ ${lines3}
|
|
|
20588
20678
|
if (st && !await this.trusted(path)) return false;
|
|
20589
20679
|
const old = st ? await fs.readFile(path) : "";
|
|
20590
20680
|
const words3 = recordedCommand(argv);
|
|
20591
|
-
const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Stdin none ${sha256Text(bound3, routeSha256)}Cmnd ${words3}
|
|
20681
|
+
const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Stdin none ${sha256Text(bound3, routeSha256, chainSha256)}Cmnd ${words3}
|
|
20592
20682
|
`;
|
|
20593
20683
|
const text = old === "" || old.endsWith("\n") ? `${old}${line}` : `${old}
|
|
20594
20684
|
${line}`;
|
|
@@ -36889,6 +36979,7 @@ function refusing(command) {
|
|
|
36889
36979
|
argv0: command.name,
|
|
36890
36980
|
args: [`${command.name}: ${command.refused}`],
|
|
36891
36981
|
refused: command.refused,
|
|
36982
|
+
...command.manifests ? { manifests: command.manifests } : {},
|
|
36892
36983
|
shows: command.script ?? command.wasm,
|
|
36893
36984
|
origin: {
|
|
36894
36985
|
abi: command.abi,
|
|
@@ -37468,7 +37559,8 @@ function expandDefaults(defaults2, env) {
|
|
|
37468
37559
|
}
|
|
37469
37560
|
return out;
|
|
37470
37561
|
}
|
|
37471
|
-
function targetOf(command) {
|
|
37562
|
+
function targetOf(command, reads) {
|
|
37563
|
+
reads?.include(command.manifests);
|
|
37472
37564
|
return {
|
|
37473
37565
|
abi: command.abi,
|
|
37474
37566
|
command: command.name,
|
|
@@ -37552,6 +37644,7 @@ var CatalogCache = class {
|
|
|
37552
37644
|
commands = /* @__PURE__ */ new Map();
|
|
37553
37645
|
own = /* @__PURE__ */ new Map();
|
|
37554
37646
|
rules = /* @__PURE__ */ new Map();
|
|
37647
|
+
declarations = /* @__PURE__ */ new Map();
|
|
37555
37648
|
fs;
|
|
37556
37649
|
};
|
|
37557
37650
|
var Launcher = class {
|
|
@@ -37978,7 +38071,8 @@ var Launcher = class {
|
|
|
37978
38071
|
tiers.length - appended2.length,
|
|
37979
38072
|
void 0,
|
|
37980
38073
|
refused5,
|
|
37981
|
-
await this.globalRoots(scope)
|
|
38074
|
+
await this.globalRoots(scope),
|
|
38075
|
+
reads !== void 0
|
|
37982
38076
|
);
|
|
37983
38077
|
this.refusedOf.set(commands, refused5.map(refusing));
|
|
37984
38078
|
return commands;
|
|
@@ -38040,11 +38134,18 @@ var Launcher = class {
|
|
|
38040
38134
|
return found;
|
|
38041
38135
|
}
|
|
38042
38136
|
async scanInterpreters(scope, reads) {
|
|
38043
|
-
|
|
38044
|
-
|
|
38045
|
-
|
|
38046
|
-
|
|
38047
|
-
|
|
38137
|
+
const declarations = reads && [];
|
|
38138
|
+
if (declarations) this.catalogOf(reads).declarations.set(scope, declarations);
|
|
38139
|
+
return scanBinfmts(
|
|
38140
|
+
this.scanFs(reads),
|
|
38141
|
+
await this.roots(scope),
|
|
38142
|
+
(message3) => {
|
|
38143
|
+
if (this.warned.has(message3)) return;
|
|
38144
|
+
this.warned.add(message3);
|
|
38145
|
+
console.warn(message3);
|
|
38146
|
+
},
|
|
38147
|
+
declarations
|
|
38148
|
+
);
|
|
38048
38149
|
}
|
|
38049
38150
|
async tiers(scope = "", appended2) {
|
|
38050
38151
|
const system = [
|
|
@@ -38151,7 +38252,7 @@ var Launcher = class {
|
|
|
38151
38252
|
async resolve(file, argv0, cwd, scope = "", reads) {
|
|
38152
38253
|
if (!file.includes("/") || COMMAND2.test(file)) {
|
|
38153
38254
|
const command = await this.commandAt(file, scope, reads);
|
|
38154
|
-
return command && !command.script ? targetOf(command) : void 0;
|
|
38255
|
+
return command && !command.script ? targetOf(command, reads) : void 0;
|
|
38155
38256
|
}
|
|
38156
38257
|
const path = this.fs.resolvePath(cwd, file);
|
|
38157
38258
|
const glue = await this.followCommand(path, reads);
|
|
@@ -38164,12 +38265,12 @@ var Launcher = class {
|
|
|
38164
38265
|
return target && byPath ? { ...target, argv0: path } : target;
|
|
38165
38266
|
}
|
|
38166
38267
|
const own = await this.ownOrRefused(glue, baseName3(file), scope, reads);
|
|
38167
|
-
if (own) return own.script ? void 0 : { ...targetOf(own), ...asked };
|
|
38268
|
+
if (own) return own.script ? void 0 : { ...targetOf(own, reads), ...asked };
|
|
38168
38269
|
const head = await this.head(glue, reads);
|
|
38169
38270
|
if (!head) return void 0;
|
|
38170
38271
|
if (isWasm(head)) {
|
|
38171
38272
|
const owner2 = await this.wasmOwner(glue, baseName3(file).replace(/\.wasm$/, ""), scope, reads);
|
|
38172
|
-
if (owner2) return { ...targetOf(owner2), ...asked };
|
|
38273
|
+
if (owner2) return { ...targetOf(owner2, reads), ...asked };
|
|
38173
38274
|
return {
|
|
38174
38275
|
abi: "wasi",
|
|
38175
38276
|
glue,
|
|
@@ -38187,9 +38288,9 @@ var Launcher = class {
|
|
|
38187
38288
|
const owner = await this.glueOwner(glue, baseName3(file), scope, reads);
|
|
38188
38289
|
if (!owner) {
|
|
38189
38290
|
const shim = await this.shimOwner(glue, baseName3(file), scope, reads);
|
|
38190
|
-
return shim && { ...targetOf(shim), ...asked, shim: glue };
|
|
38291
|
+
return shim && { ...targetOf(shim, reads), ...asked, shim: glue };
|
|
38191
38292
|
}
|
|
38192
|
-
return { ...targetOf(owner), ...asked, ...owner.glue === glue ? {} : { copy: glue } };
|
|
38293
|
+
return { ...targetOf(owner, reads), ...asked, ...owner.glue === glue ? {} : { copy: glue } };
|
|
38193
38294
|
}
|
|
38194
38295
|
async ownOrRefused(path, name2, scope, reads) {
|
|
38195
38296
|
return await this.commandAt(path, scope, reads) ?? await this.refusedAt(path, name2, scope, reads);
|
|
@@ -38212,22 +38313,23 @@ var Launcher = class {
|
|
|
38212
38313
|
}
|
|
38213
38314
|
const stem = name2.replace(/\.wasm$/, "");
|
|
38214
38315
|
const named = owners.find((c) => c.name === name2) ?? owners.find((c) => c.name === stem);
|
|
38215
|
-
return named ?? owners[0] ?? await this.refusedCopy(real2, name2, refused5);
|
|
38316
|
+
return named ?? owners[0] ?? await this.refusedCopy(real2, name2, refused5, reads);
|
|
38216
38317
|
}
|
|
38217
|
-
async refusedCopy(real2, name2, refused5) {
|
|
38318
|
+
async refusedCopy(real2, name2, refused5, reads) {
|
|
38218
38319
|
const dir = real2.slice(0, real2.lastIndexOf("/"));
|
|
38219
38320
|
for (const c of refused5) {
|
|
38220
38321
|
const origin = c.origin;
|
|
38221
38322
|
if (origin.abi !== "emscripten" || origin.script || c.name !== name2) continue;
|
|
38222
38323
|
const own = await physicalPathAsync(this.base, origin.glue).catch(() => origin.glue);
|
|
38223
|
-
if (own.slice(0, own.lastIndexOf("/")) === dir && await this.sameFile(real2, own))
|
|
38324
|
+
if (own.slice(0, own.lastIndexOf("/")) === dir && await this.sameFile(real2, own, reads))
|
|
38325
|
+
return c;
|
|
38224
38326
|
}
|
|
38225
38327
|
return void 0;
|
|
38226
38328
|
}
|
|
38227
38329
|
async shimOwner(script, name2, scope, reads) {
|
|
38228
38330
|
const command = (await this.commands(scope, reads)).get(name2);
|
|
38229
38331
|
if (!command || command.script || command.origin?.script) return void 0;
|
|
38230
|
-
const target = await this.shimTarget(script);
|
|
38332
|
+
const target = await this.shimTarget(script, reads);
|
|
38231
38333
|
if (target === void 0) return void 0;
|
|
38232
38334
|
const pkg = await this.installedPackage(await physicalPathAsync(this.base, target), scope);
|
|
38233
38335
|
if (!pkg) return void 0;
|
|
@@ -38235,10 +38337,10 @@ var Launcher = class {
|
|
|
38235
38337
|
const own = await physicalPathAsync(this.base, glue).catch(() => void 0);
|
|
38236
38338
|
return own?.startsWith(`${pkg}/`) ? command : void 0;
|
|
38237
38339
|
}
|
|
38238
|
-
async shimTarget(script) {
|
|
38340
|
+
async shimTarget(script, reads) {
|
|
38239
38341
|
const st = await this.base.stat(script).catch(() => void 0);
|
|
38240
38342
|
if (!st?.isFile || st.size > SHIM_MAX) return void 0;
|
|
38241
|
-
const text = await this.base.readFile(script).catch(() => "");
|
|
38343
|
+
const text = reads ? await reads.text(script) ?? "" : await this.base.readFile(script).catch(() => "");
|
|
38242
38344
|
const marker = [...text.matchAll(SHIM_MARKER)].at(-1)?.[1];
|
|
38243
38345
|
if (marker === void 0) return void 0;
|
|
38244
38346
|
let target;
|
|
@@ -38271,12 +38373,16 @@ var Launcher = class {
|
|
|
38271
38373
|
if (c.abi !== "emscripten" || c.script || c.name !== leaf) continue;
|
|
38272
38374
|
const own = await physicalPathAsync(this.base, c.glue).catch(() => c.glue);
|
|
38273
38375
|
if (own.slice(0, own.lastIndexOf("/")) !== dir) continue;
|
|
38274
|
-
if (await this.sameFile(glue, own)) return c;
|
|
38376
|
+
if (await this.sameFile(glue, own, reads)) return c;
|
|
38275
38377
|
}
|
|
38276
38378
|
return void 0;
|
|
38277
38379
|
}
|
|
38278
38380
|
sameFiles = /* @__PURE__ */ new Map();
|
|
38279
|
-
async sameFile(a, b) {
|
|
38381
|
+
async sameFile(a, b, reads) {
|
|
38382
|
+
if (reads) {
|
|
38383
|
+
const [left, right] = await Promise.all([reads.digest(a), reads.digest(b)]);
|
|
38384
|
+
return left !== void 0 && left === right;
|
|
38385
|
+
}
|
|
38280
38386
|
const [x, y] = await Promise.all([this.base.stat(a), this.base.stat(b)]).catch(() => []);
|
|
38281
38387
|
if (!x?.isFile || !y?.isFile || x.size !== y.size) return false;
|
|
38282
38388
|
const stamp = [x, y].map((st) => `${st.size}:${st.mtime.getTime()}:${st.ino}`).join("|");
|
|
@@ -38315,7 +38421,9 @@ var Launcher = class {
|
|
|
38315
38421
|
const direct = !file.includes("/") || COMMAND2.test(file);
|
|
38316
38422
|
const at = direct ? file : await this.followCommand(this.fs.resolvePath(cwd, file), reads);
|
|
38317
38423
|
const command = await this.commandAt(at, scope, reads);
|
|
38318
|
-
|
|
38424
|
+
if (!command?.script) return void 0;
|
|
38425
|
+
reads?.include(command.manifests);
|
|
38426
|
+
return command;
|
|
38319
38427
|
}
|
|
38320
38428
|
async mayRead(reader, path, reads) {
|
|
38321
38429
|
if (!reader || !this.dac) return true;
|
|
@@ -38323,7 +38431,10 @@ var Launcher = class {
|
|
|
38323
38431
|
}
|
|
38324
38432
|
async binfmtOf(path, head, scope, reader, reads) {
|
|
38325
38433
|
const shown2 = await this.mayRead(reader, path, reads) ? head : void 0;
|
|
38326
|
-
|
|
38434
|
+
const rules = await this.interpreters(scope, reads);
|
|
38435
|
+
if (reads)
|
|
38436
|
+
reads.include(binfmtInputs(this.catalogOf(reads).declarations.get(scope) ?? [], path, shown2));
|
|
38437
|
+
return binfmtFor(rules, path, shown2);
|
|
38327
38438
|
}
|
|
38328
38439
|
async interpreterWords(head, script, who) {
|
|
38329
38440
|
const bang = shebang(head);
|
|
@@ -38429,7 +38540,9 @@ var Launcher = class {
|
|
|
38429
38540
|
if (direct) {
|
|
38430
38541
|
const shim = direct.shim ? { sources: [direct.shim], asked: direct.asked ? { [direct.shim]: direct.asked } : {} } : {};
|
|
38431
38542
|
const args = [...direct.prefix ?? [], ...argv.slice(1)];
|
|
38432
|
-
|
|
38543
|
+
const planned = { target: direct, args, ...shim };
|
|
38544
|
+
await this.stampDirect(reads, planned);
|
|
38545
|
+
return { planned };
|
|
38433
38546
|
}
|
|
38434
38547
|
const command = await this.scriptCommand(file, cwd, scope, reads);
|
|
38435
38548
|
if (catalogOnly && !command) return {};
|
|
@@ -38437,14 +38550,17 @@ var Launcher = class {
|
|
|
38437
38550
|
const given = typeof argv0 === "string" ? { argv0 } : {};
|
|
38438
38551
|
const who = { scope, reader, reads, pid, ...given };
|
|
38439
38552
|
const script = await this.interpreted(file, argv, cwd, who, command);
|
|
38440
|
-
if (reads && script)
|
|
38441
|
-
reads.chainSha256 = await sha2562(
|
|
38442
|
-
new TextEncoder().encode(
|
|
38443
|
-
JSON.stringify([reads.interpreters, script.binfmts, script.target])
|
|
38444
|
-
)
|
|
38445
|
-
);
|
|
38553
|
+
if (reads && script) await this.stampChain(reads, script);
|
|
38446
38554
|
return { planned: script && { ...script, script: true }, ...examined };
|
|
38447
38555
|
}
|
|
38556
|
+
async stampDirect(reads, plan) {
|
|
38557
|
+
if (reads && plan.target.command) await this.stampChain(reads, plan);
|
|
38558
|
+
}
|
|
38559
|
+
async stampChain(reads, plan) {
|
|
38560
|
+
reads.chainSha256 = await sha2562(
|
|
38561
|
+
new TextEncoder().encode(JSON.stringify([reads.interpreters, plan.binfmts, plan.target]))
|
|
38562
|
+
);
|
|
38563
|
+
}
|
|
38448
38564
|
async mayExec(cred, req, { planned, examined }, reads) {
|
|
38449
38565
|
const { dac } = this;
|
|
38450
38566
|
if (!dac) return;
|
|
@@ -38505,12 +38621,18 @@ var Launcher = class {
|
|
|
38505
38621
|
});
|
|
38506
38622
|
await this.mayExec(cred, { ...req, file, pid: ppid }, plan, reads).catch(refused5);
|
|
38507
38623
|
if (plan.planned) return reads ? { ...plan.planned, reads } : plan.planned;
|
|
38508
|
-
if (grant?.files)
|
|
38624
|
+
if (grant?.files) await this.checkFailedPlan(file, req, scope, grant);
|
|
38625
|
+
if (catalogOnly) throw new SpawnError("ENOENT");
|
|
38626
|
+
throw new SpawnError(await this.unrunnable(file, req.cwd, scope, cred));
|
|
38627
|
+
}
|
|
38628
|
+
async checkFailedPlan(file, req, scope, grant) {
|
|
38629
|
+
const reads = this.sudoer.reads();
|
|
38630
|
+
const { planned } = await this.plan(file, req.argv, req.cwd, scope, { reads });
|
|
38631
|
+
if (!planned) {
|
|
38509
38632
|
const gone = await this.sudoer.missingBacking(grant.files.hashes) ?? file;
|
|
38510
38633
|
throw new ChangedError(changedText(gone), gone);
|
|
38511
38634
|
}
|
|
38512
|
-
|
|
38513
|
-
throw new SpawnError(await this.unrunnable(file, req.cwd, scope, cred));
|
|
38635
|
+
await this.unchanged({ ...planned, reads }, file, req.cwd, grant);
|
|
38514
38636
|
}
|
|
38515
38637
|
async enterable(g, cwd) {
|
|
38516
38638
|
if (!g) return;
|
|
@@ -40751,6 +40873,7 @@ var Launcher = class {
|
|
|
40751
40873
|
const name2 = system ?? path.slice(slash + 1);
|
|
40752
40874
|
const command = scope === void 0 ? void 0 : (await this.commands(scope, reads)).get(name2);
|
|
40753
40875
|
const owner = scope ? scopes.owners?.get(scope) : void 0;
|
|
40876
|
+
reads?.include(command?.manifests);
|
|
40754
40877
|
const target = command && (command.shows ?? command.script ?? command.wasm);
|
|
40755
40878
|
return target === void 0 ? void 0 : { path: target, ...owner ? { owner } : {} };
|
|
40756
40879
|
}
|