@ai-ecoverse/slicc-kernel 1.47.0 → 1.47.2
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 +2 -2
- package/dist/kernel-worker.js +4 -2
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +76 -10
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +4 -2
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +76 -10
- package/dist/process-worker.js.map +3 -3
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -3126,7 +3126,14 @@ function createProcessKernel(deps) {
|
|
|
3126
3126
|
getpgid: (pid) => number(call2({ op: "proc-getpgid", pid }, "getpgid")),
|
|
3127
3127
|
getsid: (pid) => number(call2({ op: "proc-getsid", pid }, "getsid")),
|
|
3128
3128
|
cred: () => credOf(call2({ op: "proc-cred" }, "cred")),
|
|
3129
|
-
setcred
|
|
3129
|
+
setcred(change) {
|
|
3130
|
+
const cred = credOf(call2({ op: "proc-setcred", change }, "setcred"));
|
|
3131
|
+
if (typeof cred === "object" && deps.owner) {
|
|
3132
|
+
deps.owner.uid = cred.euid;
|
|
3133
|
+
deps.owner.gid = cred.egid;
|
|
3134
|
+
}
|
|
3135
|
+
return cred;
|
|
3136
|
+
},
|
|
3130
3137
|
tcgetpgrp(fd) {
|
|
3131
3138
|
const kfd = Fs.getStream(fd)?.sliccKernelFd;
|
|
3132
3139
|
if (kfd === void 0) return -wasiErrno("ENOTTY");
|
|
@@ -3805,20 +3812,19 @@ var init_procfs = __esm({
|
|
|
3805
3812
|
});
|
|
3806
3813
|
|
|
3807
3814
|
// src/process/realm-user.ts
|
|
3808
|
-
function
|
|
3815
|
+
function ownByCaller(Fs, cred) {
|
|
3816
|
+
const owner = { uid: cred?.euid ?? 0, gid: cred?.egid ?? 0 };
|
|
3809
3817
|
const { stat, fstat } = Fs;
|
|
3810
|
-
const owned = (attr2) => ({ ...attr2, uid:
|
|
3818
|
+
const owned = (attr2) => ({ ...attr2, uid: owner.uid, gid: owner.gid });
|
|
3811
3819
|
if (typeof stat === "function") {
|
|
3812
3820
|
Fs.stat = (path, dontFollow) => owned(stat.call(Fs, path, dontFollow));
|
|
3813
3821
|
}
|
|
3814
3822
|
if (typeof fstat === "function") Fs.fstat = (fd) => owned(fstat.call(Fs, fd));
|
|
3823
|
+
return owner;
|
|
3815
3824
|
}
|
|
3816
|
-
var REALM_UID, REALM_GID;
|
|
3817
3825
|
var init_realm_user = __esm({
|
|
3818
3826
|
"src/process/realm-user.ts"() {
|
|
3819
3827
|
"use strict";
|
|
3820
|
-
REALM_UID = 1e3;
|
|
3821
|
-
REALM_GID = 1e3;
|
|
3822
3828
|
}
|
|
3823
3829
|
});
|
|
3824
3830
|
|
|
@@ -4172,7 +4178,6 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
4172
4178
|
memory: () => memory,
|
|
4173
4179
|
memalign: () => exports?.emscripten_builtin_memalign
|
|
4174
4180
|
});
|
|
4175
|
-
ownByRealmUser(running.FS);
|
|
4176
4181
|
const livePath = (s) => liveNodePath(s.node);
|
|
4177
4182
|
running.sliccKernel = createProcessKernel({
|
|
4178
4183
|
transport,
|
|
@@ -4187,7 +4192,8 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
4187
4192
|
deliveries: () => signals.deliveries(),
|
|
4188
4193
|
describeFork: () => describeForFork(running.FS, sys, streams, livePath),
|
|
4189
4194
|
inherit: (actions) => describeInherited(running.FS, sys, streams, livePath, actions),
|
|
4190
|
-
stdioPromoter: () => vfsPromoter(running.FS, sys, streams, livePath)
|
|
4195
|
+
stdioPromoter: () => vfsPromoter(running.FS, sys, streams, livePath),
|
|
4196
|
+
owner: ownByCaller(running.FS, init.cred)
|
|
4191
4197
|
});
|
|
4192
4198
|
running.sliccKernel.http = createHttpKernel(transport);
|
|
4193
4199
|
running.sliccKernel.hostname = hostnameOf(init.env);
|
|
@@ -8883,6 +8889,58 @@ function rewrite(hop, status2, location) {
|
|
|
8883
8889
|
body: toGet ? void 0 : hop.body
|
|
8884
8890
|
};
|
|
8885
8891
|
}
|
|
8892
|
+
function isHex(byte) {
|
|
8893
|
+
return byte !== void 0 && /^[0-9A-Fa-f]$/.test(String.fromCharCode(byte));
|
|
8894
|
+
}
|
|
8895
|
+
function percentDecode(input) {
|
|
8896
|
+
const bytes = new TextEncoder().encode(input);
|
|
8897
|
+
const out = new Uint8Array(bytes.length);
|
|
8898
|
+
let at = 0;
|
|
8899
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
8900
|
+
const byte = bytes[i];
|
|
8901
|
+
if (byte === 37 && isHex(bytes[i + 1]) && isHex(bytes[i + 2])) {
|
|
8902
|
+
out[at++] = Number.parseInt(
|
|
8903
|
+
String.fromCharCode(bytes[i + 1], bytes[i + 2]),
|
|
8904
|
+
16
|
|
8905
|
+
);
|
|
8906
|
+
i += 2;
|
|
8907
|
+
} else out[at++] = byte;
|
|
8908
|
+
}
|
|
8909
|
+
return out.subarray(0, at);
|
|
8910
|
+
}
|
|
8911
|
+
function latin1(bytes) {
|
|
8912
|
+
let text = "";
|
|
8913
|
+
for (let at = 0; at < bytes.length; at += SLICE) {
|
|
8914
|
+
text += String.fromCharCode(...bytes.subarray(at, at + SLICE));
|
|
8915
|
+
}
|
|
8916
|
+
return text;
|
|
8917
|
+
}
|
|
8918
|
+
function dataResponse(request) {
|
|
8919
|
+
const url = withoutFragment(new URL(request.url));
|
|
8920
|
+
const rest2 = url.slice("data:".length);
|
|
8921
|
+
const comma = rest2.indexOf(",");
|
|
8922
|
+
if (comma < 0) throw failed2(new JsCallError("EINVAL", "a data: URL without a comma"));
|
|
8923
|
+
let type = rest2.slice(0, comma).replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, "");
|
|
8924
|
+
let body = percentDecode(rest2.slice(comma + 1));
|
|
8925
|
+
const base642 = BASE64.exec(type);
|
|
8926
|
+
if (base642) {
|
|
8927
|
+
type = type.slice(0, base642.index).replace(/[\t\n\f\r ]+$/, "");
|
|
8928
|
+
let binary;
|
|
8929
|
+
try {
|
|
8930
|
+
binary = atob(latin1(body));
|
|
8931
|
+
} catch {
|
|
8932
|
+
throw failed2(new JsCallError("EINVAL", "a data: URL whose base64 does not decode"));
|
|
8933
|
+
}
|
|
8934
|
+
body = Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
8935
|
+
}
|
|
8936
|
+
if (type.startsWith(";")) type = `text/plain${type}`;
|
|
8937
|
+
if (!MIME.test(type)) type = "text/plain;charset=US-ASCII";
|
|
8938
|
+
const response = new Response(body, {
|
|
8939
|
+
status: 200,
|
|
8940
|
+
headers: { "content-type": type }
|
|
8941
|
+
});
|
|
8942
|
+
return withMeta(response, url, false);
|
|
8943
|
+
}
|
|
8886
8944
|
function withMeta(response, url, redirected) {
|
|
8887
8945
|
const clone = response.clone.bind(response);
|
|
8888
8946
|
Object.defineProperty(response, "url", { value: url });
|
|
@@ -9031,6 +9089,11 @@ function fetchOp(kernel) {
|
|
|
9031
9089
|
const request = new Request(input, init);
|
|
9032
9090
|
const { signal } = request;
|
|
9033
9091
|
signal.throwIfAborted();
|
|
9092
|
+
const { protocol } = new URL(request.url);
|
|
9093
|
+
if (protocol === "data:") return dataResponse(request);
|
|
9094
|
+
if (protocol !== "http:" && protocol !== "https:") {
|
|
9095
|
+
throw failed2(new JsCallError("EPROTONOSUPPORT", protocol));
|
|
9096
|
+
}
|
|
9034
9097
|
const known = await traitsOf().catch((err) => {
|
|
9035
9098
|
throw failed2(err);
|
|
9036
9099
|
});
|
|
@@ -9063,7 +9126,7 @@ function fetchOp(kernel) {
|
|
|
9063
9126
|
}
|
|
9064
9127
|
};
|
|
9065
9128
|
}
|
|
9066
|
-
var CHUNK, MAX_REDIRECTS, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, OVER;
|
|
9129
|
+
var CHUNK, MAX_REDIRECTS, NULL_BODY, REDIRECTS, BODY_HEADERS, DECODED, CREDENTIALS, OVER, MIME, BASE64, SLICE;
|
|
9067
9130
|
var init_js_fetch = __esm({
|
|
9068
9131
|
"src/process/js/js-fetch.ts"() {
|
|
9069
9132
|
"use strict";
|
|
@@ -9082,6 +9145,9 @@ var init_js_fetch = __esm({
|
|
|
9082
9145
|
DECODED = /* @__PURE__ */ new Set(["gzip", "x-gzip", "deflate"]);
|
|
9083
9146
|
CREDENTIALS = /* @__PURE__ */ new Set(["authorization", "proxy-authorization", "cookie", "cookie2"]);
|
|
9084
9147
|
OVER = /* @__PURE__ */ Symbol("over");
|
|
9148
|
+
MIME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+(?:[\t ]*;.*)?$/s;
|
|
9149
|
+
BASE64 = /; *base64$/i;
|
|
9150
|
+
SLICE = 32768;
|
|
9085
9151
|
}
|
|
9086
9152
|
});
|
|
9087
9153
|
|
|
@@ -9584,7 +9650,7 @@ function ttyOps(kernel) {
|
|
|
9584
9650
|
}
|
|
9585
9651
|
};
|
|
9586
9652
|
const restore = async () => {
|
|
9587
|
-
for (const [fd, original] of [...saved]) {
|
|
9653
|
+
for (const [fd, original] of [...saved].reverse()) {
|
|
9588
9654
|
saved.delete(fd);
|
|
9589
9655
|
await setAttr(fd, original).catch(() => void 0);
|
|
9590
9656
|
}
|