@ai-ecoverse/slicc-kernel 1.196.17 → 1.196.19
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 +8 -8
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +353 -101
- package/dist/cloudflare.js.map +4 -4
- package/dist/kernel-worker.js +401 -149
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +351 -99
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/types/fs/meta.d.ts +1 -0
- package/dist/types/fs/opfs.d.ts +12 -0
- package/dist/types/fs/private-rename.d.ts +25 -0
- package/dist/types/kernel/children.d.ts +1 -3
- package/dist/types/sudo.d.ts +5 -4
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -7734,7 +7734,7 @@ function satisfies(version, range2) {
|
|
|
7734
7734
|
}
|
|
7735
7735
|
|
|
7736
7736
|
// src/version.ts
|
|
7737
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
7737
|
+
var KERNEL_VERSION = true ? "1.196.19" : "0.0.0-dev";
|
|
7738
7738
|
var OS_RELEASE = "6.0.0-slicc";
|
|
7739
7739
|
function procVersion() {
|
|
7740
7740
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -12479,12 +12479,8 @@ var SpawnError = class extends Error {
|
|
|
12479
12479
|
}
|
|
12480
12480
|
};
|
|
12481
12481
|
var ChangedError = class extends SpawnError {
|
|
12482
|
-
|
|
12483
|
-
file;
|
|
12484
|
-
constructor(notice, file) {
|
|
12482
|
+
constructor() {
|
|
12485
12483
|
super("EPERM");
|
|
12486
|
-
this.notice = notice;
|
|
12487
|
-
this.file = file;
|
|
12488
12484
|
}
|
|
12489
12485
|
};
|
|
12490
12486
|
function interrupted(signal) {
|
|
@@ -20240,11 +20236,11 @@ function stdinMatches(rule2, stdin) {
|
|
|
20240
20236
|
function recordable(cwd, argv) {
|
|
20241
20237
|
return !hasControl2(cwd) && !argv.some(hasControl2);
|
|
20242
20238
|
}
|
|
20243
|
-
function changedText(
|
|
20244
|
-
return `sudo: ${
|
|
20239
|
+
function changedText(word) {
|
|
20240
|
+
return `sudo: ${quoteWord(word)} changed since it was approved`;
|
|
20245
20241
|
}
|
|
20246
|
-
function requestedText(
|
|
20247
|
-
return `sudo: ${
|
|
20242
|
+
function requestedText(word) {
|
|
20243
|
+
return `sudo: ${quoteWord(word)} changed since it was requested`;
|
|
20248
20244
|
}
|
|
20249
20245
|
function changedFile(approved, now) {
|
|
20250
20246
|
const files = /* @__PURE__ */ new Set([...Object.keys(approved), ...Object.keys(now)]);
|
|
@@ -20711,12 +20707,12 @@ var Sudo = class {
|
|
|
20711
20707
|
if (file.split("/").includes("..")) return physicalPathAsync(fs, file, true);
|
|
20712
20708
|
return await fs.realpath?.(file, true).catch(() => file) ?? file;
|
|
20713
20709
|
}
|
|
20714
|
-
async moved({ routes }
|
|
20710
|
+
async moved({ routes }) {
|
|
20715
20711
|
for (const [asked, approved] of Object.entries(routes)) {
|
|
20716
20712
|
const real = await this.real(asked).catch(() => void 0);
|
|
20717
|
-
if (real !== approved) return
|
|
20713
|
+
if (real !== approved) return true;
|
|
20718
20714
|
}
|
|
20719
|
-
return
|
|
20715
|
+
return false;
|
|
20720
20716
|
}
|
|
20721
20717
|
async missingBacking(hashes, except) {
|
|
20722
20718
|
for (const path of Object.keys(hashes)) {
|
|
@@ -20759,6 +20755,11 @@ var Sudo = class {
|
|
|
20759
20755
|
await lstat("/");
|
|
20760
20756
|
return physicalPathAsync({ lstat, readlink: (at) => fs.readlink(at) }, path, true);
|
|
20761
20757
|
}
|
|
20758
|
+
async executablePath(fs, cred, asked) {
|
|
20759
|
+
const path = await this.searched(fs, cred, asked);
|
|
20760
|
+
const st = await fs.stat(path);
|
|
20761
|
+
return st.isFile && (st.mode & 73) !== 0 ? path : void 0;
|
|
20762
|
+
}
|
|
20762
20763
|
async locate(word, cwd, reads, target) {
|
|
20763
20764
|
const fs = this.o.planFs?.(reads) ?? this.o.fs;
|
|
20764
20765
|
const candidates = word.includes("/") ? [askedPath(cwd, word)] : SECURE_PATH.split(":").map((dir) => `${dir}/${word}`);
|
|
@@ -20766,9 +20767,8 @@ var Sudo = class {
|
|
|
20766
20767
|
let denial;
|
|
20767
20768
|
for (const asked of candidates) {
|
|
20768
20769
|
try {
|
|
20769
|
-
const path = await this.
|
|
20770
|
-
|
|
20771
|
-
if (st.isFile && (st.mode & 73) !== 0) return { path, asked };
|
|
20770
|
+
const path = await this.executablePath(fs, cred, asked);
|
|
20771
|
+
if (path !== void 0) return { path, asked };
|
|
20772
20772
|
} catch (err) {
|
|
20773
20773
|
const code = err.code;
|
|
20774
20774
|
if (code === "EACCES") denial = failed2(code, `sudo: ${word}: Permission denied`);
|
|
@@ -20847,7 +20847,7 @@ ${SCRIPT_HELP}
|
|
|
20847
20847
|
const [word = "", ...args] = r.argv;
|
|
20848
20848
|
const argv = [r.path, ...args];
|
|
20849
20849
|
if (!await this.mayAsk(self, target, r, argv)) {
|
|
20850
|
-
const quoted = argv.map(quoteWord).join(" ");
|
|
20850
|
+
const quoted = r.argv.map(quoteWord).join(" ");
|
|
20851
20851
|
return failed2(
|
|
20852
20852
|
"EACCES",
|
|
20853
20853
|
`sudo: ${self.name} may no longer ask to run ${quoted} as ${target.name}`
|
|
@@ -20867,19 +20867,19 @@ ${SCRIPT_HELP}
|
|
|
20867
20867
|
if (located && "error" in located) return located;
|
|
20868
20868
|
if (!located) {
|
|
20869
20869
|
const gone = await this.missingBacking(r.bound, r.path);
|
|
20870
|
-
return gone ? failed2("EPERM", requestedText(
|
|
20870
|
+
return gone ? failed2("EPERM", requestedText(word)) : failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
20871
20871
|
}
|
|
20872
20872
|
const { path, asked } = located;
|
|
20873
|
-
if (path !== r.path) return failed2("EPERM",
|
|
20873
|
+
if (path !== r.path) return failed2("EPERM", requestedText(word));
|
|
20874
20874
|
const bound3 = await this.bound(path, r.cwd, asked, void 0, reads);
|
|
20875
|
-
if (!bound3) return failed2("EPERM", requestedText(
|
|
20875
|
+
if (!bound3) return failed2("EPERM", requestedText(word));
|
|
20876
20876
|
const changed2 = changedDecision(r.bound, r, bound3, path);
|
|
20877
20877
|
if (changed2 !== void 0) {
|
|
20878
20878
|
const missing7 = ["chainSha256", "routeSha256"].filter(
|
|
20879
20879
|
(key) => bound3[key] !== void 0 && r[key] === void 0
|
|
20880
20880
|
);
|
|
20881
20881
|
const hint = missing7.length && changedFile(r.bound, bound3.hashes) === void 0 ? `; the saved request lacks ${missing7.join(" and ")}; pass back the whole request from approve unchanged` : "";
|
|
20882
|
-
return failed2("EPERM", requestedText(
|
|
20882
|
+
return failed2("EPERM", requestedText(word) + hint);
|
|
20883
20883
|
}
|
|
20884
20884
|
const now = await this.rootOnly(r.cwd, args);
|
|
20885
20885
|
const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
|
|
@@ -20914,6 +20914,11 @@ ${SCRIPT_HELP}
|
|
|
20914
20914
|
const { caller, self, target, parsed: parsed3 } = s;
|
|
20915
20915
|
const { cred } = caller;
|
|
20916
20916
|
const [word = "", ...args] = parsed3.command;
|
|
20917
|
+
const notAllowed = () => failed2(
|
|
20918
|
+
"EPERM",
|
|
20919
|
+
`sudo: ${self.name} is not allowed to run ${parsed3.command.map(quoteWord).join(" ")} as ${target.name}`
|
|
20920
|
+
);
|
|
20921
|
+
if (!root && mine.length === 0) return notAllowed();
|
|
20917
20922
|
const cwd = await this.canonical(call.cwd, cred);
|
|
20918
20923
|
if (cwd === void 0 || !await this.reachable(cred, cwd)) {
|
|
20919
20924
|
return failed2(
|
|
@@ -20934,13 +20939,7 @@ ${SCRIPT_HELP}
|
|
|
20934
20939
|
const matching = applicable.filter((rule2) => pinned(rule2, bound3.hashes, bound3));
|
|
20935
20940
|
const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept, asked);
|
|
20936
20941
|
if (root || matching.some((rule2) => rule2.nopasswd)) return grant();
|
|
20937
|
-
|
|
20938
|
-
if (matching.length === 0) {
|
|
20939
|
-
return failed2(
|
|
20940
|
-
"EPERM",
|
|
20941
|
-
`sudo: ${self.name} is not allowed to run ${quoted} as ${target.name}`
|
|
20942
|
-
);
|
|
20943
|
-
}
|
|
20942
|
+
if (matching.length === 0) return notAllowed();
|
|
20944
20943
|
if (!parsed3.reset && this.timestamps.current(s.owner, s.policy, stampOf(bound3))) {
|
|
20945
20944
|
this.timestamps.stamp(s.owner, s.policy, stampOf(bound3));
|
|
20946
20945
|
this.logged(s, cwd, argv);
|
|
@@ -20964,14 +20963,11 @@ ${SCRIPT_HELP}
|
|
|
20964
20963
|
if (await this.canonical(call.cwd, cred) !== cwd || !await this.reachable(cred, cwd)) {
|
|
20965
20964
|
return failed2("EACCES", `sudo: ${call.cwd} changed while the request waited`);
|
|
20966
20965
|
}
|
|
20967
|
-
|
|
20968
|
-
if (moved2 !== void 0) return failed2("EPERM", changedText(moved2));
|
|
20966
|
+
if (await this.moved(bound3)) return failed2("EPERM", changedText(word));
|
|
20969
20967
|
if (answer2.answer === "once" && !answer2.person) return grant();
|
|
20970
20968
|
const now = await this.bound(path, cwd, asked, caller.pid);
|
|
20971
|
-
if (!now)
|
|
20972
|
-
return failed2("EPERM", changedText(
|
|
20973
|
-
const changed2 = changedDecision(bound3.hashes, bound3, now, path);
|
|
20974
|
-
if (changed2 !== void 0) return failed2("EPERM", changedText(changed2));
|
|
20969
|
+
if (!now || changedDecision(bound3.hashes, bound3, now, path) !== void 0)
|
|
20970
|
+
return failed2("EPERM", changedText(word));
|
|
20975
20971
|
const shown2 = recordable(cwd, [...parsed3.command, ...Object.keys(bound3.hashes)]);
|
|
20976
20972
|
const result = answer2.answer === "once" ? grant() : await this.always(
|
|
20977
20973
|
self,
|
|
@@ -29684,8 +29680,8 @@ var WasmProcess = class _WasmProcess {
|
|
|
29684
29680
|
close: () => source.release()
|
|
29685
29681
|
});
|
|
29686
29682
|
}
|
|
29687
|
-
nonblocking(fd,
|
|
29688
|
-
return
|
|
29683
|
+
nonblocking(fd, requested) {
|
|
29684
|
+
return requested === true || !this.options.perCallNonblock && ((this.fds.statusFlags(fd) ?? 0) & O_NONBLOCK3) !== 0;
|
|
29689
29685
|
}
|
|
29690
29686
|
async fdSyscall(req, cancelled) {
|
|
29691
29687
|
if (isVfsSyscall(req)) return this.vfsSyscall(req);
|
|
@@ -30567,7 +30563,8 @@ var WasmProcess = class _WasmProcess {
|
|
|
30567
30563
|
})
|
|
30568
30564
|
};
|
|
30569
30565
|
} catch (err) {
|
|
30570
|
-
if (err instanceof ChangedError)
|
|
30566
|
+
if (err instanceof ChangedError)
|
|
30567
|
+
return { error: changedText(argv[0] ?? asked), errno: err.code };
|
|
30571
30568
|
throw err;
|
|
30572
30569
|
}
|
|
30573
30570
|
}
|
|
@@ -33537,6 +33534,123 @@ function noticeOf(data) {
|
|
|
33537
33534
|
return { paths: strings3(notice.paths), trees: strings3(notice.trees), outside: true };
|
|
33538
33535
|
}
|
|
33539
33536
|
|
|
33537
|
+
// src/fs/private-rename.ts
|
|
33538
|
+
var DRAIN_MS = 500;
|
|
33539
|
+
var ADMISSION_MS = 5e3;
|
|
33540
|
+
var within10 = (at, root) => at === root || root === "/" || at.startsWith(root + "/");
|
|
33541
|
+
var PrivatePaths = class {
|
|
33542
|
+
names;
|
|
33543
|
+
bound = false;
|
|
33544
|
+
shifted = false;
|
|
33545
|
+
listing;
|
|
33546
|
+
removing;
|
|
33547
|
+
constructor(paths, listing, removing) {
|
|
33548
|
+
this.listing = listing;
|
|
33549
|
+
this.removing = removing;
|
|
33550
|
+
this.names = new Set(paths.map(normalizePath));
|
|
33551
|
+
}
|
|
33552
|
+
touches(roots, names2 = this.names) {
|
|
33553
|
+
for (const at of names2)
|
|
33554
|
+
for (const root of roots) {
|
|
33555
|
+
if (within10(at, root) || this.removing && within10(root, at)) return true;
|
|
33556
|
+
if (this.listing && at === (root.slice(0, root.lastIndexOf("/")) || "/")) return true;
|
|
33557
|
+
}
|
|
33558
|
+
return false;
|
|
33559
|
+
}
|
|
33560
|
+
bind(path) {
|
|
33561
|
+
if (this.shifted) return;
|
|
33562
|
+
this.names.clear();
|
|
33563
|
+
this.names.add(path);
|
|
33564
|
+
this.bound = true;
|
|
33565
|
+
}
|
|
33566
|
+
moved(from, to) {
|
|
33567
|
+
const names2 = this.redirected(from, to);
|
|
33568
|
+
if (!names2.size) return;
|
|
33569
|
+
this.shifted = true;
|
|
33570
|
+
if (this.bound) this.names.clear();
|
|
33571
|
+
for (const name2 of names2) this.names.add(name2);
|
|
33572
|
+
}
|
|
33573
|
+
redirected(from, to) {
|
|
33574
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
33575
|
+
for (const path of this.names)
|
|
33576
|
+
if (within10(path, from)) {
|
|
33577
|
+
const next3 = resolvePath(to, path.slice(from.length).replace(/^\//, ""));
|
|
33578
|
+
if (!this.names.has(next3)) names2.add(next3);
|
|
33579
|
+
}
|
|
33580
|
+
return names2;
|
|
33581
|
+
}
|
|
33582
|
+
};
|
|
33583
|
+
var PrivateRename = class {
|
|
33584
|
+
active = /* @__PURE__ */ new Set();
|
|
33585
|
+
barriers = /* @__PURE__ */ new Map();
|
|
33586
|
+
waiters = /* @__PURE__ */ new Set();
|
|
33587
|
+
wait(take, ms) {
|
|
33588
|
+
if (take()) return Promise.resolve();
|
|
33589
|
+
return new Promise((resolve2, reject) => {
|
|
33590
|
+
const wake = () => {
|
|
33591
|
+
if (!take()) return;
|
|
33592
|
+
this.waiters.delete(wake);
|
|
33593
|
+
clearTimeout(timer);
|
|
33594
|
+
resolve2();
|
|
33595
|
+
};
|
|
33596
|
+
const timer = setTimeout(() => {
|
|
33597
|
+
this.waiters.delete(wake);
|
|
33598
|
+
reject(fsError("EBUSY", "private rename"));
|
|
33599
|
+
}, ms);
|
|
33600
|
+
this.waiters.add(wake);
|
|
33601
|
+
});
|
|
33602
|
+
}
|
|
33603
|
+
wake() {
|
|
33604
|
+
for (const waiter of this.waiters) waiter();
|
|
33605
|
+
}
|
|
33606
|
+
blocked(op, names2 = op.names) {
|
|
33607
|
+
for (const [barrier, draining] of this.barriers) {
|
|
33608
|
+
if (!draining.has(op) && op.touches(barrier.names, names2)) return true;
|
|
33609
|
+
}
|
|
33610
|
+
return false;
|
|
33611
|
+
}
|
|
33612
|
+
enter(op) {
|
|
33613
|
+
return this.wait(() => {
|
|
33614
|
+
if (this.blocked(op)) return false;
|
|
33615
|
+
this.active.add(op);
|
|
33616
|
+
return true;
|
|
33617
|
+
}, ADMISSION_MS);
|
|
33618
|
+
}
|
|
33619
|
+
leave(op) {
|
|
33620
|
+
this.active.delete(op);
|
|
33621
|
+
for (const draining of this.barriers.values()) draining.delete(op);
|
|
33622
|
+
this.wake();
|
|
33623
|
+
}
|
|
33624
|
+
redirect(op, from, to) {
|
|
33625
|
+
const names2 = op.redirected(from, to);
|
|
33626
|
+
if (this.barriers.has(op) && names2.size) throw fsError("EBUSY", from);
|
|
33627
|
+
return this.wait(() => {
|
|
33628
|
+
if (this.blocked(op, names2)) return false;
|
|
33629
|
+
for (const name2 of names2) op.names.add(name2);
|
|
33630
|
+
return true;
|
|
33631
|
+
}, ADMISSION_MS);
|
|
33632
|
+
}
|
|
33633
|
+
moved(from, to) {
|
|
33634
|
+
for (const op of this.active) op.moved(from, to);
|
|
33635
|
+
}
|
|
33636
|
+
async exclusive(op, run2) {
|
|
33637
|
+
const draining = /* @__PURE__ */ new Set();
|
|
33638
|
+
await this.wait(() => {
|
|
33639
|
+
if (this.blocked(op)) return false;
|
|
33640
|
+
for (const active of this.active) if (active.touches(op.names)) draining.add(active);
|
|
33641
|
+
this.barriers.set(op, draining);
|
|
33642
|
+
return true;
|
|
33643
|
+
}, ADMISSION_MS);
|
|
33644
|
+
try {
|
|
33645
|
+
await this.wait(() => ![...draining].some((active) => this.active.has(active)), DRAIN_MS);
|
|
33646
|
+
return await run2();
|
|
33647
|
+
} finally {
|
|
33648
|
+
this.barriers.delete(op);
|
|
33649
|
+
this.wake();
|
|
33650
|
+
}
|
|
33651
|
+
}
|
|
33652
|
+
};
|
|
33653
|
+
|
|
33540
33654
|
// src/fs/opfs.ts
|
|
33541
33655
|
var S_IFDIR2 = 16384;
|
|
33542
33656
|
var S_IFREG3 = 32768;
|
|
@@ -33577,8 +33691,12 @@ var PAIRED = /* @__PURE__ */ new Set(["rename", "link", "copyFile"]);
|
|
|
33577
33691
|
var LISTINGS = /* @__PURE__ */ new Set(["readdir", "readdirStat"]);
|
|
33578
33692
|
var REMOVALS2 = /* @__PURE__ */ new Set(["rm", "rename"]);
|
|
33579
33693
|
var RETRY = /* @__PURE__ */ Symbol("retry");
|
|
33694
|
+
var PRIVATE_COPY = /* @__PURE__ */ Symbol("private-copy");
|
|
33580
33695
|
var ACK_SAMPLES = 4096;
|
|
33581
33696
|
var INTENT_POLL_MS = 5;
|
|
33697
|
+
function needsCopy(handle, swap) {
|
|
33698
|
+
return swap || handle.kind === "directory" && !movable(handle);
|
|
33699
|
+
}
|
|
33582
33700
|
function movable(handle) {
|
|
33583
33701
|
return typeof handle.move === "function";
|
|
33584
33702
|
}
|
|
@@ -33661,7 +33779,7 @@ function prefixes(path) {
|
|
|
33661
33779
|
const parts2 = split2(path);
|
|
33662
33780
|
return parts2.map((_, i) => `/${parts2.slice(0, i + 1).join("/")}`);
|
|
33663
33781
|
}
|
|
33664
|
-
function
|
|
33782
|
+
function within11(path, root) {
|
|
33665
33783
|
return path === root || path.startsWith(`${root}/`);
|
|
33666
33784
|
}
|
|
33667
33785
|
var unstored = () => Object.assign(new Error("the file system kept fewer bytes than were written"), {
|
|
@@ -33773,6 +33891,10 @@ function isHandle(child2) {
|
|
|
33773
33891
|
var FILE_TIMES_MS = 100;
|
|
33774
33892
|
var OpfsFs = class {
|
|
33775
33893
|
root;
|
|
33894
|
+
privateRename;
|
|
33895
|
+
insidePrivateOp = false;
|
|
33896
|
+
privateRedirect;
|
|
33897
|
+
privateSession;
|
|
33776
33898
|
meta;
|
|
33777
33899
|
dirs = new PathMap();
|
|
33778
33900
|
files = new PathMap();
|
|
@@ -33797,6 +33919,7 @@ var OpfsFs = class {
|
|
|
33797
33919
|
renamePrefix;
|
|
33798
33920
|
constructor(root, meta = new MemoryMeta(), channel, options = {}) {
|
|
33799
33921
|
this.root = root;
|
|
33922
|
+
this.privateRename = channel === void 0 ? new PrivateRename() : void 0;
|
|
33800
33923
|
this.meta = sidecar(meta);
|
|
33801
33924
|
this.ranged = options.ranged === true;
|
|
33802
33925
|
this.locks = options.locks === void 0 ? lockManager() : options.locks ?? void 0;
|
|
@@ -34376,6 +34499,7 @@ var OpfsFs = class {
|
|
|
34376
34499
|
if (this.rejectLinks) throw fsError("ELOOP", path);
|
|
34377
34500
|
const stored = link2.link;
|
|
34378
34501
|
if (overPath(stored)) throw fsError("ENAMETOOLONG", link2.path);
|
|
34502
|
+
const previous = current;
|
|
34379
34503
|
const target = stored + current.slice(link2.path.length);
|
|
34380
34504
|
if (target.split("/").includes("..") || longParent(stored) !== void 0) {
|
|
34381
34505
|
const resolved2 = await this.physical(parentOf11(link2.path), target, hops + 1, path);
|
|
@@ -34385,6 +34509,7 @@ var OpfsFs = class {
|
|
|
34385
34509
|
current = resolvePath(parentOf11(link2.path), target);
|
|
34386
34510
|
}
|
|
34387
34511
|
this.crossing(path, current);
|
|
34512
|
+
await this.privateRedirect?.(previous, current);
|
|
34388
34513
|
}
|
|
34389
34514
|
}
|
|
34390
34515
|
throw fsError("ELOOP", path);
|
|
@@ -34476,11 +34601,11 @@ var OpfsFs = class {
|
|
|
34476
34601
|
movePending(from, to) {
|
|
34477
34602
|
if (to !== void 0) {
|
|
34478
34603
|
for (const path of [...this.fileTimes.keys()]) {
|
|
34479
|
-
if (
|
|
34604
|
+
if (within11(path, to)) this.fileTimes.delete(path);
|
|
34480
34605
|
}
|
|
34481
34606
|
}
|
|
34482
34607
|
for (const [path, ms] of [...this.fileTimes]) {
|
|
34483
|
-
if (!
|
|
34608
|
+
if (!within11(path, from)) continue;
|
|
34484
34609
|
this.fileTimes.delete(path);
|
|
34485
34610
|
if (to !== void 0) this.fileTimes.set(to + path.slice(from.length), ms);
|
|
34486
34611
|
}
|
|
@@ -34760,8 +34885,8 @@ var OpfsFs = class {
|
|
|
34760
34885
|
const file = this.movingFiles.get(at);
|
|
34761
34886
|
if (file !== void 0) return { done: file, away: true };
|
|
34762
34887
|
for (const m of this.renamingDirs) {
|
|
34763
|
-
if (
|
|
34764
|
-
if (
|
|
34888
|
+
if (within11(at, m.from)) return { done: m.done, away: true };
|
|
34889
|
+
if (within11(at, m.to)) return { done: m.done, away: false };
|
|
34765
34890
|
}
|
|
34766
34891
|
return void 0;
|
|
34767
34892
|
}
|
|
@@ -34797,7 +34922,7 @@ var OpfsFs = class {
|
|
|
34797
34922
|
idle2.resolve();
|
|
34798
34923
|
}
|
|
34799
34924
|
async writesDrained(tree2) {
|
|
34800
|
-
while ([...this.fileWrites.keys()].some((at) =>
|
|
34925
|
+
while ([...this.fileWrites.keys()].some((at) => within11(at, tree2))) {
|
|
34801
34926
|
this.writesIdle ??= Promise.withResolvers();
|
|
34802
34927
|
await this.writesIdle.promise;
|
|
34803
34928
|
}
|
|
@@ -34874,6 +34999,7 @@ var OpfsFs = class {
|
|
|
34874
34999
|
}
|
|
34875
35000
|
async writeSession(path, truncate) {
|
|
34876
35001
|
const [handle, , target] = await this.fileFor(path);
|
|
35002
|
+
this.privateSession?.bind(target);
|
|
34877
35003
|
const writable3 = await this.retrying(
|
|
34878
35004
|
path,
|
|
34879
35005
|
() => this.io(handle.createWritable({ keepExistingData: !truncate })),
|
|
@@ -35256,15 +35382,14 @@ var OpfsFs = class {
|
|
|
35256
35382
|
if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", to);
|
|
35257
35383
|
const destination = resolvePath(parent.path, baseOf4(to));
|
|
35258
35384
|
this.refuse(destination, true);
|
|
35259
|
-
if (directory)
|
|
35260
|
-
|
|
35261
|
-
if (source.path === destination) return;
|
|
35262
|
-
}
|
|
35385
|
+
if (directory && source.handle?.kind !== "directory") throw fsError("ENOTDIR", from);
|
|
35386
|
+
if (source.path === destination) return;
|
|
35263
35387
|
await this.entering(destination, () => this.moveTo(source, parent, destination, to, call));
|
|
35388
|
+
this.privateRename?.moved(source.path, destination);
|
|
35264
35389
|
}
|
|
35265
35390
|
async moveTo(source, parent, destination, to, call) {
|
|
35266
35391
|
const sourceStat = await this.describe(source);
|
|
35267
|
-
if (sourceStat.isDirectory &&
|
|
35392
|
+
if (sourceStat.isDirectory && within11(destination, source.path)) throw fsError("EINVAL", to);
|
|
35268
35393
|
const target = await this.exactly(() => this.locate(destination, false)).catch((err) => {
|
|
35269
35394
|
if (missing6(err)) return null;
|
|
35270
35395
|
throw err;
|
|
@@ -35300,8 +35425,10 @@ var OpfsFs = class {
|
|
|
35300
35425
|
let lock;
|
|
35301
35426
|
const hooks = {};
|
|
35302
35427
|
const staging = swap ? `.${name2}.${crypto.randomUUID()}` : name2;
|
|
35303
|
-
const copying =
|
|
35428
|
+
const copying = needsCopy(source.handle, swap);
|
|
35304
35429
|
const staged2 = resolvePath(parent.path, staging);
|
|
35430
|
+
if (this.usePrivateCopy(source.handle, copying))
|
|
35431
|
+
return this.privateCopy(source, parent, destination, target?.handle, moving);
|
|
35305
35432
|
const place = async () => {
|
|
35306
35433
|
this.forget(destination);
|
|
35307
35434
|
const copies = /* @__PURE__ */ new Map();
|
|
@@ -35536,7 +35663,7 @@ var OpfsFs = class {
|
|
|
35536
35663
|
for (const move of this.peerMoves.values()) {
|
|
35537
35664
|
for (const tree2 of move.trees) {
|
|
35538
35665
|
for (const mine of [from, to]) {
|
|
35539
|
-
if (tree2.some((theirs) =>
|
|
35666
|
+
if (tree2.some((theirs) => within11(mine, theirs) || within11(theirs, mine))) return move;
|
|
35540
35667
|
}
|
|
35541
35668
|
}
|
|
35542
35669
|
}
|
|
@@ -35628,6 +35755,95 @@ var OpfsFs = class {
|
|
|
35628
35755
|
});
|
|
35629
35756
|
return { ...session, close: () => session.close().finally(done4) };
|
|
35630
35757
|
}
|
|
35758
|
+
async privateOp(name2, args, inner) {
|
|
35759
|
+
const gate = this.privateRename;
|
|
35760
|
+
if (!gate || this.insidePrivateOp) return inner.apply(this, args);
|
|
35761
|
+
const paths = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
|
|
35762
|
+
const op = new PrivatePaths(paths, LISTINGS.has(name2), REMOVALS2.has(name2));
|
|
35763
|
+
const inside2 = view(this, {
|
|
35764
|
+
insidePrivateOp: true,
|
|
35765
|
+
privateSession: name2 === "writeSession" ? op : void 0,
|
|
35766
|
+
privateRedirect: (from, to) => gate.redirect(op, from, to)
|
|
35767
|
+
});
|
|
35768
|
+
await gate.enter(op);
|
|
35769
|
+
const leave = () => gate.leave(op);
|
|
35770
|
+
let sessionOwnsAdmission = false;
|
|
35771
|
+
try {
|
|
35772
|
+
if (name2 === "writeSession") {
|
|
35773
|
+
const session = await inner.apply(inside2, args);
|
|
35774
|
+
sessionOwnsAdmission = true;
|
|
35775
|
+
let closed;
|
|
35776
|
+
return { ...session, close: () => closed ??= session.close().finally(leave) };
|
|
35777
|
+
}
|
|
35778
|
+
if (name2 !== "rename") return await inner.apply(inside2, args);
|
|
35779
|
+
try {
|
|
35780
|
+
return await inner.apply(inside2, args);
|
|
35781
|
+
} catch (err) {
|
|
35782
|
+
if (err !== PRIVATE_COPY) throw err;
|
|
35783
|
+
}
|
|
35784
|
+
} finally {
|
|
35785
|
+
if (!sessionOwnsAdmission) leave();
|
|
35786
|
+
}
|
|
35787
|
+
const exclusive = view(inside2, { privateCopyReady: true });
|
|
35788
|
+
return gate.exclusive(op, () => inner.apply(exclusive, args));
|
|
35789
|
+
}
|
|
35790
|
+
privateCopyReady = false;
|
|
35791
|
+
usePrivateCopy(handle, staging) {
|
|
35792
|
+
if (!this.privateRename) return false;
|
|
35793
|
+
if (this.privateCopyReady) return true;
|
|
35794
|
+
if (staging || !movable(handle)) throw PRIVATE_COPY;
|
|
35795
|
+
return false;
|
|
35796
|
+
}
|
|
35797
|
+
async privateCopy(source, parent, to, target, owner) {
|
|
35798
|
+
const handle = source.handle;
|
|
35799
|
+
const dir = parent.handle;
|
|
35800
|
+
const name2 = baseOf4(to);
|
|
35801
|
+
const copies = /* @__PURE__ */ new Map();
|
|
35802
|
+
const [entry] = await this.meta.get([source.path]);
|
|
35803
|
+
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
35804
|
+
const intent = await this.intend({ from: source.path, to, root, privateCopy: true });
|
|
35805
|
+
try {
|
|
35806
|
+
await this.duplicate(handle, dir, name2, copies, "");
|
|
35807
|
+
} catch (err) {
|
|
35808
|
+
if (!target)
|
|
35809
|
+
await dir.removeEntry(name2, { recursive: true }).catch((e) => {
|
|
35810
|
+
if (e.name !== "NotFoundError") throw e;
|
|
35811
|
+
});
|
|
35812
|
+
else if (target.kind === "directory") {
|
|
35813
|
+
for await (const child2 of target.keys())
|
|
35814
|
+
await target.removeEntry(child2, { recursive: true });
|
|
35815
|
+
}
|
|
35816
|
+
this.forget(to);
|
|
35817
|
+
await this.meta.update(intent, () => void 0);
|
|
35818
|
+
throw translate(err, to, "write");
|
|
35819
|
+
}
|
|
35820
|
+
await this.commitPrivateCopy(source.path, to, root, intent, copies);
|
|
35821
|
+
}
|
|
35822
|
+
async commitPrivateCopy(from, to, root, intent, copies) {
|
|
35823
|
+
const { ino, ...owner } = root;
|
|
35824
|
+
const entries = await this.meta.get([from, to]);
|
|
35825
|
+
if (!entries[0]?.vacated || entries[1]?.ino !== ino) {
|
|
35826
|
+
await this.meta.move(
|
|
35827
|
+
from,
|
|
35828
|
+
to,
|
|
35829
|
+
(entry) => ({ ...occupied(entry), ...owner, ino, path: to, ctimeMs: Date.now() }),
|
|
35830
|
+
vacatedAt(from)
|
|
35831
|
+
);
|
|
35832
|
+
}
|
|
35833
|
+
this.movePending(from, to);
|
|
35834
|
+
await this.removePhysical(from, true);
|
|
35835
|
+
await this.meta.update(intent, () => void 0);
|
|
35836
|
+
await this.restamp(to, copies);
|
|
35837
|
+
this.changed(from, to);
|
|
35838
|
+
this.touch(Date.now(), parentOf11(from), parentOf11(to));
|
|
35839
|
+
}
|
|
35840
|
+
async duplicate(handle, parent, name2, copies, rest2) {
|
|
35841
|
+
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
35842
|
+
const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
|
|
35843
|
+
this.others++;
|
|
35844
|
+
for await (const child2 of handle.values())
|
|
35845
|
+
await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
|
|
35846
|
+
}
|
|
35631
35847
|
renamingDirs = /* @__PURE__ */ new Set();
|
|
35632
35848
|
intents = 0;
|
|
35633
35849
|
async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
|
|
@@ -35690,6 +35906,28 @@ var OpfsFs = class {
|
|
|
35690
35906
|
this.forget(to);
|
|
35691
35907
|
try {
|
|
35692
35908
|
const left = await this.real(from);
|
|
35909
|
+
if (current.rename.privateCopy) {
|
|
35910
|
+
if (left) {
|
|
35911
|
+
const src = await this.locate(from, false);
|
|
35912
|
+
const dir = await this.locate(parentOf11(to), true);
|
|
35913
|
+
const copies = /* @__PURE__ */ new Map();
|
|
35914
|
+
await this.duplicate(
|
|
35915
|
+
src.handle,
|
|
35916
|
+
dir.handle,
|
|
35917
|
+
baseOf4(to),
|
|
35918
|
+
copies,
|
|
35919
|
+
""
|
|
35920
|
+
);
|
|
35921
|
+
await this.commitPrivateCopy(
|
|
35922
|
+
from,
|
|
35923
|
+
to,
|
|
35924
|
+
root ?? { ino: inodeOf(from) },
|
|
35925
|
+
entry.path,
|
|
35926
|
+
copies
|
|
35927
|
+
);
|
|
35928
|
+
} else await this.meta.update(entry.path, () => void 0);
|
|
35929
|
+
return;
|
|
35930
|
+
}
|
|
35693
35931
|
if (left && replace && await this.real(to))
|
|
35694
35932
|
await PLAIN3.rm.call(this, to, { recursive: true });
|
|
35695
35933
|
if (left) {
|
|
@@ -35805,7 +36043,7 @@ var OpfsFs = class {
|
|
|
35805
36043
|
}
|
|
35806
36044
|
renameAt(at) {
|
|
35807
36045
|
for (const m of this.renamingDirs) {
|
|
35808
|
-
if (
|
|
36046
|
+
if (within11(at, m.from) || within11(at, m.to) || at === parentOf11(m.from) || at === parentOf11(m.to))
|
|
35809
36047
|
return m;
|
|
35810
36048
|
}
|
|
35811
36049
|
return void 0;
|
|
@@ -35841,7 +36079,10 @@ var OpfsFs = class {
|
|
|
35841
36079
|
}
|
|
35842
36080
|
async place(handle, dir, name2, copies, admitted) {
|
|
35843
36081
|
if (await this.moved(handle, dir, name2, admitted)) return true;
|
|
35844
|
-
if (!admitted)
|
|
36082
|
+
if (!admitted) {
|
|
36083
|
+
if (this.privateRename) throw PRIVATE_COPY;
|
|
36084
|
+
throw fsError("EBUSY", name2);
|
|
36085
|
+
}
|
|
35845
36086
|
const before = this.fileMoves;
|
|
35846
36087
|
try {
|
|
35847
36088
|
await this.copy(handle, dir, name2, { copies });
|
|
@@ -35889,21 +36130,7 @@ var OpfsFs = class {
|
|
|
35889
36130
|
if (handle.kind === "file") {
|
|
35890
36131
|
if (options.restoring && await this.handleExists(dir, name2)) return;
|
|
35891
36132
|
if (await this.moveChild(handle, dir, name2)) return;
|
|
35892
|
-
|
|
35893
|
-
const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
|
|
35894
|
-
const writable3 = await this.io(made2.createWritable());
|
|
35895
|
-
try {
|
|
35896
|
-
await writable3.write(file);
|
|
35897
|
-
await writable3.close();
|
|
35898
|
-
} catch (err) {
|
|
35899
|
-
await writable3.abort().catch(nothing2);
|
|
35900
|
-
throw err;
|
|
35901
|
-
}
|
|
35902
|
-
options.copies?.set(rest2, {
|
|
35903
|
-
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
35904
|
-
made: made2
|
|
35905
|
-
});
|
|
35906
|
-
return;
|
|
36133
|
+
return this.copyBytes(handle, dir, name2, options, rest2);
|
|
35907
36134
|
}
|
|
35908
36135
|
const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
|
|
35909
36136
|
this.others++;
|
|
@@ -35911,6 +36138,22 @@ var OpfsFs = class {
|
|
|
35911
36138
|
await this.copy(child2, target, child2.name, options, `${rest2}/${child2.name}`);
|
|
35912
36139
|
}
|
|
35913
36140
|
}
|
|
36141
|
+
async copyBytes(handle, dir, name2, options, rest2) {
|
|
36142
|
+
const file = await this.io(handle.getFile());
|
|
36143
|
+
const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
|
|
36144
|
+
const writable3 = await this.io(made2.createWritable());
|
|
36145
|
+
try {
|
|
36146
|
+
await writable3.write(file);
|
|
36147
|
+
await writable3.close();
|
|
36148
|
+
} catch (err) {
|
|
36149
|
+
await writable3.abort().catch(nothing2);
|
|
36150
|
+
throw err;
|
|
36151
|
+
}
|
|
36152
|
+
options.copies?.set(rest2, {
|
|
36153
|
+
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
36154
|
+
made: made2
|
|
36155
|
+
});
|
|
36156
|
+
}
|
|
35914
36157
|
async symlink(target, path, owner) {
|
|
35915
36158
|
if (overPath(target)) throw fsError("ENAMETOOLONG", path);
|
|
35916
36159
|
const parent = await this.exactly(() => this.locate(parentOf11(path), true));
|
|
@@ -36078,7 +36321,7 @@ function nothing2() {
|
|
|
36078
36321
|
}
|
|
36079
36322
|
function touches2(at, trees, listing = true, removing = false) {
|
|
36080
36323
|
return trees.some(
|
|
36081
|
-
([from, to]) =>
|
|
36324
|
+
([from, to]) => within11(at, from) || within11(at, to) || listing && (at === parentOf11(from) || at === parentOf11(to)) || removing && (at === "/" || within11(from, at) || within11(to, at))
|
|
36082
36325
|
);
|
|
36083
36326
|
}
|
|
36084
36327
|
function byIntent(a, b) {
|
|
@@ -36123,6 +36366,7 @@ var WRITES = [
|
|
|
36123
36366
|
const proto = OpfsFs.prototype;
|
|
36124
36367
|
const inner = proto.createExclusive;
|
|
36125
36368
|
proto.createExclusive = function(...args) {
|
|
36369
|
+
if (this.privateRename) return this.privateOp("createExclusive", args, inner);
|
|
36126
36370
|
if (this.amongPeers()) return this.peerOp("createExclusive", args, inner);
|
|
36127
36371
|
return this.alonePlain(inner, args);
|
|
36128
36372
|
};
|
|
@@ -36136,6 +36380,7 @@ for (const [names2, op] of [
|
|
|
36136
36380
|
const inner = proto[name2];
|
|
36137
36381
|
proto[name2] = async function(...args) {
|
|
36138
36382
|
try {
|
|
36383
|
+
if (this.privateRename) return await this.privateOp(name2, args, inner);
|
|
36139
36384
|
if (op === "read") await this.settledRename(args[0]);
|
|
36140
36385
|
if (this.amongPeers() || name2 === "writeSession")
|
|
36141
36386
|
return await this.peerOp(name2, args, inner);
|
|
@@ -38042,8 +38287,7 @@ function describe(req, tty) {
|
|
|
38042
38287
|
return { argv: [req.argv0, ...req.args], tty, started: Date.now(), ...exe };
|
|
38043
38288
|
}
|
|
38044
38289
|
function refuseChanged(approved, now) {
|
|
38045
|
-
|
|
38046
|
-
if (changed2 !== void 0) throw new ChangedError(changedText(changed2), changed2);
|
|
38290
|
+
if (changedFile(approved, now) !== void 0) throw new ChangedError();
|
|
38047
38291
|
}
|
|
38048
38292
|
var O_WRONLY2 = 1;
|
|
38049
38293
|
var OUTPUT_MODE = 384;
|
|
@@ -38062,10 +38306,14 @@ function sudoCause(err) {
|
|
|
38062
38306
|
if (typeof code !== "string") throw err;
|
|
38063
38307
|
return code;
|
|
38064
38308
|
}
|
|
38065
|
-
|
|
38066
|
-
|
|
38067
|
-
|
|
38068
|
-
|
|
38309
|
+
var LOST_ROUTE = /* @__PURE__ */ new Set([
|
|
38310
|
+
"ENOENT",
|
|
38311
|
+
"ENOTDIR",
|
|
38312
|
+
"EACCES",
|
|
38313
|
+
"ELOOP",
|
|
38314
|
+
"ESTALE",
|
|
38315
|
+
"ENAMETOOLONG"
|
|
38316
|
+
]);
|
|
38069
38317
|
var MAX_SPAWN_TAGS = 8;
|
|
38070
38318
|
function tagList(value2) {
|
|
38071
38319
|
if (!Array.isArray(value2)) {
|
|
@@ -39365,16 +39613,20 @@ var Launcher = class {
|
|
|
39365
39613
|
const refused5 = (err) => {
|
|
39366
39614
|
throw codeOf9(err) === "EACCES" ? new SpawnError("EACCES") : err;
|
|
39367
39615
|
};
|
|
39616
|
+
const lost = (err) => {
|
|
39617
|
+
if (LOST_ROUTE.has(codeOf9(err))) throw new ChangedError();
|
|
39618
|
+
throw err;
|
|
39619
|
+
};
|
|
39368
39620
|
const { file, parentHops } = await this.execFile(
|
|
39369
39621
|
req.file,
|
|
39370
39622
|
req.cwd,
|
|
39371
39623
|
this.execGuard(cred, ppid),
|
|
39372
39624
|
ppid
|
|
39373
|
-
).catch(refused5);
|
|
39625
|
+
).catch(grant?.files ? lost : refused5);
|
|
39374
39626
|
const reads = prepared ?? (grant?.files && await this.scriptReads(grant.files, cred, ppid));
|
|
39375
39627
|
if (grant?.asked && reads) {
|
|
39376
|
-
const destination = await this.sudoer.
|
|
39377
|
-
if (destination !== file) throw new ChangedError(
|
|
39628
|
+
const destination = await this.sudoer.executablePath(this.sudoFs(reads), cred, grant.asked).catch(lost);
|
|
39629
|
+
if (destination !== file) throw new ChangedError();
|
|
39378
39630
|
}
|
|
39379
39631
|
const plan = await this.plan(file, req.argv, req.cwd, scope, {
|
|
39380
39632
|
argv0: req.argv0,
|
|
@@ -39393,10 +39645,7 @@ var Launcher = class {
|
|
|
39393
39645
|
async checkFailedPlan(file, req, scope, grant) {
|
|
39394
39646
|
const reads = this.sudoer.reads();
|
|
39395
39647
|
const { planned } = await this.plan(file, req.argv, req.cwd, scope, { reads });
|
|
39396
|
-
if (!planned)
|
|
39397
|
-
const gone = await this.sudoer.missingBacking(grant.files.hashes) ?? file;
|
|
39398
|
-
throw new ChangedError(changedText(gone), gone);
|
|
39399
|
-
}
|
|
39648
|
+
if (!planned) throw new ChangedError();
|
|
39400
39649
|
await this.unchanged({ ...planned, reads }, file, req.cwd, grant);
|
|
39401
39650
|
}
|
|
39402
39651
|
async enterable(g, cwd) {
|
|
@@ -39550,26 +39799,26 @@ var Launcher = class {
|
|
|
39550
39799
|
const now = await planned.reads.bind([file, grant.asked ?? file, ...files]);
|
|
39551
39800
|
refuseChanged(approved.hashes, now.hashes);
|
|
39552
39801
|
refuseChanged(approved.routes, now.routes);
|
|
39553
|
-
if (now.chainSha256 !== approved.chainSha256) throw new ChangedError(
|
|
39802
|
+
if (now.chainSha256 !== approved.chainSha256) throw new ChangedError();
|
|
39554
39803
|
return { pinned: approved };
|
|
39555
39804
|
}
|
|
39556
39805
|
approvedChain(planned, file, cwd, grant) {
|
|
39557
39806
|
if (!grant) return void 0;
|
|
39558
39807
|
return async (next3) => {
|
|
39559
39808
|
const chain2 = (p) => [...p.via ?? [], ...p.binfmts ?? []];
|
|
39560
|
-
if (!sameList(chain2(next3), chain2(planned))) throw new ChangedError(
|
|
39809
|
+
if (!sameList(chain2(next3), chain2(planned))) throw new ChangedError();
|
|
39561
39810
|
await this.unchanged(next3, file, cwd, grant);
|
|
39562
39811
|
};
|
|
39563
39812
|
}
|
|
39564
39813
|
async scriptReads(files, cred, pid) {
|
|
39565
|
-
await this.checkRoutes(files
|
|
39814
|
+
await this.checkRoutes(files);
|
|
39566
39815
|
const snapshots = /* @__PURE__ */ new Map();
|
|
39567
39816
|
const reads = this.sudoer.reads(snapshots);
|
|
39568
39817
|
const guard2 = { fs: this.sudoFs(reads), dac: this.dac, cred, pid, links: cred.euid };
|
|
39569
39818
|
for (const path of files.scripts ?? []) {
|
|
39570
39819
|
const real = files.routes[path];
|
|
39571
39820
|
const walked2 = await need(guard2, "open", path, R_OK, { directory: false });
|
|
39572
|
-
if (walked2.missing || walked2.path !== real) throw new ChangedError(
|
|
39821
|
+
if (walked2.missing || walked2.path !== real) throw new ChangedError();
|
|
39573
39822
|
if (!snapshots.has(real))
|
|
39574
39823
|
snapshots.set(real, new Uint8Array(await this.noLinksFs.readFileBuffer(real)));
|
|
39575
39824
|
}
|
|
@@ -39582,14 +39831,13 @@ var Launcher = class {
|
|
|
39582
39831
|
const real = files.routes[path];
|
|
39583
39832
|
if (real === void 0) continue;
|
|
39584
39833
|
const bytes = reads.snapshots.get(real);
|
|
39585
|
-
if (!bytes) throw new ChangedError(
|
|
39834
|
+
if (!bytes) throw new ChangedError();
|
|
39586
39835
|
args[args.length - fromEnd] = scriptFd(fds, bytes);
|
|
39587
39836
|
}
|
|
39588
39837
|
return { ...planned, args };
|
|
39589
39838
|
}
|
|
39590
|
-
async checkRoutes(files
|
|
39591
|
-
|
|
39592
|
-
if (file !== void 0) throw new ChangedError(changedText(file), file);
|
|
39839
|
+
async checkRoutes(files) {
|
|
39840
|
+
if (await this.sudoer.moved(files)) throw new ChangedError();
|
|
39593
39841
|
}
|
|
39594
39842
|
async pinOf(path, caller) {
|
|
39595
39843
|
const { pinned: pinned2 } = caller;
|
|
@@ -39597,7 +39845,7 @@ var Launcher = class {
|
|
|
39597
39845
|
const real = await this.sudoer.real(path);
|
|
39598
39846
|
const approved = pinned2.routes[path];
|
|
39599
39847
|
if (approved !== real && (approved !== void 0 || !await this.sudoer.trustedThrough(path)))
|
|
39600
|
-
throw new ChangedError(
|
|
39848
|
+
throw new ChangedError();
|
|
39601
39849
|
const hex4 = pinned2.hashes[real];
|
|
39602
39850
|
return hex4 === void 0 ? {} : { [real]: hex4 };
|
|
39603
39851
|
}
|
|
@@ -40039,7 +40287,7 @@ var Launcher = class {
|
|
|
40039
40287
|
const own = env.HOSTNAME;
|
|
40040
40288
|
if (asked.target.abi === "wasi") env.HOSTNAME = this.hostname;
|
|
40041
40289
|
const planned = chosen2(asked, env);
|
|
40042
|
-
if (req.pinned) await this.checkRoutes(req.pinned
|
|
40290
|
+
if (req.pinned) await this.checkRoutes(req.pinned);
|
|
40043
40291
|
const caller = {
|
|
40044
40292
|
pid: req.ppid ?? 0,
|
|
40045
40293
|
uid: req.cred.euid,
|
|
@@ -40057,9 +40305,9 @@ var Launcher = class {
|
|
|
40057
40305
|
}
|
|
40058
40306
|
packageRootIs(path) {
|
|
40059
40307
|
const at = normalizePath(path);
|
|
40060
|
-
const
|
|
40308
|
+
const within12 = `${at}/`;
|
|
40061
40309
|
const roots = [this.modulesDir, ...this.appended];
|
|
40062
|
-
const root = PACKAGE_ROOT.exec(
|
|
40310
|
+
const root = PACKAGE_ROOT.exec(within12)?.[1] ?? packageRootOf(within12, roots);
|
|
40063
40311
|
return root === at;
|
|
40064
40312
|
}
|
|
40065
40313
|
packageRoots(planned) {
|
|
@@ -41850,12 +42098,16 @@ var Launcher = class {
|
|
|
41850
42098
|
this.resetCatalogs();
|
|
41851
42099
|
const req = { file: grant.file, argv: grant.argv, env: grant.env, cwd: grant.cwd };
|
|
41852
42100
|
const ctx = { ppid: 0, cred: grant.cred, scope: "", grant };
|
|
42101
|
+
const word = grant.argv[0] ?? grant.asked;
|
|
42102
|
+
const requested = (err2) => {
|
|
42103
|
+
if (err2 instanceof ChangedError) throw sudoFailure(err2.code, requestedText(word));
|
|
42104
|
+
throw err2;
|
|
42105
|
+
};
|
|
41853
42106
|
const planned = await this.planOne(req, ctx).catch((err2) => {
|
|
41854
42107
|
if (err2 instanceof ChangedError) requested(err2);
|
|
41855
42108
|
const code = sudoCause(err2);
|
|
41856
|
-
|
|
41857
|
-
|
|
41858
|
-
throw sudoFailure(code, `sudo: ${grant.file}: ${ERRNO_TEXT[code] ?? code}`);
|
|
42109
|
+
if (code === "ENOENT") throw sudoFailure(code, `sudo: ${quoteWord(word)}: command not found`);
|
|
42110
|
+
throw sudoFailure(code, `sudo: ${quoteWord(word)}: ${ERRNO_TEXT[code] ?? code}`);
|
|
41859
42111
|
});
|
|
41860
42112
|
const pin = await this.unchanged(planned, grant.file, grant.cwd, grant).catch(requested);
|
|
41861
42113
|
const fds = await this.sudoOutputs(options, caller, this.stackFor(tags, tagged.tagBase));
|
|
@@ -42570,9 +42822,9 @@ async function accountOf(l, user) {
|
|
|
42570
42822
|
if (!found) throw fsError("ENOENT", `no user ${String(user)}`);
|
|
42571
42823
|
return found;
|
|
42572
42824
|
}
|
|
42573
|
-
async function runAs(l, self,
|
|
42574
|
-
if (
|
|
42575
|
-
const target = await accountOf(l,
|
|
42825
|
+
async function runAs(l, self, requested) {
|
|
42826
|
+
if (requested === void 0) return self;
|
|
42827
|
+
const target = await accountOf(l, requested);
|
|
42576
42828
|
if (self.uid !== 0 && target.uid !== self.uid) {
|
|
42577
42829
|
throw fsError("EPERM", `${self.name} may not run as ${target.name}`);
|
|
42578
42830
|
}
|