@ai-ecoverse/slicc-kernel 1.64.0 → 1.64.1

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.
@@ -2126,12 +2126,27 @@ var init_kernel_streams = __esm({
2126
2126
  const original = fs[name2];
2127
2127
  if (typeof original !== "function") continue;
2128
2128
  fs[name2] = (path, ...rest2) => {
2129
- if (!isPtyPath(path)) return original.call(fs, path, ...rest2);
2129
+ const owned = this.ownedTty(path);
2130
+ if (owned && isPtyPath(path)) return this.owned(path, ptyStat(path));
2131
+ if (!isPtyPath(path)) {
2132
+ const st = original.call(fs, path, ...rest2);
2133
+ return owned && TTY_PATH.test(path) ? this.owned(path, st) : st;
2134
+ }
2130
2135
  this.existingPty(path);
2131
2136
  return ptyStat(path);
2132
2137
  };
2133
2138
  }
2134
2139
  }
2140
+ ownedTty(path) {
2141
+ return this.options.owners === true && this.sys.ttyOwner !== void 0 && path !== "/dev/ptmx";
2142
+ }
2143
+ owned(path, st) {
2144
+ const ask = this.sys.ttyOwner;
2145
+ const owner = this.call(() => ask.call(this.sys, path));
2146
+ if (!owner) return st;
2147
+ const mode = st.mode & ~4095 | (owner.mode ?? 400);
2148
+ return { ...st, uid: owner.uid, gid: owner.gid, mode };
2149
+ }
2135
2150
  existingPty(path) {
2136
2151
  const n = PTY_PATH.exec(path)?.[1];
2137
2152
  const exists = n === void 0 ? this.sys.openPty !== void 0 : this.sys.ptyNumbers?.().includes(Number(n)) ?? false;
@@ -4230,6 +4245,9 @@ function kernelSys(transport) {
4230
4245
  ttyNames() {
4231
4246
  return json(call2({ op: "fd-tty-names" }, "fd-tty-names"));
4232
4247
  },
4248
+ ttyOwner(name2) {
4249
+ return json(call2({ op: "fd-tty-owner", name: name2 }, `fd-tty-owner ${name2}`));
4250
+ },
4233
4251
  openTty(name2) {
4234
4252
  const req = name2 === void 0 ? { op: "fd-open-tty" } : { op: "fd-open-tty", name: name2 };
4235
4253
  return json(call2(req, `fd-open-tty ${name2 ?? ""}`));
@@ -4474,7 +4492,8 @@ async function runWasmProcess(init, port2, deps = {}) {
4474
4492
  early = () => signals.quiet(() => vfs.flushDirty());
4475
4493
  const sigpipe = () => running.sliccSigpipe?.() === 1;
4476
4494
  const restartable = () => signals.restartable();
4477
- const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable });
4495
+ const owners = init.owners ? { owners: true } : {};
4496
+ const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable, ...owners });
4478
4497
  trackCloseOnExec(running.FS);
4479
4498
  quietQuit(running.FS);
4480
4499
  useMounts(running.FS, init.env, true);