@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.
@@ -3691,6 +3691,8 @@ var init_wasi_fds = __esm({
3691
3691
  if (kernelDevice !== void 0) return kernelDevice;
3692
3692
  const alias = stdioAlias(path);
3693
3693
  if (alias !== void 0) return this.reopen(alias);
3694
+ const outside = this.escaped(path, oflags, rights);
3695
+ if (outside !== void 0) return this.open(outside, oflags, rights, fdflags, mode);
3694
3696
  if (exclusive && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
3695
3697
  return this.regular(path, void 0, oflags, rights, fdflags, mode, true);
3696
3698
  }
@@ -3709,6 +3711,12 @@ var init_wasi_fds = __esm({
3709
3711
  refuseWrite(s, oflags, rights);
3710
3712
  return this.regular(path, s, oflags, rights, fdflags, mode);
3711
3713
  }
3714
+ escaped(path, oflags, rights) {
3715
+ const outside = this.fs.escape?.(path);
3716
+ if (outside === void 0) return void 0;
3717
+ refuseWrite({ readonly: true }, oflags | (oflags & OFLAGS.CREAT ? OFLAGS.TRUNC : 0), rights);
3718
+ return outside;
3719
+ }
3712
3720
  regular(path, s, oflags, rights, fdflags, mode, created = false) {
3713
3721
  if (s?.isFifo) return this.kernelFifo(path, s, oflags, rights, fdflags);
3714
3722
  if (s?.isSocket) throw new WasiError("ENXIO");
@@ -6710,7 +6718,7 @@ var KERNEL_VERSION, OS_RELEASE;
6710
6718
  var init_version = __esm({
6711
6719
  "src/version.ts"() {
6712
6720
  "use strict";
6713
- KERNEL_VERSION = true ? "1.140.1" : "0.0.0-dev";
6721
+ KERNEL_VERSION = true ? "1.140.2" : "0.0.0-dev";
6714
6722
  OS_RELEASE = "6.0.0-slicc";
6715
6723
  }
6716
6724
  });
@@ -10987,10 +10995,12 @@ function directMiss(err, path) {
10987
10995
  if (err?.direct !== true) return false;
10988
10996
  return !path.split("/").some((part) => part === "." || part === "..");
10989
10997
  }
10990
- function procfsBridge(fs, tree) {
10991
- const toProc = (path, follow3) => procPath(fs, path, follow3);
10992
- const shadowing = physicalProc(fs);
10993
- const via = (p, proc, own, follow3 = true) => {
10998
+ function routing(tree, toProc, shadowing) {
10999
+ return (p, inner, own, follow3 = true, outside) => {
11000
+ const proc = (q) => {
11001
+ const target = outside ? tree.escape(q) : void 0;
11002
+ return target === void 0 ? inner(q) : outside(target);
11003
+ };
10994
11004
  if (inProc(p)) return proc(p);
10995
11005
  if (shadowing()) {
10996
11006
  const real = toProc(p, follow3);
@@ -11005,6 +11015,11 @@ function procfsBridge(fs, tree) {
11005
11015
  return proc(real);
11006
11016
  }
11007
11017
  };
11018
+ }
11019
+ function procfsBridge(fs, tree) {
11020
+ const toProc = (path, follow3) => procPath(fs, path, follow3);
11021
+ const shadowing = physicalProc(fs);
11022
+ const via = routing(tree, toProc, shadowing);
11008
11023
  const readOnly2 = (paths, run) => {
11009
11024
  const physical2 = shadowing();
11010
11025
  for (const [p, follow3] of paths) {
@@ -11027,12 +11042,16 @@ function procfsBridge(fs, tree) {
11027
11042
  readFile: (p) => via(
11028
11043
  p,
11029
11044
  (q) => tree.read(q),
11030
- () => fs.readFile(p)
11045
+ () => fs.readFile(p),
11046
+ true,
11047
+ (t) => fs.readFile(t)
11031
11048
  ),
11032
11049
  stat: (p) => via(
11033
11050
  p,
11034
11051
  (q) => tree.stat(q),
11035
- () => fs.stat(p)
11052
+ () => fs.stat(p),
11053
+ true,
11054
+ (t) => fs.stat(t)
11036
11055
  ),
11037
11056
  lstat: (p) => via(
11038
11057
  p,
@@ -11111,6 +11130,7 @@ function procfsBridge(fs, tree) {
11111
11130
  return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want, seen) ?? late(p));
11112
11131
  },
11113
11132
  kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
11133
+ escape: (p) => inProc(p) ? tree.escape(p) : void 0,
11114
11134
  pinned: (handle) => {
11115
11135
  const bytes = snapshots.get(handle);
11116
11136
  return bytes ? frozen(bytes) : fs.pinned?.(handle) ?? fs;
@@ -11291,6 +11311,12 @@ var init_wasi_procfs = __esm({
11291
11311
  if (node.kind !== "dir") throw syncError("ENOTDIR", path);
11292
11312
  return node.names();
11293
11313
  }
11314
+ escape(path) {
11315
+ const node = this.node(this.parts(path, true));
11316
+ if (node?.kind !== "link" || !node.target.startsWith("/")) return void 0;
11317
+ if (node.denied) throw syncError("EACCES", path);
11318
+ return node.target;
11319
+ }
11294
11320
  readlink(path) {
11295
11321
  const node = this.find(path, false);
11296
11322
  if (node.kind !== "link") throw syncError("EINVAL", path);