@ai-ecoverse/slicc-kernel 1.84.1 → 1.85.0
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.
package/README.md
CHANGED
|
@@ -628,7 +628,7 @@ With `users: 'enforce'` the kernel checks every file call that reaches it agains
|
|
|
628
628
|
|
|
629
629
|
### `/dev/sealed`
|
|
630
630
|
|
|
631
|
-
A character device (`0666`, major 10, minor 250) through which a program talks to the embedder's `sealed` hook (`createKernel({ sealed })`), the secrets vault on the page. Emscripten
|
|
631
|
+
A character device (`0666`, major 10, minor 250) through which a program talks to the embedder's `sealed` hook (`createKernel({ sealed })`), the secrets vault on the page. Emscripten programs, WASI programs (`std::fs`) and JS programs (`ctx.open`, `ctx.sync.open`, listed by `ctx.fs.readdir('/dev')`) all open it, through the same kernel device, with the same framing, errnos and stamp: a JS program's stamp is built in the kernel from its own process, as for any other. A JS descriptor opened read-only refuses writes with `EBADF`. Emscripten programs see it in `/dev`. JS `stat` has no device numbers, and WASI's has none either.
|
|
632
632
|
- **State per open:** each `open()` is independent; `dup` and fork share one, as on Linux.
|
|
633
633
|
- **One write is one request:** a single UTF-8 JSON object of at most 64 KiB with `v` 1 and a known `op` (`seal`, `placeholder`, `list`, `test`, `request`, `status`, `cancel`, `materialize`). The write takes all the bytes or fails: `EMSGSIZE` over 64 KiB, `EINVAL` for anything else that isn't such an object. These are the only errnos; every other outcome is a JSON reply. The kernel zeroes the bytes it was given once it has parsed them.
|
|
634
634
|
- **The stamp:** the hook gets the request with `caller: { pid, ppid, uid, gid, user?, groups, users, tag? }`, from the process that writes (at the write; not the one that opened it): `uid` and `gid` the effective ids, `user` the `/etc/passwd` name of `uid` read at that moment (left out when there is none), `groups` the process's supplementary groups (only root can change them), `users` the kernel's `users` mode, since a uid means more under `'enforce'`, and `tag` the process's tag (see `kernel.run`) when it has one. A `caller` in the request is replaced.
|
|
@@ -4303,6 +4303,7 @@ function* lookup(abs) {
|
|
|
4303
4303
|
if (DEVICES.includes(name2)) return { kind: "device" };
|
|
4304
4304
|
if (name2 === "tty") return { kind: "tty" };
|
|
4305
4305
|
if (name2 === "clipboard") return { kind: "clipboard" };
|
|
4306
|
+
if (name2 === "sealed") return { kind: "sealed" };
|
|
4306
4307
|
const std = STDIO3.indexOf(name2);
|
|
4307
4308
|
if (std >= 0) return { kind: "link", target: `${SELF_FD}/${std}`, fd: std };
|
|
4308
4309
|
if (name2 === "fd") return { kind: "link", target: SELF_FD };
|
|
@@ -4346,8 +4347,7 @@ function* fdStat(fd, path) {
|
|
|
4346
4347
|
return yield* pathStat(file.path);
|
|
4347
4348
|
}
|
|
4348
4349
|
if (info.terminal) return yield* terminalStat(info.terminal);
|
|
4349
|
-
if (
|
|
4350
|
-
return nodeStat(CHAR | 438);
|
|
4350
|
+
if (CHAR_KINDS.has(info.kind)) return nodeStat(CHAR | 438);
|
|
4351
4351
|
if (info.kind === "socket") return nodeStat(49663);
|
|
4352
4352
|
return nodeStat(4480);
|
|
4353
4353
|
}
|
|
@@ -4357,7 +4357,7 @@ function* fdTarget(fd, path) {
|
|
|
4357
4357
|
if (info.kind === "file") return (yield { op: "fd-vfs-stat", fd }).path;
|
|
4358
4358
|
if (info.terminal) return info.terminal;
|
|
4359
4359
|
if (info.meta && "device" in info.meta) return `/dev/${info.meta.device}`;
|
|
4360
|
-
if (info.kind === "clipboard") return
|
|
4360
|
+
if (info.kind === "clipboard" || info.kind === "sealed") return `/dev/${info.kind}`;
|
|
4361
4361
|
return `${info.kind === "socket" ? "socket" : "pipe"}:[${fd}]`;
|
|
4362
4362
|
}
|
|
4363
4363
|
function linkStat(target) {
|
|
@@ -4371,6 +4371,7 @@ function* devStat(abs, follow2) {
|
|
|
4371
4371
|
case "device":
|
|
4372
4372
|
case "tty":
|
|
4373
4373
|
case "clipboard":
|
|
4374
|
+
case "sealed":
|
|
4374
4375
|
return nodeStat(CHAR | 438);
|
|
4375
4376
|
case "terminal":
|
|
4376
4377
|
return yield* terminalStat(node.name);
|
|
@@ -4405,7 +4406,7 @@ function* devReaddir(abs) {
|
|
|
4405
4406
|
if (node.kind !== "dir") throw new JsCallError("ENOTDIR", abs);
|
|
4406
4407
|
const names = yield { op: "fd-tty-names" };
|
|
4407
4408
|
const ttys = names.filter((n) => /^\/dev\/tty\d+$/.test(n)).map((n) => n.slice(5));
|
|
4408
|
-
return [...DEVICES, "clipboard", "tty", "fd", ...STDIO3, ...ttys].sort();
|
|
4409
|
+
return [...DEVICES, "clipboard", "sealed", "tty", "fd", ...STDIO3, ...ttys].sort();
|
|
4409
4410
|
}
|
|
4410
4411
|
function* aliasOf(fd, abs, o) {
|
|
4411
4412
|
const info = yield* fdInfo(fd, abs);
|
|
@@ -4439,6 +4440,8 @@ function* opened(abs, o) {
|
|
|
4439
4440
|
const flags = write2 ? o.read === true ? 2 : 1 : 0;
|
|
4440
4441
|
return { fd: yield { op: "fd-open-clipboard", flags }, file: false };
|
|
4441
4442
|
}
|
|
4443
|
+
case "sealed":
|
|
4444
|
+
return { fd: yield { op: "fd-open-sealed" }, file: false };
|
|
4442
4445
|
case "terminal": {
|
|
4443
4446
|
const req = node.pts === void 0 ? { op: "fd-open-tty", name: node.name } : { op: "pty-slave-open", n: node.pts, noctty: true };
|
|
4444
4447
|
return { fd: yield req, file: false };
|
|
@@ -4603,7 +4606,7 @@ function readWholeSync(file) {
|
|
|
4603
4606
|
file.close();
|
|
4604
4607
|
}
|
|
4605
4608
|
}
|
|
4606
|
-
var DEV_READ_MAX, DEVICES, STDIO3, SELF_FD, S_IFMT, DIR, LINK, CHAR, BORN;
|
|
4609
|
+
var DEV_READ_MAX, DEVICES, STDIO3, SELF_FD, S_IFMT, DIR, LINK, CHAR, BORN, CHAR_KINDS;
|
|
4607
4610
|
var init_js_dev = __esm({
|
|
4608
4611
|
"src/process/js/js-dev.ts"() {
|
|
4609
4612
|
"use strict";
|
|
@@ -4619,6 +4622,12 @@ var init_js_dev = __esm({
|
|
|
4619
4622
|
LINK = 40960;
|
|
4620
4623
|
CHAR = 8192;
|
|
4621
4624
|
BORN = Date.now();
|
|
4625
|
+
CHAR_KINDS = /* @__PURE__ */ new Set([
|
|
4626
|
+
"device",
|
|
4627
|
+
"tty",
|
|
4628
|
+
"clipboard",
|
|
4629
|
+
"sealed"
|
|
4630
|
+
]);
|
|
4622
4631
|
}
|
|
4623
4632
|
});
|
|
4624
4633
|
|