@ai-ecoverse/slicc-kernel 1.196.31 → 1.196.32

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.
@@ -10034,7 +10034,7 @@ function satisfies(version, range2) {
10034
10034
  }
10035
10035
 
10036
10036
  // src/version.ts
10037
- var KERNEL_VERSION = true ? "1.196.31" : "0.0.0-dev";
10037
+ var KERNEL_VERSION = true ? "1.196.32" : "0.0.0-dev";
10038
10038
  var OS_RELEASE = "6.0.0-slicc";
10039
10039
  function procVersion() {
10040
10040
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -32334,13 +32334,27 @@ function words2(value2) {
32334
32334
  }
32335
32335
  return [...value2];
32336
32336
  }
32337
- function variables(value2) {
32338
- if (typeof value2 !== "object" || value2 === null) return {};
32339
- return Object.fromEntries(
32340
- Object.entries(value2).filter(
32341
- ([name2, v]) => typeof v === "string" && /^[^=\0]+$/.test(name2) && !v.includes("\0")
32342
- )
32343
- );
32337
+ var SUDO_ENV_MAX = 4096;
32338
+ var SUDO_ENV_BYTES = 1024 * 1024;
32339
+ function sudoVariables(value2, term) {
32340
+ const input = typeof value2 === "object" && value2 !== null ? value2 : {};
32341
+ const env = /* @__PURE__ */ Object.create(null);
32342
+ let count3 = 0;
32343
+ let budget = SUDO_ENV_BYTES;
32344
+ const fits = (name2, text) => {
32345
+ if (++count3 > SUDO_ENV_MAX || name2.length + text.length + 2 > budget) return false;
32346
+ budget -= storedSize(name2) + storedSize(text) + 2;
32347
+ return budget >= 0;
32348
+ };
32349
+ for (const name2 in input) {
32350
+ if (!Object.hasOwn(input, name2)) continue;
32351
+ const entry = input[name2];
32352
+ if (!fits(name2, typeof entry === "string" ? entry : "")) return void 0;
32353
+ if (typeof entry === "string" && /^[^=\0]+$/.test(name2) && !entry.includes("\0"))
32354
+ env[name2] = entry;
32355
+ }
32356
+ if (term !== void 0 && env.TERM !== term && !fits("TERM", term)) return void 0;
32357
+ return env;
32344
32358
  }
32345
32359
  var ESCAPES = { " ": "\\t", "\n": "\\n", "\r": "\\r" };
32346
32360
  function clipboardLine(text) {
@@ -34327,12 +34341,17 @@ var WasmProcess = class _WasmProcess {
34327
34341
  async sudo(req, cancelled) {
34328
34342
  const { sudo } = this.options;
34329
34343
  if (!sudo) throw new KernelError("ENOSYS");
34344
+ const args = words2(req.args);
34345
+ const term = typeof req.term === "string" ? req.term : void 0;
34346
+ const submitted = sudoVariables(req.env, term);
34347
+ if (submitted === void 0)
34348
+ return { errno: "E2BIG", error: "sudo: the submitted environment is too large" };
34330
34349
  const call = {
34331
34350
  op: "proc-sudo",
34332
- args: words2(req.args),
34351
+ args,
34333
34352
  cwd: typeof req.cwd === "string" && req.cwd.startsWith("/") ? req.cwd : "/",
34334
- ...typeof req.term === "string" ? { term: req.term } : {},
34335
- env: variables(req.env)
34353
+ ...term !== void 0 ? { term } : {},
34354
+ env: submitted
34336
34355
  };
34337
34356
  const answer2 = await sudo(
34338
34357
  call,