@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.
@@ -6895,12 +6895,27 @@ var init_kernel_streams = __esm({
6895
6895
  const original = fs[name2];
6896
6896
  if (typeof original !== "function") continue;
6897
6897
  fs[name2] = (path, ...rest2) => {
6898
- if (!isPtyPath(path)) return original.call(fs, path, ...rest2);
6898
+ const owned = this.ownedTty(path);
6899
+ if (owned && isPtyPath(path)) return this.owned(path, ptyStat(path));
6900
+ if (!isPtyPath(path)) {
6901
+ const st = original.call(fs, path, ...rest2);
6902
+ return owned && TTY_PATH.test(path) ? this.owned(path, st) : st;
6903
+ }
6899
6904
  this.existingPty(path);
6900
6905
  return ptyStat(path);
6901
6906
  };
6902
6907
  }
6903
6908
  }
6909
+ ownedTty(path) {
6910
+ return this.options.owners === true && this.sys.ttyOwner !== void 0 && path !== "/dev/ptmx";
6911
+ }
6912
+ owned(path, st) {
6913
+ const ask = this.sys.ttyOwner;
6914
+ const owner = this.call(() => ask.call(this.sys, path));
6915
+ if (!owner) return st;
6916
+ const mode = st.mode & ~4095 | (owner.mode ?? 400);
6917
+ return { ...st, uid: owner.uid, gid: owner.gid, mode };
6918
+ }
6904
6919
  existingPty(path) {
6905
6920
  const n = PTY_PATH.exec(path)?.[1];
6906
6921
  const exists = n === void 0 ? this.sys.openPty !== void 0 : this.sys.ptyNumbers?.().includes(Number(n)) ?? false;
@@ -8980,6 +8995,9 @@ function kernelSys(transport) {
8980
8995
  ttyNames() {
8981
8996
  return json(call2({ op: "fd-tty-names" }, "fd-tty-names"));
8982
8997
  },
8998
+ ttyOwner(name2) {
8999
+ return json(call2({ op: "fd-tty-owner", name: name2 }, `fd-tty-owner ${name2}`));
9000
+ },
8983
9001
  openTty(name2) {
8984
9002
  const req = name2 === void 0 ? { op: "fd-open-tty" } : { op: "fd-open-tty", name: name2 };
8985
9003
  return json(call2(req, `fd-open-tty ${name2 ?? ""}`));
@@ -9224,7 +9242,8 @@ async function runWasmProcess(init, port3, deps = {}) {
9224
9242
  early = () => signals.quiet(() => vfs.flushDirty());
9225
9243
  const sigpipe = () => running.sliccSigpipe?.() === 1;
9226
9244
  const restartable = () => signals.restartable();
9227
- const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable });
9245
+ const owners = init.owners ? { owners: true } : {};
9246
+ const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable, ...owners });
9228
9247
  trackCloseOnExec(running.FS);
9229
9248
  quietQuit(running.FS);
9230
9249
  useMounts(running.FS, init.env, true);