@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.
@@ -9280,7 +9280,7 @@ function satisfies(version, range2) {
9280
9280
  }
9281
9281
 
9282
9282
  // src/version.ts
9283
- var KERNEL_VERSION = true ? "1.195.5" : "0.0.0-dev";
9283
+ var KERNEL_VERSION = true ? "1.195.6" : "0.0.0-dev";
9284
9284
  var OS_RELEASE = "6.0.0-slicc";
9285
9285
  function procVersion() {
9286
9286
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -22203,11 +22203,11 @@ function replayOf(value2) {
22203
22203
  return failed2("EINVAL", `sudo: the request read a ${r.stdin}, and that input is gone`);
22204
22204
  }
22205
22205
  const { id: id2, user, uid, target, argv, path, cwd, stdin, tag, tags } = r;
22206
- const rootOnly2 = flagsOf(r.rootOnly);
22206
+ const rootOnly = flagsOf(r.rootOnly);
22207
22207
  const bound3 = filesOf(r.userWritable);
22208
22208
  const named = (s) => typeof s === "string" && s !== "";
22209
22209
  const absolute2 = (s) => typeof s === "string" && s.startsWith("/") && s.length <= PATH_MAX && !s.includes("\0");
22210
- 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;
22210
+ 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;
22211
22211
  if (!valid2) return failed2("EINVAL", NOT_A_REQUEST);
22212
22212
  const all = tags ?? (tag === void 0 ? [] : [tag]);
22213
22213
  return {
@@ -22219,7 +22219,7 @@ function replayOf(value2) {
22219
22219
  path,
22220
22220
  cwd,
22221
22221
  stdin,
22222
- rootOnly: rootOnly2,
22222
+ rootOnly,
22223
22223
  bound: bound3,
22224
22224
  tags: [...new Set(all)]
22225
22225
  };
@@ -36192,12 +36192,10 @@ function shebang(head) {
36192
36192
  if (head[0] !== 35 || head[1] !== 33) return void 0;
36193
36193
  return new TextDecoder().decode(head.subarray(0, SHEBANG_MAX)).slice(2).split("\n")[0].trim().split(/[ \t]+/);
36194
36194
  }
36195
- async function rootOnly(fs, path, dir = false) {
36196
- const names2 = chain(path);
36197
- for (const [i, at] of names2.entries()) {
36195
+ async function rootOnlyDir(fs, path) {
36196
+ for (const at of chain(path)) {
36198
36197
  const st = await fs.lstat(at).catch(() => void 0);
36199
- const kind = i === names2.length - 1 && !dir ? st?.isFile : st?.isDirectory;
36200
- if (!kind || st?.uid !== 0 || (st.mode & 18) !== 0) return false;
36198
+ if (!st?.isDirectory || st.uid !== 0 || (st.mode & 18) !== 0) return false;
36201
36199
  }
36202
36200
  return true;
36203
36201
  }
@@ -36776,7 +36774,7 @@ var Launcher = class {
36776
36774
  async rootOnlyPath(root) {
36777
36775
  for (const at of chain(root)) {
36778
36776
  const real = await physicalPathAsync(this.base, at);
36779
- if (!await rootOnly(this.base, real, true)) return false;
36777
+ if (!await rootOnlyDir(this.base, real)) return false;
36780
36778
  }
36781
36779
  return true;
36782
36780
  }
@@ -37232,19 +37230,20 @@ var Launcher = class {
37232
37230
  throw new SpawnError("EACCES");
37233
37231
  }
37234
37232
  }
37235
- async redeem(req, { ppid, cred, scope, booked }, planned) {
37233
+ async redeem(req, { ppid, cred, scope, booked, resolved: resolved2 }, planned) {
37236
37234
  const { [TICKET_ENV]: ticket = "", ...env } = req.env;
37237
37235
  const caller = this.jobs.shown(ppid);
37238
37236
  const named = typeof req.argv0 === "string" && !planned.script && !planned.target.fixed;
37239
37237
  const argv = named ? [req.argv0, ...req.argv.slice(1)] : req.argv;
37240
- const exact2 = booked?.pid === caller && req.file === booked.path && await physicalPathAsync(this.base, req.cwd) === booked.cwd && await argvDigest(argv) === booked.argv;
37238
+ const exact2 = booked?.pid === caller && resolved2 === booked.path && await physicalPathAsync(this.base, req.cwd) === booked.cwd && await argvDigest(argv) === booked.argv;
37241
37239
  if (!exact2) throw new SpawnError("EACCES");
37242
- const { requested: path, requestedCwd: cwd, path: resolved2 } = booked;
37240
+ const { requested: path, requestedCwd: cwd } = booked;
37243
37241
  const pid = this.nextPid++;
37244
37242
  const ids = { pid: req.exec ? caller : pid, ppid: caller };
37245
37243
  const stamp = await this.sealed.stamp(ids, cred, this.tagsOf(ppid));
37246
37244
  const interpreters = await this.interpreterChain(planned, booked.cwd, scope);
37247
- const trusted = this.usersMode === "enforce" && await this.trustedFiles(planned, req.file, booked.cwd);
37245
+ const trust = async (plan) => this.usersMode === "enforce" && (req.file === resolved2 || await this.sudoer.trustedThrough(req.file)) && await this.trustedFiles(plan, resolved2, booked.cwd);
37246
+ const trusted = await trust(planned);
37248
37247
  const swap = await this.sealed.consume({
37249
37248
  ticket,
37250
37249
  stamp,
@@ -37265,7 +37264,7 @@ var Launcher = class {
37265
37264
  }
37266
37265
  const scrub = scrubberOf(secrets);
37267
37266
  const recheck = async (next3) => {
37268
- const same3 = 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;
37267
+ const same3 = sameList(planFiles(next3), planFiles(planned)) && sameList(await this.interpreterChain(next3, booked.cwd, scope), interpreters) && await trust(next3) === trusted;
37269
37268
  if (!same3) throw new SpawnError("EACCES");
37270
37269
  };
37271
37270
  return { env, pid, cwd: booked.cwd, ...scrub ? { scrub } : {}, recheck };
@@ -37294,7 +37293,8 @@ var Launcher = class {
37294
37293
  const files = await this.backingOf(planned, file, cwd);
37295
37294
  files.push(...(planned.target.variants ?? []).map((variant) => variant.wasm));
37296
37295
  for (const at of files) {
37297
- if (!await rootOnly(this.base, await physicalPathAsync(this.base, at))) return false;
37296
+ if (!await this.sudoer.trustedThrough(at)) return false;
37297
+ if (!(await this.base.stat(at).catch(() => void 0))?.isFile) return false;
37298
37298
  }
37299
37299
  return true;
37300
37300
  }
@@ -38352,8 +38352,8 @@ var Launcher = class {
38352
38352
  const planned = await this.checkedPlan({ ...req, file }, { ppid, cred, scope }, fds);
38353
38353
  const pin = await this.unchanged(planned, file, req.cwd, grant);
38354
38354
  const { recheck, ...redeemed } = await this.redeemed(
38355
- { ...req, file },
38356
- { ppid, cred, scope, booked },
38355
+ req,
38356
+ { ppid, cred, scope, booked, resolved: file },
38357
38357
  planned,
38358
38358
  fds
38359
38359
  );