@ai-ecoverse/slicc-kernel 1.43.0 → 1.44.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 +42 -14
- package/dist/driver-worker.js +5 -1
- package/dist/driver-worker.js.map +2 -2
- package/dist/index.js +18 -3
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +591 -198
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +5 -1
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +65 -6
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +594 -209
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +65 -6
- package/dist/process-worker.js.map +3 -3
- package/package.json +3 -3
package/dist/process-worker.js
CHANGED
|
@@ -2896,6 +2896,9 @@ var init_process_fork = __esm({
|
|
|
2896
2896
|
function status(r) {
|
|
2897
2897
|
return r.ok ? 0 : -wasiErrno(r.errno);
|
|
2898
2898
|
}
|
|
2899
|
+
function credOf(r) {
|
|
2900
|
+
return r.ok ? r.json : -wasiErrno(r.errno);
|
|
2901
|
+
}
|
|
2899
2902
|
function number(r) {
|
|
2900
2903
|
if (!r.ok) return -wasiErrno(r.errno);
|
|
2901
2904
|
return r.kind === "json" && typeof r.json === "number" ? r.json : -wasiErrno("EIO");
|
|
@@ -3103,6 +3106,8 @@ function createProcessKernel(deps) {
|
|
|
3103
3106
|
setsid: () => number(call2({ op: "proc-setsid" }, "setsid")),
|
|
3104
3107
|
getpgid: (pid) => number(call2({ op: "proc-getpgid", pid }, "getpgid")),
|
|
3105
3108
|
getsid: (pid) => number(call2({ op: "proc-getsid", pid }, "getsid")),
|
|
3109
|
+
cred: () => credOf(call2({ op: "proc-cred" }, "cred")),
|
|
3110
|
+
setcred: (change) => credOf(call2({ op: "proc-setcred", change }, "setcred")),
|
|
3106
3111
|
tcgetpgrp(fd) {
|
|
3107
3112
|
const kfd = Fs.getStream(fd)?.sliccKernelFd;
|
|
3108
3113
|
if (kfd === void 0) return -wasiErrno("ENOTTY");
|
|
@@ -3436,6 +3441,25 @@ var init_process_sockets = __esm({
|
|
|
3436
3441
|
}
|
|
3437
3442
|
});
|
|
3438
3443
|
|
|
3444
|
+
// src/kernel/cred.ts
|
|
3445
|
+
var ROOT, MAX_GROUPS;
|
|
3446
|
+
var init_cred = __esm({
|
|
3447
|
+
"src/kernel/cred.ts"() {
|
|
3448
|
+
"use strict";
|
|
3449
|
+
init_types();
|
|
3450
|
+
ROOT = Object.freeze({
|
|
3451
|
+
ruid: 0,
|
|
3452
|
+
euid: 0,
|
|
3453
|
+
suid: 0,
|
|
3454
|
+
rgid: 0,
|
|
3455
|
+
egid: 0,
|
|
3456
|
+
sgid: 0,
|
|
3457
|
+
groups: [0]
|
|
3458
|
+
});
|
|
3459
|
+
MAX_GROUPS = 65536;
|
|
3460
|
+
}
|
|
3461
|
+
});
|
|
3462
|
+
|
|
3439
3463
|
// src/process/procfs.ts
|
|
3440
3464
|
function commOf(info) {
|
|
3441
3465
|
const name = info.argv[0] ?? "";
|
|
@@ -3496,7 +3520,8 @@ function pidStat(info, boot) {
|
|
|
3496
3520
|
}
|
|
3497
3521
|
function pidStatus(info) {
|
|
3498
3522
|
const state = info.state === "Z" ? "Z (zombie)" : "S (sleeping)";
|
|
3499
|
-
const
|
|
3523
|
+
const c = info.cred ?? ROOT;
|
|
3524
|
+
const ids = (r, e, s) => `${r} ${e} ${s} ${e}`;
|
|
3500
3525
|
return [
|
|
3501
3526
|
`Name: ${commOf(info)}`,
|
|
3502
3527
|
`Umask: ${(info.umask ?? 18).toString(8).padStart(4, "0")}`,
|
|
@@ -3506,12 +3531,12 @@ function pidStatus(info) {
|
|
|
3506
3531
|
`Pid: ${info.pid}`,
|
|
3507
3532
|
`PPid: ${info.ppid}`,
|
|
3508
3533
|
"TracerPid: 0",
|
|
3509
|
-
`Uid: ${ids}`,
|
|
3510
|
-
`Gid: ${ids}`,
|
|
3534
|
+
`Uid: ${ids(c.ruid, c.euid, c.suid)}`,
|
|
3535
|
+
`Gid: ${ids(c.rgid, c.egid, c.sgid)}`,
|
|
3511
3536
|
"FDSize: 64",
|
|
3512
3537
|
`VmSize: ${Math.ceil(info.memory / KIB)} kB`,
|
|
3513
3538
|
`VmRSS: ${Math.ceil(info.memory / KIB)} kB`,
|
|
3514
|
-
|
|
3539
|
+
`Groups: ${c.groups.join(" ")}`,
|
|
3515
3540
|
`NSpid: ${info.pid}`,
|
|
3516
3541
|
`NSpgid: ${info.pgid}`,
|
|
3517
3542
|
`NSsid: ${info.sid}`,
|
|
@@ -3730,6 +3755,7 @@ var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, ESRCH, EINVAL, UID, KIB, FALLB
|
|
|
3730
3755
|
var init_procfs = __esm({
|
|
3731
3756
|
"src/process/procfs.ts"() {
|
|
3732
3757
|
"use strict";
|
|
3758
|
+
init_cred();
|
|
3733
3759
|
init_process_fds();
|
|
3734
3760
|
HZ = 100;
|
|
3735
3761
|
DIR_MODE2 = 16749;
|
|
@@ -5453,10 +5479,11 @@ function wrap(table) {
|
|
|
5453
5479
|
}
|
|
5454
5480
|
return out;
|
|
5455
5481
|
}
|
|
5456
|
-
var WasiExit, NS_PER_MS, AT_SYMLINK_NOFOLLOW2, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, WasiHost;
|
|
5482
|
+
var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW2, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, WasiHost;
|
|
5457
5483
|
var init_wasi_host = __esm({
|
|
5458
5484
|
"src/process/wasi/wasi-host.ts"() {
|
|
5459
5485
|
"use strict";
|
|
5486
|
+
init_cred();
|
|
5460
5487
|
init_wasi_abi();
|
|
5461
5488
|
init_wasi_fds();
|
|
5462
5489
|
init_wasi_files();
|
|
@@ -5469,6 +5496,7 @@ var init_wasi_host = __esm({
|
|
|
5469
5496
|
this.code = code2;
|
|
5470
5497
|
}
|
|
5471
5498
|
};
|
|
5499
|
+
IDS = ["ruid", "euid", "suid", "rgid", "egid", "sgid"];
|
|
5472
5500
|
NS_PER_MS = 1000000n;
|
|
5473
5501
|
AT_SYMLINK_NOFOLLOW2 = 1;
|
|
5474
5502
|
DEFAULT_UMASK = 18;
|
|
@@ -5567,6 +5595,35 @@ var init_wasi_host = __esm({
|
|
|
5567
5595
|
data: mem.string(dp, dl)
|
|
5568
5596
|
}),
|
|
5569
5597
|
umount2: (tp, tl, flags) => void this.o.kernel.call({ op: "umount", target: path(tp, tl), flags }),
|
|
5598
|
+
cred_get: (out) => {
|
|
5599
|
+
const cred = this.o.kernel.call({ op: "proc-cred" });
|
|
5600
|
+
const view = mem.view();
|
|
5601
|
+
view.getUint32(out + 20, true);
|
|
5602
|
+
IDS.forEach((key, i) => void view.setUint32(out + i * 4, cred[key], true));
|
|
5603
|
+
},
|
|
5604
|
+
cred_set: (...ids) => {
|
|
5605
|
+
const change = {};
|
|
5606
|
+
IDS.forEach((key, i) => {
|
|
5607
|
+
if (ids[i] !== -1) change[key] = ids[i] >>> 0;
|
|
5608
|
+
});
|
|
5609
|
+
void this.o.kernel.call({ op: "proc-setcred", change });
|
|
5610
|
+
},
|
|
5611
|
+
groups_get: (buf, cap, count) => {
|
|
5612
|
+
const { groups } = this.o.kernel.call({ op: "proc-cred" });
|
|
5613
|
+
if (cap !== 0 && cap < groups.length) throw new WasiError("EINVAL");
|
|
5614
|
+
const shown = cap === 0 ? [] : groups;
|
|
5615
|
+
const view = mem.view();
|
|
5616
|
+
view.getUint32(count, true);
|
|
5617
|
+
if (shown.length > 0) view.getUint32(buf + (shown.length - 1) * 4, true);
|
|
5618
|
+
shown.forEach((g, i) => void view.setUint32(buf + i * 4, g, true));
|
|
5619
|
+
view.setUint32(count, groups.length, true);
|
|
5620
|
+
},
|
|
5621
|
+
groups_set: (buf, n) => {
|
|
5622
|
+
if (n < 0 || n > MAX_GROUPS) throw new WasiError("EINVAL");
|
|
5623
|
+
const view = mem.view();
|
|
5624
|
+
const groups = Array.from({ length: n }, (_, i) => view.getUint32(buf + i * 4, true));
|
|
5625
|
+
void this.o.kernel.call({ op: "proc-setcred", change: { groups } });
|
|
5626
|
+
},
|
|
5570
5627
|
sigaction_set: (sig, disposition, flags) => this.signals ? this.signals.disposition(sig, disposition, flags) : E.NOSYS
|
|
5571
5628
|
});
|
|
5572
5629
|
}
|
|
@@ -8898,9 +8955,11 @@ function netOps(kernel, io) {
|
|
|
8898
8955
|
connect: async (options) => {
|
|
8899
8956
|
const signal = options.signal ?? NEVER;
|
|
8900
8957
|
signal.throwIfAborted();
|
|
8958
|
+
const host = options.host ?? "127.0.0.1";
|
|
8959
|
+
if (host.includes(":")) throw new JsCallError("EADDRNOTAVAIL", host);
|
|
8901
8960
|
const addr = {
|
|
8902
8961
|
family: "inet",
|
|
8903
|
-
host: await resolve(
|
|
8962
|
+
host: await resolve(host, signal),
|
|
8904
8963
|
port: port(options.port)
|
|
8905
8964
|
};
|
|
8906
8965
|
return opened(async (fd) => {
|