@ai-ecoverse/slicc-kernel 1.136.7 → 1.137.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 +22 -4
- package/dist/index.js +3 -1
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +666 -164
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +72 -12
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +653 -160
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +72 -12
- package/dist/process-worker.js.map +4 -4
- package/dist/testing.js +1 -0
- package/dist/testing.js.map +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/kernel/net/dns-stub.d.ts +65 -0
- package/dist/types/kernel/net/resolver.d.ts +4 -1
- package/dist/types/kernel/net/sealed-pg.d.ts +1 -0
- package/dist/types/kernel/net/uplink.d.ts +3 -1
- package/dist/types/kernel/proc-info.d.ts +2 -0
- package/dist/types/kernel/socket.d.ts +3 -1
- package/dist/types/launcher.d.ts +2 -0
- package/dist/types/node.d.ts +1 -0
- package/dist/types/process/process-runtime.d.ts +4 -1
- package/dist/types/process/procfs.d.ts +1 -1
- package/dist/types/process/wasi/wasi-procfs.d.ts +2 -1
- package/dist/types/serve.d.ts +2 -0
- package/dist/types/testing.d.ts +1 -0
- package/package.json +3 -3
package/dist/process-worker.js
CHANGED
|
@@ -2783,7 +2783,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
2783
2783
|
var init_version = __esm({
|
|
2784
2784
|
"src/version.ts"() {
|
|
2785
2785
|
"use strict";
|
|
2786
|
-
KERNEL_VERSION = true ? "1.
|
|
2786
|
+
KERNEL_VERSION = true ? "1.137.0" : "0.0.0-dev";
|
|
2787
2787
|
OS_RELEASE = "6.0.0-slicc";
|
|
2788
2788
|
}
|
|
2789
2789
|
});
|
|
@@ -5484,6 +5484,20 @@ var init_cred = __esm({
|
|
|
5484
5484
|
}
|
|
5485
5485
|
});
|
|
5486
5486
|
|
|
5487
|
+
// src/kernel/proc-info.ts
|
|
5488
|
+
function mayTrace(viewer, target) {
|
|
5489
|
+
const by = viewer?.cred;
|
|
5490
|
+
const of = target.cred;
|
|
5491
|
+
if (!by || !of || by.euid === 0) return true;
|
|
5492
|
+
const uid = of.ruid === by.euid && of.euid === by.euid && of.suid === by.euid;
|
|
5493
|
+
return uid && of.rgid === by.egid && of.egid === by.egid && of.sgid === by.egid;
|
|
5494
|
+
}
|
|
5495
|
+
var init_proc_info = __esm({
|
|
5496
|
+
"src/kernel/proc-info.ts"() {
|
|
5497
|
+
"use strict";
|
|
5498
|
+
}
|
|
5499
|
+
});
|
|
5500
|
+
|
|
5487
5501
|
// src/process/procfs.ts
|
|
5488
5502
|
function isSysFile(at) {
|
|
5489
5503
|
return typeof at === "string" || typeof at === "function";
|
|
@@ -5687,6 +5701,25 @@ function attr(node) {
|
|
|
5687
5701
|
blocks: 0
|
|
5688
5702
|
};
|
|
5689
5703
|
}
|
|
5704
|
+
function withPidFiles(names, extra) {
|
|
5705
|
+
return [.../* @__PURE__ */ new Set([...names, ...PID_FILES, ...extra])];
|
|
5706
|
+
}
|
|
5707
|
+
function exeNodes(fresh, info, error, self) {
|
|
5708
|
+
return {
|
|
5709
|
+
exeLink: (parent, target, own = false) => {
|
|
5710
|
+
const of = info(target, own);
|
|
5711
|
+
const exe = of?.exe;
|
|
5712
|
+
if (!of || exe === void 0) throw error();
|
|
5713
|
+
const link = fresh(parent, "exe", LINK_MODE2);
|
|
5714
|
+
link.node_ops.readlink = () => {
|
|
5715
|
+
if (!mayTrace(info(self, true), of)) throw error(EACCES);
|
|
5716
|
+
return exe;
|
|
5717
|
+
};
|
|
5718
|
+
return link;
|
|
5719
|
+
},
|
|
5720
|
+
hasExe: (target, own = false) => info(target, own)?.exe === void 0 ? [] : ["exe"]
|
|
5721
|
+
};
|
|
5722
|
+
}
|
|
5690
5723
|
function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
5691
5724
|
const { lookupPath, createNode, hashRemoveNode } = Fs;
|
|
5692
5725
|
const procList = sys.procList?.bind(sys);
|
|
@@ -5753,14 +5786,16 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
5753
5786
|
dir.node_ops.readdir = () => [".", "..", ...Object.keys(tree)];
|
|
5754
5787
|
return dir;
|
|
5755
5788
|
};
|
|
5756
|
-
const
|
|
5789
|
+
const exe = exeNodes(fresh, (at, own) => find(procList().processes, at, own), error, pid);
|
|
5790
|
+
const pidNames = (names) => withPidFiles(names, exe.hasExe(pid, true));
|
|
5757
5791
|
const pidDir = (name2, target) => {
|
|
5758
5792
|
const dir = fresh(proc, name2, DIR_MODE2);
|
|
5759
5793
|
dir.node_ops.lookup = (parent, child) => {
|
|
5794
|
+
if (child === "exe") return exe.exeLink(parent, target);
|
|
5760
5795
|
if (!PID_FILES.includes(child)) throw error();
|
|
5761
5796
|
return file(parent, child, pidContent(target, child));
|
|
5762
5797
|
};
|
|
5763
|
-
dir.node_ops.readdir = () => [".", "..", ...PID_FILES];
|
|
5798
|
+
dir.node_ops.readdir = () => [".", "..", ...PID_FILES, ...exe.hasExe(target)];
|
|
5764
5799
|
return dir;
|
|
5765
5800
|
};
|
|
5766
5801
|
const scans = /* @__PURE__ */ new Map();
|
|
@@ -5844,6 +5879,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
5844
5879
|
self.node_ops = {
|
|
5845
5880
|
...selfOps,
|
|
5846
5881
|
lookup: (parent, name2) => {
|
|
5882
|
+
if (name2 === "exe") return exe.exeLink(parent, pid, true);
|
|
5847
5883
|
if (PID_FILES.includes(name2)) {
|
|
5848
5884
|
return file(parent, name2, pidContent(pid, name2, true));
|
|
5849
5885
|
}
|
|
@@ -5853,11 +5889,12 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
5853
5889
|
readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
|
|
5854
5890
|
};
|
|
5855
5891
|
}
|
|
5856
|
-
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, SYS_TREE, sigMask, STATES, tagLine;
|
|
5892
|
+
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, EACCES, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, SYS_TREE, sigMask, STATES, tagLine;
|
|
5857
5893
|
var init_procfs = __esm({
|
|
5858
5894
|
"src/process/procfs.ts"() {
|
|
5859
5895
|
"use strict";
|
|
5860
5896
|
init_cred();
|
|
5897
|
+
init_proc_info();
|
|
5861
5898
|
init_version();
|
|
5862
5899
|
init_process_fds();
|
|
5863
5900
|
HZ = 100;
|
|
@@ -5866,6 +5903,7 @@ var init_procfs = __esm({
|
|
|
5866
5903
|
LINK_MODE2 = 41471;
|
|
5867
5904
|
ENOENT = 44;
|
|
5868
5905
|
EINVAL = 28;
|
|
5906
|
+
EACCES = 2;
|
|
5869
5907
|
UID = 1e3;
|
|
5870
5908
|
KIB = 1024;
|
|
5871
5909
|
FALLBACK_MEMORY = 4 * KIB * KIB * KIB;
|
|
@@ -6165,11 +6203,19 @@ function identify(transport, init) {
|
|
|
6165
6203
|
function liveParent(imports, parent, glue) {
|
|
6166
6204
|
wrapImport(imports, "getppid", glue, () => parent);
|
|
6167
6205
|
}
|
|
6168
|
-
function
|
|
6206
|
+
function seedInherited(transport, seeded) {
|
|
6207
|
+
const bits = inheritedSignals(transport);
|
|
6208
|
+
seeded.bits |= bits;
|
|
6209
|
+
return bits;
|
|
6210
|
+
}
|
|
6211
|
+
function signalMasks(m, seeded = { bits: 0 }) {
|
|
6169
6212
|
const mask = m.sliccSigMask;
|
|
6170
6213
|
const caught = mask?.(0) ?? -1;
|
|
6171
6214
|
if (!mask || caught === -1) return null;
|
|
6172
|
-
|
|
6215
|
+
const ignored = mask(1);
|
|
6216
|
+
const defaults = seeded.bits & ~ignored & ~caught;
|
|
6217
|
+
seeded.bits &= ~defaults;
|
|
6218
|
+
return { caught, ignored, restart: mask(2), ...defaults ? { defaults } : {} };
|
|
6173
6219
|
}
|
|
6174
6220
|
function reportGrowth(imports, publish, glue) {
|
|
6175
6221
|
wrapImport(imports, "resizeHeap", glue, (resize) => (...args) => {
|
|
@@ -6273,13 +6319,12 @@ function sigpipeSpared(transport) {
|
|
|
6273
6319
|
return r.ok && !(r.kind === "json" && r.json === "terminate");
|
|
6274
6320
|
}
|
|
6275
6321
|
async function runWasmProcess(init, port2, deps = {}) {
|
|
6322
|
+
const seeded = { bits: 0 };
|
|
6276
6323
|
const signals = new SignalGate(
|
|
6277
|
-
createSyncSabTransport(init.sab, port2, {
|
|
6278
|
-
memory: () => memory?.buffer.byteLength ?? 0
|
|
6279
|
-
}),
|
|
6324
|
+
createSyncSabTransport(init.sab, port2, { memory: () => memory?.buffer.byteLength ?? 0 }),
|
|
6280
6325
|
new Int32Array(init.sab, 0, SAB_HEADER_I32),
|
|
6281
6326
|
{
|
|
6282
|
-
masks: () => signalMasks(module),
|
|
6327
|
+
masks: () => signalMasks(module, seeded),
|
|
6283
6328
|
raise: (sig) => module.sliccRaise?.(sig),
|
|
6284
6329
|
timer: (which) => {
|
|
6285
6330
|
const running2 = module;
|
|
@@ -6312,7 +6357,7 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
6312
6357
|
sliccPid: id.pid,
|
|
6313
6358
|
sliccPpid: id.ppid,
|
|
6314
6359
|
sliccEnv: init.env,
|
|
6315
|
-
sliccKernel: { sigInherited: () =>
|
|
6360
|
+
sliccKernel: { sigInherited: () => seedInherited(transport, seeded) },
|
|
6316
6361
|
print: say(1),
|
|
6317
6362
|
printErr: say(2),
|
|
6318
6363
|
instantiateWasm(imports, done) {
|
|
@@ -12498,6 +12543,7 @@ var DIR_MODE3, FILE_MODE2, LINK_MODE3, PID_NAMES, SYSTEM_NAMES, ProcTree, FOLLOW
|
|
|
12498
12543
|
var init_wasi_procfs = __esm({
|
|
12499
12544
|
"src/process/wasi/wasi-procfs.ts"() {
|
|
12500
12545
|
"use strict";
|
|
12546
|
+
init_proc_info();
|
|
12501
12547
|
init_sync_fs_wire();
|
|
12502
12548
|
init_process_fds();
|
|
12503
12549
|
init_procfs();
|
|
@@ -12558,7 +12604,16 @@ var init_wasi_procfs = __esm({
|
|
|
12558
12604
|
if (!/^[1-9]\d*$/.test(top) || !this.alive(Number(top))) return void 0;
|
|
12559
12605
|
if (leaf === "task") return this.task(Number(top), rest2);
|
|
12560
12606
|
if (rest2.length > 0) return void 0;
|
|
12561
|
-
if (leaf === void 0)
|
|
12607
|
+
if (leaf === void 0) {
|
|
12608
|
+
const exe = () => this.info(Number(top))?.exe === void 0 ? [] : ["exe"];
|
|
12609
|
+
return { kind: "dir", names: () => [...PID_NAMES, ...exe(), "task"] };
|
|
12610
|
+
}
|
|
12611
|
+
if (leaf === "exe") {
|
|
12612
|
+
const info = this.info(Number(top));
|
|
12613
|
+
if (info?.exe === void 0) return void 0;
|
|
12614
|
+
const denied = !mayTrace(this.ownInfo(), info);
|
|
12615
|
+
return { kind: "link", target: info.exe, ...denied ? { denied } : {} };
|
|
12616
|
+
}
|
|
12562
12617
|
if (!PID_NAMES.includes(leaf)) return void 0;
|
|
12563
12618
|
return {
|
|
12564
12619
|
kind: "file",
|
|
@@ -12570,6 +12625,10 @@ var init_wasi_procfs = __esm({
|
|
|
12570
12625
|
}
|
|
12571
12626
|
};
|
|
12572
12627
|
}
|
|
12628
|
+
ownInfo() {
|
|
12629
|
+
const processes2 = this.listing().processes;
|
|
12630
|
+
return processes2.find((p) => p.tid === this.pid) ?? processes2.find((p) => p.pid === this.pid);
|
|
12631
|
+
}
|
|
12573
12632
|
info(pid) {
|
|
12574
12633
|
return this.listing().processes.find((p) => p.pid === pid);
|
|
12575
12634
|
}
|
|
@@ -12633,6 +12692,7 @@ var init_wasi_procfs = __esm({
|
|
|
12633
12692
|
readlink(path) {
|
|
12634
12693
|
const node = this.find(path, false);
|
|
12635
12694
|
if (node.kind !== "link") throw syncError("EINVAL", path);
|
|
12695
|
+
if (node.denied) throw syncError("EACCES", path);
|
|
12636
12696
|
return node.target;
|
|
12637
12697
|
}
|
|
12638
12698
|
exists(path) {
|