@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.
@@ -348,6 +348,9 @@ function isHostname(name2) {
348
348
  function hostnameOf(env) {
349
349
  return isHostname(env.HOSTNAME) ? env.HOSTNAME : DEFAULT_HOSTNAME;
350
350
  }
351
+ function initHostname(init) {
352
+ return isHostname(init.hostname) ? init.hostname : hostnameOf(init.env);
353
+ }
351
354
  function ownNames(hostname) {
352
355
  return [.../* @__PURE__ */ new Set([hostname.toLowerCase(), ...LIBC_HOSTNAMES])];
353
356
  }
@@ -2775,7 +2778,7 @@ var KERNEL_VERSION, OS_RELEASE;
2775
2778
  var init_version = __esm({
2776
2779
  "src/version.ts"() {
2777
2780
  "use strict";
2778
- KERNEL_VERSION = true ? "1.140.1" : "0.0.0-dev";
2781
+ KERNEL_VERSION = true ? "1.140.3" : "0.0.0-dev";
2779
2782
  OS_RELEASE = "6.0.0-slicc";
2780
2783
  }
2781
2784
  });
@@ -6259,7 +6262,7 @@ function kernelWrappers(imports, module, deps) {
6259
6262
  goneCwdGetcwd(imports, fsOf, kernelGlue);
6260
6263
  kernelLink(imports, fsOf, memory, kernelGlue);
6261
6264
  devCreations(imports, fsOf, memory, kernelGlue);
6262
- kernelUname(imports, hostnameOf(init.env), memory, kernelGlue);
6265
+ kernelUname(imports, initHostname(init), memory, kernelGlue);
6263
6266
  wrapImport(
6264
6267
  imports,
6265
6268
  "flock",
@@ -6432,7 +6435,7 @@ async function runWasmProcess(init, port2, deps = {}) {
6432
6435
  streams2.quitting = on;
6433
6436
  });
6434
6437
  atExit = () => streams2.exiting();
6435
- useMounts(running.FS, init.env, true);
6438
+ useMounts(running.FS, { ...init.env, HOSTNAME: initHostname(init) }, true);
6436
6439
  useZeroDevices(running.FS);
6437
6440
  useProcfs(running.FS, sys, init.pid);
6438
6441
  if (init.fork) restoreForkedStreams(running.FS, streams2, init.fork.streams ?? []);
@@ -6470,7 +6473,7 @@ async function runWasmProcess(init, port2, deps = {}) {
6470
6473
  ...callerOwner(running.FS, init)
6471
6474
  });
6472
6475
  running.sliccKernel.http = createHttpKernel(transport);
6473
- running.sliccKernel.hostname = hostnameOf(init.env);
6476
+ running.sliccKernel.hostname = initHostname(init);
6474
6477
  running.sliccKernel.net = createSocketKernel({
6475
6478
  transport,
6476
6479
  Fs: running.FS,
@@ -9307,6 +9310,8 @@ var init_wasi_fds = __esm({
9307
9310
  if (kernelDevice !== void 0) return kernelDevice;
9308
9311
  const alias = stdioAlias(path);
9309
9312
  if (alias !== void 0) return this.reopen(alias);
9313
+ const outside = this.escaped(path, oflags, rights);
9314
+ if (outside !== void 0) return this.open(outside, oflags, rights, fdflags, mode);
9310
9315
  if (exclusive && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
9311
9316
  return this.regular(path, void 0, oflags, rights, fdflags, mode, true);
9312
9317
  }
@@ -9325,6 +9330,12 @@ var init_wasi_fds = __esm({
9325
9330
  refuseWrite(s, oflags, rights);
9326
9331
  return this.regular(path, s, oflags, rights, fdflags, mode);
9327
9332
  }
9333
+ escaped(path, oflags, rights) {
9334
+ const outside = this.fs.escape?.(path);
9335
+ if (outside === void 0) return void 0;
9336
+ refuseWrite({ readonly: true }, oflags | (oflags & OFLAGS.CREAT ? OFLAGS.TRUNC : 0), rights);
9337
+ return outside;
9338
+ }
9328
9339
  regular(path, s, oflags, rights, fdflags, mode, created = false) {
9329
9340
  if (s?.isFifo) return this.kernelFifo(path, s, oflags, rights, fdflags);
9330
9341
  if (s?.isSocket) throw new WasiError("ENXIO");
@@ -12396,10 +12407,12 @@ function directMiss(err, path) {
12396
12407
  if (err?.direct !== true) return false;
12397
12408
  return !path.split("/").some((part) => part === "." || part === "..");
12398
12409
  }
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) => {
12410
+ function routing(tree, toProc, shadowing) {
12411
+ return (p, inner, own, follow3 = true, outside) => {
12412
+ const proc = (q) => {
12413
+ const target = outside ? tree.escape(q) : void 0;
12414
+ return target === void 0 ? inner(q) : outside(target);
12415
+ };
12403
12416
  if (inProc(p)) return proc(p);
12404
12417
  if (shadowing()) {
12405
12418
  const real = toProc(p, follow3);
@@ -12414,6 +12427,11 @@ function procfsBridge(fs, tree) {
12414
12427
  return proc(real);
12415
12428
  }
12416
12429
  };
12430
+ }
12431
+ function procfsBridge(fs, tree) {
12432
+ const toProc = (path, follow3) => procPath(fs, path, follow3);
12433
+ const shadowing = physicalProc(fs);
12434
+ const via = routing(tree, toProc, shadowing);
12417
12435
  const readOnly2 = (paths, run) => {
12418
12436
  const physical2 = shadowing();
12419
12437
  for (const [p, follow3] of paths) {
@@ -12436,12 +12454,16 @@ function procfsBridge(fs, tree) {
12436
12454
  readFile: (p) => via(
12437
12455
  p,
12438
12456
  (q) => tree.read(q),
12439
- () => fs.readFile(p)
12457
+ () => fs.readFile(p),
12458
+ true,
12459
+ (t) => fs.readFile(t)
12440
12460
  ),
12441
12461
  stat: (p) => via(
12442
12462
  p,
12443
12463
  (q) => tree.stat(q),
12444
- () => fs.stat(p)
12464
+ () => fs.stat(p),
12465
+ true,
12466
+ (t) => fs.stat(t)
12445
12467
  ),
12446
12468
  lstat: (p) => via(
12447
12469
  p,
@@ -12520,6 +12542,7 @@ function procfsBridge(fs, tree) {
12520
12542
  return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want, seen) ?? late(p));
12521
12543
  },
12522
12544
  kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
12545
+ escape: (p) => inProc(p) ? tree.escape(p) : void 0,
12523
12546
  pinned: (handle) => {
12524
12547
  const bytes = snapshots.get(handle);
12525
12548
  return bytes ? frozen(bytes) : fs.pinned?.(handle) ?? fs;
@@ -12700,6 +12723,12 @@ var init_wasi_procfs = __esm({
12700
12723
  if (node.kind !== "dir") throw syncError("ENOTDIR", path);
12701
12724
  return node.names();
12702
12725
  }
12726
+ escape(path) {
12727
+ const node = this.node(this.parts(path, true));
12728
+ if (node?.kind !== "link" || !node.target.startsWith("/")) return void 0;
12729
+ if (node.denied) throw syncError("EACCES", path);
12730
+ return node.target;
12731
+ }
12703
12732
  readlink(path) {
12704
12733
  const node = this.find(path, false);
12705
12734
  if (node.kind !== "link") throw syncError("EINVAL", path);