@ai-ecoverse/slicc-kernel 1.195.5 → 1.195.6

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.
@@ -8228,7 +8228,7 @@ var init_version = __esm({
8228
8228
  "src/version.ts"() {
8229
8229
  "use strict";
8230
8230
  init_captured_globals();
8231
- KERNEL_VERSION = true ? "1.195.5" : "0.0.0-dev";
8231
+ KERNEL_VERSION = true ? "1.195.6" : "0.0.0-dev";
8232
8232
  OS_RELEASE = "6.0.0-slicc";
8233
8233
  }
8234
8234
  });
@@ -8227,7 +8227,7 @@ var init_version = __esm({
8227
8227
  "src/version.ts"() {
8228
8228
  "use strict";
8229
8229
  init_captured_globals();
8230
- KERNEL_VERSION = true ? "1.195.5" : "0.0.0-dev";
8230
+ KERNEL_VERSION = true ? "1.195.6" : "0.0.0-dev";
8231
8231
  OS_RELEASE = "6.0.0-slicc";
8232
8232
  }
8233
8233
  });
package/dist/node.js CHANGED
@@ -7512,7 +7512,7 @@ function satisfies(version, range2) {
7512
7512
  }
7513
7513
 
7514
7514
  // src/version.ts
7515
- var KERNEL_VERSION = true ? "1.195.5" : "0.0.0-dev";
7515
+ var KERNEL_VERSION = true ? "1.195.6" : "0.0.0-dev";
7516
7516
  var OS_RELEASE = "6.0.0-slicc";
7517
7517
  function procVersion() {
7518
7518
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -19355,11 +19355,11 @@ function replayOf(value2) {
19355
19355
  return failed2("EINVAL", `sudo: the request read a ${r.stdin}, and that input is gone`);
19356
19356
  }
19357
19357
  const { id: id2, user, uid, target, argv, path, cwd, stdin, tag, tags } = r;
19358
- const rootOnly2 = flagsOf(r.rootOnly);
19358
+ const rootOnly = flagsOf(r.rootOnly);
19359
19359
  const bound3 = filesOf(r.userWritable);
19360
19360
  const named = (s) => typeof s === "string" && s !== "";
19361
19361
  const absolute2 = (s) => typeof s === "string" && s.startsWith("/") && s.length <= PATH_MAX && !s.includes("\0");
19362
- const valid2 = typeof id2 === "string" && REPLAY_ID.test(id2) && named(user) && named(target) && Number.isInteger(uid) && uid >= 0 && words(argv) && absolute2(path) && absolute2(cwd) && (stdin === "tty" || stdin === "none") && (tag === void 0 || typeof tag === "string") && (tags === void 0 || strings2(tags, REPLAY_TAGS_MAX)) && rootOnly2 !== void 0 && bound3 !== void 0;
19362
+ const valid2 = typeof id2 === "string" && REPLAY_ID.test(id2) && named(user) && named(target) && Number.isInteger(uid) && uid >= 0 && words(argv) && absolute2(path) && absolute2(cwd) && (stdin === "tty" || stdin === "none") && (tag === void 0 || typeof tag === "string") && (tags === void 0 || strings2(tags, REPLAY_TAGS_MAX)) && rootOnly !== void 0 && bound3 !== void 0;
19363
19363
  if (!valid2) return failed2("EINVAL", NOT_A_REQUEST);
19364
19364
  const all = tags ?? (tag === void 0 ? [] : [tag]);
19365
19365
  return {
@@ -19371,7 +19371,7 @@ function replayOf(value2) {
19371
19371
  path,
19372
19372
  cwd,
19373
19373
  stdin,
19374
- rootOnly: rootOnly2,
19374
+ rootOnly,
19375
19375
  bound: bound3,
19376
19376
  tags: [...new Set(all)]
19377
19377
  };
@@ -36153,12 +36153,10 @@ function shebang(head) {
36153
36153
  if (head[0] !== 35 || head[1] !== 33) return void 0;
36154
36154
  return new TextDecoder().decode(head.subarray(0, SHEBANG_MAX)).slice(2).split("\n")[0].trim().split(/[ \t]+/);
36155
36155
  }
36156
- async function rootOnly(fs, path, dir = false) {
36157
- const names2 = chain(path);
36158
- for (const [i, at] of names2.entries()) {
36156
+ async function rootOnlyDir(fs, path) {
36157
+ for (const at of chain(path)) {
36159
36158
  const st = await fs.lstat(at).catch(() => void 0);
36160
- const kind = i === names2.length - 1 && !dir ? st?.isFile : st?.isDirectory;
36161
- if (!kind || st?.uid !== 0 || (st.mode & 18) !== 0) return false;
36159
+ if (!st?.isDirectory || st.uid !== 0 || (st.mode & 18) !== 0) return false;
36162
36160
  }
36163
36161
  return true;
36164
36162
  }
@@ -36737,7 +36735,7 @@ var Launcher = class {
36737
36735
  async rootOnlyPath(root) {
36738
36736
  for (const at of chain(root)) {
36739
36737
  const real = await physicalPathAsync(this.base, at);
36740
- if (!await rootOnly(this.base, real, true)) return false;
36738
+ if (!await rootOnlyDir(this.base, real)) return false;
36741
36739
  }
36742
36740
  return true;
36743
36741
  }
@@ -37193,19 +37191,20 @@ var Launcher = class {
37193
37191
  throw new SpawnError("EACCES");
37194
37192
  }
37195
37193
  }
37196
- async redeem(req, { ppid, cred, scope, booked }, planned) {
37194
+ async redeem(req, { ppid, cred, scope, booked, resolved: resolved2 }, planned) {
37197
37195
  const { [TICKET_ENV]: ticket = "", ...env } = req.env;
37198
37196
  const caller = this.jobs.shown(ppid);
37199
37197
  const named = typeof req.argv0 === "string" && !planned.script && !planned.target.fixed;
37200
37198
  const argv = named ? [req.argv0, ...req.argv.slice(1)] : req.argv;
37201
- const exact2 = booked?.pid === caller && req.file === booked.path && await physicalPathAsync(this.base, req.cwd) === booked.cwd && await argvDigest(argv) === booked.argv;
37199
+ const exact2 = booked?.pid === caller && resolved2 === booked.path && await physicalPathAsync(this.base, req.cwd) === booked.cwd && await argvDigest(argv) === booked.argv;
37202
37200
  if (!exact2) throw new SpawnError("EACCES");
37203
- const { requested: path, requestedCwd: cwd, path: resolved2 } = booked;
37201
+ const { requested: path, requestedCwd: cwd } = booked;
37204
37202
  const pid = this.nextPid++;
37205
37203
  const ids = { pid: req.exec ? caller : pid, ppid: caller };
37206
37204
  const stamp = await this.sealed.stamp(ids, cred, this.tagsOf(ppid));
37207
37205
  const interpreters = await this.interpreterChain(planned, booked.cwd, scope);
37208
- const trusted = this.usersMode === "enforce" && await this.trustedFiles(planned, req.file, booked.cwd);
37206
+ const trust = async (plan) => this.usersMode === "enforce" && (req.file === resolved2 || await this.sudoer.trustedThrough(req.file)) && await this.trustedFiles(plan, resolved2, booked.cwd);
37207
+ const trusted = await trust(planned);
37209
37208
  const swap = await this.sealed.consume({
37210
37209
  ticket,
37211
37210
  stamp,
@@ -37226,7 +37225,7 @@ var Launcher = class {
37226
37225
  }
37227
37226
  const scrub = scrubberOf(secrets);
37228
37227
  const recheck = async (next3) => {
37229
- const same2 = sameList(planFiles(next3), planFiles(planned)) && sameList(await this.interpreterChain(next3, booked.cwd, scope), interpreters) && (this.usersMode === "enforce" && await this.trustedFiles(next3, req.file, booked.cwd)) === trusted;
37228
+ const same2 = sameList(planFiles(next3), planFiles(planned)) && sameList(await this.interpreterChain(next3, booked.cwd, scope), interpreters) && await trust(next3) === trusted;
37230
37229
  if (!same2) throw new SpawnError("EACCES");
37231
37230
  };
37232
37231
  return { env, pid, cwd: booked.cwd, ...scrub ? { scrub } : {}, recheck };
@@ -37255,7 +37254,8 @@ var Launcher = class {
37255
37254
  const files = await this.backingOf(planned, file, cwd);
37256
37255
  files.push(...(planned.target.variants ?? []).map((variant) => variant.wasm));
37257
37256
  for (const at of files) {
37258
- if (!await rootOnly(this.base, await physicalPathAsync(this.base, at))) return false;
37257
+ if (!await this.sudoer.trustedThrough(at)) return false;
37258
+ if (!(await this.base.stat(at).catch(() => void 0))?.isFile) return false;
37259
37259
  }
37260
37260
  return true;
37261
37261
  }
@@ -38313,8 +38313,8 @@ var Launcher = class {
38313
38313
  const planned = await this.checkedPlan({ ...req, file }, { ppid, cred, scope }, fds);
38314
38314
  const pin = await this.unchanged(planned, file, req.cwd, grant);
38315
38315
  const { recheck, ...redeemed } = await this.redeemed(
38316
- { ...req, file },
38317
- { ppid, cred, scope, booked },
38316
+ req,
38317
+ { ppid, cred, scope, booked, resolved: file },
38318
38318
  planned,
38319
38319
  fds
38320
38320
  );