@ai-ecoverse/slicc-kernel 1.196.36 → 1.196.38

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.
@@ -372,23 +372,23 @@ var KernelSide = class {
372
372
  ...cwds ? { cwds } : {}
373
373
  };
374
374
  }
375
- applyWords(words3) {
376
- if (!words3 || typeof words3.n !== "number" || words3.n <= this.words) return;
377
- this.words = words3.n;
378
- while (this.history.length > 0 && (this.history[0]?.seq ?? 0) <= words3.seen) {
375
+ applyWords(words2) {
376
+ if (!words2 || typeof words2.n !== "number" || words2.n <= this.words) return;
377
+ this.words = words2.n;
378
+ while (this.history.length > 0 && (this.history[0]?.seq ?? 0) <= words2.seen) {
379
379
  this.history.shift();
380
380
  }
381
- let signals = words3.signals | this.raised.signals;
382
- let timers = words3.timers | this.raised.timers;
381
+ let signals = words2.signals | this.raised.signals;
382
+ let timers = words2.timers | this.raised.timers;
383
383
  for (const entry of this.history) {
384
384
  signals |= entry.signals;
385
385
  timers |= entry.timers;
386
386
  }
387
387
  Atomics.store(this.header, SAB_I_SIGNALS, signals);
388
388
  Atomics.store(this.header, SAB_I_TIMERS, timers);
389
- storeBlocked(this.header, words3.blocked);
390
- Atomics.store(this.header, SAB_I_MEMORY, words3.memory);
391
- Atomics.store(this.clock, CLOCK_IDLE, BigInt(words3.idle));
389
+ storeBlocked(this.header, words2.blocked);
390
+ Atomics.store(this.header, SAB_I_MEMORY, words2.memory);
391
+ Atomics.store(this.clock, CLOCK_IDLE, BigInt(words2.idle));
392
392
  }
393
393
  keep(bytes) {
394
394
  const id2 = ++this.nextPart;
@@ -5303,7 +5303,7 @@ function satisfies(version, range2) {
5303
5303
  }
5304
5304
 
5305
5305
  // src/version.ts
5306
- var KERNEL_VERSION = true ? "1.196.36" : "0.0.0-dev";
5306
+ var KERNEL_VERSION = true ? "1.196.38" : "0.0.0-dev";
5307
5307
  var OS_RELEASE = "6.0.0-slicc";
5308
5308
  function procVersion() {
5309
5309
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -5452,12 +5452,22 @@ async function withPackagePaths(fs, pkg, command, provenance) {
5452
5452
  if (!command.env) return command;
5453
5453
  const env = {};
5454
5454
  const envPaths = /* @__PURE__ */ new Set();
5455
+ const missingEnv = {};
5455
5456
  for (const [key, value2] of Object.entries(command.env)) {
5456
5457
  const path = !value2.startsWith("/") && value2.includes("/") && inside(pkg, value2);
5457
- if (path && provenance) envPaths.add(path);
5458
- env[key] = path && await fs.exists(path) ? path : value2;
5458
+ const present4 = path && await fs.exists(path);
5459
+ if (path && provenance) {
5460
+ envPaths.add(path);
5461
+ if (!present4) missingEnv[key] = { pkg, value: value2 };
5462
+ }
5463
+ env[key] = present4 ? path : value2;
5459
5464
  }
5460
- return { ...command, env, ...envPaths.size ? { envPaths: [...envPaths] } : {} };
5465
+ return {
5466
+ ...command,
5467
+ env,
5468
+ ...envPaths.size ? { envPaths: [...envPaths] } : {},
5469
+ ...Object.keys(missingEnv).length ? { missingEnv } : {}
5470
+ };
5461
5471
  }
5462
5472
  async function packages(fs, modules) {
5463
5473
  const names2 = await fs.readdir(modules).catch(() => []);
@@ -6238,27 +6248,27 @@ function hashId(text) {
6238
6248
  return hex5(a) + hex5(b);
6239
6249
  }
6240
6250
  function split(text, count3) {
6241
- const words3 = [];
6251
+ const words2 = [];
6242
6252
  let rest2 = text;
6243
6253
  for (let i = 0; i < count3; i++) {
6244
6254
  const match = /^(\S+)\s+/.exec(rest2);
6245
6255
  if (!match) return void 0;
6246
- words3.push(match[1]);
6256
+ words2.push(match[1]);
6247
6257
  rest2 = rest2.slice(match[0].length);
6248
6258
  }
6249
- return [words3, rest2.trim()];
6259
+ return [words2, rest2.trim()];
6250
6260
  }
6251
6261
  function jobOf(content, pending, ctx, env) {
6252
6262
  const fields2 = content.startsWith("@") ? 1 : 5;
6253
6263
  const parts2 = split(content, fields2 + (ctx.system ? 1 : 0));
6254
6264
  if (!parts2 || parts2[1] === "") throw new Error("no command");
6255
- const [words3, command] = parts2;
6256
- const schedule = words3.slice(0, fields2).join(" ");
6265
+ const [words2, command] = parts2;
6266
+ const schedule = words2.slice(0, fields2).join(" ");
6257
6267
  const when = parseWhen(schedule);
6258
6268
  const zone = env.CRON_TZ;
6259
6269
  if (zone && !when.reboot && canonicalZone(zone) === void 0)
6260
6270
  throw new Error(`CRON_TZ: unknown time zone "${zone}"`);
6261
- const user = ctx.system ? words3[fields2] : void 0;
6271
+ const user = ctx.system ? words2[fields2] : void 0;
6262
6272
  if (user !== void 0 && !USER_NAME.test(user)) throw new Error(`bad user name ${user}`);
6263
6273
  if (pending !== void 0 && !JOB_NAME.test(pending))
6264
6274
  throw new Error(`bad job name "${pending}"`);
@@ -19197,21 +19207,21 @@ function unescaped2(double) {
19197
19207
  }
19198
19208
  function splitWords(text) {
19199
19209
  const piece = /'([^']*)'|"((?:[^"\\]|\\[\s\S])*)"|\\([\s\S])|([^\s'"\\]+)|(\s+)/y;
19200
- const words3 = [];
19210
+ const words2 = [];
19201
19211
  let word;
19202
19212
  while (piece.lastIndex < text.length) {
19203
19213
  const m = piece.exec(text);
19204
19214
  if (!m) return void 0;
19205
19215
  const [, single, double, escaped, plain3, space] = m;
19206
19216
  if (space !== void 0) {
19207
- if (word !== void 0) words3.push(word);
19217
+ if (word !== void 0) words2.push(word);
19208
19218
  word = void 0;
19209
19219
  continue;
19210
19220
  }
19211
19221
  word = (word ?? "") + (single ?? (double !== void 0 ? unescaped2(double) : escaped ?? plain3));
19212
19222
  }
19213
- if (word !== void 0) words3.push(word);
19214
- return words3;
19223
+ if (word !== void 0) words2.push(word);
19224
+ return words2;
19215
19225
  }
19216
19226
  function shellQuote(word) {
19217
19227
  return PLAIN.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
@@ -19234,14 +19244,14 @@ function addPlain(word, plain3) {
19234
19244
  }
19235
19245
  function splitPatterns(text) {
19236
19246
  const piece = /'([^']*)'|"((?:[^"\\]|\\[\s\S])*)"|\\([\s\S])|([^\s'"\\]+)|(\s+)/y;
19237
- const words3 = [];
19247
+ const words2 = [];
19238
19248
  let word;
19239
19249
  while (piece.lastIndex < text.length) {
19240
19250
  const m = piece.exec(text);
19241
19251
  if (!m) return void 0;
19242
19252
  const [, single, double, escaped, plain3, space] = m;
19243
19253
  if (space !== void 0) {
19244
- if (word !== void 0) words3.push(word);
19254
+ if (word !== void 0) words2.push(word);
19245
19255
  word = void 0;
19246
19256
  continue;
19247
19257
  }
@@ -19249,8 +19259,8 @@ function splitPatterns(text) {
19249
19259
  if (plain3 !== void 0) addPlain(word, plain3);
19250
19260
  else addPart(word, single ?? (double !== void 0 ? unescaped2(double) : escaped));
19251
19261
  }
19252
- if (word !== void 0) words3.push(word);
19253
- return words3;
19262
+ if (word !== void 0) words2.push(word);
19263
+ return words2;
19254
19264
  }
19255
19265
  var literal = (pattern) => pattern.map((p) => p ?? "*").join("");
19256
19266
  var isAny = (pattern) => pattern?.length === 1 && pattern[0] === null;
@@ -19326,14 +19336,14 @@ function whoError(who) {
19326
19336
  return `expected a user name, %group or ALL first, not ${shown(who)}`;
19327
19337
  }
19328
19338
  function cwdOf(word) {
19329
- const words3 = splitWords(word);
19330
- const path = words3?.length === 1 ? words3[0] : "";
19339
+ const words2 = splitWords(word);
19340
+ const path = words2?.length === 1 ? words2[0] : "";
19331
19341
  return path.startsWith("/") ? normalizePath(path) : "";
19332
19342
  }
19333
19343
  function commandOf2(text, after) {
19334
- const words3 = splitPatterns(text);
19335
- if (words3 === void 0) return "a quote in the command is not closed, or it ends in a \\";
19336
- const [first, ...args] = words3;
19344
+ const words2 = splitPatterns(text);
19345
+ if (words2 === void 0) return "a quote in the command is not closed, or it ends in a \\";
19346
+ const [first, ...args] = words2;
19337
19347
  const path = first ? literal(first) : "";
19338
19348
  if (path === "") return `expected a command after ${after}`;
19339
19349
  if (!path.startsWith("/")) return `expected an absolute command path, not ${shown(path)}`;
@@ -19516,14 +19526,14 @@ function legacyApproval(line, file, rule2) {
19516
19526
  const stdin = rule2.stdin === void 0 ? "" : "Stdin none ";
19517
19527
  const prefix = `NOPASSWD ${rule2.who} (${rule2.target}) ${cwd}${stdin}Cmnd `;
19518
19528
  if (!line.startsWith(prefix)) return rule2;
19519
- const words3 = line.slice(prefix.length).trimEnd();
19529
+ const words2 = line.slice(prefix.length).trimEnd();
19520
19530
  if (cmnd.args === void 0) {
19521
- if (words3 !== quote(cmnd.path)) return rule2;
19531
+ if (words2 !== quote(cmnd.path)) return rule2;
19522
19532
  return { ...rule2, cmnd: { ...cmnd, args: [] }, ...stdin ? {} : { sha256: {} } };
19523
19533
  }
19524
19534
  if (cmnd.args.some((arg) => arg.includes(null))) return rule2;
19525
- const current = rule2.cwd !== void 0 && words3 === formatCommand(cmnd, quote);
19526
- const earliest = !stdin && words3 === [cmnd.path, ...cmnd.args.map(literal)].map(quote).join(" ");
19535
+ const current = rule2.cwd !== void 0 && words2 === formatCommand(cmnd, quote);
19536
+ const earliest = !stdin && words2 === [cmnd.path, ...cmnd.args.map(literal)].map(quote).join(" ");
19527
19537
  return current || earliest ? { ...rule2, sha256: {} } : rule2;
19528
19538
  }
19529
19539
  function kernelLine(m, line, file) {
@@ -21051,8 +21061,8 @@ ${lines3}
21051
21061
  const st = await fs.lstat(path).catch(() => void 0);
21052
21062
  if (st && !await this.trusted(path)) return false;
21053
21063
  const old = st ? await fs.readFile(path) : "";
21054
- const words3 = recordedCommand(argv);
21055
- const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Stdin none ${sha256Text(bound3, routeSha256, chainSha256)}Cmnd ${words3}
21064
+ const words2 = recordedCommand(argv);
21065
+ const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Stdin none ${sha256Text(bound3, routeSha256, chainSha256)}Cmnd ${words2}
21056
21066
  `;
21057
21067
  const text = old === "" || old.endsWith("\n") ? `${old}${line}` : `${old}
21058
21068
  ${line}`;
@@ -22359,8 +22369,8 @@ function ipv6(host) {
22359
22369
  const head = groups(halves[0]);
22360
22370
  const back = halves.length === 2 ? groups(halves[1]) : [];
22361
22371
  if (![...head, ...back].every((g) => /^[0-9A-Fa-f]{1,4}$/.test(g))) return void 0;
22362
- const words3 = [...head, ...back].map((g) => Number.parseInt(g, 16));
22363
- const missing7 = 8 - words3.length - tail2.length;
22372
+ const words2 = [...head, ...back].map((g) => Number.parseInt(g, 16));
22373
+ const missing7 = 8 - words2.length - tail2.length;
22364
22374
  if (halves.length === 2 ? missing7 < 1 : missing7 !== 0) return void 0;
22365
22375
  const all = [
22366
22376
  ...head.map((g) => Number.parseInt(g, 16)),
@@ -28544,21 +28554,26 @@ var PATH_FLAGS = PATH_ONLY | 65536 | 131072;
28544
28554
  var KEYBOARD = /* @__PURE__ */ new Set([SIG.INT, SIG.QUIT, SIG.TSTP]);
28545
28555
  var STUCK_ESCAPES = /* @__PURE__ */ new Set([SIG.INT, SIG.TERM, SIG.QUIT, SIG.HUP]);
28546
28556
  var DEFAULT_UMASK2 = 18;
28547
- function words2(value2) {
28548
- if (!Array.isArray(value2) || !value2.every((w) => typeof w === "string")) {
28549
- throw new KernelError("EINVAL");
28550
- }
28551
- return [...value2];
28552
- }
28553
- var SUDO_ENV_MAX = 4096;
28554
- var SUDO_ENV_BYTES = 1024 * 1024;
28555
- function sudoVariables(value2, term) {
28557
+ var SUDO_VECTOR_MAX = 4096;
28558
+ var SUDO_INPUT_BYTES = 1024 * 1024;
28559
+ function budgetAfterArgs(args) {
28560
+ if (!Array.isArray(args)) throw new KernelError("EINVAL");
28561
+ if (args.length > SUDO_VECTOR_MAX) return -1;
28562
+ let remaining = SUDO_INPUT_BYTES;
28563
+ for (const word of args) {
28564
+ if (typeof word !== "string") throw new KernelError("EINVAL");
28565
+ if (word.length + 1 > remaining) return -1;
28566
+ remaining -= storedSize(word) + 1;
28567
+ if (remaining < 0) return -1;
28568
+ }
28569
+ return remaining;
28570
+ }
28571
+ function sudoVariables(value2, term, budget) {
28556
28572
  const input = typeof value2 === "object" && value2 !== null ? value2 : {};
28557
28573
  const env = /* @__PURE__ */ Object.create(null);
28558
28574
  let count3 = 0;
28559
- let budget = SUDO_ENV_BYTES;
28560
28575
  const fits = (name2, text) => {
28561
- if (++count3 > SUDO_ENV_MAX || name2.length + text.length + 2 > budget) return false;
28576
+ if (++count3 > SUDO_VECTOR_MAX || name2.length + text.length + 2 > budget) return false;
28562
28577
  budget -= storedSize(name2) + storedSize(text) + 2;
28563
28578
  return budget >= 0;
28564
28579
  };
@@ -30607,14 +30622,15 @@ var WasmProcess = class _WasmProcess {
30607
30622
  async sudo(req, cancelled) {
30608
30623
  const { sudo } = this.options;
30609
30624
  if (!sudo) throw new KernelError("ENOSYS");
30610
- const args = words2(req.args);
30625
+ const budget = budgetAfterArgs(req.args);
30626
+ if (budget < 0) return { errno: "E2BIG", error: "sudo: the submitted arguments are too large" };
30611
30627
  const term = typeof req.term === "string" ? req.term : void 0;
30612
- const submitted = sudoVariables(req.env, term);
30628
+ const submitted = sudoVariables(req.env, term, budget);
30613
30629
  if (submitted === void 0)
30614
30630
  return { errno: "E2BIG", error: "sudo: the submitted environment is too large" };
30615
30631
  const call = {
30616
30632
  op: "proc-sudo",
30617
- args,
30633
+ args: [...req.args],
30618
30634
  cwd: typeof req.cwd === "string" && req.cwd.startsWith("/") ? req.cwd : "/",
30619
30635
  ...term !== void 0 ? { term } : {},
30620
30636
  env: submitted
@@ -38914,38 +38930,40 @@ function appendedRoots(given) {
38914
38930
  }
38915
38931
  return [...roots];
38916
38932
  }
38917
- function plainEnv(words3) {
38918
- const next3 = words3[1];
38919
- if (baseName3(words3[0] ?? "") !== "env" || next3 === void 0) return false;
38933
+ function plainEnv(words2) {
38934
+ const next3 = words2[1];
38935
+ if (baseName3(words2[0] ?? "") !== "env" || next3 === void 0) return false;
38920
38936
  return next3 === "-S" || !next3.startsWith("-") && !next3.includes("=");
38921
38937
  }
38922
- function shebangCommand(words3) {
38923
- if (!plainEnv(words3)) {
38924
- const arg2 = words3.slice(1).join(" ");
38925
- return { interp: words3[0], args: arg2 ? [arg2] : [] };
38938
+ function shebangCommand(words2) {
38939
+ if (!plainEnv(words2)) {
38940
+ const arg2 = words2.slice(1).join(" ");
38941
+ return { interp: words2[0], args: arg2 ? [arg2] : [] };
38926
38942
  }
38927
- const split3 = words3[1] === "-S";
38928
- const [interp, ...rest2] = words3.slice(split3 ? 2 : 1);
38943
+ const split3 = words2[1] === "-S";
38944
+ const [interp, ...rest2] = words2.slice(split3 ? 2 : 1);
38929
38945
  const arg = rest2.join(" ");
38930
38946
  return { interp, args: split3 ? rest2 : arg ? [arg] : [] };
38931
38947
  }
38932
38948
  function interpreter(head) {
38933
- const words3 = shebang(head);
38934
- if (!words3) return "node";
38935
- if (baseName3(words3[0]) === "env") words3.shift();
38936
- if (words3[0] === "-S") words3.shift();
38937
- return baseName3(words3[0] ?? "");
38949
+ const words2 = shebang(head);
38950
+ if (!words2) return "node";
38951
+ if (baseName3(words2[0]) === "env") words2.shift();
38952
+ if (words2[0] === "-S") words2.shift();
38953
+ return baseName3(words2[0] ?? "");
38938
38954
  }
38939
38955
  function expandDefaults(defaults2, env) {
38940
38956
  const out = {};
38941
- for (const [key, value2] of Object.entries(defaults2 ?? {})) {
38957
+ for (const [key, entry] of Object.entries(defaults2 ?? {})) {
38942
38958
  let missing7 = false;
38959
+ const value2 = typeof entry === "string" ? entry : entry.value;
38943
38960
  const expanded = value2.replace(ENV_REFERENCE, (_, name2) => {
38944
38961
  const set3 = Object.hasOwn(env, name2) ? env[name2] : void 0;
38945
38962
  if (set3 === void 0) missing7 = true;
38946
38963
  return set3 ?? "";
38947
38964
  });
38948
- if (!missing7) out[key] = expanded;
38965
+ if (missing7) continue;
38966
+ out[key] = typeof entry !== "string" && !expanded.startsWith("/") ? `${entry.pkg}/${expanded.replace(/^\.\//, "")}` : expanded;
38949
38967
  }
38950
38968
  return out;
38951
38969
  }
@@ -38959,7 +38977,7 @@ function targetOf(command, reads) {
38959
38977
  argv0: command.argv0,
38960
38978
  ...command.argv0Fixed ? { fixed: true } : {},
38961
38979
  ...command.args ? { prefix: command.args } : {},
38962
- ...command.env ? { env: command.env } : {},
38980
+ ...command.env ? { env: { ...command.env, ...command.missingEnv } } : {},
38963
38981
  ...command.unset ? { unset: command.unset } : {},
38964
38982
  ...command.imports ? { imports: command.imports } : {},
38965
38983
  ...command.preopenRoot ? { preopenRoot: true } : {},
@@ -38987,7 +39005,7 @@ function withScriptEnv(target, command) {
38987
39005
  if (!command) return target;
38988
39006
  return {
38989
39007
  ...target,
38990
- env: { ...target.env, ...command.env },
39008
+ env: { ...target.env, ...command.env, ...command.missingEnv },
38991
39009
  unset: [
38992
39010
  ...(target.unset ?? []).filter((key) => !Object.hasOwn(command.env ?? {}, key)),
38993
39011
  ...command.unset ?? []
@@ -39872,13 +39890,13 @@ var Launcher = class {
39872
39890
  const named = byPath ? { [script]: this.fs.resolvePath(cwd, file) } : {};
39873
39891
  const head = await this.head(script, who.reads);
39874
39892
  if (!head) return void 0;
39875
- const words3 = await this.interpreterWords(head, script, { ...who, argv: [...argv, file] });
39876
- if (!words3) return void 0;
39877
- const { interp, args } = shebangCommand(words3.words);
39878
- const passed = [...args, command ? script : file, ...words3.kept, ...argv.slice(1)];
39893
+ const words2 = await this.interpreterWords(head, script, { ...who, argv: [...argv, file] });
39894
+ if (!words2) return void 0;
39895
+ const { interp, args } = shebangCommand(words2.words);
39896
+ const passed = [...args, command ? script : file, ...words2.kept, ...argv.slice(1)];
39879
39897
  if (!interp) return void 0;
39880
39898
  who.reads?.operandsFromEnd.set(passed.length - args.length, script);
39881
- who.reads?.interpreters.push([script, ...words3.words, String(words3.kept.length)]);
39899
+ who.reads?.interpreters.push([script, ...words2.words, String(words2.kept.length)]);
39882
39900
  const entry = await this.interpreterFile(interp, cwd, reader, who.pid, who.relative);
39883
39901
  if (!entry) return void 0;
39884
39902
  const { file: walked2, parentHops } = entry;
@@ -39897,7 +39915,7 @@ var Launcher = class {
39897
39915
  const via = [interp, ...inner?.via ?? []];
39898
39916
  const sources = [script, ...inner?.sources ?? []];
39899
39917
  const bins = [...command?.bin ? [script] : [], ...inner?.bins ?? []];
39900
- const chain2 = [...words3.binfmts, ...inner?.binfmts ?? []];
39918
+ const chain2 = [...words2.binfmts, ...inner?.binfmts ?? []];
39901
39919
  return inner && {
39902
39920
  ...inner,
39903
39921
  target: withScriptEnv(inner.target, command),
@@ -39917,7 +39935,7 @@ var Launcher = class {
39917
39935
  walkedVia: [walked2],
39918
39936
  sources: [script],
39919
39937
  ...command?.bin ? { bins: [script] } : {},
39920
- ...words3.binfmts.length > 0 ? { binfmts: words3.binfmts } : {},
39938
+ ...words2.binfmts.length > 0 ? { binfmts: words2.binfmts } : {},
39921
39939
  asked: named
39922
39940
  };
39923
39941
  }