@ai-ecoverse/slicc-kernel 1.196.36 → 1.196.37

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.
@@ -10254,7 +10254,7 @@ function satisfies(version, range2) {
10254
10254
  }
10255
10255
 
10256
10256
  // src/version.ts
10257
- var KERNEL_VERSION = true ? "1.196.36" : "0.0.0-dev";
10257
+ var KERNEL_VERSION = true ? "1.196.37" : "0.0.0-dev";
10258
10258
  var OS_RELEASE = "6.0.0-slicc";
10259
10259
  function procVersion() {
10260
10260
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -11189,27 +11189,27 @@ function hashId(text) {
11189
11189
  return hex4(a) + hex4(b);
11190
11190
  }
11191
11191
  function split2(text, count3) {
11192
- const words3 = [];
11192
+ const words2 = [];
11193
11193
  let rest2 = text;
11194
11194
  for (let i = 0; i < count3; i++) {
11195
11195
  const match = /^(\S+)\s+/.exec(rest2);
11196
11196
  if (!match) return void 0;
11197
- words3.push(match[1]);
11197
+ words2.push(match[1]);
11198
11198
  rest2 = rest2.slice(match[0].length);
11199
11199
  }
11200
- return [words3, rest2.trim()];
11200
+ return [words2, rest2.trim()];
11201
11201
  }
11202
11202
  function jobOf(content, pending, ctx, env) {
11203
11203
  const fields = content.startsWith("@") ? 1 : 5;
11204
11204
  const parts2 = split2(content, fields + (ctx.system ? 1 : 0));
11205
11205
  if (!parts2 || parts2[1] === "") throw new Error("no command");
11206
- const [words3, command] = parts2;
11207
- const schedule = words3.slice(0, fields).join(" ");
11206
+ const [words2, command] = parts2;
11207
+ const schedule = words2.slice(0, fields).join(" ");
11208
11208
  const when = parseWhen(schedule);
11209
11209
  const zone = env.CRON_TZ;
11210
11210
  if (zone && !when.reboot && canonicalZone(zone) === void 0)
11211
11211
  throw new Error(`CRON_TZ: unknown time zone "${zone}"`);
11212
- const user = ctx.system ? words3[fields] : void 0;
11212
+ const user = ctx.system ? words2[fields] : void 0;
11213
11213
  if (user !== void 0 && !USER_NAME.test(user)) throw new Error(`bad user name ${user}`);
11214
11214
  if (pending !== void 0 && !JOB_NAME.test(pending))
11215
11215
  throw new Error(`bad job name "${pending}"`);
@@ -23462,21 +23462,21 @@ function unescaped2(double) {
23462
23462
  }
23463
23463
  function splitWords(text) {
23464
23464
  const piece = /'([^']*)'|"((?:[^"\\]|\\[\s\S])*)"|\\([\s\S])|([^\s'"\\]+)|(\s+)/y;
23465
- const words3 = [];
23465
+ const words2 = [];
23466
23466
  let word;
23467
23467
  while (piece.lastIndex < text.length) {
23468
23468
  const m = piece.exec(text);
23469
23469
  if (!m) return void 0;
23470
23470
  const [, single, double, escaped, plain3, space] = m;
23471
23471
  if (space !== void 0) {
23472
- if (word !== void 0) words3.push(word);
23472
+ if (word !== void 0) words2.push(word);
23473
23473
  word = void 0;
23474
23474
  continue;
23475
23475
  }
23476
23476
  word = (word ?? "") + (single ?? (double !== void 0 ? unescaped2(double) : escaped ?? plain3));
23477
23477
  }
23478
- if (word !== void 0) words3.push(word);
23479
- return words3;
23478
+ if (word !== void 0) words2.push(word);
23479
+ return words2;
23480
23480
  }
23481
23481
  function shellQuote(word) {
23482
23482
  return PLAIN2.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
@@ -23499,14 +23499,14 @@ function addPlain(word, plain3) {
23499
23499
  }
23500
23500
  function splitPatterns(text) {
23501
23501
  const piece = /'([^']*)'|"((?:[^"\\]|\\[\s\S])*)"|\\([\s\S])|([^\s'"\\]+)|(\s+)/y;
23502
- const words3 = [];
23502
+ const words2 = [];
23503
23503
  let word;
23504
23504
  while (piece.lastIndex < text.length) {
23505
23505
  const m = piece.exec(text);
23506
23506
  if (!m) return void 0;
23507
23507
  const [, single, double, escaped, plain3, space] = m;
23508
23508
  if (space !== void 0) {
23509
- if (word !== void 0) words3.push(word);
23509
+ if (word !== void 0) words2.push(word);
23510
23510
  word = void 0;
23511
23511
  continue;
23512
23512
  }
@@ -23514,8 +23514,8 @@ function splitPatterns(text) {
23514
23514
  if (plain3 !== void 0) addPlain(word, plain3);
23515
23515
  else addPart(word, single ?? (double !== void 0 ? unescaped2(double) : escaped));
23516
23516
  }
23517
- if (word !== void 0) words3.push(word);
23518
- return words3;
23517
+ if (word !== void 0) words2.push(word);
23518
+ return words2;
23519
23519
  }
23520
23520
  var literal = (pattern) => pattern.map((p) => p ?? "*").join("");
23521
23521
  var isAny = (pattern) => pattern?.length === 1 && pattern[0] === null;
@@ -23591,14 +23591,14 @@ function whoError(who) {
23591
23591
  return `expected a user name, %group or ALL first, not ${shown(who)}`;
23592
23592
  }
23593
23593
  function cwdOf(word) {
23594
- const words3 = splitWords(word);
23595
- const path = words3?.length === 1 ? words3[0] : "";
23594
+ const words2 = splitWords(word);
23595
+ const path = words2?.length === 1 ? words2[0] : "";
23596
23596
  return path.startsWith("/") ? normalizePath(path) : "";
23597
23597
  }
23598
23598
  function commandOf2(text, after) {
23599
- const words3 = splitPatterns(text);
23600
- if (words3 === void 0) return "a quote in the command is not closed, or it ends in a \\";
23601
- const [first, ...args] = words3;
23599
+ const words2 = splitPatterns(text);
23600
+ if (words2 === void 0) return "a quote in the command is not closed, or it ends in a \\";
23601
+ const [first, ...args] = words2;
23602
23602
  const path = first ? literal(first) : "";
23603
23603
  if (path === "") return `expected a command after ${after}`;
23604
23604
  if (!path.startsWith("/")) return `expected an absolute command path, not ${shown(path)}`;
@@ -23781,14 +23781,14 @@ function legacyApproval(line, file, rule) {
23781
23781
  const stdin = rule.stdin === void 0 ? "" : "Stdin none ";
23782
23782
  const prefix = `NOPASSWD ${rule.who} (${rule.target}) ${cwd}${stdin}Cmnd `;
23783
23783
  if (!line.startsWith(prefix)) return rule;
23784
- const words3 = line.slice(prefix.length).trimEnd();
23784
+ const words2 = line.slice(prefix.length).trimEnd();
23785
23785
  if (cmnd.args === void 0) {
23786
- if (words3 !== quote(cmnd.path)) return rule;
23786
+ if (words2 !== quote(cmnd.path)) return rule;
23787
23787
  return { ...rule, cmnd: { ...cmnd, args: [] }, ...stdin ? {} : { sha256: {} } };
23788
23788
  }
23789
23789
  if (cmnd.args.some((arg) => arg.includes(null))) return rule;
23790
- const current = rule.cwd !== void 0 && words3 === formatCommand(cmnd, quote);
23791
- const earliest = !stdin && words3 === [cmnd.path, ...cmnd.args.map(literal)].map(quote).join(" ");
23790
+ const current = rule.cwd !== void 0 && words2 === formatCommand(cmnd, quote);
23791
+ const earliest = !stdin && words2 === [cmnd.path, ...cmnd.args.map(literal)].map(quote).join(" ");
23792
23792
  return current || earliest ? { ...rule, sha256: {} } : rule;
23793
23793
  }
23794
23794
  function kernelLine(m, line, file) {
@@ -24939,8 +24939,8 @@ ${lines3}
24939
24939
  const st = await fs.lstat(path).catch(() => void 0);
24940
24940
  if (st && !await this.trusted(path)) return false;
24941
24941
  const old = st ? await fs.readFile(path) : "";
24942
- const words3 = recordedCommand(argv);
24943
- const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Stdin none ${sha256Text(bound3, routeSha256, chainSha256)}Cmnd ${words3}
24942
+ const words2 = recordedCommand(argv);
24943
+ const line = `NOPASSWD ${self.name} (${target.name}) Cwd ${quoteWord(cwd)} Stdin none ${sha256Text(bound3, routeSha256, chainSha256)}Cmnd ${words2}
24944
24944
  `;
24945
24945
  const text = old === "" || old.endsWith("\n") ? `${old}${line}` : `${old}
24946
24946
  ${line}`;
@@ -26247,8 +26247,8 @@ function ipv6(host) {
26247
26247
  const head = groups(halves[0]);
26248
26248
  const back = halves.length === 2 ? groups(halves[1]) : [];
26249
26249
  if (![...head, ...back].every((g) => /^[0-9A-Fa-f]{1,4}$/.test(g))) return void 0;
26250
- const words3 = [...head, ...back].map((g) => Number.parseInt(g, 16));
26251
- const missing7 = 8 - words3.length - tail2.length;
26250
+ const words2 = [...head, ...back].map((g) => Number.parseInt(g, 16));
26251
+ const missing7 = 8 - words2.length - tail2.length;
26252
26252
  if (halves.length === 2 ? missing7 < 1 : missing7 !== 0) return void 0;
26253
26253
  const all = [
26254
26254
  ...head.map((g) => Number.parseInt(g, 16)),
@@ -32589,21 +32589,26 @@ var PATH_FLAGS = PATH_ONLY | 65536 | 131072;
32589
32589
  var KEYBOARD = /* @__PURE__ */ new Set([SIG.INT, SIG.QUIT, SIG.TSTP]);
32590
32590
  var STUCK_ESCAPES = /* @__PURE__ */ new Set([SIG.INT, SIG.TERM, SIG.QUIT, SIG.HUP]);
32591
32591
  var DEFAULT_UMASK2 = 18;
32592
- function words2(value2) {
32593
- if (!Array.isArray(value2) || !value2.every((w) => typeof w === "string")) {
32594
- throw new KernelError("EINVAL");
32595
- }
32596
- return [...value2];
32597
- }
32598
- var SUDO_ENV_MAX = 4096;
32599
- var SUDO_ENV_BYTES = 1024 * 1024;
32600
- function sudoVariables(value2, term) {
32592
+ var SUDO_VECTOR_MAX = 4096;
32593
+ var SUDO_INPUT_BYTES = 1024 * 1024;
32594
+ function budgetAfterArgs(args) {
32595
+ if (!Array.isArray(args)) throw new KernelError("EINVAL");
32596
+ if (args.length > SUDO_VECTOR_MAX) return -1;
32597
+ let remaining = SUDO_INPUT_BYTES;
32598
+ for (const word of args) {
32599
+ if (typeof word !== "string") throw new KernelError("EINVAL");
32600
+ if (word.length + 1 > remaining) return -1;
32601
+ remaining -= storedSize(word) + 1;
32602
+ if (remaining < 0) return -1;
32603
+ }
32604
+ return remaining;
32605
+ }
32606
+ function sudoVariables(value2, term, budget) {
32601
32607
  const input = typeof value2 === "object" && value2 !== null ? value2 : {};
32602
32608
  const env = /* @__PURE__ */ Object.create(null);
32603
32609
  let count3 = 0;
32604
- let budget = SUDO_ENV_BYTES;
32605
32610
  const fits = (name2, text) => {
32606
- if (++count3 > SUDO_ENV_MAX || name2.length + text.length + 2 > budget) return false;
32611
+ if (++count3 > SUDO_VECTOR_MAX || name2.length + text.length + 2 > budget) return false;
32607
32612
  budget -= storedSize(name2) + storedSize(text) + 2;
32608
32613
  return budget >= 0;
32609
32614
  };
@@ -34652,14 +34657,15 @@ var WasmProcess = class _WasmProcess {
34652
34657
  async sudo(req, cancelled) {
34653
34658
  const { sudo } = this.options;
34654
34659
  if (!sudo) throw new KernelError("ENOSYS");
34655
- const args = words2(req.args);
34660
+ const budget = budgetAfterArgs(req.args);
34661
+ if (budget < 0) return { errno: "E2BIG", error: "sudo: the submitted arguments are too large" };
34656
34662
  const term = typeof req.term === "string" ? req.term : void 0;
34657
- const submitted = sudoVariables(req.env, term);
34663
+ const submitted = sudoVariables(req.env, term, budget);
34658
34664
  if (submitted === void 0)
34659
34665
  return { errno: "E2BIG", error: "sudo: the submitted environment is too large" };
34660
34666
  const call = {
34661
34667
  op: "proc-sudo",
34662
- args,
34668
+ args: [...req.args],
34663
34669
  cwd: typeof req.cwd === "string" && req.cwd.startsWith("/") ? req.cwd : "/",
34664
34670
  ...term !== void 0 ? { term } : {},
34665
34671
  env: submitted
@@ -39331,27 +39337,27 @@ function appendedRoots(given) {
39331
39337
  }
39332
39338
  return [...roots];
39333
39339
  }
39334
- function plainEnv(words3) {
39335
- const next3 = words3[1];
39336
- if (baseName3(words3[0] ?? "") !== "env" || next3 === void 0) return false;
39340
+ function plainEnv(words2) {
39341
+ const next3 = words2[1];
39342
+ if (baseName3(words2[0] ?? "") !== "env" || next3 === void 0) return false;
39337
39343
  return next3 === "-S" || !next3.startsWith("-") && !next3.includes("=");
39338
39344
  }
39339
- function shebangCommand(words3) {
39340
- if (!plainEnv(words3)) {
39341
- const arg2 = words3.slice(1).join(" ");
39342
- return { interp: words3[0], args: arg2 ? [arg2] : [] };
39345
+ function shebangCommand(words2) {
39346
+ if (!plainEnv(words2)) {
39347
+ const arg2 = words2.slice(1).join(" ");
39348
+ return { interp: words2[0], args: arg2 ? [arg2] : [] };
39343
39349
  }
39344
- const split3 = words3[1] === "-S";
39345
- const [interp, ...rest2] = words3.slice(split3 ? 2 : 1);
39350
+ const split3 = words2[1] === "-S";
39351
+ const [interp, ...rest2] = words2.slice(split3 ? 2 : 1);
39346
39352
  const arg = rest2.join(" ");
39347
39353
  return { interp, args: split3 ? rest2 : arg ? [arg] : [] };
39348
39354
  }
39349
39355
  function interpreter(head) {
39350
- const words3 = shebang(head);
39351
- if (!words3) return "node";
39352
- if (baseName3(words3[0]) === "env") words3.shift();
39353
- if (words3[0] === "-S") words3.shift();
39354
- return baseName3(words3[0] ?? "");
39356
+ const words2 = shebang(head);
39357
+ if (!words2) return "node";
39358
+ if (baseName3(words2[0]) === "env") words2.shift();
39359
+ if (words2[0] === "-S") words2.shift();
39360
+ return baseName3(words2[0] ?? "");
39355
39361
  }
39356
39362
  function expandDefaults(defaults2, env) {
39357
39363
  const out = {};
@@ -40289,13 +40295,13 @@ var Launcher = class {
40289
40295
  const named = byPath ? { [script]: this.fs.resolvePath(cwd, file) } : {};
40290
40296
  const head = await this.head(script, who.reads);
40291
40297
  if (!head) return void 0;
40292
- const words3 = await this.interpreterWords(head, script, { ...who, argv: [...argv, file] });
40293
- if (!words3) return void 0;
40294
- const { interp, args } = shebangCommand(words3.words);
40295
- const passed = [...args, command ? script : file, ...words3.kept, ...argv.slice(1)];
40298
+ const words2 = await this.interpreterWords(head, script, { ...who, argv: [...argv, file] });
40299
+ if (!words2) return void 0;
40300
+ const { interp, args } = shebangCommand(words2.words);
40301
+ const passed = [...args, command ? script : file, ...words2.kept, ...argv.slice(1)];
40296
40302
  if (!interp) return void 0;
40297
40303
  who.reads?.operandsFromEnd.set(passed.length - args.length, script);
40298
- who.reads?.interpreters.push([script, ...words3.words, String(words3.kept.length)]);
40304
+ who.reads?.interpreters.push([script, ...words2.words, String(words2.kept.length)]);
40299
40305
  const entry = await this.interpreterFile(interp, cwd, reader, who.pid, who.relative);
40300
40306
  if (!entry) return void 0;
40301
40307
  const { file: walked2, parentHops } = entry;
@@ -40314,7 +40320,7 @@ var Launcher = class {
40314
40320
  const via = [interp, ...inner?.via ?? []];
40315
40321
  const sources = [script, ...inner?.sources ?? []];
40316
40322
  const bins = [...command?.bin ? [script] : [], ...inner?.bins ?? []];
40317
- const chain2 = [...words3.binfmts, ...inner?.binfmts ?? []];
40323
+ const chain2 = [...words2.binfmts, ...inner?.binfmts ?? []];
40318
40324
  return inner && {
40319
40325
  ...inner,
40320
40326
  target: withScriptEnv(inner.target, command),
@@ -40334,7 +40340,7 @@ var Launcher = class {
40334
40340
  walkedVia: [walked2],
40335
40341
  sources: [script],
40336
40342
  ...command?.bin ? { bins: [script] } : {},
40337
- ...words3.binfmts.length > 0 ? { binfmts: words3.binfmts } : {},
40343
+ ...words2.binfmts.length > 0 ? { binfmts: words2.binfmts } : {},
40338
40344
  asked: named
40339
40345
  };
40340
40346
  }