@ai-ecoverse/slicc-kernel 1.192.0 → 1.193.1

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.
package/dist/node.js CHANGED
@@ -7292,7 +7292,7 @@ function satisfies(version, range2) {
7292
7292
  }
7293
7293
 
7294
7294
  // src/version.ts
7295
- var KERNEL_VERSION = true ? "1.192.0" : "0.0.0-dev";
7295
+ var KERNEL_VERSION = true ? "1.193.1" : "0.0.0-dev";
7296
7296
  var OS_RELEASE = "6.0.0-slicc";
7297
7297
  function procVersion() {
7298
7298
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -18393,10 +18393,12 @@ function kernelLine(m, line, file) {
18393
18393
  };
18394
18394
  }
18395
18395
  var DEFAULTS = /^Defaults(?=[:@>!\s]|$)/;
18396
- var DEFAULTS_ONLY = `Defaults aren't supported, except timestamp_timeout and timestamp_type for everyone, a user or a %group: this line changes nothing`;
18396
+ var DEFAULTS_ONLY = `Defaults aren't supported, except timestamp_timeout, timestamp_type and env_keep for everyone, a user or a %group: this line changes nothing`;
18397
+ var DEFAULTS_EXPECTED = 'expected timestamp_timeout=<minutes>, timestamp_type=<type> or env_keep+="<names>" after Defaults';
18397
18398
  var PARAM = /^(!*)([A-Za-z_]+)(?:\s*([-+]?=)\s*(.*))?$/s;
18398
18399
  var MINUTES = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)$/;
18399
18400
  var TYPES = ["tty", "ppid", "global"];
18401
+ var KEEP_OPS = ["=", "+=", "-="];
18400
18402
  function defaultsValue(raw2) {
18401
18403
  const quoted = /^"(.*)"$/s.exec(raw2);
18402
18404
  return quoted ? quoted[1] : raw2;
@@ -18415,10 +18417,33 @@ function typeParam({ text, negated, op, value: value2 }) {
18415
18417
  if (value2 === "kernel") return "timestamp_type=kernel isn't supported: use tty, ppid or global";
18416
18418
  return `timestamp_type takes =tty, =ppid or =global, not ${shown(text)}`;
18417
18419
  }
18420
+ function keepValue(names2) {
18421
+ const text = names2.join(" ");
18422
+ return names2.length === 1 ? text : `"${text}"`;
18423
+ }
18424
+ function keepParam(param, bangs, op, raw2) {
18425
+ if (bangs === "!" && op === void 0) {
18426
+ return { settings: {}, keep: { op: "!", names: [] }, text: "!env_keep" };
18427
+ }
18428
+ const quoted = /^"(.*)"$/s.exec(raw2);
18429
+ const value2 = (quoted ? quoted[1] : raw2).trim();
18430
+ const names2 = value2 === "" ? [] : value2.split(/[ \t]+/);
18431
+ const named = names2.every((name2) => !/["\\]/.test(name2) && !hasControl(name2));
18432
+ const listed = quoted ? named : named && names2.length === 1;
18433
+ if (bangs !== "" || op === void 0 || !KEEP_OPS.includes(op) || !listed) {
18434
+ return `env_keep takes a double-quoted, space-separated list of names, or one name without quotes, after =, += or -= (!env_keep empties the list), not ${shown(param)}`;
18435
+ }
18436
+ return {
18437
+ settings: {},
18438
+ keep: { op, names: names2 },
18439
+ text: `env_keep${op}${keepValue(names2)}`
18440
+ };
18441
+ }
18418
18442
  function defaultsParam(param) {
18419
18443
  const m = PARAM.exec(param);
18420
18444
  if (!m) return DEFAULTS_ONLY;
18421
18445
  const [, bangs = "", name2, op, raw2 = ""] = m;
18446
+ if (name2 === "env_keep") return keepParam(param, bangs, op, raw2.trim());
18422
18447
  const read = { text: param, negated: bangs !== "", op, value: defaultsValue(raw2.trim()) };
18423
18448
  const settings = name2 === "timestamp_timeout" ? timeoutParam(read) : name2 === "timestamp_type" ? typeParam(read) : DEFAULTS_ONLY;
18424
18449
  if (typeof settings === "string") return settings;
@@ -18435,24 +18460,98 @@ function defaultsWho(binding) {
18435
18460
  }
18436
18461
  return who;
18437
18462
  }
18463
+ function splitParams(list) {
18464
+ const params = [];
18465
+ let from = 0;
18466
+ let quoted = false;
18467
+ for (let i = 0; i < list.length; i++) {
18468
+ if (list[i] === '"') quoted = !quoted;
18469
+ else if (list[i] === "," && !quoted) {
18470
+ params.push(list.slice(from, i));
18471
+ from = i + 1;
18472
+ }
18473
+ }
18474
+ params.push(list.slice(from));
18475
+ return params;
18476
+ }
18438
18477
  function defaultsLine(text) {
18439
18478
  const m = /^Defaults(\S*)(?:\s+(.*))?$/s.exec(text);
18440
18479
  const who = defaultsWho(m?.[1] ?? "");
18441
18480
  if (typeof who === "string") return { error: who };
18442
18481
  const list = (m?.[2] ?? "").trim();
18443
- if (list === "")
18444
- return {
18445
- error: "expected timestamp_timeout=<minutes> or timestamp_type=<type> after Defaults"
18446
- };
18482
+ if (list === "") return { error: DEFAULTS_EXPECTED };
18447
18483
  const settings = {};
18484
+ const keep2 = [];
18448
18485
  const params = [];
18449
- for (const param of list.split(",")) {
18486
+ for (const param of splitParams(list)) {
18450
18487
  const read = defaultsParam(param.trim());
18451
18488
  if (typeof read === "string") return { error: read };
18452
18489
  Object.assign(settings, read.settings);
18490
+ if (read.keep) keep2.push(read.keep);
18453
18491
  params.push(read.text);
18454
18492
  }
18455
- return { defaults: { who, settings, params } };
18493
+ return { defaults: { who, settings, ...keep2.length > 0 ? { keep: keep2 } : {}, params } };
18494
+ }
18495
+ function keepList(entries) {
18496
+ let list = [];
18497
+ for (const { op, names: names2 } of entries.flatMap((e) => e.keep ?? [])) {
18498
+ if (op === "=" || op === "!") list = [];
18499
+ for (const name2 of names2) {
18500
+ const at = list.indexOf(name2);
18501
+ if (op !== "-=" && at < 0) list.push(name2);
18502
+ else if (op === "-=" && at >= 0) list.splice(at, 1);
18503
+ }
18504
+ }
18505
+ return list;
18506
+ }
18507
+ function seek(entry, from, ch, stop) {
18508
+ let at = from;
18509
+ while (at !== stop && at < entry.length && entry[at] !== ch) at++;
18510
+ return at;
18511
+ }
18512
+ function wildEnd(pattern, entry, star, sep) {
18513
+ let len = star;
18514
+ let sawSep = false;
18515
+ for (let at = star; at < pattern.length; at++, len++) {
18516
+ if (pattern[at] === "*") {
18517
+ while (pattern[at] === "*") at++;
18518
+ if (at === pattern.length) return len;
18519
+ sawSep ||= pattern[at] === "=";
18520
+ len = seek(entry, len, pattern[at], sawSep ? -1 : sep);
18521
+ }
18522
+ if (entry[len] !== pattern[at]) return void 0;
18523
+ }
18524
+ return len === sep || len === entry.length ? len : void 0;
18525
+ }
18526
+ function envPatternMatch(pattern, entry) {
18527
+ const eq = entry.indexOf("=");
18528
+ const sep = eq < 0 ? entry.length : eq;
18529
+ const star = pattern.indexOf("*");
18530
+ const prefix = star < 0 ? pattern.length : star;
18531
+ if (!entry.startsWith(pattern.slice(0, prefix))) return void 0;
18532
+ const whole = prefix === sep || prefix === entry.length ? prefix : void 0;
18533
+ const len = star < 0 ? whole : wildEnd(pattern, entry, star, sep);
18534
+ return len === void 0 ? void 0 : len > sep + 1;
18535
+ }
18536
+ function keptEnv(env, keep2) {
18537
+ const kept = {};
18538
+ const patterns = [...keep2].reverse();
18539
+ for (const [name2, value2] of Object.entries(env)) {
18540
+ const entries = name2 === "LOGNAME" || name2 === "USER" ? ["LOGNAME", "USER"] : [`${name2}=${value2}`];
18541
+ let full;
18542
+ for (const pattern of patterns) {
18543
+ for (const entry of entries) full ??= envPatternMatch(pattern, entry);
18544
+ if (full !== void 0) break;
18545
+ }
18546
+ if (full === void 0 || !full && value2.startsWith("() ")) continue;
18547
+ kept[name2] = value2;
18548
+ }
18549
+ const user = kept.LOGNAME ?? kept.USER;
18550
+ if (user !== void 0) {
18551
+ kept.LOGNAME ??= user;
18552
+ kept.USER ??= user;
18553
+ }
18554
+ return kept;
18456
18555
  }
18457
18556
  function resolveDefaults(entries, applies) {
18458
18557
  const everyone = entries.filter((e) => e.who === null);
@@ -18462,13 +18561,15 @@ function resolveDefaults(entries, applies) {
18462
18561
  return {
18463
18562
  timestampTimeout: settings.timestampTimeout ?? TIMESTAMP_TIMEOUT,
18464
18563
  timestampType: settings.timestampType ?? TIMESTAMP_TYPE,
18564
+ envKeep: keepList(matching),
18465
18565
  matching
18466
18566
  };
18467
18567
  }
18468
18568
  function defaultsText(entries) {
18469
18569
  const all = resolveDefaults(entries, () => false);
18570
+ const keep2 = all.envKeep.length === 0 ? "" : `, env_keep="${all.envKeep.join(" ")}"`;
18470
18571
  return [
18471
- `Defaults timestamp_timeout=${all.timestampTimeout}, timestamp_type=${all.timestampType}`,
18572
+ `Defaults timestamp_timeout=${all.timestampTimeout}, timestamp_type=${all.timestampType}${keep2}`,
18472
18573
  ...entries.filter((e) => e.who !== null).map((e) => `Defaults:${e.who.join(",")} ${e.params.join(", ")}`)
18473
18574
  ];
18474
18575
  }
@@ -19377,7 +19478,17 @@ var Sudo = class {
19377
19478
  const rules = root ? [] : policy.rules;
19378
19479
  const mine = rules.filter((rule) => applies(rule.who));
19379
19480
  if (parsed3.list) return await this.listed(self, root, mine, settings.matching);
19380
- const session = { caller, self, target, owner, policy: policyOf(settings), parsed: parsed3, signal };
19481
+ const kept = keptEnv(call.env ?? {}, settings.envKeep);
19482
+ const session = {
19483
+ caller,
19484
+ self,
19485
+ target,
19486
+ owner,
19487
+ policy: policyOf(settings),
19488
+ kept,
19489
+ parsed: parsed3,
19490
+ signal
19491
+ };
19381
19492
  if (parsed3.validate) return this.validate(session, root, mine, call.cwd);
19382
19493
  return this.command(session, root, mine, call);
19383
19494
  }
@@ -19421,7 +19532,7 @@ var Sudo = class {
19421
19532
  const now = await this.rootOnly(r.cwd, args);
19422
19533
  const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
19423
19534
  if (flipped !== void 0) return failed2("EPERM", `sudo: ${flipped} is no longer root-only`);
19424
- const { grant } = this.grant(self, target, cred, r.argv, path, r.cwd, void 0, bound3);
19535
+ const { grant } = this.grant(self, target, cred, r.argv, path, r.cwd, void 0, bound3, {});
19425
19536
  (this.o.warn ?? console.warn)(
19426
19537
  `sudo: ${self.name} : TTY=unknown ; PWD=${quoteWord(r.cwd)} ; USER=${target.name} ; REPLAY=${r.id} ; COMMAND=${argv.map(quoteWord).join(" ")}`
19427
19538
  );
@@ -19454,7 +19565,7 @@ var Sudo = class {
19454
19565
  const matching = mine.filter(
19455
19566
  (rule) => (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === cwd) && stdinMatches(rule, caller.stdin) && commandMatches(rule.cmnd, argv) && pinned(rule, bound3)
19456
19567
  );
19457
- const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3);
19568
+ const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept);
19458
19569
  if (root || matching.some((rule) => rule.nopasswd)) return grant();
19459
19570
  const quoted = argv.map(quoteWord).join(" ");
19460
19571
  if (matching.length === 0) {
@@ -19627,11 +19738,13 @@ ${line}`;
19627
19738
  return false;
19628
19739
  }
19629
19740
  }
19630
- grant(self, target, cred, argv, file, cwd, term, files) {
19741
+ grant(self, target, cred, argv, file, cwd, term, files, kept) {
19742
+ const { TERM: _term, [TICKET_ENV]: _ticket, ...caller } = kept;
19631
19743
  const env = {
19632
19744
  ...this.o.env(),
19633
19745
  ...userEnv(target, this.o.pnpmHome),
19634
19746
  SHELL: target.shell,
19747
+ ...caller,
19635
19748
  PATH: SECURE_PATH,
19636
19749
  PWD: cwd,
19637
19750
  ...term !== void 0 && TERM.test(term) ? { TERM: term } : {},
@@ -26769,6 +26882,14 @@ function words2(value2) {
26769
26882
  }
26770
26883
  return [...value2];
26771
26884
  }
26885
+ function variables(value2) {
26886
+ if (typeof value2 !== "object" || value2 === null) return {};
26887
+ return Object.fromEntries(
26888
+ Object.entries(value2).filter(
26889
+ ([name2, v]) => typeof v === "string" && /^[^=\0]+$/.test(name2) && !v.includes("\0")
26890
+ )
26891
+ );
26892
+ }
26772
26893
  var ESCAPES = { " ": "\\t", "\n": "\\n", "\r": "\\r" };
26773
26894
  function clipboardLine(text) {
26774
26895
  let out = "";
@@ -28291,7 +28412,8 @@ var WasmProcess = class {
28291
28412
  op: "proc-sudo",
28292
28413
  args: words2(req.args),
28293
28414
  cwd: typeof req.cwd === "string" && req.cwd.startsWith("/") ? req.cwd : "/",
28294
- ...typeof req.term === "string" ? { term: req.term } : {}
28415
+ ...typeof req.term === "string" ? { term: req.term } : {},
28416
+ env: variables(req.env)
28295
28417
  };
28296
28418
  const answer2 = await sudo(
28297
28419
  call,