@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.
@@ -5109,7 +5109,7 @@ function satisfies(version, range2) {
5109
5109
  }
5110
5110
 
5111
5111
  // src/version.ts
5112
- var KERNEL_VERSION = true ? "1.195.5" : "0.0.0-dev";
5112
+ var KERNEL_VERSION = true ? "1.195.6" : "0.0.0-dev";
5113
5113
  var OS_RELEASE = "6.0.0-slicc";
5114
5114
  function procVersion() {
5115
5115
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -19056,11 +19056,11 @@ function replayOf(value2) {
19056
19056
  return failed2("EINVAL", `sudo: the request read a ${r.stdin}, and that input is gone`);
19057
19057
  }
19058
19058
  const { id: id2, user, uid, target, argv, path, cwd, stdin, tag, tags } = r;
19059
- const rootOnly2 = flagsOf(r.rootOnly);
19059
+ const rootOnly = flagsOf(r.rootOnly);
19060
19060
  const bound3 = filesOf(r.userWritable);
19061
19061
  const named = (s) => typeof s === "string" && s !== "";
19062
19062
  const absolute2 = (s) => typeof s === "string" && s.startsWith("/") && s.length <= PATH_MAX && !s.includes("\0");
19063
- const valid3 = 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;
19063
+ const valid3 = 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;
19064
19064
  if (!valid3) return failed2("EINVAL", NOT_A_REQUEST);
19065
19065
  const all = tags ?? (tag === void 0 ? [] : [tag]);
19066
19066
  return {
@@ -19072,7 +19072,7 @@ function replayOf(value2) {
19072
19072
  path,
19073
19073
  cwd,
19074
19074
  stdin,
19075
- rootOnly: rootOnly2,
19075
+ rootOnly,
19076
19076
  bound: bound3,
19077
19077
  tags: [...new Set(all)]
19078
19078
  };
@@ -35775,12 +35775,10 @@ function shebang(head) {
35775
35775
  if (head[0] !== 35 || head[1] !== 33) return void 0;
35776
35776
  return new TextDecoder().decode(head.subarray(0, SHEBANG_MAX)).slice(2).split("\n")[0].trim().split(/[ \t]+/);
35777
35777
  }
35778
- async function rootOnly(fs, path, dir = false) {
35779
- const names2 = chain(path);
35780
- for (const [i, at] of names2.entries()) {
35778
+ async function rootOnlyDir(fs, path) {
35779
+ for (const at of chain(path)) {
35781
35780
  const st = await fs.lstat(at).catch(() => void 0);
35782
- const kind = i === names2.length - 1 && !dir ? st?.isFile : st?.isDirectory;
35783
- if (!kind || st?.uid !== 0 || (st.mode & 18) !== 0) return false;
35781
+ if (!st?.isDirectory || st.uid !== 0 || (st.mode & 18) !== 0) return false;
35784
35782
  }
35785
35783
  return true;
35786
35784
  }
@@ -36359,7 +36357,7 @@ var Launcher = class {
36359
36357
  async rootOnlyPath(root) {
36360
36358
  for (const at of chain(root)) {
36361
36359
  const real2 = await physicalPathAsync(this.base, at);
36362
- if (!await rootOnly(this.base, real2, true)) return false;
36360
+ if (!await rootOnlyDir(this.base, real2)) return false;
36363
36361
  }
36364
36362
  return true;
36365
36363
  }
@@ -36815,19 +36813,20 @@ var Launcher = class {
36815
36813
  throw new SpawnError("EACCES");
36816
36814
  }
36817
36815
  }
36818
- async redeem(req, { ppid, cred, scope, booked }, planned) {
36816
+ async redeem(req, { ppid, cred, scope, booked, resolved: resolved2 }, planned) {
36819
36817
  const { [TICKET_ENV]: ticket2 = "", ...env } = req.env;
36820
36818
  const caller = this.jobs.shown(ppid);
36821
36819
  const named = typeof req.argv0 === "string" && !planned.script && !planned.target.fixed;
36822
36820
  const argv = named ? [req.argv0, ...req.argv.slice(1)] : req.argv;
36823
- const exact2 = booked?.pid === caller && req.file === booked.path && await physicalPathAsync(this.base, req.cwd) === booked.cwd && await argvDigest(argv) === booked.argv;
36821
+ const exact2 = booked?.pid === caller && resolved2 === booked.path && await physicalPathAsync(this.base, req.cwd) === booked.cwd && await argvDigest(argv) === booked.argv;
36824
36822
  if (!exact2) throw new SpawnError("EACCES");
36825
- const { requested: path, requestedCwd: cwd, path: resolved2 } = booked;
36823
+ const { requested: path, requestedCwd: cwd } = booked;
36826
36824
  const pid = this.nextPid++;
36827
36825
  const ids = { pid: req.exec ? caller : pid, ppid: caller };
36828
36826
  const stamp = await this.sealed.stamp(ids, cred, this.tagsOf(ppid));
36829
36827
  const interpreters = await this.interpreterChain(planned, booked.cwd, scope);
36830
- const trusted = this.usersMode === "enforce" && await this.trustedFiles(planned, req.file, booked.cwd);
36828
+ const trust = async (plan) => this.usersMode === "enforce" && (req.file === resolved2 || await this.sudoer.trustedThrough(req.file)) && await this.trustedFiles(plan, resolved2, booked.cwd);
36829
+ const trusted = await trust(planned);
36831
36830
  const swap = await this.sealed.consume({
36832
36831
  ticket: ticket2,
36833
36832
  stamp,
@@ -36848,7 +36847,7 @@ var Launcher = class {
36848
36847
  }
36849
36848
  const scrub = scrubberOf(secrets);
36850
36849
  const recheck = async (next3) => {
36851
- 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;
36850
+ const same2 = sameList(planFiles(next3), planFiles(planned)) && sameList(await this.interpreterChain(next3, booked.cwd, scope), interpreters) && await trust(next3) === trusted;
36852
36851
  if (!same2) throw new SpawnError("EACCES");
36853
36852
  };
36854
36853
  return { env, pid, cwd: booked.cwd, ...scrub ? { scrub } : {}, recheck };
@@ -36877,7 +36876,8 @@ var Launcher = class {
36877
36876
  const files = await this.backingOf(planned, file, cwd);
36878
36877
  files.push(...(planned.target.variants ?? []).map((variant) => variant.wasm));
36879
36878
  for (const at of files) {
36880
- if (!await rootOnly(this.base, await physicalPathAsync(this.base, at))) return false;
36879
+ if (!await this.sudoer.trustedThrough(at)) return false;
36880
+ if (!(await this.base.stat(at).catch(() => void 0))?.isFile) return false;
36881
36881
  }
36882
36882
  return true;
36883
36883
  }
@@ -37935,8 +37935,8 @@ var Launcher = class {
37935
37935
  const planned = await this.checkedPlan({ ...req, file }, { ppid, cred, scope }, fds);
37936
37936
  const pin = await this.unchanged(planned, file, req.cwd, grant);
37937
37937
  const { recheck, ...redeemed } = await this.redeemed(
37938
- { ...req, file },
37939
- { ppid, cred, scope, booked },
37938
+ req,
37939
+ { ppid, cred, scope, booked, resolved: file },
37940
37940
  planned,
37941
37941
  fds
37942
37942
  );