@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/kernel-worker.js
CHANGED
|
@@ -838,6 +838,123 @@ async function chownAs(fs, cred, path, change) {
|
|
|
838
838
|
});
|
|
839
839
|
}
|
|
840
840
|
|
|
841
|
+
// src/fs/private-rename.ts
|
|
842
|
+
var DRAIN_MS = 500;
|
|
843
|
+
var ADMISSION_MS = 5e3;
|
|
844
|
+
var within2 = (at, root) => at === root || root === "/" || at.startsWith(root + "/");
|
|
845
|
+
var PrivatePaths = class {
|
|
846
|
+
names;
|
|
847
|
+
bound = false;
|
|
848
|
+
shifted = false;
|
|
849
|
+
listing;
|
|
850
|
+
removing;
|
|
851
|
+
constructor(paths, listing, removing) {
|
|
852
|
+
this.listing = listing;
|
|
853
|
+
this.removing = removing;
|
|
854
|
+
this.names = new Set(paths.map(normalizePath));
|
|
855
|
+
}
|
|
856
|
+
touches(roots, names2 = this.names) {
|
|
857
|
+
for (const at of names2)
|
|
858
|
+
for (const root of roots) {
|
|
859
|
+
if (within2(at, root) || this.removing && within2(root, at)) return true;
|
|
860
|
+
if (this.listing && at === (root.slice(0, root.lastIndexOf("/")) || "/")) return true;
|
|
861
|
+
}
|
|
862
|
+
return false;
|
|
863
|
+
}
|
|
864
|
+
bind(path) {
|
|
865
|
+
if (this.shifted) return;
|
|
866
|
+
this.names.clear();
|
|
867
|
+
this.names.add(path);
|
|
868
|
+
this.bound = true;
|
|
869
|
+
}
|
|
870
|
+
moved(from, to) {
|
|
871
|
+
const names2 = this.redirected(from, to);
|
|
872
|
+
if (!names2.size) return;
|
|
873
|
+
this.shifted = true;
|
|
874
|
+
if (this.bound) this.names.clear();
|
|
875
|
+
for (const name2 of names2) this.names.add(name2);
|
|
876
|
+
}
|
|
877
|
+
redirected(from, to) {
|
|
878
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
879
|
+
for (const path of this.names)
|
|
880
|
+
if (within2(path, from)) {
|
|
881
|
+
const next3 = resolvePath(to, path.slice(from.length).replace(/^\//, ""));
|
|
882
|
+
if (!this.names.has(next3)) names2.add(next3);
|
|
883
|
+
}
|
|
884
|
+
return names2;
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
var PrivateRename = class {
|
|
888
|
+
active = /* @__PURE__ */ new Set();
|
|
889
|
+
barriers = /* @__PURE__ */ new Map();
|
|
890
|
+
waiters = /* @__PURE__ */ new Set();
|
|
891
|
+
wait(take, ms) {
|
|
892
|
+
if (take()) return Promise.resolve();
|
|
893
|
+
return new Promise((resolve2, reject) => {
|
|
894
|
+
const wake = () => {
|
|
895
|
+
if (!take()) return;
|
|
896
|
+
this.waiters.delete(wake);
|
|
897
|
+
clearTimeout(timer);
|
|
898
|
+
resolve2();
|
|
899
|
+
};
|
|
900
|
+
const timer = setTimeout(() => {
|
|
901
|
+
this.waiters.delete(wake);
|
|
902
|
+
reject(fsError("EBUSY", "private rename"));
|
|
903
|
+
}, ms);
|
|
904
|
+
this.waiters.add(wake);
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
wake() {
|
|
908
|
+
for (const waiter of this.waiters) waiter();
|
|
909
|
+
}
|
|
910
|
+
blocked(op, names2 = op.names) {
|
|
911
|
+
for (const [barrier, draining] of this.barriers) {
|
|
912
|
+
if (!draining.has(op) && op.touches(barrier.names, names2)) return true;
|
|
913
|
+
}
|
|
914
|
+
return false;
|
|
915
|
+
}
|
|
916
|
+
enter(op) {
|
|
917
|
+
return this.wait(() => {
|
|
918
|
+
if (this.blocked(op)) return false;
|
|
919
|
+
this.active.add(op);
|
|
920
|
+
return true;
|
|
921
|
+
}, ADMISSION_MS);
|
|
922
|
+
}
|
|
923
|
+
leave(op) {
|
|
924
|
+
this.active.delete(op);
|
|
925
|
+
for (const draining of this.barriers.values()) draining.delete(op);
|
|
926
|
+
this.wake();
|
|
927
|
+
}
|
|
928
|
+
redirect(op, from, to) {
|
|
929
|
+
const names2 = op.redirected(from, to);
|
|
930
|
+
if (this.barriers.has(op) && names2.size) throw fsError("EBUSY", from);
|
|
931
|
+
return this.wait(() => {
|
|
932
|
+
if (this.blocked(op, names2)) return false;
|
|
933
|
+
for (const name2 of names2) op.names.add(name2);
|
|
934
|
+
return true;
|
|
935
|
+
}, ADMISSION_MS);
|
|
936
|
+
}
|
|
937
|
+
moved(from, to) {
|
|
938
|
+
for (const op of this.active) op.moved(from, to);
|
|
939
|
+
}
|
|
940
|
+
async exclusive(op, run2) {
|
|
941
|
+
const draining = /* @__PURE__ */ new Set();
|
|
942
|
+
await this.wait(() => {
|
|
943
|
+
if (this.blocked(op)) return false;
|
|
944
|
+
for (const active of this.active) if (active.touches(op.names)) draining.add(active);
|
|
945
|
+
this.barriers.set(op, draining);
|
|
946
|
+
return true;
|
|
947
|
+
}, ADMISSION_MS);
|
|
948
|
+
try {
|
|
949
|
+
await this.wait(() => ![...draining].some((active) => this.active.has(active)), DRAIN_MS);
|
|
950
|
+
return await run2();
|
|
951
|
+
} finally {
|
|
952
|
+
this.barriers.delete(op);
|
|
953
|
+
this.wake();
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
|
|
841
958
|
// src/fs/integrity.ts
|
|
842
959
|
var SOURCE_SUFFIXES = [
|
|
843
960
|
".js",
|
|
@@ -1059,14 +1176,14 @@ function protectedPrefixes(paths) {
|
|
|
1059
1176
|
}
|
|
1060
1177
|
return [...new Set(paths.map((p) => normalizePath(p)))];
|
|
1061
1178
|
}
|
|
1062
|
-
function
|
|
1179
|
+
function within3(path, prefix) {
|
|
1063
1180
|
return prefix === "/" || path === prefix || path.startsWith(`${prefix}/`);
|
|
1064
1181
|
}
|
|
1065
1182
|
function isProtected(prefixes2, path) {
|
|
1066
|
-
return prefixes2.some((prefix) =>
|
|
1183
|
+
return prefixes2.some((prefix) => within3(path, prefix));
|
|
1067
1184
|
}
|
|
1068
1185
|
function holdsProtected(prefixes2, path) {
|
|
1069
|
-
return prefixes2.some((prefix) =>
|
|
1186
|
+
return prefixes2.some((prefix) => within3(prefix, path));
|
|
1070
1187
|
}
|
|
1071
1188
|
var MAX_LINKS2 = 40;
|
|
1072
1189
|
function partsOf(path) {
|
|
@@ -1781,8 +1898,12 @@ var PAIRED = /* @__PURE__ */ new Set(["rename", "link", "copyFile"]);
|
|
|
1781
1898
|
var LISTINGS = /* @__PURE__ */ new Set(["readdir", "readdirStat"]);
|
|
1782
1899
|
var REMOVALS = /* @__PURE__ */ new Set(["rm", "rename"]);
|
|
1783
1900
|
var RETRY = /* @__PURE__ */ Symbol("retry");
|
|
1901
|
+
var PRIVATE_COPY = /* @__PURE__ */ Symbol("private-copy");
|
|
1784
1902
|
var ACK_SAMPLES = 4096;
|
|
1785
1903
|
var INTENT_POLL_MS = 5;
|
|
1904
|
+
function needsCopy(handle, swap) {
|
|
1905
|
+
return swap || handle.kind === "directory" && !movable(handle);
|
|
1906
|
+
}
|
|
1786
1907
|
function movable(handle) {
|
|
1787
1908
|
return typeof handle.move === "function";
|
|
1788
1909
|
}
|
|
@@ -1865,7 +1986,7 @@ function prefixes(path) {
|
|
|
1865
1986
|
const parts2 = split(path);
|
|
1866
1987
|
return parts2.map((_, i) => `/${parts2.slice(0, i + 1).join("/")}`);
|
|
1867
1988
|
}
|
|
1868
|
-
function
|
|
1989
|
+
function within4(path, root) {
|
|
1869
1990
|
return path === root || path.startsWith(`${root}/`);
|
|
1870
1991
|
}
|
|
1871
1992
|
var unstored = () => Object.assign(new Error("the file system kept fewer bytes than were written"), {
|
|
@@ -1981,6 +2102,10 @@ function isHandle(child2) {
|
|
|
1981
2102
|
var FILE_TIMES_MS = 100;
|
|
1982
2103
|
var OpfsFs = class {
|
|
1983
2104
|
root;
|
|
2105
|
+
privateRename;
|
|
2106
|
+
insidePrivateOp = false;
|
|
2107
|
+
privateRedirect;
|
|
2108
|
+
privateSession;
|
|
1984
2109
|
meta;
|
|
1985
2110
|
dirs = new PathMap();
|
|
1986
2111
|
files = new PathMap();
|
|
@@ -2005,6 +2130,7 @@ var OpfsFs = class {
|
|
|
2005
2130
|
renamePrefix;
|
|
2006
2131
|
constructor(root, meta = new MemoryMeta(), channel, options = {}) {
|
|
2007
2132
|
this.root = root;
|
|
2133
|
+
this.privateRename = channel === void 0 ? new PrivateRename() : void 0;
|
|
2008
2134
|
this.meta = sidecar(meta);
|
|
2009
2135
|
this.ranged = options.ranged === true;
|
|
2010
2136
|
this.locks = options.locks === void 0 ? lockManager() : options.locks ?? void 0;
|
|
@@ -2584,6 +2710,7 @@ var OpfsFs = class {
|
|
|
2584
2710
|
if (this.rejectLinks) throw fsError("ELOOP", path);
|
|
2585
2711
|
const stored2 = link2.link;
|
|
2586
2712
|
if (overPath(stored2)) throw fsError("ENAMETOOLONG", link2.path);
|
|
2713
|
+
const previous = current;
|
|
2587
2714
|
const target = stored2 + current.slice(link2.path.length);
|
|
2588
2715
|
if (target.split("/").includes("..") || longParent(stored2) !== void 0) {
|
|
2589
2716
|
const resolved2 = await this.physical(parentOf4(link2.path), target, hops + 1, path);
|
|
@@ -2593,6 +2720,7 @@ var OpfsFs = class {
|
|
|
2593
2720
|
current = resolvePath(parentOf4(link2.path), target);
|
|
2594
2721
|
}
|
|
2595
2722
|
this.crossing(path, current);
|
|
2723
|
+
await this.privateRedirect?.(previous, current);
|
|
2596
2724
|
}
|
|
2597
2725
|
}
|
|
2598
2726
|
throw fsError("ELOOP", path);
|
|
@@ -2684,11 +2812,11 @@ var OpfsFs = class {
|
|
|
2684
2812
|
movePending(from, to) {
|
|
2685
2813
|
if (to !== void 0) {
|
|
2686
2814
|
for (const path of [...this.fileTimes.keys()]) {
|
|
2687
|
-
if (
|
|
2815
|
+
if (within4(path, to)) this.fileTimes.delete(path);
|
|
2688
2816
|
}
|
|
2689
2817
|
}
|
|
2690
2818
|
for (const [path, ms] of [...this.fileTimes]) {
|
|
2691
|
-
if (!
|
|
2819
|
+
if (!within4(path, from)) continue;
|
|
2692
2820
|
this.fileTimes.delete(path);
|
|
2693
2821
|
if (to !== void 0) this.fileTimes.set(to + path.slice(from.length), ms);
|
|
2694
2822
|
}
|
|
@@ -2968,8 +3096,8 @@ var OpfsFs = class {
|
|
|
2968
3096
|
const file = this.movingFiles.get(at);
|
|
2969
3097
|
if (file !== void 0) return { done: file, away: true };
|
|
2970
3098
|
for (const m of this.renamingDirs) {
|
|
2971
|
-
if (
|
|
2972
|
-
if (
|
|
3099
|
+
if (within4(at, m.from)) return { done: m.done, away: true };
|
|
3100
|
+
if (within4(at, m.to)) return { done: m.done, away: false };
|
|
2973
3101
|
}
|
|
2974
3102
|
return void 0;
|
|
2975
3103
|
}
|
|
@@ -3005,7 +3133,7 @@ var OpfsFs = class {
|
|
|
3005
3133
|
idle2.resolve();
|
|
3006
3134
|
}
|
|
3007
3135
|
async writesDrained(tree2) {
|
|
3008
|
-
while ([...this.fileWrites.keys()].some((at) =>
|
|
3136
|
+
while ([...this.fileWrites.keys()].some((at) => within4(at, tree2))) {
|
|
3009
3137
|
this.writesIdle ??= Promise.withResolvers();
|
|
3010
3138
|
await this.writesIdle.promise;
|
|
3011
3139
|
}
|
|
@@ -3082,6 +3210,7 @@ var OpfsFs = class {
|
|
|
3082
3210
|
}
|
|
3083
3211
|
async writeSession(path, truncate) {
|
|
3084
3212
|
const [handle, , target] = await this.fileFor(path);
|
|
3213
|
+
this.privateSession?.bind(target);
|
|
3085
3214
|
const writable3 = await this.retrying(
|
|
3086
3215
|
path,
|
|
3087
3216
|
() => this.io(handle.createWritable({ keepExistingData: !truncate })),
|
|
@@ -3464,15 +3593,14 @@ var OpfsFs = class {
|
|
|
3464
3593
|
if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", to);
|
|
3465
3594
|
const destination = resolvePath(parent.path, baseOf(to));
|
|
3466
3595
|
this.refuse(destination, true);
|
|
3467
|
-
if (directory)
|
|
3468
|
-
|
|
3469
|
-
if (source.path === destination) return;
|
|
3470
|
-
}
|
|
3596
|
+
if (directory && source.handle?.kind !== "directory") throw fsError("ENOTDIR", from);
|
|
3597
|
+
if (source.path === destination) return;
|
|
3471
3598
|
await this.entering(destination, () => this.moveTo(source, parent, destination, to, call));
|
|
3599
|
+
this.privateRename?.moved(source.path, destination);
|
|
3472
3600
|
}
|
|
3473
3601
|
async moveTo(source, parent, destination, to, call) {
|
|
3474
3602
|
const sourceStat = await this.describe(source);
|
|
3475
|
-
if (sourceStat.isDirectory &&
|
|
3603
|
+
if (sourceStat.isDirectory && within4(destination, source.path)) throw fsError("EINVAL", to);
|
|
3476
3604
|
const target = await this.exactly(() => this.locate(destination, false)).catch((err) => {
|
|
3477
3605
|
if (missing2(err)) return null;
|
|
3478
3606
|
throw err;
|
|
@@ -3508,8 +3636,10 @@ var OpfsFs = class {
|
|
|
3508
3636
|
let lock;
|
|
3509
3637
|
const hooks = {};
|
|
3510
3638
|
const staging = swap ? `.${name2}.${crypto.randomUUID()}` : name2;
|
|
3511
|
-
const copying =
|
|
3639
|
+
const copying = needsCopy(source.handle, swap);
|
|
3512
3640
|
const staged2 = resolvePath(parent.path, staging);
|
|
3641
|
+
if (this.usePrivateCopy(source.handle, copying))
|
|
3642
|
+
return this.privateCopy(source, parent, destination, target?.handle, moving);
|
|
3513
3643
|
const place = async () => {
|
|
3514
3644
|
this.forget(destination);
|
|
3515
3645
|
const copies = /* @__PURE__ */ new Map();
|
|
@@ -3744,7 +3874,7 @@ var OpfsFs = class {
|
|
|
3744
3874
|
for (const move of this.peerMoves.values()) {
|
|
3745
3875
|
for (const tree2 of move.trees) {
|
|
3746
3876
|
for (const mine of [from, to]) {
|
|
3747
|
-
if (tree2.some((theirs) =>
|
|
3877
|
+
if (tree2.some((theirs) => within4(mine, theirs) || within4(theirs, mine))) return move;
|
|
3748
3878
|
}
|
|
3749
3879
|
}
|
|
3750
3880
|
}
|
|
@@ -3836,6 +3966,95 @@ var OpfsFs = class {
|
|
|
3836
3966
|
});
|
|
3837
3967
|
return { ...session, close: () => session.close().finally(done5) };
|
|
3838
3968
|
}
|
|
3969
|
+
async privateOp(name2, args, inner) {
|
|
3970
|
+
const gate = this.privateRename;
|
|
3971
|
+
if (!gate || this.insidePrivateOp) return inner.apply(this, args);
|
|
3972
|
+
const paths = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
|
|
3973
|
+
const op = new PrivatePaths(paths, LISTINGS.has(name2), REMOVALS.has(name2));
|
|
3974
|
+
const inside2 = view(this, {
|
|
3975
|
+
insidePrivateOp: true,
|
|
3976
|
+
privateSession: name2 === "writeSession" ? op : void 0,
|
|
3977
|
+
privateRedirect: (from, to) => gate.redirect(op, from, to)
|
|
3978
|
+
});
|
|
3979
|
+
await gate.enter(op);
|
|
3980
|
+
const leave = () => gate.leave(op);
|
|
3981
|
+
let sessionOwnsAdmission = false;
|
|
3982
|
+
try {
|
|
3983
|
+
if (name2 === "writeSession") {
|
|
3984
|
+
const session = await inner.apply(inside2, args);
|
|
3985
|
+
sessionOwnsAdmission = true;
|
|
3986
|
+
let closed;
|
|
3987
|
+
return { ...session, close: () => closed ??= session.close().finally(leave) };
|
|
3988
|
+
}
|
|
3989
|
+
if (name2 !== "rename") return await inner.apply(inside2, args);
|
|
3990
|
+
try {
|
|
3991
|
+
return await inner.apply(inside2, args);
|
|
3992
|
+
} catch (err) {
|
|
3993
|
+
if (err !== PRIVATE_COPY) throw err;
|
|
3994
|
+
}
|
|
3995
|
+
} finally {
|
|
3996
|
+
if (!sessionOwnsAdmission) leave();
|
|
3997
|
+
}
|
|
3998
|
+
const exclusive = view(inside2, { privateCopyReady: true });
|
|
3999
|
+
return gate.exclusive(op, () => inner.apply(exclusive, args));
|
|
4000
|
+
}
|
|
4001
|
+
privateCopyReady = false;
|
|
4002
|
+
usePrivateCopy(handle, staging) {
|
|
4003
|
+
if (!this.privateRename) return false;
|
|
4004
|
+
if (this.privateCopyReady) return true;
|
|
4005
|
+
if (staging || !movable(handle)) throw PRIVATE_COPY;
|
|
4006
|
+
return false;
|
|
4007
|
+
}
|
|
4008
|
+
async privateCopy(source, parent, to, target, owner) {
|
|
4009
|
+
const handle = source.handle;
|
|
4010
|
+
const dir = parent.handle;
|
|
4011
|
+
const name2 = baseOf(to);
|
|
4012
|
+
const copies = /* @__PURE__ */ new Map();
|
|
4013
|
+
const [entry] = await this.meta.get([source.path]);
|
|
4014
|
+
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
4015
|
+
const intent = await this.intend({ from: source.path, to, root, privateCopy: true });
|
|
4016
|
+
try {
|
|
4017
|
+
await this.duplicate(handle, dir, name2, copies, "");
|
|
4018
|
+
} catch (err) {
|
|
4019
|
+
if (!target)
|
|
4020
|
+
await dir.removeEntry(name2, { recursive: true }).catch((e) => {
|
|
4021
|
+
if (e.name !== "NotFoundError") throw e;
|
|
4022
|
+
});
|
|
4023
|
+
else if (target.kind === "directory") {
|
|
4024
|
+
for await (const child2 of target.keys())
|
|
4025
|
+
await target.removeEntry(child2, { recursive: true });
|
|
4026
|
+
}
|
|
4027
|
+
this.forget(to);
|
|
4028
|
+
await this.meta.update(intent, () => void 0);
|
|
4029
|
+
throw translate(err, to, "write");
|
|
4030
|
+
}
|
|
4031
|
+
await this.commitPrivateCopy(source.path, to, root, intent, copies);
|
|
4032
|
+
}
|
|
4033
|
+
async commitPrivateCopy(from, to, root, intent, copies) {
|
|
4034
|
+
const { ino, ...owner } = root;
|
|
4035
|
+
const entries = await this.meta.get([from, to]);
|
|
4036
|
+
if (!entries[0]?.vacated || entries[1]?.ino !== ino) {
|
|
4037
|
+
await this.meta.move(
|
|
4038
|
+
from,
|
|
4039
|
+
to,
|
|
4040
|
+
(entry) => ({ ...occupied(entry), ...owner, ino, path: to, ctimeMs: Date.now() }),
|
|
4041
|
+
vacatedAt(from)
|
|
4042
|
+
);
|
|
4043
|
+
}
|
|
4044
|
+
this.movePending(from, to);
|
|
4045
|
+
await this.removePhysical(from, true);
|
|
4046
|
+
await this.meta.update(intent, () => void 0);
|
|
4047
|
+
await this.restamp(to, copies);
|
|
4048
|
+
this.changed(from, to);
|
|
4049
|
+
this.touch(Date.now(), parentOf4(from), parentOf4(to));
|
|
4050
|
+
}
|
|
4051
|
+
async duplicate(handle, parent, name2, copies, rest2) {
|
|
4052
|
+
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
4053
|
+
const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
|
|
4054
|
+
this.others++;
|
|
4055
|
+
for await (const child2 of handle.values())
|
|
4056
|
+
await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
|
|
4057
|
+
}
|
|
3839
4058
|
renamingDirs = /* @__PURE__ */ new Set();
|
|
3840
4059
|
intents = 0;
|
|
3841
4060
|
async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
|
|
@@ -3898,6 +4117,28 @@ var OpfsFs = class {
|
|
|
3898
4117
|
this.forget(to);
|
|
3899
4118
|
try {
|
|
3900
4119
|
const left = await this.real(from);
|
|
4120
|
+
if (current.rename.privateCopy) {
|
|
4121
|
+
if (left) {
|
|
4122
|
+
const src = await this.locate(from, false);
|
|
4123
|
+
const dir = await this.locate(parentOf4(to), true);
|
|
4124
|
+
const copies = /* @__PURE__ */ new Map();
|
|
4125
|
+
await this.duplicate(
|
|
4126
|
+
src.handle,
|
|
4127
|
+
dir.handle,
|
|
4128
|
+
baseOf(to),
|
|
4129
|
+
copies,
|
|
4130
|
+
""
|
|
4131
|
+
);
|
|
4132
|
+
await this.commitPrivateCopy(
|
|
4133
|
+
from,
|
|
4134
|
+
to,
|
|
4135
|
+
root ?? { ino: inodeOf(from) },
|
|
4136
|
+
entry.path,
|
|
4137
|
+
copies
|
|
4138
|
+
);
|
|
4139
|
+
} else await this.meta.update(entry.path, () => void 0);
|
|
4140
|
+
return;
|
|
4141
|
+
}
|
|
3901
4142
|
if (left && replace && await this.real(to))
|
|
3902
4143
|
await PLAIN.rm.call(this, to, { recursive: true });
|
|
3903
4144
|
if (left) {
|
|
@@ -4013,7 +4254,7 @@ var OpfsFs = class {
|
|
|
4013
4254
|
}
|
|
4014
4255
|
renameAt(at) {
|
|
4015
4256
|
for (const m of this.renamingDirs) {
|
|
4016
|
-
if (
|
|
4257
|
+
if (within4(at, m.from) || within4(at, m.to) || at === parentOf4(m.from) || at === parentOf4(m.to))
|
|
4017
4258
|
return m;
|
|
4018
4259
|
}
|
|
4019
4260
|
return void 0;
|
|
@@ -4049,7 +4290,10 @@ var OpfsFs = class {
|
|
|
4049
4290
|
}
|
|
4050
4291
|
async place(handle, dir, name2, copies, admitted) {
|
|
4051
4292
|
if (await this.moved(handle, dir, name2, admitted)) return true;
|
|
4052
|
-
if (!admitted)
|
|
4293
|
+
if (!admitted) {
|
|
4294
|
+
if (this.privateRename) throw PRIVATE_COPY;
|
|
4295
|
+
throw fsError("EBUSY", name2);
|
|
4296
|
+
}
|
|
4053
4297
|
const before = this.fileMoves;
|
|
4054
4298
|
try {
|
|
4055
4299
|
await this.copy(handle, dir, name2, { copies });
|
|
@@ -4097,21 +4341,7 @@ var OpfsFs = class {
|
|
|
4097
4341
|
if (handle.kind === "file") {
|
|
4098
4342
|
if (options.restoring && await this.handleExists(dir, name2)) return;
|
|
4099
4343
|
if (await this.moveChild(handle, dir, name2)) return;
|
|
4100
|
-
|
|
4101
|
-
const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
|
|
4102
|
-
const writable3 = await this.io(made2.createWritable());
|
|
4103
|
-
try {
|
|
4104
|
-
await writable3.write(file);
|
|
4105
|
-
await writable3.close();
|
|
4106
|
-
} catch (err) {
|
|
4107
|
-
await writable3.abort().catch(nothing);
|
|
4108
|
-
throw err;
|
|
4109
|
-
}
|
|
4110
|
-
options.copies?.set(rest2, {
|
|
4111
|
-
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
4112
|
-
made: made2
|
|
4113
|
-
});
|
|
4114
|
-
return;
|
|
4344
|
+
return this.copyBytes(handle, dir, name2, options, rest2);
|
|
4115
4345
|
}
|
|
4116
4346
|
const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
|
|
4117
4347
|
this.others++;
|
|
@@ -4119,6 +4349,22 @@ var OpfsFs = class {
|
|
|
4119
4349
|
await this.copy(child2, target, child2.name, options, `${rest2}/${child2.name}`);
|
|
4120
4350
|
}
|
|
4121
4351
|
}
|
|
4352
|
+
async copyBytes(handle, dir, name2, options, rest2) {
|
|
4353
|
+
const file = await this.io(handle.getFile());
|
|
4354
|
+
const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
|
|
4355
|
+
const writable3 = await this.io(made2.createWritable());
|
|
4356
|
+
try {
|
|
4357
|
+
await writable3.write(file);
|
|
4358
|
+
await writable3.close();
|
|
4359
|
+
} catch (err) {
|
|
4360
|
+
await writable3.abort().catch(nothing);
|
|
4361
|
+
throw err;
|
|
4362
|
+
}
|
|
4363
|
+
options.copies?.set(rest2, {
|
|
4364
|
+
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
4365
|
+
made: made2
|
|
4366
|
+
});
|
|
4367
|
+
}
|
|
4122
4368
|
async symlink(target, path, owner) {
|
|
4123
4369
|
if (overPath(target)) throw fsError("ENAMETOOLONG", path);
|
|
4124
4370
|
const parent = await this.exactly(() => this.locate(parentOf4(path), true));
|
|
@@ -4286,7 +4532,7 @@ function nothing() {
|
|
|
4286
4532
|
}
|
|
4287
4533
|
function touches(at, trees, listing = true, removing = false) {
|
|
4288
4534
|
return trees.some(
|
|
4289
|
-
([from, to]) =>
|
|
4535
|
+
([from, to]) => within4(at, from) || within4(at, to) || listing && (at === parentOf4(from) || at === parentOf4(to)) || removing && (at === "/" || within4(from, at) || within4(to, at))
|
|
4290
4536
|
);
|
|
4291
4537
|
}
|
|
4292
4538
|
function byIntent(a, b) {
|
|
@@ -4331,6 +4577,7 @@ var WRITES = [
|
|
|
4331
4577
|
const proto = OpfsFs.prototype;
|
|
4332
4578
|
const inner = proto.createExclusive;
|
|
4333
4579
|
proto.createExclusive = function(...args) {
|
|
4580
|
+
if (this.privateRename) return this.privateOp("createExclusive", args, inner);
|
|
4334
4581
|
if (this.amongPeers()) return this.peerOp("createExclusive", args, inner);
|
|
4335
4582
|
return this.alonePlain(inner, args);
|
|
4336
4583
|
};
|
|
@@ -4344,6 +4591,7 @@ for (const [names2, op] of [
|
|
|
4344
4591
|
const inner = proto[name2];
|
|
4345
4592
|
proto[name2] = async function(...args) {
|
|
4346
4593
|
try {
|
|
4594
|
+
if (this.privateRename) return await this.privateOp(name2, args, inner);
|
|
4347
4595
|
if (op === "read") await this.settledRename(args[0]);
|
|
4348
4596
|
if (this.amongPeers() || name2 === "writeSession")
|
|
4349
4597
|
return await this.peerOp(name2, args, inner);
|
|
@@ -7074,7 +7322,7 @@ function parsePrefix(text) {
|
|
|
7074
7322
|
if (length2 < 0 || length2 > max) return void 0;
|
|
7075
7323
|
return { ...parsed3, length: length2 };
|
|
7076
7324
|
}
|
|
7077
|
-
function
|
|
7325
|
+
function within5(prefix, addr) {
|
|
7078
7326
|
if (prefix.v6 !== addr.v6) return false;
|
|
7079
7327
|
const shift = BigInt((prefix.v6 ? 128 : 32) - prefix.length);
|
|
7080
7328
|
return addr.bits >> shift === prefix.bits >> shift;
|
|
@@ -7114,9 +7362,9 @@ var Routes = class {
|
|
|
7114
7362
|
if (!addr) return "unreachable";
|
|
7115
7363
|
if (addr.v6 && addr.bits === 1n) return "loopback";
|
|
7116
7364
|
if (!addr.v6 && addr.bits >> 24n === 127n) return "loopback";
|
|
7117
|
-
if (RESERVED.some((p) =>
|
|
7365
|
+
if (RESERVED.some((p) => within5(p, addr))) return "reserved";
|
|
7118
7366
|
if (addr.v6 && !this.ipv6) return "unreachable";
|
|
7119
|
-
if (this.exit || this.table.some((p) =>
|
|
7367
|
+
if (this.exit || this.table.some((p) => within5(p, addr))) return "uplink";
|
|
7120
7368
|
return "unreachable";
|
|
7121
7369
|
}
|
|
7122
7370
|
};
|
|
@@ -9053,9 +9301,9 @@ async function accountOf(l, user) {
|
|
|
9053
9301
|
if (!found) throw fsError("ENOENT", `no user ${String(user)}`);
|
|
9054
9302
|
return found;
|
|
9055
9303
|
}
|
|
9056
|
-
async function runAs(l, self,
|
|
9057
|
-
if (
|
|
9058
|
-
const target = await accountOf(l,
|
|
9304
|
+
async function runAs(l, self, requested) {
|
|
9305
|
+
if (requested === void 0) return self;
|
|
9306
|
+
const target = await accountOf(l, requested);
|
|
9059
9307
|
if (self.uid !== 0 && target.uid !== self.uid) {
|
|
9060
9308
|
throw fsError("EPERM", `${self.name} may not run as ${target.name}`);
|
|
9061
9309
|
}
|
|
@@ -9626,7 +9874,7 @@ function satisfies(version, range2) {
|
|
|
9626
9874
|
}
|
|
9627
9875
|
|
|
9628
9876
|
// src/version.ts
|
|
9629
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
9877
|
+
var KERNEL_VERSION = true ? "1.196.19" : "0.0.0-dev";
|
|
9630
9878
|
var OS_RELEASE = "6.0.0-slicc";
|
|
9631
9879
|
function procVersion() {
|
|
9632
9880
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -10788,7 +11036,7 @@ var PathMarks = class {
|
|
|
10788
11036
|
this.naming.set(promise, paths);
|
|
10789
11037
|
try {
|
|
10790
11038
|
if (this.active.size) {
|
|
10791
|
-
const pending = [...this.active].filter(([, at]) => paths.some((p) =>
|
|
11039
|
+
const pending = [...this.active].filter(([, at]) => paths.some((p) => within6(at, p)));
|
|
10792
11040
|
await Promise.all(pending.map(([done5]) => done5));
|
|
10793
11041
|
}
|
|
10794
11042
|
return await op();
|
|
@@ -10799,7 +11047,7 @@ var PathMarks = class {
|
|
|
10799
11047
|
}
|
|
10800
11048
|
async metadata(path, op) {
|
|
10801
11049
|
while (this.naming.size) {
|
|
10802
|
-
const pending = [...this.naming].filter(([, paths]) => paths.some((p) =>
|
|
11050
|
+
const pending = [...this.naming].filter(([, paths]) => paths.some((p) => within6(path, p)));
|
|
10803
11051
|
if (!pending.length) break;
|
|
10804
11052
|
await Promise.all(pending.map(([done5]) => done5));
|
|
10805
11053
|
}
|
|
@@ -10844,7 +11092,7 @@ var LOOKUP_OPS = [
|
|
|
10844
11092
|
"readlink",
|
|
10845
11093
|
"realpath"
|
|
10846
11094
|
];
|
|
10847
|
-
var
|
|
11095
|
+
var within6 = (path, target) => path === target || target === "/" || path.startsWith(`${target}/`);
|
|
10848
11096
|
var TOUCHED_MAX = 4096;
|
|
10849
11097
|
var parentOf6 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
|
|
10850
11098
|
var PEER_RM_MS = 1e3;
|
|
@@ -11088,7 +11336,7 @@ var UnlinkedKeeper = class {
|
|
|
11088
11336
|
for (const holder of this.holders) {
|
|
11089
11337
|
if (holder.owns(target)) continue;
|
|
11090
11338
|
for (const path of holder.held()) {
|
|
11091
|
-
if (!
|
|
11339
|
+
if (!within6(path, target) || holder.isKept(path)) continue;
|
|
11092
11340
|
held2.set(path, [...held2.get(path) ?? [], holder]);
|
|
11093
11341
|
}
|
|
11094
11342
|
}
|
|
@@ -13143,7 +13391,7 @@ var DEFAULT_UMASK = 18;
|
|
|
13143
13391
|
function isModule(bytes) {
|
|
13144
13392
|
return MAGIC.every((b, i) => bytes[i] === b);
|
|
13145
13393
|
}
|
|
13146
|
-
function
|
|
13394
|
+
function within7(path, dir) {
|
|
13147
13395
|
return path.startsWith(dir === "/" ? "/" : `${dir}/`);
|
|
13148
13396
|
}
|
|
13149
13397
|
var FreshModules = class {
|
|
@@ -13167,10 +13415,10 @@ var FreshModules = class {
|
|
|
13167
13415
|
const target = normalizePath(to);
|
|
13168
13416
|
if (source === target) return;
|
|
13169
13417
|
for (const key of [...this.fresh.keys()]) {
|
|
13170
|
-
if (key === target ||
|
|
13418
|
+
if (key === target || within7(key, target)) this.fresh.delete(key);
|
|
13171
13419
|
}
|
|
13172
13420
|
for (const [key, fresh4] of [...this.fresh]) {
|
|
13173
|
-
if (key !== source && !
|
|
13421
|
+
if (key !== source && !within7(key, source)) continue;
|
|
13174
13422
|
this.fresh.delete(key);
|
|
13175
13423
|
this.fresh.set(target + key.slice(source.length), fresh4);
|
|
13176
13424
|
}
|
|
@@ -13212,7 +13460,7 @@ var FreshModules = class {
|
|
|
13212
13460
|
await fs.rm(path, options);
|
|
13213
13461
|
const at = normalizePath(path);
|
|
13214
13462
|
for (const key of [...this.fresh.keys()]) {
|
|
13215
|
-
if (key === at ||
|
|
13463
|
+
if (key === at || within7(key, at)) this.fresh.delete(key);
|
|
13216
13464
|
}
|
|
13217
13465
|
},
|
|
13218
13466
|
rename: async (from, to) => {
|
|
@@ -13266,7 +13514,7 @@ var FreshModules = class {
|
|
|
13266
13514
|
};
|
|
13267
13515
|
|
|
13268
13516
|
// src/fs/text-busy.ts
|
|
13269
|
-
var
|
|
13517
|
+
var within8 = (path, prefix) => prefix === "/" || path === prefix || path.startsWith(`${prefix}/`);
|
|
13270
13518
|
var baseName = (path) => path.slice(path.lastIndexOf("/") + 1);
|
|
13271
13519
|
var PLAIN_LIMIT = 4096;
|
|
13272
13520
|
function busyError(path) {
|
|
@@ -13301,10 +13549,10 @@ var TextBusy = class {
|
|
|
13301
13549
|
let changed2 = false;
|
|
13302
13550
|
for (const run2 of this.runs) {
|
|
13303
13551
|
if (run2.name === void 0) continue;
|
|
13304
|
-
if (
|
|
13552
|
+
if (within8(run2.name, from)) {
|
|
13305
13553
|
run2.name = to + run2.name.slice(from.length);
|
|
13306
13554
|
changed2 = true;
|
|
13307
|
-
} else if (
|
|
13555
|
+
} else if (within8(run2.name, to)) {
|
|
13308
13556
|
run2.name = void 0;
|
|
13309
13557
|
changed2 = true;
|
|
13310
13558
|
}
|
|
@@ -13315,7 +13563,7 @@ var TextBusy = class {
|
|
|
13315
13563
|
if (this.runs.size === 0) return;
|
|
13316
13564
|
let changed2 = false;
|
|
13317
13565
|
for (const run2 of this.runs) {
|
|
13318
|
-
if (run2.name === void 0 || !
|
|
13566
|
+
if (run2.name === void 0 || !within8(run2.name, path)) continue;
|
|
13319
13567
|
run2.name = void 0;
|
|
13320
13568
|
changed2 = true;
|
|
13321
13569
|
}
|
|
@@ -13827,12 +14075,8 @@ var SpawnError = class extends Error {
|
|
|
13827
14075
|
}
|
|
13828
14076
|
};
|
|
13829
14077
|
var ChangedError = class extends SpawnError {
|
|
13830
|
-
|
|
13831
|
-
file;
|
|
13832
|
-
constructor(notice, file) {
|
|
14078
|
+
constructor() {
|
|
13833
14079
|
super("EPERM");
|
|
13834
|
-
this.notice = notice;
|
|
13835
|
-
this.file = file;
|
|
13836
14080
|
}
|
|
13837
14081
|
};
|
|
13838
14082
|
function interrupted(signal) {
|
|
@@ -15961,7 +16205,7 @@ function linkedTo(mount, path) {
|
|
|
15961
16205
|
return own?.kind !== "directory" && (attr2.nlink ?? 1) > 1;
|
|
15962
16206
|
};
|
|
15963
16207
|
}
|
|
15964
|
-
var
|
|
16208
|
+
var within9 = (path, target) => path === target || target === "/" || path.startsWith(`${target}/`);
|
|
15965
16209
|
var HeldSet = class extends Set {
|
|
15966
16210
|
idle;
|
|
15967
16211
|
moved;
|
|
@@ -15997,7 +16241,7 @@ var HeldSet = class extends Set {
|
|
|
15997
16241
|
}
|
|
15998
16242
|
};
|
|
15999
16243
|
function heldUnder(held2, target) {
|
|
16000
|
-
for (const paths of held2) for (const path of paths.keys()) if (
|
|
16244
|
+
for (const paths of held2) for (const path of paths.keys()) if (within9(path, target)) return true;
|
|
16001
16245
|
return false;
|
|
16002
16246
|
}
|
|
16003
16247
|
var HeldPaths = class extends Map {
|
|
@@ -16039,7 +16283,7 @@ var HeldPaths = class extends Map {
|
|
|
16039
16283
|
if (this.bound.size === 0) return;
|
|
16040
16284
|
for (const [handle, key] of this.handles) {
|
|
16041
16285
|
if (!this.bound.has(handle) || this.keptHandles.has(handle)) continue;
|
|
16042
|
-
if (exact2 ? key === over :
|
|
16286
|
+
if (exact2 ? key === over : within9(key, over)) this.doubted.set(handle, ++this.doubts);
|
|
16043
16287
|
}
|
|
16044
16288
|
}
|
|
16045
16289
|
heldIdentity(handle) {
|
|
@@ -16186,24 +16430,24 @@ var HeldPaths = class extends Map {
|
|
|
16186
16430
|
return this.owning === path;
|
|
16187
16431
|
}
|
|
16188
16432
|
revoke(prefix) {
|
|
16189
|
-
for (const path of this.keys()) if (
|
|
16433
|
+
for (const path of this.keys()) if (within9(path, prefix)) this.revoked.add(path);
|
|
16190
16434
|
}
|
|
16191
16435
|
renamed(from, to) {
|
|
16192
16436
|
for (const [path, count3] of [...this]) {
|
|
16193
|
-
if (!
|
|
16437
|
+
if (!within9(path, from)) continue;
|
|
16194
16438
|
const moved2 = to + path.slice(from.length);
|
|
16195
16439
|
this.delete(path);
|
|
16196
16440
|
this.set(moved2, (this.get(moved2) ?? 0) + count3);
|
|
16197
16441
|
if (this.revoked.delete(path)) this.revoked.add(moved2);
|
|
16198
16442
|
}
|
|
16199
16443
|
for (const [path, count3] of [...this.opens]) {
|
|
16200
|
-
if (!
|
|
16444
|
+
if (!within9(path, from)) continue;
|
|
16201
16445
|
const moved2 = to + path.slice(from.length);
|
|
16202
16446
|
this.opens.delete(path);
|
|
16203
16447
|
this.opens.set(moved2, (this.opens.get(moved2) ?? 0) + count3);
|
|
16204
16448
|
}
|
|
16205
16449
|
for (const [id2, key] of this.handles) {
|
|
16206
|
-
if (
|
|
16450
|
+
if (within9(key, from)) this.handles.set(id2, to + key.slice(from.length));
|
|
16207
16451
|
}
|
|
16208
16452
|
this.onMoved?.(from, to);
|
|
16209
16453
|
}
|
|
@@ -16347,7 +16591,7 @@ var MountTable = class {
|
|
|
16347
16591
|
});
|
|
16348
16592
|
}
|
|
16349
16593
|
under(path) {
|
|
16350
|
-
for (const mount of this.mounts.values()) if (
|
|
16594
|
+
for (const mount of this.mounts.values()) if (within9(mount.target, path)) return true;
|
|
16351
16595
|
return false;
|
|
16352
16596
|
}
|
|
16353
16597
|
linksAt(path) {
|
|
@@ -16360,7 +16604,7 @@ var MountTable = class {
|
|
|
16360
16604
|
locate(path) {
|
|
16361
16605
|
let best;
|
|
16362
16606
|
for (const mount of this.mounts.values()) {
|
|
16363
|
-
if (
|
|
16607
|
+
if (within9(path, mount.target) && (!best || mount.target.length > best.target.length))
|
|
16364
16608
|
best = mount;
|
|
16365
16609
|
}
|
|
16366
16610
|
if (!best) return void 0;
|
|
@@ -16508,7 +16752,7 @@ var MountTable = class {
|
|
|
16508
16752
|
async commitUnder(prefix) {
|
|
16509
16753
|
const at = normalizePath(prefix);
|
|
16510
16754
|
await Promise.all(
|
|
16511
|
-
[...this.sessions.keys()].filter((p) =>
|
|
16755
|
+
[...this.sessions.keys()].filter((p) => within9(p, at)).map((p) => this.commit(p))
|
|
16512
16756
|
);
|
|
16513
16757
|
}
|
|
16514
16758
|
async commitOverlapping(real, offset, length2) {
|
|
@@ -16546,11 +16790,11 @@ var MountTable = class {
|
|
|
16546
16790
|
mount.epoch++;
|
|
16547
16791
|
const linked2 = mount.caps.links ? linkedTo(mount, path) : () => false;
|
|
16548
16792
|
for (const [key, cached] of [...mount.attrs])
|
|
16549
|
-
if (
|
|
16793
|
+
if (within9(key, path) || linked2(cached.value)) mount.attrs.delete(key);
|
|
16550
16794
|
mount.lists.delete(path);
|
|
16551
16795
|
mount.lists.delete(parentOf9(path));
|
|
16552
16796
|
for (const [key, cached] of [...mount.lists])
|
|
16553
|
-
if (
|
|
16797
|
+
if (within9(key, path) || cached.value.some((e) => linked2(e.attr))) mount.lists.delete(key);
|
|
16554
16798
|
}
|
|
16555
16799
|
async getattr(mount, path, rel2, settled = false) {
|
|
16556
16800
|
for (let round = 1; ; round++) {
|
|
@@ -16691,7 +16935,7 @@ var MountFs = class _MountFs {
|
|
|
16691
16935
|
if (redirects >= MAX_LINKS6) throw errnoError("ELOOP", paths[0]);
|
|
16692
16936
|
const at = paths.map((path) => {
|
|
16693
16937
|
const real = normalizePath(path);
|
|
16694
|
-
return
|
|
16938
|
+
return within9(real, moved2.of) ? normalizePath(moved2.to + real.slice(moved2.of.length)) : real;
|
|
16695
16939
|
});
|
|
16696
16940
|
return again(at, redirects + 1);
|
|
16697
16941
|
}
|
|
@@ -23227,11 +23471,11 @@ function stdinMatches(rule, stdin) {
|
|
|
23227
23471
|
function recordable(cwd, argv) {
|
|
23228
23472
|
return !hasControl(cwd) && !argv.some(hasControl);
|
|
23229
23473
|
}
|
|
23230
|
-
function changedText(
|
|
23231
|
-
return `sudo: ${
|
|
23474
|
+
function changedText(word) {
|
|
23475
|
+
return `sudo: ${quoteWord(word)} changed since it was approved`;
|
|
23232
23476
|
}
|
|
23233
|
-
function requestedText(
|
|
23234
|
-
return `sudo: ${
|
|
23477
|
+
function requestedText(word) {
|
|
23478
|
+
return `sudo: ${quoteWord(word)} changed since it was requested`;
|
|
23235
23479
|
}
|
|
23236
23480
|
function changedFile(approved, now) {
|
|
23237
23481
|
const files = /* @__PURE__ */ new Set([...Object.keys(approved), ...Object.keys(now)]);
|
|
@@ -23698,12 +23942,12 @@ var Sudo = class {
|
|
|
23698
23942
|
if (file.split("/").includes("..")) return physicalPathAsync(fs, file, true);
|
|
23699
23943
|
return await fs.realpath?.(file, true).catch(() => file) ?? file;
|
|
23700
23944
|
}
|
|
23701
|
-
async moved({ routes }
|
|
23945
|
+
async moved({ routes }) {
|
|
23702
23946
|
for (const [asked, approved] of Object.entries(routes)) {
|
|
23703
23947
|
const real = await this.real(asked).catch(() => void 0);
|
|
23704
|
-
if (real !== approved) return
|
|
23948
|
+
if (real !== approved) return true;
|
|
23705
23949
|
}
|
|
23706
|
-
return
|
|
23950
|
+
return false;
|
|
23707
23951
|
}
|
|
23708
23952
|
async missingBacking(hashes, except) {
|
|
23709
23953
|
for (const path of Object.keys(hashes)) {
|
|
@@ -23746,6 +23990,11 @@ var Sudo = class {
|
|
|
23746
23990
|
await lstat("/");
|
|
23747
23991
|
return physicalPathAsync({ lstat, readlink: (at) => fs.readlink(at) }, path, true);
|
|
23748
23992
|
}
|
|
23993
|
+
async executablePath(fs, cred, asked) {
|
|
23994
|
+
const path = await this.searched(fs, cred, asked);
|
|
23995
|
+
const st = await fs.stat(path);
|
|
23996
|
+
return st.isFile && (st.mode & 73) !== 0 ? path : void 0;
|
|
23997
|
+
}
|
|
23749
23998
|
async locate(word, cwd, reads, target) {
|
|
23750
23999
|
const fs = this.o.planFs?.(reads) ?? this.o.fs;
|
|
23751
24000
|
const candidates = word.includes("/") ? [askedPath(cwd, word)] : SECURE_PATH.split(":").map((dir) => `${dir}/${word}`);
|
|
@@ -23753,9 +24002,8 @@ var Sudo = class {
|
|
|
23753
24002
|
let denial;
|
|
23754
24003
|
for (const asked of candidates) {
|
|
23755
24004
|
try {
|
|
23756
|
-
const path = await this.
|
|
23757
|
-
|
|
23758
|
-
if (st.isFile && (st.mode & 73) !== 0) return { path, asked };
|
|
24005
|
+
const path = await this.executablePath(fs, cred, asked);
|
|
24006
|
+
if (path !== void 0) return { path, asked };
|
|
23759
24007
|
} catch (err) {
|
|
23760
24008
|
const code = err.code;
|
|
23761
24009
|
if (code === "EACCES") denial = failed2(code, `sudo: ${word}: Permission denied`);
|
|
@@ -23834,7 +24082,7 @@ ${SCRIPT_HELP}
|
|
|
23834
24082
|
const [word = "", ...args] = r.argv;
|
|
23835
24083
|
const argv = [r.path, ...args];
|
|
23836
24084
|
if (!await this.mayAsk(self, target, r, argv)) {
|
|
23837
|
-
const quoted = argv.map(quoteWord).join(" ");
|
|
24085
|
+
const quoted = r.argv.map(quoteWord).join(" ");
|
|
23838
24086
|
return failed2(
|
|
23839
24087
|
"EACCES",
|
|
23840
24088
|
`sudo: ${self.name} may no longer ask to run ${quoted} as ${target.name}`
|
|
@@ -23854,19 +24102,19 @@ ${SCRIPT_HELP}
|
|
|
23854
24102
|
if (located && "error" in located) return located;
|
|
23855
24103
|
if (!located) {
|
|
23856
24104
|
const gone = await this.missingBacking(r.bound, r.path);
|
|
23857
|
-
return gone ? failed2("EPERM", requestedText(
|
|
24105
|
+
return gone ? failed2("EPERM", requestedText(word)) : failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
23858
24106
|
}
|
|
23859
24107
|
const { path, asked } = located;
|
|
23860
|
-
if (path !== r.path) return failed2("EPERM",
|
|
24108
|
+
if (path !== r.path) return failed2("EPERM", requestedText(word));
|
|
23861
24109
|
const bound3 = await this.bound(path, r.cwd, asked, void 0, reads);
|
|
23862
|
-
if (!bound3) return failed2("EPERM", requestedText(
|
|
24110
|
+
if (!bound3) return failed2("EPERM", requestedText(word));
|
|
23863
24111
|
const changed2 = changedDecision(r.bound, r, bound3, path);
|
|
23864
24112
|
if (changed2 !== void 0) {
|
|
23865
24113
|
const missing7 = ["chainSha256", "routeSha256"].filter(
|
|
23866
24114
|
(key) => bound3[key] !== void 0 && r[key] === void 0
|
|
23867
24115
|
);
|
|
23868
24116
|
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` : "";
|
|
23869
|
-
return failed2("EPERM", requestedText(
|
|
24117
|
+
return failed2("EPERM", requestedText(word) + hint);
|
|
23870
24118
|
}
|
|
23871
24119
|
const now = await this.rootOnly(r.cwd, args);
|
|
23872
24120
|
const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
|
|
@@ -23901,6 +24149,11 @@ ${SCRIPT_HELP}
|
|
|
23901
24149
|
const { caller, self, target, parsed: parsed3 } = s;
|
|
23902
24150
|
const { cred } = caller;
|
|
23903
24151
|
const [word = "", ...args] = parsed3.command;
|
|
24152
|
+
const notAllowed = () => failed2(
|
|
24153
|
+
"EPERM",
|
|
24154
|
+
`sudo: ${self.name} is not allowed to run ${parsed3.command.map(quoteWord).join(" ")} as ${target.name}`
|
|
24155
|
+
);
|
|
24156
|
+
if (!root && mine.length === 0) return notAllowed();
|
|
23904
24157
|
const cwd = await this.canonical(call.cwd, cred);
|
|
23905
24158
|
if (cwd === void 0 || !await this.reachable(cred, cwd)) {
|
|
23906
24159
|
return failed2(
|
|
@@ -23921,13 +24174,7 @@ ${SCRIPT_HELP}
|
|
|
23921
24174
|
const matching = applicable.filter((rule) => pinned(rule, bound3.hashes, bound3));
|
|
23922
24175
|
const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept, asked);
|
|
23923
24176
|
if (root || matching.some((rule) => rule.nopasswd)) return grant();
|
|
23924
|
-
|
|
23925
|
-
if (matching.length === 0) {
|
|
23926
|
-
return failed2(
|
|
23927
|
-
"EPERM",
|
|
23928
|
-
`sudo: ${self.name} is not allowed to run ${quoted} as ${target.name}`
|
|
23929
|
-
);
|
|
23930
|
-
}
|
|
24177
|
+
if (matching.length === 0) return notAllowed();
|
|
23931
24178
|
if (!parsed3.reset && this.timestamps.current(s.owner, s.policy, stampOf(bound3))) {
|
|
23932
24179
|
this.timestamps.stamp(s.owner, s.policy, stampOf(bound3));
|
|
23933
24180
|
this.logged(s, cwd, argv);
|
|
@@ -23951,14 +24198,11 @@ ${SCRIPT_HELP}
|
|
|
23951
24198
|
if (await this.canonical(call.cwd, cred) !== cwd || !await this.reachable(cred, cwd)) {
|
|
23952
24199
|
return failed2("EACCES", `sudo: ${call.cwd} changed while the request waited`);
|
|
23953
24200
|
}
|
|
23954
|
-
|
|
23955
|
-
if (moved2 !== void 0) return failed2("EPERM", changedText(moved2));
|
|
24201
|
+
if (await this.moved(bound3)) return failed2("EPERM", changedText(word));
|
|
23956
24202
|
if (answer2.answer === "once" && !answer2.person) return grant();
|
|
23957
24203
|
const now = await this.bound(path, cwd, asked, caller.pid);
|
|
23958
|
-
if (!now)
|
|
23959
|
-
return failed2("EPERM", changedText(
|
|
23960
|
-
const changed2 = changedDecision(bound3.hashes, bound3, now, path);
|
|
23961
|
-
if (changed2 !== void 0) return failed2("EPERM", changedText(changed2));
|
|
24204
|
+
if (!now || changedDecision(bound3.hashes, bound3, now, path) !== void 0)
|
|
24205
|
+
return failed2("EPERM", changedText(word));
|
|
23962
24206
|
const shown2 = recordable(cwd, [...parsed3.command, ...Object.keys(bound3.hashes)]);
|
|
23963
24207
|
const result = answer2.answer === "once" ? grant() : await this.always(
|
|
23964
24208
|
self,
|
|
@@ -28134,7 +28378,7 @@ function ranges(text) {
|
|
|
28134
28378
|
return [Number.parseInt(lo, 16), Number.parseInt(hi, 16)];
|
|
28135
28379
|
});
|
|
28136
28380
|
}
|
|
28137
|
-
function
|
|
28381
|
+
function within10(table, code) {
|
|
28138
28382
|
let lo = 0;
|
|
28139
28383
|
let hi = table.length - 1;
|
|
28140
28384
|
while (lo <= hi) {
|
|
@@ -28157,10 +28401,10 @@ var LCAT = ranges(LCAT_TEXT);
|
|
|
28157
28401
|
function prepFails(prepared) {
|
|
28158
28402
|
const codes = Array.from(prepared, (ch) => ch.codePointAt(0) ?? 0);
|
|
28159
28403
|
if (codes.length === 0) return true;
|
|
28160
|
-
if (codes.some((c) =>
|
|
28161
|
-
if (!codes.some((c) =>
|
|
28162
|
-
if (codes.some((c) =>
|
|
28163
|
-
return !
|
|
28404
|
+
if (codes.some((c) => within10(PROHIBITED, c) || within10(UNASSIGNED, c))) return true;
|
|
28405
|
+
if (!codes.some((c) => within10(RANDAL, c))) return false;
|
|
28406
|
+
if (codes.some((c) => within10(LCAT, c))) return true;
|
|
28407
|
+
return !within10(RANDAL, codes[0] ?? 0) || !within10(RANDAL, codes.at(-1) ?? 0);
|
|
28164
28408
|
}
|
|
28165
28409
|
|
|
28166
28410
|
// src/kernel/net/sealed-scram.ts
|
|
@@ -30474,7 +30718,7 @@ function isMissing(err) {
|
|
|
30474
30718
|
if (err?.code === "ENOENT") return true;
|
|
30475
30719
|
return err instanceof Error && err.message.startsWith("ENOENT");
|
|
30476
30720
|
}
|
|
30477
|
-
function
|
|
30721
|
+
function within11(path, root) {
|
|
30478
30722
|
return path === root || path.startsWith(root.endsWith("/") ? root : `${root}/`);
|
|
30479
30723
|
}
|
|
30480
30724
|
var VfsNode = class {
|
|
@@ -31038,12 +31282,12 @@ var VfsNodes = class {
|
|
|
31038
31282
|
return node;
|
|
31039
31283
|
}
|
|
31040
31284
|
holds(prefix) {
|
|
31041
|
-
for (const path of this.byPath.keys()) if (
|
|
31285
|
+
for (const path of this.byPath.keys()) if (within11(path, prefix)) return true;
|
|
31042
31286
|
return false;
|
|
31043
31287
|
}
|
|
31044
31288
|
writes(prefix) {
|
|
31045
31289
|
for (const [path, node] of this.byPath)
|
|
31046
|
-
if (node.writers > 0 &&
|
|
31290
|
+
if (node.writers > 0 && within11(path, prefix)) return true;
|
|
31047
31291
|
return false;
|
|
31048
31292
|
}
|
|
31049
31293
|
closed(node, writable3 = false) {
|
|
@@ -31126,17 +31370,17 @@ var VfsNodes = class {
|
|
|
31126
31370
|
this.byPath.get(path)?.reread();
|
|
31127
31371
|
}
|
|
31128
31372
|
rewrittenUnder(tree2) {
|
|
31129
|
-
for (const [p, node] of this.byPath) if (
|
|
31373
|
+
for (const [p, node] of this.byPath) if (within11(p, tree2)) node.reread();
|
|
31130
31374
|
}
|
|
31131
31375
|
doubted(path) {
|
|
31132
|
-
for (const [p, node] of this.byPath) if (
|
|
31376
|
+
for (const [p, node] of this.byPath) if (within11(p, path)) node.doubted();
|
|
31133
31377
|
}
|
|
31134
31378
|
async flush(path) {
|
|
31135
|
-
for (const [p, node] of this.byPath) if (
|
|
31379
|
+
for (const [p, node] of this.byPath) if (within11(p, path)) await node.serial(() => node.flush());
|
|
31136
31380
|
}
|
|
31137
31381
|
async unlinking(path) {
|
|
31138
31382
|
for (const [held2, node] of [...this.byPath]) {
|
|
31139
|
-
if (!
|
|
31383
|
+
if (!within11(held2, path)) continue;
|
|
31140
31384
|
await node.serial(async () => {
|
|
31141
31385
|
await Promise.all([this.keepsOnDisk || node.keep(), node.limit(), node.retainMetadata()]);
|
|
31142
31386
|
});
|
|
@@ -31144,14 +31388,14 @@ var VfsNodes = class {
|
|
|
31144
31388
|
}
|
|
31145
31389
|
revoke(prefix) {
|
|
31146
31390
|
for (const [path, node] of [...this.byPath]) {
|
|
31147
|
-
if (!
|
|
31391
|
+
if (!within11(path, prefix)) continue;
|
|
31148
31392
|
node.revoke();
|
|
31149
31393
|
this.forget(node);
|
|
31150
31394
|
}
|
|
31151
31395
|
}
|
|
31152
31396
|
unlinked(path) {
|
|
31153
31397
|
for (const [held2, node] of [...this.byPath]) {
|
|
31154
|
-
if (!
|
|
31398
|
+
if (!within11(held2, path) || this.byPath.get(held2) !== node) continue;
|
|
31155
31399
|
if (!this.dropName(held2, node)) this.orphan(node);
|
|
31156
31400
|
}
|
|
31157
31401
|
}
|
|
@@ -31159,8 +31403,8 @@ var VfsNodes = class {
|
|
|
31159
31403
|
if (from === to) return;
|
|
31160
31404
|
const moved2 = [];
|
|
31161
31405
|
for (const [p, node] of [...this.byPath]) {
|
|
31162
|
-
if (
|
|
31163
|
-
else if (
|
|
31406
|
+
if (within11(p, from)) moved2.push([p, node]);
|
|
31407
|
+
else if (within11(p, to) && this.byPath.get(p) === node && !this.dropName(p, node)) {
|
|
31164
31408
|
this.orphan(node);
|
|
31165
31409
|
}
|
|
31166
31410
|
}
|
|
@@ -32841,8 +33085,8 @@ var WasmProcess = class _WasmProcess {
|
|
|
32841
33085
|
close: () => source.release()
|
|
32842
33086
|
});
|
|
32843
33087
|
}
|
|
32844
|
-
nonblocking(fd,
|
|
32845
|
-
return
|
|
33088
|
+
nonblocking(fd, requested) {
|
|
33089
|
+
return requested === true || !this.options.perCallNonblock && ((this.fds.statusFlags(fd) ?? 0) & O_NONBLOCK2) !== 0;
|
|
32846
33090
|
}
|
|
32847
33091
|
async fdSyscall(req, cancelled) {
|
|
32848
33092
|
if (isVfsSyscall(req)) return this.vfsSyscall(req);
|
|
@@ -33724,7 +33968,8 @@ var WasmProcess = class _WasmProcess {
|
|
|
33724
33968
|
})
|
|
33725
33969
|
};
|
|
33726
33970
|
} catch (err) {
|
|
33727
|
-
if (err instanceof ChangedError)
|
|
33971
|
+
if (err instanceof ChangedError)
|
|
33972
|
+
return { error: changedText(argv[0] ?? asked), errno: err.code };
|
|
33728
33973
|
throw err;
|
|
33729
33974
|
}
|
|
33730
33975
|
}
|
|
@@ -35826,7 +36071,7 @@ var PackageSwaps = class {
|
|
|
35826
36071
|
|
|
35827
36072
|
// src/kernel/rename-log.ts
|
|
35828
36073
|
var RENAME_LOG_SIZE = 4096;
|
|
35829
|
-
function
|
|
36074
|
+
function within12(path, root) {
|
|
35830
36075
|
return path === root || path.startsWith(root === "/" ? "/" : `${root}/`);
|
|
35831
36076
|
}
|
|
35832
36077
|
var RenameLog = class {
|
|
@@ -35853,9 +36098,9 @@ var RenameLog = class {
|
|
|
35853
36098
|
const renames = [];
|
|
35854
36099
|
let paths = [...held2];
|
|
35855
36100
|
for (const { seq: seq2, from, to } of this.entries) {
|
|
35856
|
-
if (seq2 <= seen || !paths.some((path) =>
|
|
36101
|
+
if (seq2 <= seen || !paths.some((path) => within12(path, from))) continue;
|
|
35857
36102
|
renames.push([from, to]);
|
|
35858
|
-
paths = paths.map((path) =>
|
|
36103
|
+
paths = paths.map((path) => within12(path, from) ? to + path.slice(from.length) : path);
|
|
35859
36104
|
}
|
|
35860
36105
|
return { now, renames };
|
|
35861
36106
|
}
|
|
@@ -38093,8 +38338,7 @@ function describe(req, tty) {
|
|
|
38093
38338
|
return { argv: [req.argv0, ...req.args], tty, started: Date.now(), ...exe };
|
|
38094
38339
|
}
|
|
38095
38340
|
function refuseChanged(approved, now) {
|
|
38096
|
-
|
|
38097
|
-
if (changed2 !== void 0) throw new ChangedError(changedText(changed2), changed2);
|
|
38341
|
+
if (changedFile(approved, now) !== void 0) throw new ChangedError();
|
|
38098
38342
|
}
|
|
38099
38343
|
var O_WRONLY2 = 1;
|
|
38100
38344
|
var OUTPUT_MODE = 384;
|
|
@@ -38113,10 +38357,14 @@ function sudoCause(err) {
|
|
|
38113
38357
|
if (typeof code !== "string") throw err;
|
|
38114
38358
|
return code;
|
|
38115
38359
|
}
|
|
38116
|
-
|
|
38117
|
-
|
|
38118
|
-
|
|
38119
|
-
|
|
38360
|
+
var LOST_ROUTE = /* @__PURE__ */ new Set([
|
|
38361
|
+
"ENOENT",
|
|
38362
|
+
"ENOTDIR",
|
|
38363
|
+
"EACCES",
|
|
38364
|
+
"ELOOP",
|
|
38365
|
+
"ESTALE",
|
|
38366
|
+
"ENAMETOOLONG"
|
|
38367
|
+
]);
|
|
38120
38368
|
var MAX_SPAWN_TAGS = 8;
|
|
38121
38369
|
function tagList(value2) {
|
|
38122
38370
|
if (!Array.isArray(value2)) {
|
|
@@ -39416,16 +39664,20 @@ var Launcher = class {
|
|
|
39416
39664
|
const refused5 = (err) => {
|
|
39417
39665
|
throw codeOf9(err) === "EACCES" ? new SpawnError("EACCES") : err;
|
|
39418
39666
|
};
|
|
39667
|
+
const lost = (err) => {
|
|
39668
|
+
if (LOST_ROUTE.has(codeOf9(err))) throw new ChangedError();
|
|
39669
|
+
throw err;
|
|
39670
|
+
};
|
|
39419
39671
|
const { file, parentHops } = await this.execFile(
|
|
39420
39672
|
req.file,
|
|
39421
39673
|
req.cwd,
|
|
39422
39674
|
this.execGuard(cred, ppid),
|
|
39423
39675
|
ppid
|
|
39424
|
-
).catch(refused5);
|
|
39676
|
+
).catch(grant?.files ? lost : refused5);
|
|
39425
39677
|
const reads = prepared ?? (grant?.files && await this.scriptReads(grant.files, cred, ppid));
|
|
39426
39678
|
if (grant?.asked && reads) {
|
|
39427
|
-
const destination = await this.sudoer.
|
|
39428
|
-
if (destination !== file) throw new ChangedError(
|
|
39679
|
+
const destination = await this.sudoer.executablePath(this.sudoFs(reads), cred, grant.asked).catch(lost);
|
|
39680
|
+
if (destination !== file) throw new ChangedError();
|
|
39429
39681
|
}
|
|
39430
39682
|
const plan = await this.plan(file, req.argv, req.cwd, scope, {
|
|
39431
39683
|
argv0: req.argv0,
|
|
@@ -39444,10 +39696,7 @@ var Launcher = class {
|
|
|
39444
39696
|
async checkFailedPlan(file, req, scope, grant) {
|
|
39445
39697
|
const reads = this.sudoer.reads();
|
|
39446
39698
|
const { planned } = await this.plan(file, req.argv, req.cwd, scope, { reads });
|
|
39447
|
-
if (!planned)
|
|
39448
|
-
const gone = await this.sudoer.missingBacking(grant.files.hashes) ?? file;
|
|
39449
|
-
throw new ChangedError(changedText(gone), gone);
|
|
39450
|
-
}
|
|
39699
|
+
if (!planned) throw new ChangedError();
|
|
39451
39700
|
await this.unchanged({ ...planned, reads }, file, req.cwd, grant);
|
|
39452
39701
|
}
|
|
39453
39702
|
async enterable(g, cwd) {
|
|
@@ -39601,26 +39850,26 @@ var Launcher = class {
|
|
|
39601
39850
|
const now = await planned.reads.bind([file, grant.asked ?? file, ...files]);
|
|
39602
39851
|
refuseChanged(approved.hashes, now.hashes);
|
|
39603
39852
|
refuseChanged(approved.routes, now.routes);
|
|
39604
|
-
if (now.chainSha256 !== approved.chainSha256) throw new ChangedError(
|
|
39853
|
+
if (now.chainSha256 !== approved.chainSha256) throw new ChangedError();
|
|
39605
39854
|
return { pinned: approved };
|
|
39606
39855
|
}
|
|
39607
39856
|
approvedChain(planned, file, cwd, grant) {
|
|
39608
39857
|
if (!grant) return void 0;
|
|
39609
39858
|
return async (next3) => {
|
|
39610
39859
|
const chain2 = (p) => [...p.via ?? [], ...p.binfmts ?? []];
|
|
39611
|
-
if (!sameList(chain2(next3), chain2(planned))) throw new ChangedError(
|
|
39860
|
+
if (!sameList(chain2(next3), chain2(planned))) throw new ChangedError();
|
|
39612
39861
|
await this.unchanged(next3, file, cwd, grant);
|
|
39613
39862
|
};
|
|
39614
39863
|
}
|
|
39615
39864
|
async scriptReads(files, cred, pid) {
|
|
39616
|
-
await this.checkRoutes(files
|
|
39865
|
+
await this.checkRoutes(files);
|
|
39617
39866
|
const snapshots = /* @__PURE__ */ new Map();
|
|
39618
39867
|
const reads = this.sudoer.reads(snapshots);
|
|
39619
39868
|
const guard2 = { fs: this.sudoFs(reads), dac: this.dac, cred, pid, links: cred.euid };
|
|
39620
39869
|
for (const path of files.scripts ?? []) {
|
|
39621
39870
|
const real = files.routes[path];
|
|
39622
39871
|
const walked2 = await need(guard2, "open", path, R_OK, { directory: false });
|
|
39623
|
-
if (walked2.missing || walked2.path !== real) throw new ChangedError(
|
|
39872
|
+
if (walked2.missing || walked2.path !== real) throw new ChangedError();
|
|
39624
39873
|
if (!snapshots.has(real))
|
|
39625
39874
|
snapshots.set(real, new Uint8Array(await this.noLinksFs.readFileBuffer(real)));
|
|
39626
39875
|
}
|
|
@@ -39633,14 +39882,13 @@ var Launcher = class {
|
|
|
39633
39882
|
const real = files.routes[path];
|
|
39634
39883
|
if (real === void 0) continue;
|
|
39635
39884
|
const bytes = reads.snapshots.get(real);
|
|
39636
|
-
if (!bytes) throw new ChangedError(
|
|
39885
|
+
if (!bytes) throw new ChangedError();
|
|
39637
39886
|
args[args.length - fromEnd] = scriptFd(fds, bytes);
|
|
39638
39887
|
}
|
|
39639
39888
|
return { ...planned, args };
|
|
39640
39889
|
}
|
|
39641
|
-
async checkRoutes(files
|
|
39642
|
-
|
|
39643
|
-
if (file !== void 0) throw new ChangedError(changedText(file), file);
|
|
39890
|
+
async checkRoutes(files) {
|
|
39891
|
+
if (await this.sudoer.moved(files)) throw new ChangedError();
|
|
39644
39892
|
}
|
|
39645
39893
|
async pinOf(path, caller) {
|
|
39646
39894
|
const { pinned: pinned2 } = caller;
|
|
@@ -39648,7 +39896,7 @@ var Launcher = class {
|
|
|
39648
39896
|
const real = await this.sudoer.real(path);
|
|
39649
39897
|
const approved = pinned2.routes[path];
|
|
39650
39898
|
if (approved !== real && (approved !== void 0 || !await this.sudoer.trustedThrough(path)))
|
|
39651
|
-
throw new ChangedError(
|
|
39899
|
+
throw new ChangedError();
|
|
39652
39900
|
const hex4 = pinned2.hashes[real];
|
|
39653
39901
|
return hex4 === void 0 ? {} : { [real]: hex4 };
|
|
39654
39902
|
}
|
|
@@ -40090,7 +40338,7 @@ var Launcher = class {
|
|
|
40090
40338
|
const own = env.HOSTNAME;
|
|
40091
40339
|
if (asked.target.abi === "wasi") env.HOSTNAME = this.hostname;
|
|
40092
40340
|
const planned = chosen2(asked, env);
|
|
40093
|
-
if (req.pinned) await this.checkRoutes(req.pinned
|
|
40341
|
+
if (req.pinned) await this.checkRoutes(req.pinned);
|
|
40094
40342
|
const caller = {
|
|
40095
40343
|
pid: req.ppid ?? 0,
|
|
40096
40344
|
uid: req.cred.euid,
|
|
@@ -40108,9 +40356,9 @@ var Launcher = class {
|
|
|
40108
40356
|
}
|
|
40109
40357
|
packageRootIs(path) {
|
|
40110
40358
|
const at = normalizePath(path);
|
|
40111
|
-
const
|
|
40359
|
+
const within13 = `${at}/`;
|
|
40112
40360
|
const roots = [this.modulesDir, ...this.appended];
|
|
40113
|
-
const root = PACKAGE_ROOT.exec(
|
|
40361
|
+
const root = PACKAGE_ROOT.exec(within13)?.[1] ?? packageRootOf(within13, roots);
|
|
40114
40362
|
return root === at;
|
|
40115
40363
|
}
|
|
40116
40364
|
packageRoots(planned) {
|
|
@@ -41901,12 +42149,16 @@ var Launcher = class {
|
|
|
41901
42149
|
this.resetCatalogs();
|
|
41902
42150
|
const req = { file: grant.file, argv: grant.argv, env: grant.env, cwd: grant.cwd };
|
|
41903
42151
|
const ctx = { ppid: 0, cred: grant.cred, scope: "", grant };
|
|
42152
|
+
const word = grant.argv[0] ?? grant.asked;
|
|
42153
|
+
const requested = (err2) => {
|
|
42154
|
+
if (err2 instanceof ChangedError) throw sudoFailure(err2.code, requestedText(word));
|
|
42155
|
+
throw err2;
|
|
42156
|
+
};
|
|
41904
42157
|
const planned = await this.planOne(req, ctx).catch((err2) => {
|
|
41905
42158
|
if (err2 instanceof ChangedError) requested(err2);
|
|
41906
42159
|
const code = sudoCause(err2);
|
|
41907
|
-
|
|
41908
|
-
|
|
41909
|
-
throw sudoFailure(code, `sudo: ${grant.file}: ${ERRNO_TEXT[code] ?? code}`);
|
|
42160
|
+
if (code === "ENOENT") throw sudoFailure(code, `sudo: ${quoteWord(word)}: command not found`);
|
|
42161
|
+
throw sudoFailure(code, `sudo: ${quoteWord(word)}: ${ERRNO_TEXT[code] ?? code}`);
|
|
41910
42162
|
});
|
|
41911
42163
|
const pin = await this.unchanged(planned, grant.file, grant.cwd, grant).catch(requested);
|
|
41912
42164
|
const fds = await this.sudoOutputs(options, caller, this.stackFor(tags, tagged.tagBase));
|