@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.
@@ -9131,7 +9131,7 @@ function satisfies(version, range2) {
9131
9131
  }
9132
9132
 
9133
9133
  // src/version.ts
9134
- var KERNEL_VERSION = true ? "1.192.0" : "0.0.0-dev";
9134
+ var KERNEL_VERSION = true ? "1.193.1" : "0.0.0-dev";
9135
9135
  var OS_RELEASE = "6.0.0-slicc";
9136
9136
  function procVersion() {
9137
9137
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -21695,10 +21695,12 @@ function kernelLine(m, line, file) {
21695
21695
  };
21696
21696
  }
21697
21697
  var DEFAULTS = /^Defaults(?=[:@>!\s]|$)/;
21698
- var DEFAULTS_ONLY = `Defaults aren't supported, except timestamp_timeout and timestamp_type for everyone, a user or a %group: this line changes nothing`;
21698
+ 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`;
21699
+ var DEFAULTS_EXPECTED = 'expected timestamp_timeout=<minutes>, timestamp_type=<type> or env_keep+="<names>" after Defaults';
21699
21700
  var PARAM = /^(!*)([A-Za-z_]+)(?:\s*([-+]?=)\s*(.*))?$/s;
21700
21701
  var MINUTES = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)$/;
21701
21702
  var TYPES = ["tty", "ppid", "global"];
21703
+ var KEEP_OPS = ["=", "+=", "-="];
21702
21704
  function defaultsValue(raw2) {
21703
21705
  const quoted = /^"(.*)"$/s.exec(raw2);
21704
21706
  return quoted ? quoted[1] : raw2;
@@ -21717,10 +21719,33 @@ function typeParam({ text, negated, op, value: value2 }) {
21717
21719
  if (value2 === "kernel") return "timestamp_type=kernel isn't supported: use tty, ppid or global";
21718
21720
  return `timestamp_type takes =tty, =ppid or =global, not ${shown(text)}`;
21719
21721
  }
21722
+ function keepValue(names2) {
21723
+ const text = names2.join(" ");
21724
+ return names2.length === 1 ? text : `"${text}"`;
21725
+ }
21726
+ function keepParam(param, bangs, op, raw2) {
21727
+ if (bangs === "!" && op === void 0) {
21728
+ return { settings: {}, keep: { op: "!", names: [] }, text: "!env_keep" };
21729
+ }
21730
+ const quoted = /^"(.*)"$/s.exec(raw2);
21731
+ const value2 = (quoted ? quoted[1] : raw2).trim();
21732
+ const names2 = value2 === "" ? [] : value2.split(/[ \t]+/);
21733
+ const named = names2.every((name2) => !/["\\]/.test(name2) && !hasControl(name2));
21734
+ const listed = quoted ? named : named && names2.length === 1;
21735
+ if (bangs !== "" || op === void 0 || !KEEP_OPS.includes(op) || !listed) {
21736
+ 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)}`;
21737
+ }
21738
+ return {
21739
+ settings: {},
21740
+ keep: { op, names: names2 },
21741
+ text: `env_keep${op}${keepValue(names2)}`
21742
+ };
21743
+ }
21720
21744
  function defaultsParam(param) {
21721
21745
  const m = PARAM.exec(param);
21722
21746
  if (!m) return DEFAULTS_ONLY;
21723
21747
  const [, bangs = "", name2, op, raw2 = ""] = m;
21748
+ if (name2 === "env_keep") return keepParam(param, bangs, op, raw2.trim());
21724
21749
  const read = { text: param, negated: bangs !== "", op, value: defaultsValue(raw2.trim()) };
21725
21750
  const settings = name2 === "timestamp_timeout" ? timeoutParam(read) : name2 === "timestamp_type" ? typeParam(read) : DEFAULTS_ONLY;
21726
21751
  if (typeof settings === "string") return settings;
@@ -21737,24 +21762,98 @@ function defaultsWho(binding) {
21737
21762
  }
21738
21763
  return who;
21739
21764
  }
21765
+ function splitParams(list) {
21766
+ const params = [];
21767
+ let from = 0;
21768
+ let quoted = false;
21769
+ for (let i = 0; i < list.length; i++) {
21770
+ if (list[i] === '"') quoted = !quoted;
21771
+ else if (list[i] === "," && !quoted) {
21772
+ params.push(list.slice(from, i));
21773
+ from = i + 1;
21774
+ }
21775
+ }
21776
+ params.push(list.slice(from));
21777
+ return params;
21778
+ }
21740
21779
  function defaultsLine(text) {
21741
21780
  const m = /^Defaults(\S*)(?:\s+(.*))?$/s.exec(text);
21742
21781
  const who = defaultsWho(m?.[1] ?? "");
21743
21782
  if (typeof who === "string") return { error: who };
21744
21783
  const list = (m?.[2] ?? "").trim();
21745
- if (list === "")
21746
- return {
21747
- error: "expected timestamp_timeout=<minutes> or timestamp_type=<type> after Defaults"
21748
- };
21784
+ if (list === "") return { error: DEFAULTS_EXPECTED };
21749
21785
  const settings = {};
21786
+ const keep2 = [];
21750
21787
  const params = [];
21751
- for (const param of list.split(",")) {
21788
+ for (const param of splitParams(list)) {
21752
21789
  const read = defaultsParam(param.trim());
21753
21790
  if (typeof read === "string") return { error: read };
21754
21791
  Object.assign(settings, read.settings);
21792
+ if (read.keep) keep2.push(read.keep);
21755
21793
  params.push(read.text);
21756
21794
  }
21757
- return { defaults: { who, settings, params } };
21795
+ return { defaults: { who, settings, ...keep2.length > 0 ? { keep: keep2 } : {}, params } };
21796
+ }
21797
+ function keepList(entries) {
21798
+ let list = [];
21799
+ for (const { op, names: names2 } of entries.flatMap((e) => e.keep ?? [])) {
21800
+ if (op === "=" || op === "!") list = [];
21801
+ for (const name2 of names2) {
21802
+ const at = list.indexOf(name2);
21803
+ if (op !== "-=" && at < 0) list.push(name2);
21804
+ else if (op === "-=" && at >= 0) list.splice(at, 1);
21805
+ }
21806
+ }
21807
+ return list;
21808
+ }
21809
+ function seek(entry, from, ch, stop) {
21810
+ let at = from;
21811
+ while (at !== stop && at < entry.length && entry[at] !== ch) at++;
21812
+ return at;
21813
+ }
21814
+ function wildEnd(pattern, entry, star, sep) {
21815
+ let len = star;
21816
+ let sawSep = false;
21817
+ for (let at = star; at < pattern.length; at++, len++) {
21818
+ if (pattern[at] === "*") {
21819
+ while (pattern[at] === "*") at++;
21820
+ if (at === pattern.length) return len;
21821
+ sawSep ||= pattern[at] === "=";
21822
+ len = seek(entry, len, pattern[at], sawSep ? -1 : sep);
21823
+ }
21824
+ if (entry[len] !== pattern[at]) return void 0;
21825
+ }
21826
+ return len === sep || len === entry.length ? len : void 0;
21827
+ }
21828
+ function envPatternMatch(pattern, entry) {
21829
+ const eq = entry.indexOf("=");
21830
+ const sep = eq < 0 ? entry.length : eq;
21831
+ const star = pattern.indexOf("*");
21832
+ const prefix = star < 0 ? pattern.length : star;
21833
+ if (!entry.startsWith(pattern.slice(0, prefix))) return void 0;
21834
+ const whole = prefix === sep || prefix === entry.length ? prefix : void 0;
21835
+ const len = star < 0 ? whole : wildEnd(pattern, entry, star, sep);
21836
+ return len === void 0 ? void 0 : len > sep + 1;
21837
+ }
21838
+ function keptEnv(env, keep2) {
21839
+ const kept = {};
21840
+ const patterns = [...keep2].reverse();
21841
+ for (const [name2, value2] of Object.entries(env)) {
21842
+ const entries = name2 === "LOGNAME" || name2 === "USER" ? ["LOGNAME", "USER"] : [`${name2}=${value2}`];
21843
+ let full;
21844
+ for (const pattern of patterns) {
21845
+ for (const entry of entries) full ??= envPatternMatch(pattern, entry);
21846
+ if (full !== void 0) break;
21847
+ }
21848
+ if (full === void 0 || !full && value2.startsWith("() ")) continue;
21849
+ kept[name2] = value2;
21850
+ }
21851
+ const user = kept.LOGNAME ?? kept.USER;
21852
+ if (user !== void 0) {
21853
+ kept.LOGNAME ??= user;
21854
+ kept.USER ??= user;
21855
+ }
21856
+ return kept;
21758
21857
  }
21759
21858
  function resolveDefaults(entries, applies) {
21760
21859
  const everyone = entries.filter((e) => e.who === null);
@@ -21764,13 +21863,15 @@ function resolveDefaults(entries, applies) {
21764
21863
  return {
21765
21864
  timestampTimeout: settings.timestampTimeout ?? TIMESTAMP_TIMEOUT,
21766
21865
  timestampType: settings.timestampType ?? TIMESTAMP_TYPE,
21866
+ envKeep: keepList(matching),
21767
21867
  matching
21768
21868
  };
21769
21869
  }
21770
21870
  function defaultsText(entries) {
21771
21871
  const all = resolveDefaults(entries, () => false);
21872
+ const keep2 = all.envKeep.length === 0 ? "" : `, env_keep="${all.envKeep.join(" ")}"`;
21772
21873
  return [
21773
- `Defaults timestamp_timeout=${all.timestampTimeout}, timestamp_type=${all.timestampType}`,
21874
+ `Defaults timestamp_timeout=${all.timestampTimeout}, timestamp_type=${all.timestampType}${keep2}`,
21774
21875
  ...entries.filter((e) => e.who !== null).map((e) => `Defaults:${e.who.join(",")} ${e.params.join(", ")}`)
21775
21876
  ];
21776
21877
  }
@@ -22302,7 +22403,17 @@ var Sudo = class {
22302
22403
  const rules = root ? [] : policy.rules;
22303
22404
  const mine = rules.filter((rule) => applies(rule.who));
22304
22405
  if (parsed3.list) return await this.listed(self, root, mine, settings.matching);
22305
- const session = { caller, self, target, owner, policy: policyOf(settings), parsed: parsed3, signal };
22406
+ const kept = keptEnv(call.env ?? {}, settings.envKeep);
22407
+ const session = {
22408
+ caller,
22409
+ self,
22410
+ target,
22411
+ owner,
22412
+ policy: policyOf(settings),
22413
+ kept,
22414
+ parsed: parsed3,
22415
+ signal
22416
+ };
22306
22417
  if (parsed3.validate) return this.validate(session, root, mine, call.cwd);
22307
22418
  return this.command(session, root, mine, call);
22308
22419
  }
@@ -22346,7 +22457,7 @@ var Sudo = class {
22346
22457
  const now = await this.rootOnly(r.cwd, args);
22347
22458
  const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
22348
22459
  if (flipped !== void 0) return failed2("EPERM", `sudo: ${flipped} is no longer root-only`);
22349
- const { grant } = this.grant(self, target, cred, r.argv, path, r.cwd, void 0, bound3);
22460
+ const { grant } = this.grant(self, target, cred, r.argv, path, r.cwd, void 0, bound3, {});
22350
22461
  (this.o.warn ?? console.warn)(
22351
22462
  `sudo: ${self.name} : TTY=unknown ; PWD=${quoteWord(r.cwd)} ; USER=${target.name} ; REPLAY=${r.id} ; COMMAND=${argv.map(quoteWord).join(" ")}`
22352
22463
  );
@@ -22379,7 +22490,7 @@ var Sudo = class {
22379
22490
  const matching = mine.filter(
22380
22491
  (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)
22381
22492
  );
22382
- const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3);
22493
+ const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept);
22383
22494
  if (root || matching.some((rule) => rule.nopasswd)) return grant();
22384
22495
  const quoted = argv.map(quoteWord).join(" ");
22385
22496
  if (matching.length === 0) {
@@ -22552,11 +22663,13 @@ ${line}`;
22552
22663
  return false;
22553
22664
  }
22554
22665
  }
22555
- grant(self, target, cred, argv, file, cwd, term, files) {
22666
+ grant(self, target, cred, argv, file, cwd, term, files, kept) {
22667
+ const { TERM: _term, [TICKET_ENV]: _ticket, ...caller } = kept;
22556
22668
  const env = {
22557
22669
  ...this.o.env(),
22558
22670
  ...userEnv(target, this.o.pnpmHome),
22559
22671
  SHELL: target.shell,
22672
+ ...caller,
22560
22673
  PATH: SECURE_PATH,
22561
22674
  PWD: cwd,
22562
22675
  ...term !== void 0 && TERM.test(term) ? { TERM: term } : {},
@@ -29864,6 +29977,14 @@ function words2(value2) {
29864
29977
  }
29865
29978
  return [...value2];
29866
29979
  }
29980
+ function variables(value2) {
29981
+ if (typeof value2 !== "object" || value2 === null) return {};
29982
+ return Object.fromEntries(
29983
+ Object.entries(value2).filter(
29984
+ ([name2, v]) => typeof v === "string" && /^[^=\0]+$/.test(name2) && !v.includes("\0")
29985
+ )
29986
+ );
29987
+ }
29867
29988
  var ESCAPES = { " ": "\\t", "\n": "\\n", "\r": "\\r" };
29868
29989
  function clipboardLine(text) {
29869
29990
  let out = "";
@@ -31386,7 +31507,8 @@ var WasmProcess = class {
31386
31507
  op: "proc-sudo",
31387
31508
  args: words2(req.args),
31388
31509
  cwd: typeof req.cwd === "string" && req.cwd.startsWith("/") ? req.cwd : "/",
31389
- ...typeof req.term === "string" ? { term: req.term } : {}
31510
+ ...typeof req.term === "string" ? { term: req.term } : {},
31511
+ env: variables(req.env)
31390
31512
  };
31391
31513
  const answer2 = await sudo(
31392
31514
  call,