@ai-ecoverse/slicc-kernel 1.140.1 → 1.140.3

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");
@@ -4439,6 +4447,9 @@ function isHostname(name2) {
4439
4447
  function hostnameOf(env) {
4440
4448
  return isHostname(env.HOSTNAME) ? env.HOSTNAME : DEFAULT_HOSTNAME;
4441
4449
  }
4450
+ function initHostname(init) {
4451
+ return isHostname(init.hostname) ? init.hostname : hostnameOf(init.env);
4452
+ }
4442
4453
  function ownNames(hostname) {
4443
4454
  return [.../* @__PURE__ */ new Set([hostname.toLowerCase(), ...LIBC_HOSTNAMES])];
4444
4455
  }
@@ -6710,7 +6721,7 @@ var KERNEL_VERSION, OS_RELEASE;
6710
6721
  var init_version = __esm({
6711
6722
  "src/version.ts"() {
6712
6723
  "use strict";
6713
- KERNEL_VERSION = true ? "1.140.1" : "0.0.0-dev";
6724
+ KERNEL_VERSION = true ? "1.140.3" : "0.0.0-dev";
6714
6725
  OS_RELEASE = "6.0.0-slicc";
6715
6726
  }
6716
6727
  });
@@ -10987,10 +10998,12 @@ function directMiss(err, path) {
10987
10998
  if (err?.direct !== true) return false;
10988
10999
  return !path.split("/").some((part) => part === "." || part === "..");
10989
11000
  }
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) => {
11001
+ function routing(tree, toProc, shadowing) {
11002
+ return (p, inner, own, follow3 = true, outside) => {
11003
+ const proc = (q) => {
11004
+ const target = outside ? tree.escape(q) : void 0;
11005
+ return target === void 0 ? inner(q) : outside(target);
11006
+ };
10994
11007
  if (inProc(p)) return proc(p);
10995
11008
  if (shadowing()) {
10996
11009
  const real = toProc(p, follow3);
@@ -11005,6 +11018,11 @@ function procfsBridge(fs, tree) {
11005
11018
  return proc(real);
11006
11019
  }
11007
11020
  };
11021
+ }
11022
+ function procfsBridge(fs, tree) {
11023
+ const toProc = (path, follow3) => procPath(fs, path, follow3);
11024
+ const shadowing = physicalProc(fs);
11025
+ const via = routing(tree, toProc, shadowing);
11008
11026
  const readOnly2 = (paths, run) => {
11009
11027
  const physical2 = shadowing();
11010
11028
  for (const [p, follow3] of paths) {
@@ -11027,12 +11045,16 @@ function procfsBridge(fs, tree) {
11027
11045
  readFile: (p) => via(
11028
11046
  p,
11029
11047
  (q) => tree.read(q),
11030
- () => fs.readFile(p)
11048
+ () => fs.readFile(p),
11049
+ true,
11050
+ (t) => fs.readFile(t)
11031
11051
  ),
11032
11052
  stat: (p) => via(
11033
11053
  p,
11034
11054
  (q) => tree.stat(q),
11035
- () => fs.stat(p)
11055
+ () => fs.stat(p),
11056
+ true,
11057
+ (t) => fs.stat(t)
11036
11058
  ),
11037
11059
  lstat: (p) => via(
11038
11060
  p,
@@ -11111,6 +11133,7 @@ function procfsBridge(fs, tree) {
11111
11133
  return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want, seen) ?? late(p));
11112
11134
  },
11113
11135
  kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
11136
+ escape: (p) => inProc(p) ? tree.escape(p) : void 0,
11114
11137
  pinned: (handle) => {
11115
11138
  const bytes = snapshots.get(handle);
11116
11139
  return bytes ? frozen(bytes) : fs.pinned?.(handle) ?? fs;
@@ -11291,6 +11314,12 @@ var init_wasi_procfs = __esm({
11291
11314
  if (node.kind !== "dir") throw syncError("ENOTDIR", path);
11292
11315
  return node.names();
11293
11316
  }
11317
+ escape(path) {
11318
+ const node = this.node(this.parts(path, true));
11319
+ if (node?.kind !== "link" || !node.target.startsWith("/")) return void 0;
11320
+ if (node.denied) throw syncError("EACCES", path);
11321
+ return node.target;
11322
+ }
11294
11323
  readlink(path) {
11295
11324
  const node = this.find(path, false);
11296
11325
  if (node.kind !== "link") throw syncError("EINVAL", path);
@@ -13971,7 +14000,7 @@ function kernelWrappers(imports, module, deps) {
13971
14000
  goneCwdGetcwd(imports, fsOf, kernelGlue);
13972
14001
  kernelLink(imports, fsOf, memory, kernelGlue);
13973
14002
  devCreations(imports, fsOf, memory, kernelGlue);
13974
- kernelUname(imports, hostnameOf(init.env), memory, kernelGlue);
14003
+ kernelUname(imports, initHostname(init), memory, kernelGlue);
13975
14004
  wrapImport(
13976
14005
  imports,
13977
14006
  "flock",
@@ -14144,7 +14173,7 @@ async function runWasmProcess(init, port3, deps = {}) {
14144
14173
  streams2.quitting = on;
14145
14174
  });
14146
14175
  atExit = () => streams2.exiting();
14147
- useMounts(running.FS, init.env, true);
14176
+ useMounts(running.FS, { ...init.env, HOSTNAME: initHostname(init) }, true);
14148
14177
  useZeroDevices(running.FS);
14149
14178
  useProcfs(running.FS, sys, init.pid);
14150
14179
  if (init.fork) restoreForkedStreams(running.FS, streams2, init.fork.streams ?? []);
@@ -14182,7 +14211,7 @@ async function runWasmProcess(init, port3, deps = {}) {
14182
14211
  ...callerOwner(running.FS, init)
14183
14212
  });
14184
14213
  running.sliccKernel.http = createHttpKernel(transport);
14185
- running.sliccKernel.hostname = hostnameOf(init.env);
14214
+ running.sliccKernel.hostname = initHostname(init);
14186
14215
  running.sliccKernel.net = createSocketKernel({
14187
14216
  transport,
14188
14217
  Fs: running.FS,