@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/cloudflare.js
CHANGED
|
@@ -5237,7 +5237,7 @@ function satisfies(version, range2) {
|
|
|
5237
5237
|
}
|
|
5238
5238
|
|
|
5239
5239
|
// src/version.ts
|
|
5240
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
5240
|
+
var KERNEL_VERSION = true ? "1.196.19" : "0.0.0-dev";
|
|
5241
5241
|
var OS_RELEASE = "6.0.0-slicc";
|
|
5242
5242
|
function procVersion() {
|
|
5243
5243
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -10190,12 +10190,8 @@ var SpawnError = class extends Error {
|
|
|
10190
10190
|
}
|
|
10191
10191
|
};
|
|
10192
10192
|
var ChangedError = class extends SpawnError {
|
|
10193
|
-
|
|
10194
|
-
file;
|
|
10195
|
-
constructor(notice, file) {
|
|
10193
|
+
constructor() {
|
|
10196
10194
|
super("EPERM");
|
|
10197
|
-
this.notice = notice;
|
|
10198
|
-
this.file = file;
|
|
10199
10195
|
}
|
|
10200
10196
|
};
|
|
10201
10197
|
function interrupted(signal) {
|
|
@@ -19900,11 +19896,11 @@ function stdinMatches(rule2, stdin) {
|
|
|
19900
19896
|
function recordable(cwd, argv) {
|
|
19901
19897
|
return !hasControl2(cwd) && !argv.some(hasControl2);
|
|
19902
19898
|
}
|
|
19903
|
-
function changedText(
|
|
19904
|
-
return `sudo: ${
|
|
19899
|
+
function changedText(word) {
|
|
19900
|
+
return `sudo: ${quoteWord(word)} changed since it was approved`;
|
|
19905
19901
|
}
|
|
19906
|
-
function requestedText(
|
|
19907
|
-
return `sudo: ${
|
|
19902
|
+
function requestedText(word) {
|
|
19903
|
+
return `sudo: ${quoteWord(word)} changed since it was requested`;
|
|
19908
19904
|
}
|
|
19909
19905
|
function changedFile(approved, now) {
|
|
19910
19906
|
const files = /* @__PURE__ */ new Set([...Object.keys(approved), ...Object.keys(now)]);
|
|
@@ -20371,12 +20367,12 @@ var Sudo = class {
|
|
|
20371
20367
|
if (file.split("/").includes("..")) return physicalPathAsync(fs, file, true);
|
|
20372
20368
|
return await fs.realpath?.(file, true).catch(() => file) ?? file;
|
|
20373
20369
|
}
|
|
20374
|
-
async moved({ routes }
|
|
20370
|
+
async moved({ routes }) {
|
|
20375
20371
|
for (const [asked, approved] of Object.entries(routes)) {
|
|
20376
20372
|
const real2 = await this.real(asked).catch(() => void 0);
|
|
20377
|
-
if (real2 !== approved) return
|
|
20373
|
+
if (real2 !== approved) return true;
|
|
20378
20374
|
}
|
|
20379
|
-
return
|
|
20375
|
+
return false;
|
|
20380
20376
|
}
|
|
20381
20377
|
async missingBacking(hashes, except) {
|
|
20382
20378
|
for (const path of Object.keys(hashes)) {
|
|
@@ -20419,6 +20415,11 @@ var Sudo = class {
|
|
|
20419
20415
|
await lstat("/");
|
|
20420
20416
|
return physicalPathAsync({ lstat, readlink: (at) => fs.readlink(at) }, path, true);
|
|
20421
20417
|
}
|
|
20418
|
+
async executablePath(fs, cred, asked) {
|
|
20419
|
+
const path = await this.searched(fs, cred, asked);
|
|
20420
|
+
const st = await fs.stat(path);
|
|
20421
|
+
return st.isFile && (st.mode & 73) !== 0 ? path : void 0;
|
|
20422
|
+
}
|
|
20422
20423
|
async locate(word, cwd, reads, target) {
|
|
20423
20424
|
const fs = this.o.planFs?.(reads) ?? this.o.fs;
|
|
20424
20425
|
const candidates = word.includes("/") ? [askedPath(cwd, word)] : SECURE_PATH.split(":").map((dir) => `${dir}/${word}`);
|
|
@@ -20426,9 +20427,8 @@ var Sudo = class {
|
|
|
20426
20427
|
let denial;
|
|
20427
20428
|
for (const asked of candidates) {
|
|
20428
20429
|
try {
|
|
20429
|
-
const path = await this.
|
|
20430
|
-
|
|
20431
|
-
if (st.isFile && (st.mode & 73) !== 0) return { path, asked };
|
|
20430
|
+
const path = await this.executablePath(fs, cred, asked);
|
|
20431
|
+
if (path !== void 0) return { path, asked };
|
|
20432
20432
|
} catch (err) {
|
|
20433
20433
|
const code = err.code;
|
|
20434
20434
|
if (code === "EACCES") denial = failed2(code, `sudo: ${word}: Permission denied`);
|
|
@@ -20507,7 +20507,7 @@ ${SCRIPT_HELP}
|
|
|
20507
20507
|
const [word = "", ...args] = r.argv;
|
|
20508
20508
|
const argv = [r.path, ...args];
|
|
20509
20509
|
if (!await this.mayAsk(self, target, r, argv)) {
|
|
20510
|
-
const quoted = argv.map(quoteWord).join(" ");
|
|
20510
|
+
const quoted = r.argv.map(quoteWord).join(" ");
|
|
20511
20511
|
return failed2(
|
|
20512
20512
|
"EACCES",
|
|
20513
20513
|
`sudo: ${self.name} may no longer ask to run ${quoted} as ${target.name}`
|
|
@@ -20527,19 +20527,19 @@ ${SCRIPT_HELP}
|
|
|
20527
20527
|
if (located && "error" in located) return located;
|
|
20528
20528
|
if (!located) {
|
|
20529
20529
|
const gone = await this.missingBacking(r.bound, r.path);
|
|
20530
|
-
return gone ? failed2("EPERM", requestedText(
|
|
20530
|
+
return gone ? failed2("EPERM", requestedText(word)) : failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
20531
20531
|
}
|
|
20532
20532
|
const { path, asked } = located;
|
|
20533
|
-
if (path !== r.path) return failed2("EPERM",
|
|
20533
|
+
if (path !== r.path) return failed2("EPERM", requestedText(word));
|
|
20534
20534
|
const bound3 = await this.bound(path, r.cwd, asked, void 0, reads);
|
|
20535
|
-
if (!bound3) return failed2("EPERM", requestedText(
|
|
20535
|
+
if (!bound3) return failed2("EPERM", requestedText(word));
|
|
20536
20536
|
const changed2 = changedDecision(r.bound, r, bound3, path);
|
|
20537
20537
|
if (changed2 !== void 0) {
|
|
20538
20538
|
const missing7 = ["chainSha256", "routeSha256"].filter(
|
|
20539
20539
|
(key) => bound3[key] !== void 0 && r[key] === void 0
|
|
20540
20540
|
);
|
|
20541
20541
|
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` : "";
|
|
20542
|
-
return failed2("EPERM", requestedText(
|
|
20542
|
+
return failed2("EPERM", requestedText(word) + hint);
|
|
20543
20543
|
}
|
|
20544
20544
|
const now = await this.rootOnly(r.cwd, args);
|
|
20545
20545
|
const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
|
|
@@ -20574,6 +20574,11 @@ ${SCRIPT_HELP}
|
|
|
20574
20574
|
const { caller, self, target, parsed: parsed3 } = s;
|
|
20575
20575
|
const { cred } = caller;
|
|
20576
20576
|
const [word = "", ...args] = parsed3.command;
|
|
20577
|
+
const notAllowed = () => failed2(
|
|
20578
|
+
"EPERM",
|
|
20579
|
+
`sudo: ${self.name} is not allowed to run ${parsed3.command.map(quoteWord).join(" ")} as ${target.name}`
|
|
20580
|
+
);
|
|
20581
|
+
if (!root && mine.length === 0) return notAllowed();
|
|
20577
20582
|
const cwd = await this.canonical(call.cwd, cred);
|
|
20578
20583
|
if (cwd === void 0 || !await this.reachable(cred, cwd)) {
|
|
20579
20584
|
return failed2(
|
|
@@ -20594,13 +20599,7 @@ ${SCRIPT_HELP}
|
|
|
20594
20599
|
const matching = applicable.filter((rule2) => pinned(rule2, bound3.hashes, bound3));
|
|
20595
20600
|
const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept, asked);
|
|
20596
20601
|
if (root || matching.some((rule2) => rule2.nopasswd)) return grant();
|
|
20597
|
-
|
|
20598
|
-
if (matching.length === 0) {
|
|
20599
|
-
return failed2(
|
|
20600
|
-
"EPERM",
|
|
20601
|
-
`sudo: ${self.name} is not allowed to run ${quoted} as ${target.name}`
|
|
20602
|
-
);
|
|
20603
|
-
}
|
|
20602
|
+
if (matching.length === 0) return notAllowed();
|
|
20604
20603
|
if (!parsed3.reset && this.timestamps.current(s.owner, s.policy, stampOf(bound3))) {
|
|
20605
20604
|
this.timestamps.stamp(s.owner, s.policy, stampOf(bound3));
|
|
20606
20605
|
this.logged(s, cwd, argv);
|
|
@@ -20624,14 +20623,11 @@ ${SCRIPT_HELP}
|
|
|
20624
20623
|
if (await this.canonical(call.cwd, cred) !== cwd || !await this.reachable(cred, cwd)) {
|
|
20625
20624
|
return failed2("EACCES", `sudo: ${call.cwd} changed while the request waited`);
|
|
20626
20625
|
}
|
|
20627
|
-
|
|
20628
|
-
if (moved3 !== void 0) return failed2("EPERM", changedText(moved3));
|
|
20626
|
+
if (await this.moved(bound3)) return failed2("EPERM", changedText(word));
|
|
20629
20627
|
if (answer2.answer === "once" && !answer2.person) return grant();
|
|
20630
20628
|
const now = await this.bound(path, cwd, asked, caller.pid);
|
|
20631
|
-
if (!now)
|
|
20632
|
-
return failed2("EPERM", changedText(
|
|
20633
|
-
const changed2 = changedDecision(bound3.hashes, bound3, now, path);
|
|
20634
|
-
if (changed2 !== void 0) return failed2("EPERM", changedText(changed2));
|
|
20629
|
+
if (!now || changedDecision(bound3.hashes, bound3, now, path) !== void 0)
|
|
20630
|
+
return failed2("EPERM", changedText(word));
|
|
20635
20631
|
const shown2 = recordable(cwd, [...parsed3.command, ...Object.keys(bound3.hashes)]);
|
|
20636
20632
|
const result = answer2.answer === "once" ? grant() : await this.always(
|
|
20637
20633
|
self,
|
|
@@ -29357,8 +29353,8 @@ var WasmProcess = class _WasmProcess {
|
|
|
29357
29353
|
close: () => source.release()
|
|
29358
29354
|
});
|
|
29359
29355
|
}
|
|
29360
|
-
nonblocking(fd,
|
|
29361
|
-
return
|
|
29356
|
+
nonblocking(fd, requested) {
|
|
29357
|
+
return requested === true || !this.options.perCallNonblock && ((this.fds.statusFlags(fd) ?? 0) & O_NONBLOCK2) !== 0;
|
|
29362
29358
|
}
|
|
29363
29359
|
async fdSyscall(req, cancelled) {
|
|
29364
29360
|
if (isVfsSyscall(req)) return this.vfsSyscall(req);
|
|
@@ -30240,7 +30236,8 @@ var WasmProcess = class _WasmProcess {
|
|
|
30240
30236
|
})
|
|
30241
30237
|
};
|
|
30242
30238
|
} catch (err) {
|
|
30243
|
-
if (err instanceof ChangedError)
|
|
30239
|
+
if (err instanceof ChangedError)
|
|
30240
|
+
return { error: changedText(argv[0] ?? asked), errno: err.code };
|
|
30244
30241
|
throw err;
|
|
30245
30242
|
}
|
|
30246
30243
|
}
|
|
@@ -33209,6 +33206,123 @@ function noticeOf(data) {
|
|
|
33209
33206
|
return { paths: strings3(notice.paths), trees: strings3(notice.trees), outside: true };
|
|
33210
33207
|
}
|
|
33211
33208
|
|
|
33209
|
+
// src/fs/private-rename.ts
|
|
33210
|
+
var DRAIN_MS = 500;
|
|
33211
|
+
var ADMISSION_MS = 5e3;
|
|
33212
|
+
var within10 = (at, root) => at === root || root === "/" || at.startsWith(root + "/");
|
|
33213
|
+
var PrivatePaths = class {
|
|
33214
|
+
names;
|
|
33215
|
+
bound = false;
|
|
33216
|
+
shifted = false;
|
|
33217
|
+
listing;
|
|
33218
|
+
removing;
|
|
33219
|
+
constructor(paths, listing, removing) {
|
|
33220
|
+
this.listing = listing;
|
|
33221
|
+
this.removing = removing;
|
|
33222
|
+
this.names = new Set(paths.map(normalizePath));
|
|
33223
|
+
}
|
|
33224
|
+
touches(roots, names2 = this.names) {
|
|
33225
|
+
for (const at of names2)
|
|
33226
|
+
for (const root of roots) {
|
|
33227
|
+
if (within10(at, root) || this.removing && within10(root, at)) return true;
|
|
33228
|
+
if (this.listing && at === (root.slice(0, root.lastIndexOf("/")) || "/")) return true;
|
|
33229
|
+
}
|
|
33230
|
+
return false;
|
|
33231
|
+
}
|
|
33232
|
+
bind(path) {
|
|
33233
|
+
if (this.shifted) return;
|
|
33234
|
+
this.names.clear();
|
|
33235
|
+
this.names.add(path);
|
|
33236
|
+
this.bound = true;
|
|
33237
|
+
}
|
|
33238
|
+
moved(from, to) {
|
|
33239
|
+
const names2 = this.redirected(from, to);
|
|
33240
|
+
if (!names2.size) return;
|
|
33241
|
+
this.shifted = true;
|
|
33242
|
+
if (this.bound) this.names.clear();
|
|
33243
|
+
for (const name2 of names2) this.names.add(name2);
|
|
33244
|
+
}
|
|
33245
|
+
redirected(from, to) {
|
|
33246
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
33247
|
+
for (const path of this.names)
|
|
33248
|
+
if (within10(path, from)) {
|
|
33249
|
+
const next3 = resolvePath(to, path.slice(from.length).replace(/^\//, ""));
|
|
33250
|
+
if (!this.names.has(next3)) names2.add(next3);
|
|
33251
|
+
}
|
|
33252
|
+
return names2;
|
|
33253
|
+
}
|
|
33254
|
+
};
|
|
33255
|
+
var PrivateRename = class {
|
|
33256
|
+
active = /* @__PURE__ */ new Set();
|
|
33257
|
+
barriers = /* @__PURE__ */ new Map();
|
|
33258
|
+
waiters = /* @__PURE__ */ new Set();
|
|
33259
|
+
wait(take, ms) {
|
|
33260
|
+
if (take()) return Promise.resolve();
|
|
33261
|
+
return new Promise((resolve2, reject) => {
|
|
33262
|
+
const wake = () => {
|
|
33263
|
+
if (!take()) return;
|
|
33264
|
+
this.waiters.delete(wake);
|
|
33265
|
+
clearTimeout(timer);
|
|
33266
|
+
resolve2();
|
|
33267
|
+
};
|
|
33268
|
+
const timer = setTimeout(() => {
|
|
33269
|
+
this.waiters.delete(wake);
|
|
33270
|
+
reject(fsError("EBUSY", "private rename"));
|
|
33271
|
+
}, ms);
|
|
33272
|
+
this.waiters.add(wake);
|
|
33273
|
+
});
|
|
33274
|
+
}
|
|
33275
|
+
wake() {
|
|
33276
|
+
for (const waiter of this.waiters) waiter();
|
|
33277
|
+
}
|
|
33278
|
+
blocked(op, names2 = op.names) {
|
|
33279
|
+
for (const [barrier, draining] of this.barriers) {
|
|
33280
|
+
if (!draining.has(op) && op.touches(barrier.names, names2)) return true;
|
|
33281
|
+
}
|
|
33282
|
+
return false;
|
|
33283
|
+
}
|
|
33284
|
+
enter(op) {
|
|
33285
|
+
return this.wait(() => {
|
|
33286
|
+
if (this.blocked(op)) return false;
|
|
33287
|
+
this.active.add(op);
|
|
33288
|
+
return true;
|
|
33289
|
+
}, ADMISSION_MS);
|
|
33290
|
+
}
|
|
33291
|
+
leave(op) {
|
|
33292
|
+
this.active.delete(op);
|
|
33293
|
+
for (const draining of this.barriers.values()) draining.delete(op);
|
|
33294
|
+
this.wake();
|
|
33295
|
+
}
|
|
33296
|
+
redirect(op, from, to) {
|
|
33297
|
+
const names2 = op.redirected(from, to);
|
|
33298
|
+
if (this.barriers.has(op) && names2.size) throw fsError("EBUSY", from);
|
|
33299
|
+
return this.wait(() => {
|
|
33300
|
+
if (this.blocked(op, names2)) return false;
|
|
33301
|
+
for (const name2 of names2) op.names.add(name2);
|
|
33302
|
+
return true;
|
|
33303
|
+
}, ADMISSION_MS);
|
|
33304
|
+
}
|
|
33305
|
+
moved(from, to) {
|
|
33306
|
+
for (const op of this.active) op.moved(from, to);
|
|
33307
|
+
}
|
|
33308
|
+
async exclusive(op, run2) {
|
|
33309
|
+
const draining = /* @__PURE__ */ new Set();
|
|
33310
|
+
await this.wait(() => {
|
|
33311
|
+
if (this.blocked(op)) return false;
|
|
33312
|
+
for (const active of this.active) if (active.touches(op.names)) draining.add(active);
|
|
33313
|
+
this.barriers.set(op, draining);
|
|
33314
|
+
return true;
|
|
33315
|
+
}, ADMISSION_MS);
|
|
33316
|
+
try {
|
|
33317
|
+
await this.wait(() => ![...draining].some((active) => this.active.has(active)), DRAIN_MS);
|
|
33318
|
+
return await run2();
|
|
33319
|
+
} finally {
|
|
33320
|
+
this.barriers.delete(op);
|
|
33321
|
+
this.wake();
|
|
33322
|
+
}
|
|
33323
|
+
}
|
|
33324
|
+
};
|
|
33325
|
+
|
|
33212
33326
|
// src/fs/opfs.ts
|
|
33213
33327
|
var S_IFDIR2 = 16384;
|
|
33214
33328
|
var S_IFREG3 = 32768;
|
|
@@ -33249,8 +33363,12 @@ var PAIRED = /* @__PURE__ */ new Set(["rename", "link", "copyFile"]);
|
|
|
33249
33363
|
var LISTINGS = /* @__PURE__ */ new Set(["readdir", "readdirStat"]);
|
|
33250
33364
|
var REMOVALS2 = /* @__PURE__ */ new Set(["rm", "rename"]);
|
|
33251
33365
|
var RETRY = /* @__PURE__ */ Symbol("retry");
|
|
33366
|
+
var PRIVATE_COPY = /* @__PURE__ */ Symbol("private-copy");
|
|
33252
33367
|
var ACK_SAMPLES = 4096;
|
|
33253
33368
|
var INTENT_POLL_MS = 5;
|
|
33369
|
+
function needsCopy(handle, swap) {
|
|
33370
|
+
return swap || handle.kind === "directory" && !movable(handle);
|
|
33371
|
+
}
|
|
33254
33372
|
function movable(handle) {
|
|
33255
33373
|
return typeof handle.move === "function";
|
|
33256
33374
|
}
|
|
@@ -33333,7 +33451,7 @@ function prefixes(path) {
|
|
|
33333
33451
|
const parts2 = split2(path);
|
|
33334
33452
|
return parts2.map((_, i) => `/${parts2.slice(0, i + 1).join("/")}`);
|
|
33335
33453
|
}
|
|
33336
|
-
function
|
|
33454
|
+
function within11(path, root) {
|
|
33337
33455
|
return path === root || path.startsWith(`${root}/`);
|
|
33338
33456
|
}
|
|
33339
33457
|
var unstored = () => Object.assign(new Error("the file system kept fewer bytes than were written"), {
|
|
@@ -33445,6 +33563,10 @@ function isHandle(child2) {
|
|
|
33445
33563
|
var FILE_TIMES_MS = 100;
|
|
33446
33564
|
var OpfsFs = class {
|
|
33447
33565
|
root;
|
|
33566
|
+
privateRename;
|
|
33567
|
+
insidePrivateOp = false;
|
|
33568
|
+
privateRedirect;
|
|
33569
|
+
privateSession;
|
|
33448
33570
|
meta;
|
|
33449
33571
|
dirs = new PathMap();
|
|
33450
33572
|
files = new PathMap();
|
|
@@ -33469,6 +33591,7 @@ var OpfsFs = class {
|
|
|
33469
33591
|
renamePrefix;
|
|
33470
33592
|
constructor(root, meta = new MemoryMeta(), channel, options = {}) {
|
|
33471
33593
|
this.root = root;
|
|
33594
|
+
this.privateRename = channel === void 0 ? new PrivateRename() : void 0;
|
|
33472
33595
|
this.meta = sidecar(meta);
|
|
33473
33596
|
this.ranged = options.ranged === true;
|
|
33474
33597
|
this.locks = options.locks === void 0 ? lockManager() : options.locks ?? void 0;
|
|
@@ -34048,6 +34171,7 @@ var OpfsFs = class {
|
|
|
34048
34171
|
if (this.rejectLinks) throw fsError("ELOOP", path);
|
|
34049
34172
|
const stored = link2.link;
|
|
34050
34173
|
if (overPath(stored)) throw fsError("ENAMETOOLONG", link2.path);
|
|
34174
|
+
const previous = current;
|
|
34051
34175
|
const target = stored + current.slice(link2.path.length);
|
|
34052
34176
|
if (target.split("/").includes("..") || longParent(stored) !== void 0) {
|
|
34053
34177
|
const resolved2 = await this.physical(parentOf11(link2.path), target, hops + 1, path);
|
|
@@ -34057,6 +34181,7 @@ var OpfsFs = class {
|
|
|
34057
34181
|
current = resolvePath(parentOf11(link2.path), target);
|
|
34058
34182
|
}
|
|
34059
34183
|
this.crossing(path, current);
|
|
34184
|
+
await this.privateRedirect?.(previous, current);
|
|
34060
34185
|
}
|
|
34061
34186
|
}
|
|
34062
34187
|
throw fsError("ELOOP", path);
|
|
@@ -34148,11 +34273,11 @@ var OpfsFs = class {
|
|
|
34148
34273
|
movePending(from, to) {
|
|
34149
34274
|
if (to !== void 0) {
|
|
34150
34275
|
for (const path of [...this.fileTimes.keys()]) {
|
|
34151
|
-
if (
|
|
34276
|
+
if (within11(path, to)) this.fileTimes.delete(path);
|
|
34152
34277
|
}
|
|
34153
34278
|
}
|
|
34154
34279
|
for (const [path, ms] of [...this.fileTimes]) {
|
|
34155
|
-
if (!
|
|
34280
|
+
if (!within11(path, from)) continue;
|
|
34156
34281
|
this.fileTimes.delete(path);
|
|
34157
34282
|
if (to !== void 0) this.fileTimes.set(to + path.slice(from.length), ms);
|
|
34158
34283
|
}
|
|
@@ -34432,8 +34557,8 @@ var OpfsFs = class {
|
|
|
34432
34557
|
const file = this.movingFiles.get(at);
|
|
34433
34558
|
if (file !== void 0) return { done: file, away: true };
|
|
34434
34559
|
for (const m of this.renamingDirs) {
|
|
34435
|
-
if (
|
|
34436
|
-
if (
|
|
34560
|
+
if (within11(at, m.from)) return { done: m.done, away: true };
|
|
34561
|
+
if (within11(at, m.to)) return { done: m.done, away: false };
|
|
34437
34562
|
}
|
|
34438
34563
|
return void 0;
|
|
34439
34564
|
}
|
|
@@ -34469,7 +34594,7 @@ var OpfsFs = class {
|
|
|
34469
34594
|
idle2.resolve();
|
|
34470
34595
|
}
|
|
34471
34596
|
async writesDrained(tree2) {
|
|
34472
|
-
while ([...this.fileWrites.keys()].some((at) =>
|
|
34597
|
+
while ([...this.fileWrites.keys()].some((at) => within11(at, tree2))) {
|
|
34473
34598
|
this.writesIdle ??= Promise.withResolvers();
|
|
34474
34599
|
await this.writesIdle.promise;
|
|
34475
34600
|
}
|
|
@@ -34546,6 +34671,7 @@ var OpfsFs = class {
|
|
|
34546
34671
|
}
|
|
34547
34672
|
async writeSession(path, truncate) {
|
|
34548
34673
|
const [handle, , target] = await this.fileFor(path);
|
|
34674
|
+
this.privateSession?.bind(target);
|
|
34549
34675
|
const writable3 = await this.retrying(
|
|
34550
34676
|
path,
|
|
34551
34677
|
() => this.io(handle.createWritable({ keepExistingData: !truncate })),
|
|
@@ -34928,15 +35054,14 @@ var OpfsFs = class {
|
|
|
34928
35054
|
if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", to);
|
|
34929
35055
|
const destination = resolvePath(parent.path, baseOf4(to));
|
|
34930
35056
|
this.refuse(destination, true);
|
|
34931
|
-
if (directory2)
|
|
34932
|
-
|
|
34933
|
-
if (source.path === destination) return;
|
|
34934
|
-
}
|
|
35057
|
+
if (directory2 && source.handle?.kind !== "directory") throw fsError("ENOTDIR", from);
|
|
35058
|
+
if (source.path === destination) return;
|
|
34935
35059
|
await this.entering(destination, () => this.moveTo(source, parent, destination, to, call));
|
|
35060
|
+
this.privateRename?.moved(source.path, destination);
|
|
34936
35061
|
}
|
|
34937
35062
|
async moveTo(source, parent, destination, to, call) {
|
|
34938
35063
|
const sourceStat = await this.describe(source);
|
|
34939
|
-
if (sourceStat.isDirectory &&
|
|
35064
|
+
if (sourceStat.isDirectory && within11(destination, source.path)) throw fsError("EINVAL", to);
|
|
34940
35065
|
const target = await this.exactly(() => this.locate(destination, false)).catch((err) => {
|
|
34941
35066
|
if (missing5(err)) return null;
|
|
34942
35067
|
throw err;
|
|
@@ -34972,8 +35097,10 @@ var OpfsFs = class {
|
|
|
34972
35097
|
let lock;
|
|
34973
35098
|
const hooks = {};
|
|
34974
35099
|
const staging = swap ? `.${name2}.${crypto.randomUUID()}` : name2;
|
|
34975
|
-
const copying =
|
|
35100
|
+
const copying = needsCopy(source.handle, swap);
|
|
34976
35101
|
const staged2 = resolvePath(parent.path, staging);
|
|
35102
|
+
if (this.usePrivateCopy(source.handle, copying))
|
|
35103
|
+
return this.privateCopy(source, parent, destination, target?.handle, moving);
|
|
34977
35104
|
const place = async () => {
|
|
34978
35105
|
this.forget(destination);
|
|
34979
35106
|
const copies = /* @__PURE__ */ new Map();
|
|
@@ -35208,7 +35335,7 @@ var OpfsFs = class {
|
|
|
35208
35335
|
for (const move of this.peerMoves.values()) {
|
|
35209
35336
|
for (const tree2 of move.trees) {
|
|
35210
35337
|
for (const mine of [from, to]) {
|
|
35211
|
-
if (tree2.some((theirs) =>
|
|
35338
|
+
if (tree2.some((theirs) => within11(mine, theirs) || within11(theirs, mine))) return move;
|
|
35212
35339
|
}
|
|
35213
35340
|
}
|
|
35214
35341
|
}
|
|
@@ -35300,6 +35427,95 @@ var OpfsFs = class {
|
|
|
35300
35427
|
});
|
|
35301
35428
|
return { ...session, close: () => session.close().finally(done4) };
|
|
35302
35429
|
}
|
|
35430
|
+
async privateOp(name2, args, inner) {
|
|
35431
|
+
const gate = this.privateRename;
|
|
35432
|
+
if (!gate || this.insidePrivateOp) return inner.apply(this, args);
|
|
35433
|
+
const paths = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
|
|
35434
|
+
const op = new PrivatePaths(paths, LISTINGS.has(name2), REMOVALS2.has(name2));
|
|
35435
|
+
const inside2 = view(this, {
|
|
35436
|
+
insidePrivateOp: true,
|
|
35437
|
+
privateSession: name2 === "writeSession" ? op : void 0,
|
|
35438
|
+
privateRedirect: (from, to) => gate.redirect(op, from, to)
|
|
35439
|
+
});
|
|
35440
|
+
await gate.enter(op);
|
|
35441
|
+
const leave = () => gate.leave(op);
|
|
35442
|
+
let sessionOwnsAdmission = false;
|
|
35443
|
+
try {
|
|
35444
|
+
if (name2 === "writeSession") {
|
|
35445
|
+
const session = await inner.apply(inside2, args);
|
|
35446
|
+
sessionOwnsAdmission = true;
|
|
35447
|
+
let closed;
|
|
35448
|
+
return { ...session, close: () => closed ??= session.close().finally(leave) };
|
|
35449
|
+
}
|
|
35450
|
+
if (name2 !== "rename") return await inner.apply(inside2, args);
|
|
35451
|
+
try {
|
|
35452
|
+
return await inner.apply(inside2, args);
|
|
35453
|
+
} catch (err) {
|
|
35454
|
+
if (err !== PRIVATE_COPY) throw err;
|
|
35455
|
+
}
|
|
35456
|
+
} finally {
|
|
35457
|
+
if (!sessionOwnsAdmission) leave();
|
|
35458
|
+
}
|
|
35459
|
+
const exclusive = view(inside2, { privateCopyReady: true });
|
|
35460
|
+
return gate.exclusive(op, () => inner.apply(exclusive, args));
|
|
35461
|
+
}
|
|
35462
|
+
privateCopyReady = false;
|
|
35463
|
+
usePrivateCopy(handle, staging) {
|
|
35464
|
+
if (!this.privateRename) return false;
|
|
35465
|
+
if (this.privateCopyReady) return true;
|
|
35466
|
+
if (staging || !movable(handle)) throw PRIVATE_COPY;
|
|
35467
|
+
return false;
|
|
35468
|
+
}
|
|
35469
|
+
async privateCopy(source, parent, to, target, owner) {
|
|
35470
|
+
const handle = source.handle;
|
|
35471
|
+
const dir = parent.handle;
|
|
35472
|
+
const name2 = baseOf4(to);
|
|
35473
|
+
const copies = /* @__PURE__ */ new Map();
|
|
35474
|
+
const [entry] = await this.meta.get([source.path]);
|
|
35475
|
+
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
35476
|
+
const intent = await this.intend({ from: source.path, to, root, privateCopy: true });
|
|
35477
|
+
try {
|
|
35478
|
+
await this.duplicate(handle, dir, name2, copies, "");
|
|
35479
|
+
} catch (err) {
|
|
35480
|
+
if (!target)
|
|
35481
|
+
await dir.removeEntry(name2, { recursive: true }).catch((e) => {
|
|
35482
|
+
if (e.name !== "NotFoundError") throw e;
|
|
35483
|
+
});
|
|
35484
|
+
else if (target.kind === "directory") {
|
|
35485
|
+
for await (const child2 of target.keys())
|
|
35486
|
+
await target.removeEntry(child2, { recursive: true });
|
|
35487
|
+
}
|
|
35488
|
+
this.forget(to);
|
|
35489
|
+
await this.meta.update(intent, () => void 0);
|
|
35490
|
+
throw translate(err, to, "write");
|
|
35491
|
+
}
|
|
35492
|
+
await this.commitPrivateCopy(source.path, to, root, intent, copies);
|
|
35493
|
+
}
|
|
35494
|
+
async commitPrivateCopy(from, to, root, intent, copies) {
|
|
35495
|
+
const { ino, ...owner } = root;
|
|
35496
|
+
const entries = await this.meta.get([from, to]);
|
|
35497
|
+
if (!entries[0]?.vacated || entries[1]?.ino !== ino) {
|
|
35498
|
+
await this.meta.move(
|
|
35499
|
+
from,
|
|
35500
|
+
to,
|
|
35501
|
+
(entry) => ({ ...occupied(entry), ...owner, ino, path: to, ctimeMs: Date.now() }),
|
|
35502
|
+
vacatedAt(from)
|
|
35503
|
+
);
|
|
35504
|
+
}
|
|
35505
|
+
this.movePending(from, to);
|
|
35506
|
+
await this.removePhysical(from, true);
|
|
35507
|
+
await this.meta.update(intent, () => void 0);
|
|
35508
|
+
await this.restamp(to, copies);
|
|
35509
|
+
this.changed(from, to);
|
|
35510
|
+
this.touch(Date.now(), parentOf11(from), parentOf11(to));
|
|
35511
|
+
}
|
|
35512
|
+
async duplicate(handle, parent, name2, copies, rest2) {
|
|
35513
|
+
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
35514
|
+
const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
|
|
35515
|
+
this.others++;
|
|
35516
|
+
for await (const child2 of handle.values())
|
|
35517
|
+
await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
|
|
35518
|
+
}
|
|
35303
35519
|
renamingDirs = /* @__PURE__ */ new Set();
|
|
35304
35520
|
intents = 0;
|
|
35305
35521
|
async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
|
|
@@ -35362,6 +35578,28 @@ var OpfsFs = class {
|
|
|
35362
35578
|
this.forget(to);
|
|
35363
35579
|
try {
|
|
35364
35580
|
const left = await this.real(from);
|
|
35581
|
+
if (current.rename.privateCopy) {
|
|
35582
|
+
if (left) {
|
|
35583
|
+
const src = await this.locate(from, false);
|
|
35584
|
+
const dir = await this.locate(parentOf11(to), true);
|
|
35585
|
+
const copies = /* @__PURE__ */ new Map();
|
|
35586
|
+
await this.duplicate(
|
|
35587
|
+
src.handle,
|
|
35588
|
+
dir.handle,
|
|
35589
|
+
baseOf4(to),
|
|
35590
|
+
copies,
|
|
35591
|
+
""
|
|
35592
|
+
);
|
|
35593
|
+
await this.commitPrivateCopy(
|
|
35594
|
+
from,
|
|
35595
|
+
to,
|
|
35596
|
+
root ?? { ino: inodeOf(from) },
|
|
35597
|
+
entry.path,
|
|
35598
|
+
copies
|
|
35599
|
+
);
|
|
35600
|
+
} else await this.meta.update(entry.path, () => void 0);
|
|
35601
|
+
return;
|
|
35602
|
+
}
|
|
35365
35603
|
if (left && replace && await this.real(to))
|
|
35366
35604
|
await PLAIN3.rm.call(this, to, { recursive: true });
|
|
35367
35605
|
if (left) {
|
|
@@ -35477,7 +35715,7 @@ var OpfsFs = class {
|
|
|
35477
35715
|
}
|
|
35478
35716
|
renameAt(at) {
|
|
35479
35717
|
for (const m of this.renamingDirs) {
|
|
35480
|
-
if (
|
|
35718
|
+
if (within11(at, m.from) || within11(at, m.to) || at === parentOf11(m.from) || at === parentOf11(m.to))
|
|
35481
35719
|
return m;
|
|
35482
35720
|
}
|
|
35483
35721
|
return void 0;
|
|
@@ -35513,7 +35751,10 @@ var OpfsFs = class {
|
|
|
35513
35751
|
}
|
|
35514
35752
|
async place(handle, dir, name2, copies, admitted) {
|
|
35515
35753
|
if (await this.moved(handle, dir, name2, admitted)) return true;
|
|
35516
|
-
if (!admitted)
|
|
35754
|
+
if (!admitted) {
|
|
35755
|
+
if (this.privateRename) throw PRIVATE_COPY;
|
|
35756
|
+
throw fsError("EBUSY", name2);
|
|
35757
|
+
}
|
|
35517
35758
|
const before = this.fileMoves;
|
|
35518
35759
|
try {
|
|
35519
35760
|
await this.copy(handle, dir, name2, { copies });
|
|
@@ -35561,21 +35802,7 @@ var OpfsFs = class {
|
|
|
35561
35802
|
if (handle.kind === "file") {
|
|
35562
35803
|
if (options.restoring && await this.handleExists(dir, name2)) return;
|
|
35563
35804
|
if (await this.moveChild(handle, dir, name2)) return;
|
|
35564
|
-
|
|
35565
|
-
const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
|
|
35566
|
-
const writable3 = await this.io(made2.createWritable());
|
|
35567
|
-
try {
|
|
35568
|
-
await writable3.write(file);
|
|
35569
|
-
await writable3.close();
|
|
35570
|
-
} catch (err) {
|
|
35571
|
-
await writable3.abort().catch(nothing2);
|
|
35572
|
-
throw err;
|
|
35573
|
-
}
|
|
35574
|
-
options.copies?.set(rest2, {
|
|
35575
|
-
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
35576
|
-
made: made2
|
|
35577
|
-
});
|
|
35578
|
-
return;
|
|
35805
|
+
return this.copyBytes(handle, dir, name2, options, rest2);
|
|
35579
35806
|
}
|
|
35580
35807
|
const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
|
|
35581
35808
|
this.others++;
|
|
@@ -35583,6 +35810,22 @@ var OpfsFs = class {
|
|
|
35583
35810
|
await this.copy(child2, target, child2.name, options, `${rest2}/${child2.name}`);
|
|
35584
35811
|
}
|
|
35585
35812
|
}
|
|
35813
|
+
async copyBytes(handle, dir, name2, options, rest2) {
|
|
35814
|
+
const file = await this.io(handle.getFile());
|
|
35815
|
+
const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
|
|
35816
|
+
const writable3 = await this.io(made2.createWritable());
|
|
35817
|
+
try {
|
|
35818
|
+
await writable3.write(file);
|
|
35819
|
+
await writable3.close();
|
|
35820
|
+
} catch (err) {
|
|
35821
|
+
await writable3.abort().catch(nothing2);
|
|
35822
|
+
throw err;
|
|
35823
|
+
}
|
|
35824
|
+
options.copies?.set(rest2, {
|
|
35825
|
+
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
35826
|
+
made: made2
|
|
35827
|
+
});
|
|
35828
|
+
}
|
|
35586
35829
|
async symlink(target, path, owner) {
|
|
35587
35830
|
if (overPath(target)) throw fsError("ENAMETOOLONG", path);
|
|
35588
35831
|
const parent = await this.exactly(() => this.locate(parentOf11(path), true));
|
|
@@ -35750,7 +35993,7 @@ function nothing2() {
|
|
|
35750
35993
|
}
|
|
35751
35994
|
function touches2(at, trees, listing = true, removing = false) {
|
|
35752
35995
|
return trees.some(
|
|
35753
|
-
([from, to]) =>
|
|
35996
|
+
([from, to]) => within11(at, from) || within11(at, to) || listing && (at === parentOf11(from) || at === parentOf11(to)) || removing && (at === "/" || within11(from, at) || within11(to, at))
|
|
35754
35997
|
);
|
|
35755
35998
|
}
|
|
35756
35999
|
function byIntent(a, b) {
|
|
@@ -35795,6 +36038,7 @@ var WRITES = [
|
|
|
35795
36038
|
const proto = OpfsFs.prototype;
|
|
35796
36039
|
const inner = proto.createExclusive;
|
|
35797
36040
|
proto.createExclusive = function(...args) {
|
|
36041
|
+
if (this.privateRename) return this.privateOp("createExclusive", args, inner);
|
|
35798
36042
|
if (this.amongPeers()) return this.peerOp("createExclusive", args, inner);
|
|
35799
36043
|
return this.alonePlain(inner, args);
|
|
35800
36044
|
};
|
|
@@ -35808,6 +36052,7 @@ for (const [names2, op] of [
|
|
|
35808
36052
|
const inner = proto[name2];
|
|
35809
36053
|
proto[name2] = async function(...args) {
|
|
35810
36054
|
try {
|
|
36055
|
+
if (this.privateRename) return await this.privateOp(name2, args, inner);
|
|
35811
36056
|
if (op === "read") await this.settledRename(args[0]);
|
|
35812
36057
|
if (this.amongPeers() || name2 === "writeSession")
|
|
35813
36058
|
return await this.peerOp(name2, args, inner);
|
|
@@ -37676,8 +37921,7 @@ function describe(req, tty) {
|
|
|
37676
37921
|
return { argv: [req.argv0, ...req.args], tty, started: Date.now(), ...exe };
|
|
37677
37922
|
}
|
|
37678
37923
|
function refuseChanged(approved, now) {
|
|
37679
|
-
|
|
37680
|
-
if (changed2 !== void 0) throw new ChangedError(changedText(changed2), changed2);
|
|
37924
|
+
if (changedFile(approved, now) !== void 0) throw new ChangedError();
|
|
37681
37925
|
}
|
|
37682
37926
|
var O_WRONLY2 = 1;
|
|
37683
37927
|
var OUTPUT_MODE = 384;
|
|
@@ -37696,10 +37940,14 @@ function sudoCause(err) {
|
|
|
37696
37940
|
if (typeof code !== "string") throw err;
|
|
37697
37941
|
return code;
|
|
37698
37942
|
}
|
|
37699
|
-
|
|
37700
|
-
|
|
37701
|
-
|
|
37702
|
-
|
|
37943
|
+
var LOST_ROUTE = /* @__PURE__ */ new Set([
|
|
37944
|
+
"ENOENT",
|
|
37945
|
+
"ENOTDIR",
|
|
37946
|
+
"EACCES",
|
|
37947
|
+
"ELOOP",
|
|
37948
|
+
"ESTALE",
|
|
37949
|
+
"ENAMETOOLONG"
|
|
37950
|
+
]);
|
|
37703
37951
|
var MAX_SPAWN_TAGS = 8;
|
|
37704
37952
|
function tagList(value2) {
|
|
37705
37953
|
if (!Array.isArray(value2)) {
|
|
@@ -38999,16 +39247,20 @@ var Launcher = class {
|
|
|
38999
39247
|
const refused5 = (err) => {
|
|
39000
39248
|
throw codeOf9(err) === "EACCES" ? new SpawnError("EACCES") : err;
|
|
39001
39249
|
};
|
|
39250
|
+
const lost = (err) => {
|
|
39251
|
+
if (LOST_ROUTE.has(codeOf9(err))) throw new ChangedError();
|
|
39252
|
+
throw err;
|
|
39253
|
+
};
|
|
39002
39254
|
const { file, parentHops } = await this.execFile(
|
|
39003
39255
|
req.file,
|
|
39004
39256
|
req.cwd,
|
|
39005
39257
|
this.execGuard(cred, ppid),
|
|
39006
39258
|
ppid
|
|
39007
|
-
).catch(refused5);
|
|
39259
|
+
).catch(grant?.files ? lost : refused5);
|
|
39008
39260
|
const reads = prepared ?? (grant?.files && await this.scriptReads(grant.files, cred, ppid));
|
|
39009
39261
|
if (grant?.asked && reads) {
|
|
39010
|
-
const destination = await this.sudoer.
|
|
39011
|
-
if (destination !== file) throw new ChangedError(
|
|
39262
|
+
const destination = await this.sudoer.executablePath(this.sudoFs(reads), cred, grant.asked).catch(lost);
|
|
39263
|
+
if (destination !== file) throw new ChangedError();
|
|
39012
39264
|
}
|
|
39013
39265
|
const plan = await this.plan(file, req.argv, req.cwd, scope, {
|
|
39014
39266
|
argv0: req.argv0,
|
|
@@ -39027,10 +39279,7 @@ var Launcher = class {
|
|
|
39027
39279
|
async checkFailedPlan(file, req, scope, grant) {
|
|
39028
39280
|
const reads = this.sudoer.reads();
|
|
39029
39281
|
const { planned } = await this.plan(file, req.argv, req.cwd, scope, { reads });
|
|
39030
|
-
if (!planned)
|
|
39031
|
-
const gone = await this.sudoer.missingBacking(grant.files.hashes) ?? file;
|
|
39032
|
-
throw new ChangedError(changedText(gone), gone);
|
|
39033
|
-
}
|
|
39282
|
+
if (!planned) throw new ChangedError();
|
|
39034
39283
|
await this.unchanged({ ...planned, reads }, file, req.cwd, grant);
|
|
39035
39284
|
}
|
|
39036
39285
|
async enterable(g, cwd) {
|
|
@@ -39184,26 +39433,26 @@ var Launcher = class {
|
|
|
39184
39433
|
const now = await planned.reads.bind([file, grant.asked ?? file, ...files]);
|
|
39185
39434
|
refuseChanged(approved.hashes, now.hashes);
|
|
39186
39435
|
refuseChanged(approved.routes, now.routes);
|
|
39187
|
-
if (now.chainSha256 !== approved.chainSha256) throw new ChangedError(
|
|
39436
|
+
if (now.chainSha256 !== approved.chainSha256) throw new ChangedError();
|
|
39188
39437
|
return { pinned: approved };
|
|
39189
39438
|
}
|
|
39190
39439
|
approvedChain(planned, file, cwd, grant) {
|
|
39191
39440
|
if (!grant) return void 0;
|
|
39192
39441
|
return async (next3) => {
|
|
39193
39442
|
const chain2 = (p) => [...p.via ?? [], ...p.binfmts ?? []];
|
|
39194
|
-
if (!sameList(chain2(next3), chain2(planned))) throw new ChangedError(
|
|
39443
|
+
if (!sameList(chain2(next3), chain2(planned))) throw new ChangedError();
|
|
39195
39444
|
await this.unchanged(next3, file, cwd, grant);
|
|
39196
39445
|
};
|
|
39197
39446
|
}
|
|
39198
39447
|
async scriptReads(files, cred, pid) {
|
|
39199
|
-
await this.checkRoutes(files
|
|
39448
|
+
await this.checkRoutes(files);
|
|
39200
39449
|
const snapshots = /* @__PURE__ */ new Map();
|
|
39201
39450
|
const reads = this.sudoer.reads(snapshots);
|
|
39202
39451
|
const guard2 = { fs: this.sudoFs(reads), dac: this.dac, cred, pid, links: cred.euid };
|
|
39203
39452
|
for (const path of files.scripts ?? []) {
|
|
39204
39453
|
const real2 = files.routes[path];
|
|
39205
39454
|
const walked2 = await need(guard2, "open", path, R_OK, { directory: false });
|
|
39206
|
-
if (walked2.missing || walked2.path !== real2) throw new ChangedError(
|
|
39455
|
+
if (walked2.missing || walked2.path !== real2) throw new ChangedError();
|
|
39207
39456
|
if (!snapshots.has(real2))
|
|
39208
39457
|
snapshots.set(real2, new Uint8Array(await this.noLinksFs.readFileBuffer(real2)));
|
|
39209
39458
|
}
|
|
@@ -39216,14 +39465,13 @@ var Launcher = class {
|
|
|
39216
39465
|
const real2 = files.routes[path];
|
|
39217
39466
|
if (real2 === void 0) continue;
|
|
39218
39467
|
const bytes = reads.snapshots.get(real2);
|
|
39219
|
-
if (!bytes) throw new ChangedError(
|
|
39468
|
+
if (!bytes) throw new ChangedError();
|
|
39220
39469
|
args[args.length - fromEnd] = scriptFd(fds, bytes);
|
|
39221
39470
|
}
|
|
39222
39471
|
return { ...planned, args };
|
|
39223
39472
|
}
|
|
39224
|
-
async checkRoutes(files
|
|
39225
|
-
|
|
39226
|
-
if (file !== void 0) throw new ChangedError(changedText(file), file);
|
|
39473
|
+
async checkRoutes(files) {
|
|
39474
|
+
if (await this.sudoer.moved(files)) throw new ChangedError();
|
|
39227
39475
|
}
|
|
39228
39476
|
async pinOf(path, caller) {
|
|
39229
39477
|
const { pinned: pinned2 } = caller;
|
|
@@ -39231,7 +39479,7 @@ var Launcher = class {
|
|
|
39231
39479
|
const real2 = await this.sudoer.real(path);
|
|
39232
39480
|
const approved = pinned2.routes[path];
|
|
39233
39481
|
if (approved !== real2 && (approved !== void 0 || !await this.sudoer.trustedThrough(path)))
|
|
39234
|
-
throw new ChangedError(
|
|
39482
|
+
throw new ChangedError();
|
|
39235
39483
|
const hex5 = pinned2.hashes[real2];
|
|
39236
39484
|
return hex5 === void 0 ? {} : { [real2]: hex5 };
|
|
39237
39485
|
}
|
|
@@ -39673,7 +39921,7 @@ var Launcher = class {
|
|
|
39673
39921
|
const own = env.HOSTNAME;
|
|
39674
39922
|
if (asked.target.abi === "wasi") env.HOSTNAME = this.hostname;
|
|
39675
39923
|
const planned = chosen2(asked, env);
|
|
39676
|
-
if (req.pinned) await this.checkRoutes(req.pinned
|
|
39924
|
+
if (req.pinned) await this.checkRoutes(req.pinned);
|
|
39677
39925
|
const caller = {
|
|
39678
39926
|
pid: req.ppid ?? 0,
|
|
39679
39927
|
uid: req.cred.euid,
|
|
@@ -39691,9 +39939,9 @@ var Launcher = class {
|
|
|
39691
39939
|
}
|
|
39692
39940
|
packageRootIs(path) {
|
|
39693
39941
|
const at = normalizePath(path);
|
|
39694
|
-
const
|
|
39942
|
+
const within13 = `${at}/`;
|
|
39695
39943
|
const roots = [this.modulesDir, ...this.appended];
|
|
39696
|
-
const root = PACKAGE_ROOT.exec(
|
|
39944
|
+
const root = PACKAGE_ROOT.exec(within13)?.[1] ?? packageRootOf(within13, roots);
|
|
39697
39945
|
return root === at;
|
|
39698
39946
|
}
|
|
39699
39947
|
packageRoots(planned) {
|
|
@@ -41484,12 +41732,16 @@ var Launcher = class {
|
|
|
41484
41732
|
this.resetCatalogs();
|
|
41485
41733
|
const req = { file: grant.file, argv: grant.argv, env: grant.env, cwd: grant.cwd };
|
|
41486
41734
|
const ctx = { ppid: 0, cred: grant.cred, scope: "", grant };
|
|
41735
|
+
const word = grant.argv[0] ?? grant.asked;
|
|
41736
|
+
const requested = (err2) => {
|
|
41737
|
+
if (err2 instanceof ChangedError) throw sudoFailure(err2.code, requestedText(word));
|
|
41738
|
+
throw err2;
|
|
41739
|
+
};
|
|
41487
41740
|
const planned = await this.planOne(req, ctx).catch((err2) => {
|
|
41488
41741
|
if (err2 instanceof ChangedError) requested(err2);
|
|
41489
41742
|
const code = sudoCause(err2);
|
|
41490
|
-
|
|
41491
|
-
|
|
41492
|
-
throw sudoFailure(code, `sudo: ${grant.file}: ${ERRNO_TEXT[code] ?? code}`);
|
|
41743
|
+
if (code === "ENOENT") throw sudoFailure(code, `sudo: ${quoteWord(word)}: command not found`);
|
|
41744
|
+
throw sudoFailure(code, `sudo: ${quoteWord(word)}: ${ERRNO_TEXT[code] ?? code}`);
|
|
41493
41745
|
});
|
|
41494
41746
|
const pin = await this.unchanged(planned, grant.file, grant.cwd, grant).catch(requested);
|
|
41495
41747
|
const fds = await this.sudoOutputs(options, caller, this.stackFor(tags, tagged.tagBase));
|
|
@@ -42204,9 +42456,9 @@ async function accountOf(l, user) {
|
|
|
42204
42456
|
if (!found) throw fsError("ENOENT", `no user ${String(user)}`);
|
|
42205
42457
|
return found;
|
|
42206
42458
|
}
|
|
42207
|
-
async function runAs(l, self,
|
|
42208
|
-
if (
|
|
42209
|
-
const target = await accountOf(l,
|
|
42459
|
+
async function runAs(l, self, requested) {
|
|
42460
|
+
if (requested === void 0) return self;
|
|
42461
|
+
const target = await accountOf(l, requested);
|
|
42210
42462
|
if (self.uid !== 0 && target.uid !== self.uid) {
|
|
42211
42463
|
throw fsError("EPERM", `${self.name} may not run as ${target.name}`);
|
|
42212
42464
|
}
|
|
@@ -43953,7 +44205,7 @@ function treeBindings(path) {
|
|
|
43953
44205
|
return [encodeText(path), encodeText(`${path}/`), encodeText(`${path}0`)];
|
|
43954
44206
|
}
|
|
43955
44207
|
var CACHED = 8192;
|
|
43956
|
-
function
|
|
44208
|
+
function within12(path, root) {
|
|
43957
44209
|
return root === "/" || path === root || path.startsWith(`${root}/`);
|
|
43958
44210
|
}
|
|
43959
44211
|
var SqliteMeta = class {
|
|
@@ -44062,7 +44314,7 @@ var SqliteMeta = class {
|
|
|
44062
44314
|
return out;
|
|
44063
44315
|
}
|
|
44064
44316
|
async under(path) {
|
|
44065
|
-
return this.tree(path).filter((entry) =>
|
|
44317
|
+
return this.tree(path).filter((entry) => within12(entry.path, path));
|
|
44066
44318
|
}
|
|
44067
44319
|
async all() {
|
|
44068
44320
|
return this.tree("/");
|