@ai-ecoverse/slicc-kernel 1.140.1 → 1.140.2

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.
@@ -2775,7 +2775,7 @@ var KERNEL_VERSION, OS_RELEASE;
2775
2775
  var init_version = __esm({
2776
2776
  "src/version.ts"() {
2777
2777
  "use strict";
2778
- KERNEL_VERSION = true ? "1.140.1" : "0.0.0-dev";
2778
+ KERNEL_VERSION = true ? "1.140.2" : "0.0.0-dev";
2779
2779
  OS_RELEASE = "6.0.0-slicc";
2780
2780
  }
2781
2781
  });
@@ -9307,6 +9307,8 @@ var init_wasi_fds = __esm({
9307
9307
  if (kernelDevice !== void 0) return kernelDevice;
9308
9308
  const alias = stdioAlias(path);
9309
9309
  if (alias !== void 0) return this.reopen(alias);
9310
+ const outside = this.escaped(path, oflags, rights);
9311
+ if (outside !== void 0) return this.open(outside, oflags, rights, fdflags, mode);
9310
9312
  if (exclusive && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
9311
9313
  return this.regular(path, void 0, oflags, rights, fdflags, mode, true);
9312
9314
  }
@@ -9325,6 +9327,12 @@ var init_wasi_fds = __esm({
9325
9327
  refuseWrite(s, oflags, rights);
9326
9328
  return this.regular(path, s, oflags, rights, fdflags, mode);
9327
9329
  }
9330
+ escaped(path, oflags, rights) {
9331
+ const outside = this.fs.escape?.(path);
9332
+ if (outside === void 0) return void 0;
9333
+ refuseWrite({ readonly: true }, oflags | (oflags & OFLAGS.CREAT ? OFLAGS.TRUNC : 0), rights);
9334
+ return outside;
9335
+ }
9328
9336
  regular(path, s, oflags, rights, fdflags, mode, created = false) {
9329
9337
  if (s?.isFifo) return this.kernelFifo(path, s, oflags, rights, fdflags);
9330
9338
  if (s?.isSocket) throw new WasiError("ENXIO");
@@ -12396,10 +12404,12 @@ function directMiss(err, path) {
12396
12404
  if (err?.direct !== true) return false;
12397
12405
  return !path.split("/").some((part) => part === "." || part === "..");
12398
12406
  }
12399
- function procfsBridge(fs, tree) {
12400
- const toProc = (path, follow3) => procPath(fs, path, follow3);
12401
- const shadowing = physicalProc(fs);
12402
- const via = (p, proc, own, follow3 = true) => {
12407
+ function routing(tree, toProc, shadowing) {
12408
+ return (p, inner, own, follow3 = true, outside) => {
12409
+ const proc = (q) => {
12410
+ const target = outside ? tree.escape(q) : void 0;
12411
+ return target === void 0 ? inner(q) : outside(target);
12412
+ };
12403
12413
  if (inProc(p)) return proc(p);
12404
12414
  if (shadowing()) {
12405
12415
  const real = toProc(p, follow3);
@@ -12414,6 +12424,11 @@ function procfsBridge(fs, tree) {
12414
12424
  return proc(real);
12415
12425
  }
12416
12426
  };
12427
+ }
12428
+ function procfsBridge(fs, tree) {
12429
+ const toProc = (path, follow3) => procPath(fs, path, follow3);
12430
+ const shadowing = physicalProc(fs);
12431
+ const via = routing(tree, toProc, shadowing);
12417
12432
  const readOnly2 = (paths, run) => {
12418
12433
  const physical2 = shadowing();
12419
12434
  for (const [p, follow3] of paths) {
@@ -12436,12 +12451,16 @@ function procfsBridge(fs, tree) {
12436
12451
  readFile: (p) => via(
12437
12452
  p,
12438
12453
  (q) => tree.read(q),
12439
- () => fs.readFile(p)
12454
+ () => fs.readFile(p),
12455
+ true,
12456
+ (t) => fs.readFile(t)
12440
12457
  ),
12441
12458
  stat: (p) => via(
12442
12459
  p,
12443
12460
  (q) => tree.stat(q),
12444
- () => fs.stat(p)
12461
+ () => fs.stat(p),
12462
+ true,
12463
+ (t) => fs.stat(t)
12445
12464
  ),
12446
12465
  lstat: (p) => via(
12447
12466
  p,
@@ -12520,6 +12539,7 @@ function procfsBridge(fs, tree) {
12520
12539
  return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want, seen) ?? late(p));
12521
12540
  },
12522
12541
  kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
12542
+ escape: (p) => inProc(p) ? tree.escape(p) : void 0,
12523
12543
  pinned: (handle) => {
12524
12544
  const bytes = snapshots.get(handle);
12525
12545
  return bytes ? frozen(bytes) : fs.pinned?.(handle) ?? fs;
@@ -12700,6 +12720,12 @@ var init_wasi_procfs = __esm({
12700
12720
  if (node.kind !== "dir") throw syncError("ENOTDIR", path);
12701
12721
  return node.names();
12702
12722
  }
12723
+ escape(path) {
12724
+ const node = this.node(this.parts(path, true));
12725
+ if (node?.kind !== "link" || !node.target.startsWith("/")) return void 0;
12726
+ if (node.denied) throw syncError("EACCES", path);
12727
+ return node.target;
12728
+ }
12703
12729
  readlink(path) {
12704
12730
  const node = this.find(path, false);
12705
12731
  if (node.kind !== "link") throw syncError("EINVAL", path);