@ai-ecoverse/slicc-kernel 1.196.52 → 1.196.53

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.
@@ -5338,7 +5338,7 @@ function satisfies(version, range2) {
5338
5338
  }
5339
5339
 
5340
5340
  // src/version.ts
5341
- var KERNEL_VERSION = true ? "1.196.52" : "0.0.0-dev";
5341
+ var KERNEL_VERSION = true ? "1.196.53" : "0.0.0-dev";
5342
5342
  var OS_RELEASE = "6.0.0-slicc";
5343
5343
  function procVersion() {
5344
5344
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -19087,6 +19087,21 @@ var SealedBroker = class {
19087
19087
  }
19088
19088
  };
19089
19089
 
19090
+ // src/sudo-argv.ts
19091
+ var SUDO_VECTOR_MAX = 4096;
19092
+ var SUDO_INPUT_BYTES = 1024 * 1024;
19093
+ function budgetAfterArgs(args) {
19094
+ if (!Array.isArray(args)) return void 0;
19095
+ let remaining = args.length > SUDO_VECTOR_MAX ? -1 : SUDO_INPUT_BYTES;
19096
+ for (const word of args) {
19097
+ if (typeof word !== "string") return void 0;
19098
+ if (word.includes("\0")) return "nul";
19099
+ if (remaining >= 0)
19100
+ remaining = word.length + 1 > remaining ? -1 : remaining - storedSize(word) - 1;
19101
+ }
19102
+ return remaining;
19103
+ }
19104
+
19090
19105
  // src/sudo-files.ts
19091
19106
  var HEADER_BYTES = 256;
19092
19107
  async function fingerprint(bytes) {
@@ -19322,6 +19337,8 @@ var PLAIN = /^[A-Za-z0-9_@%+=:,./-]+$/;
19322
19337
  var CONTROL2 = /[\p{Cc}\u2028\u2029]/u;
19323
19338
  var CONTROLS = /[\p{Cc}\u2028\u2029]/gu;
19324
19339
  var SHOWN_MAX = 60;
19340
+ var DISPLAY_BYTES = 4096;
19341
+ var encoder9 = new TextEncoder();
19325
19342
  var KERNEL_SYNTAX = "[NOPASSWD] <user|%group|ALL> [(<target>)] [Cwd <dir>] [Stdin none] [ChainSha256 <sha256>] [RouteSha256 <sha256>] [Sha256 none|<file>=<sha256>\u2026] Cmnd <command\u2026|*>";
19326
19343
  var SUDOERS_SYNTAX = "<user|%group|ALL> ALL=[(<target>[,<target>\u2026])] [NOPASSWD:] <command\u2026|ALL>";
19327
19344
  var EXPECTED = `expected '${KERNEL_SYNTAX}' or '${SUDOERS_SYNTAX}'`;
@@ -19372,6 +19389,36 @@ function shellQuote(word) {
19372
19389
  function quoteWord(word) {
19373
19390
  return shellQuote(hasControl2(word) ? withoutControl(word) : word);
19374
19391
  }
19392
+ function clip(text, bytes, marker = "\u2026") {
19393
+ const { read } = encoder9.encodeInto(text, new Uint8Array(bytes - encoder9.encode(marker).length));
19394
+ return text.slice(0, read) + marker;
19395
+ }
19396
+ function limitText(text, bytes) {
19397
+ return encoder9.encode(text.slice(0, bytes + 1)).length > bytes ? clip(text, bytes) : text;
19398
+ }
19399
+ function auditField(value2, bytes = 256) {
19400
+ return limitText(quoteWord(value2.slice(0, bytes + 1)), bytes);
19401
+ }
19402
+ async function commandDisplay(prefix, argv, suffix = "", fullArgv = argv) {
19403
+ const before = limitText(prefix, 2048);
19404
+ const after = limitText(suffix, 512);
19405
+ const limit = DISPLAY_BYTES - encoder9.encode(before + after).length;
19406
+ let room = limit;
19407
+ let text = "";
19408
+ for (const [i, arg] of argv.entries()) {
19409
+ const part = (i ? " " : "") + quoteWord(arg.slice(0, room + 1));
19410
+ room -= encoder9.encode(part).length;
19411
+ if (room < 0) {
19412
+ const marker = `\u2026 [sha256=${await argvDigest(fullArgv)}]`;
19413
+ return before + clip(text + part, limit, marker) + after;
19414
+ }
19415
+ text += part;
19416
+ }
19417
+ return before + text + after;
19418
+ }
19419
+ function wordDisplay(argv, suffix) {
19420
+ return commandDisplay("sudo: ", argv.slice(0, 1), suffix, argv);
19421
+ }
19375
19422
  function addPart(word, part) {
19376
19423
  const last = word.length - 1;
19377
19424
  if (part === null) {
@@ -20303,11 +20350,14 @@ function stdinMatches(rule2, stdin) {
20303
20350
  function recordable(cwd, argv) {
20304
20351
  return !hasControl2(cwd) && !argv.some(hasControl2);
20305
20352
  }
20306
- function changedText(word) {
20307
- return `sudo: ${quoteWord(word)} changed since it was approved`;
20353
+ function changedText(argv) {
20354
+ return wordDisplay(argv, " changed since it was approved");
20308
20355
  }
20309
- function requestedText(word) {
20310
- return `sudo: ${quoteWord(word)} changed since it was requested`;
20356
+ function requestedText(argv, hint = "") {
20357
+ return wordDisplay(argv, " changed since it was requested" + hint);
20358
+ }
20359
+ function auditPrefix(user, tty, cwd, target, kind) {
20360
+ return `sudo: ${auditField(user)} : TTY=${auditField(tty)} ; PWD=${auditField(cwd, 768)} ; USER=${auditField(target)} ; ${kind} ; COMMAND=`;
20311
20361
  }
20312
20362
  function changedFile(approved, now) {
20313
20363
  const files = /* @__PURE__ */ new Set([...Object.keys(approved), ...Object.keys(now)]);
@@ -20345,16 +20395,15 @@ function stampOf(files) {
20345
20395
  }
20346
20396
  var REPLAY_ID = /^[!-~]{1,256}$/;
20347
20397
  var REPLAY_TAGS_MAX = 64;
20348
- var REPLAY_ARGV_MAX = 4096;
20349
20398
  var REPLAY_BYTES_MAX = 1024 * 1024;
20350
20399
  var NOT_A_REQUEST = "sudo: that isn't a sudo request this kernel can run";
20351
20400
  function strings2(value2, max) {
20352
20401
  return Array.isArray(value2) && value2.length <= max && value2.every((s) => typeof s === "string");
20353
20402
  }
20354
20403
  function words(value2) {
20355
- if (!strings2(value2, REPLAY_ARGV_MAX) || value2.length === 0) return false;
20356
- const bytes = value2.reduce((n, s) => n + s.length + 1, 0);
20357
- return bytes <= REPLAY_BYTES_MAX && !value2.some((s) => s.includes("\0"));
20404
+ if (!Array.isArray(value2) || value2.length === 0 || value2.length > SUDO_VECTOR_MAX) return false;
20405
+ const remaining = budgetAfterArgs(value2);
20406
+ return typeof remaining === "number" && remaining >= 0;
20358
20407
  }
20359
20408
  var FACT_OVERHEAD = 66;
20360
20409
  function factsFit(files) {
@@ -20849,8 +20898,9 @@ var Sudo = class {
20849
20898
  const st = await fs.stat(path);
20850
20899
  return st.isFile && (st.mode & 73) !== 0 ? path : void 0;
20851
20900
  }
20852
- async locate(word, cwd, reads, target) {
20901
+ async locate(argv, cwd, reads, target) {
20853
20902
  const fs = this.o.planFs?.(reads) ?? this.o.fs;
20903
+ const [word = ""] = argv;
20854
20904
  const candidates = word.includes("/") ? [askedPath(cwd, word)] : SECURE_PATH.split(":").map((dir) => `${dir}/${word}`);
20855
20905
  const cred = credOf(target);
20856
20906
  let denial;
@@ -20860,9 +20910,10 @@ var Sudo = class {
20860
20910
  if (path !== void 0) return { path, asked };
20861
20911
  } catch (err) {
20862
20912
  const code = err.code;
20863
- if (code === "EACCES") denial = failed2(code, `sudo: ${word}: Permission denied`);
20913
+ if (code === "EACCES")
20914
+ denial = failed2(code, await wordDisplay(argv, ": Permission denied"));
20864
20915
  else if (code === "ELOOP")
20865
- return failed2(code, `sudo: ${word}: Too many levels of symbolic links`);
20916
+ return failed2(code, await wordDisplay(argv, ": Too many levels of symbolic links"));
20866
20917
  }
20867
20918
  }
20868
20919
  return denial;
@@ -20933,12 +20984,16 @@ ${SCRIPT_HELP}
20933
20984
  const target = await this.lookup(r.target);
20934
20985
  if (!target) return failed2("ENOENT", `sudo: unknown user ${r.target}`);
20935
20986
  const cred = credOf(self);
20936
- const [word = "", ...args] = r.argv;
20987
+ const args = r.argv.slice(1);
20937
20988
  const argv = [r.path, ...args];
20938
20989
  const rules = await this.replayRules(self, target, r, argv);
20939
- const denied2 = () => failed2(
20990
+ const denied2 = async () => failed2(
20940
20991
  "EACCES",
20941
- `sudo: ${self.name} may no longer ask to run ${r.argv.map(quoteWord).join(" ")} as ${target.name}`
20992
+ await commandDisplay(
20993
+ `sudo: ${self.name} may no longer ask to run `,
20994
+ r.argv,
20995
+ ` as ${target.name}`
20996
+ )
20942
20997
  );
20943
20998
  if (rules?.length === 0) return denied2();
20944
20999
  if (await this.canonical(r.cwd) !== r.cwd) {
@@ -20951,23 +21006,23 @@ ${SCRIPT_HELP}
20951
21006
  );
20952
21007
  }
20953
21008
  const reads = this.reads();
20954
- const located = await this.locate(word, r.cwd, reads, target);
21009
+ const located = await this.locate(r.argv, r.cwd, reads, target);
20955
21010
  if (located && "error" in located) return located;
20956
21011
  if (!located) {
20957
21012
  const gone = await this.missingBacking(r.bound, r.path);
20958
- return gone ? failed2("EPERM", requestedText(word)) : failed2("ENOENT", `sudo: ${word}: command not found`);
21013
+ return gone ? failed2("EPERM", await requestedText(r.argv)) : failed2("ENOENT", await wordDisplay(r.argv, ": command not found"));
20959
21014
  }
20960
21015
  const { path, asked } = located;
20961
- if (path !== r.path) return failed2("EPERM", requestedText(word));
21016
+ if (path !== r.path) return failed2("EPERM", await requestedText(r.argv));
20962
21017
  const bound3 = await this.bound(path, r.cwd, asked, void 0, reads);
20963
- if (!bound3) return failed2("EPERM", requestedText(word));
21018
+ if (!bound3) return failed2("EPERM", await requestedText(r.argv));
20964
21019
  const changed2 = changedDecision(r.bound, r, bound3, path);
20965
21020
  if (changed2 !== void 0) {
20966
21021
  const missing7 = ["chainSha256", "routeSha256"].filter(
20967
21022
  (key) => bound3[key] !== void 0 && r[key] === void 0
20968
21023
  );
20969
21024
  const hint = missing7.length && changedFile(r.bound, bound3.hashes) === void 0 ? `; the saved request lacks ${missing7.join(" and ")}; pass back the whole request from approve unchanged` : "";
20970
- return failed2("EPERM", requestedText(word) + hint);
21025
+ return failed2("EPERM", await requestedText(r.argv, hint));
20971
21026
  }
20972
21027
  if (bound3.writableEnvPath && rules && !rules.some((rule2) => pinned(rule2, bound3.hashes, bound3)))
20973
21028
  return denied2();
@@ -20987,7 +21042,10 @@ ${SCRIPT_HELP}
20987
21042
  asked
20988
21043
  );
20989
21044
  (this.o.warn ?? console.warn)(
20990
- `sudo: ${self.name} : TTY=unknown ; PWD=${quoteWord(r.cwd)} ; USER=${target.name} ; REPLAY=${r.id} ; COMMAND=${argv.map(quoteWord).join(" ")}`
21045
+ await commandDisplay(
21046
+ auditPrefix(self.name, "unknown", r.cwd, target.name, `REPLAY=${auditField(r.id)}`),
21047
+ argv
21048
+ )
20991
21049
  );
20992
21050
  return { grant, caller: self, target, tags: r.tags };
20993
21051
  }
@@ -21003,10 +21061,14 @@ ${SCRIPT_HELP}
21003
21061
  async command(s, root, mine, call) {
21004
21062
  const { caller, self, target, parsed: parsed3 } = s;
21005
21063
  const { cred } = caller;
21006
- const [word = "", ...args] = parsed3.command;
21007
- const notAllowed = () => failed2(
21064
+ const args = parsed3.command.slice(1);
21065
+ const notAllowed = async () => failed2(
21008
21066
  "EPERM",
21009
- `sudo: ${self.name} is not allowed to run ${parsed3.command.map(quoteWord).join(" ")} as ${target.name}`
21067
+ await commandDisplay(
21068
+ `sudo: ${self.name} is not allowed to run `,
21069
+ parsed3.command,
21070
+ ` as ${target.name}`
21071
+ )
21010
21072
  );
21011
21073
  if (!root && mine.length === 0) return notAllowed();
21012
21074
  const cwd = await this.canonical(call.cwd, cred);
@@ -21017,10 +21079,11 @@ ${SCRIPT_HELP}
21017
21079
  );
21018
21080
  }
21019
21081
  const reads = this.reads();
21020
- const located = await this.locate(word, cwd, reads, target);
21082
+ const located = await this.locate(parsed3.command, cwd, reads, target);
21021
21083
  if (located && "error" in located) return located;
21022
21084
  const bound3 = located && await this.bound(located.path, cwd, located.asked, caller.pid, reads);
21023
- if (!located || !bound3) return failed2("ENOENT", `sudo: ${word}: command not found`);
21085
+ if (!located || !bound3)
21086
+ return failed2("ENOENT", await wordDisplay(parsed3.command, ": command not found"));
21024
21087
  const { path, asked } = located;
21025
21088
  const argv = [path, ...args];
21026
21089
  const applicable = mine.filter(
@@ -21032,7 +21095,7 @@ ${SCRIPT_HELP}
21032
21095
  if (matching.length === 0) return notAllowed();
21033
21096
  if (!parsed3.reset && this.timestamps.current(s.owner, s.policy, stampOf(bound3))) {
21034
21097
  this.timestamps.stamp(s.owner, s.policy, stampOf(bound3));
21035
- this.logged(s, cwd, argv);
21098
+ await this.logged(s, cwd, argv);
21036
21099
  return grant();
21037
21100
  }
21038
21101
  if (parsed3.nonInteractive) return failed2("EPERM", "sudo: a password is required");
@@ -21053,11 +21116,11 @@ ${SCRIPT_HELP}
21053
21116
  if (await this.canonical(call.cwd, cred) !== cwd || !await this.reachable(cred, cwd)) {
21054
21117
  return failed2("EACCES", `sudo: ${call.cwd} changed while the request waited`);
21055
21118
  }
21056
- if (await this.moved(bound3)) return failed2("EPERM", changedText(word));
21119
+ if (await this.moved(bound3)) return failed2("EPERM", await changedText(parsed3.command));
21057
21120
  if (answer2.answer === "once" && !answer2.person) return grant();
21058
21121
  const now = await this.bound(path, cwd, asked, caller.pid);
21059
21122
  if (!now || changedDecision(bound3.hashes, bound3, now, path) !== void 0)
21060
- return failed2("EPERM", changedText(word));
21123
+ return failed2("EPERM", await changedText(parsed3.command));
21061
21124
  const shown2 = recordable(cwd, [...parsed3.command, ...Object.keys(bound3.hashes)]);
21062
21125
  const result = answer2.answer === "once" ? grant() : await this.always(
21063
21126
  self,
@@ -21103,13 +21166,12 @@ ${SCRIPT_HELP}
21103
21166
  stamped(s, answer2, bound3 = {}) {
21104
21167
  if (answer2.person && !s.parsed.reset) this.timestamps.stamp(s.owner, s.policy, bound3);
21105
21168
  }
21106
- logged(s, cwd, argv) {
21169
+ async logged(s, cwd, argv) {
21107
21170
  const { caller, self, target, owner, policy } = s;
21108
21171
  const type = policy.type === "tty" && !owner.terminal ? "ppid" : policy.type;
21109
21172
  const tty = owner.terminal?.tty ?? caller.tty ?? "unknown";
21110
- const command = argv.map(quoteWord).join(" ");
21111
21173
  (this.o.warn ?? console.warn)(
21112
- `sudo: ${self.name} : TTY=${tty} ; PWD=${quoteWord(cwd)} ; USER=${target.name} ; TIMESTAMP=${type} ; COMMAND=${command}`
21174
+ await commandDisplay(auditPrefix(self.name, tty, cwd, target.name, `TIMESTAMP=${type}`), argv)
21113
21175
  );
21114
21176
  }
21115
21177
  async always(self, target, line, shown2, grant) {
@@ -24995,10 +25057,10 @@ var ANY_PLACEHOLDER = /fnox_proxy_[0-9a-f]{24}/g;
24995
25057
  var REQUEST_LINE2 = /^([!#$%&'*+.^_`|~0-9A-Za-z-]+) ([\x21-\x7e]+) HTTP\/1\.[01]$/;
24996
25058
  var HEADER_LINE = /^([!#$%&'*+.^_`|~0-9A-Za-z-]+):[ \t]*(.*?)[ \t]*$/;
24997
25059
  var BASIC2 = /^(Basic[ \t]+)([A-Za-z0-9+/]+={0,2})$/i;
24998
- var encoder9 = new TextEncoder();
25060
+ var encoder10 = new TextEncoder();
24999
25061
  function binary(text) {
25000
25062
  let out = "";
25001
- for (const b of encoder9.encode(text)) out += String.fromCharCode(b);
25063
+ for (const b of encoder10.encode(text)) out += String.fromCharCode(b);
25002
25064
  return out;
25003
25065
  }
25004
25066
  function sniffHttp1(start2) {
@@ -25042,7 +25104,7 @@ function replaced(text, values) {
25042
25104
  function usable2(values) {
25043
25105
  const out = {};
25044
25106
  for (const [ph, value2] of Object.entries(values ?? {}))
25045
- if (encoder9.encode(value2).length >= MIN_VALUE) out[ph] = value2;
25107
+ if (encoder10.encode(value2).length >= MIN_VALUE) out[ph] = value2;
25046
25108
  return out;
25047
25109
  }
25048
25110
  async function substituteHead(head, ask) {
@@ -25106,7 +25168,7 @@ function prepFails(prepared) {
25106
25168
  }
25107
25169
 
25108
25170
  // src/kernel/net/sealed-scram.ts
25109
- var encoder10 = new TextEncoder();
25171
+ var encoder11 = new TextEncoder();
25110
25172
  function base64Bytes(text) {
25111
25173
  try {
25112
25174
  return Uint8Array.from(atob(text), (c) => c.charCodeAt(0));
@@ -25178,7 +25240,7 @@ async function hmac(key, data) {
25178
25240
  return new Uint8Array(await crypto.subtle.sign("HMAC", k, data));
25179
25241
  }
25180
25242
  async function scramKeys(password, x) {
25181
- const base = await crypto.subtle.importKey("raw", encoder10.encode(password), "PBKDF2", false, [
25243
+ const base = await crypto.subtle.importKey("raw", encoder11.encode(password), "PBKDF2", false, [
25182
25244
  "deriveBits"
25183
25245
  ]);
25184
25246
  const salted = new Uint8Array(
@@ -25193,14 +25255,14 @@ async function scramKeys(password, x) {
25193
25255
  256
25194
25256
  )
25195
25257
  );
25196
- const clientKey = await hmac(salted, encoder10.encode("Client Key"));
25258
+ const clientKey = await hmac(salted, encoder11.encode("Client Key"));
25197
25259
  const stored = new Uint8Array(
25198
25260
  await crypto.subtle.digest("SHA-256", clientKey)
25199
25261
  );
25200
- const auth = encoder10.encode(`${x.clientFirstBare},${x.serverFirst},${x.clientFinalBare}`);
25262
+ const auth = encoder11.encode(`${x.clientFirstBare},${x.serverFirst},${x.clientFinalBare}`);
25201
25263
  const signature = await hmac(stored, auth);
25202
25264
  const proof = clientKey.map((b, i) => b ^ signature[i]);
25203
- const serverKey = await hmac(salted, encoder10.encode("Server Key"));
25265
+ const serverKey = await hmac(salted, encoder11.encode("Server Key"));
25204
25266
  const serverSignature = await hmac(serverKey, auth);
25205
25267
  for (const k of [salted, clientKey, stored, signature, serverKey]) k.fill(0);
25206
25268
  return { proof, serverSignature };
@@ -28700,20 +28762,6 @@ var PATH_FLAGS = PATH_ONLY | 65536 | 131072;
28700
28762
  var KEYBOARD = /* @__PURE__ */ new Set([SIG.INT, SIG.QUIT, SIG.TSTP]);
28701
28763
  var STUCK_ESCAPES = /* @__PURE__ */ new Set([SIG.INT, SIG.TERM, SIG.QUIT, SIG.HUP]);
28702
28764
  var DEFAULT_UMASK2 = 18;
28703
- var SUDO_VECTOR_MAX = 4096;
28704
- var SUDO_INPUT_BYTES = 1024 * 1024;
28705
- function budgetAfterArgs(args) {
28706
- if (!Array.isArray(args)) throw new KernelError("EINVAL");
28707
- if (args.length > SUDO_VECTOR_MAX) return -1;
28708
- let remaining = SUDO_INPUT_BYTES;
28709
- for (const word of args) {
28710
- if (typeof word !== "string") throw new KernelError("EINVAL");
28711
- if (word.length + 1 > remaining) return -1;
28712
- remaining -= storedSize(word) + 1;
28713
- if (remaining < 0) return -1;
28714
- }
28715
- return remaining;
28716
- }
28717
28765
  function sudoVariables(value2, term, budget) {
28718
28766
  const input = typeof value2 === "object" && value2 !== null ? value2 : {};
28719
28767
  const env = /* @__PURE__ */ Object.create(null);
@@ -30802,6 +30850,9 @@ var WasmProcess = class _WasmProcess {
30802
30850
  const { sudo } = this.options;
30803
30851
  if (!sudo) throw new KernelError("ENOSYS");
30804
30852
  const budget = budgetAfterArgs(req.args);
30853
+ if (budget === "nul")
30854
+ return { errno: "EINVAL", error: "sudo: an argument contains a NUL character" };
30855
+ if (budget === void 0) throw new KernelError("EINVAL");
30805
30856
  if (budget < 0) return { errno: "E2BIG", error: "sudo: the submitted arguments are too large" };
30806
30857
  const term = typeof req.term === "string" ? req.term : void 0;
30807
30858
  const submitted = sudoVariables(req.env, term, budget);
@@ -30835,8 +30886,7 @@ var WasmProcess = class _WasmProcess {
30835
30886
  })
30836
30887
  };
30837
30888
  } catch (err) {
30838
- if (err instanceof ChangedError)
30839
- return { error: changedText(argv[0] ?? asked), errno: err.code };
30889
+ if (err instanceof ChangedError) return { error: await changedText(argv), errno: err.code };
30840
30890
  throw err;
30841
30891
  }
30842
30892
  }
@@ -39270,7 +39320,7 @@ var LAYOUT = [
39270
39320
  var IN_TREE = /* @__PURE__ */ new Set([SUDO_PATH, VISUDO_PATH, CRONTAB_PATH, SEALED_BIN]);
39271
39321
  var LOAD_SAMPLE_MS = 5e3;
39272
39322
  var LOAD_WINDOWS_MS = [6e4, 3e5, 9e5];
39273
- var encoder11 = new TextEncoder();
39323
+ var encoder12 = new TextEncoder();
39274
39324
  var USERS_MODES = ["off", "report", "enforce"];
39275
39325
  function usersMode(mode = "off") {
39276
39326
  if (USERS_MODES.includes(mode)) return mode;
@@ -43097,7 +43147,7 @@ var Launcher = class {
43097
43147
  account,
43098
43148
  options.session
43099
43149
  );
43100
- const report = (message3) => options.onData(encoder11.encode(`${message3}\r
43150
+ const report = (message3) => options.onData(encoder12.encode(`${message3}\r
43101
43151
  `));
43102
43152
  const handle = await this.launch(planned, {
43103
43153
  ...reserved2,
@@ -43145,7 +43195,7 @@ var Launcher = class {
43145
43195
  };
43146
43196
  const stdout = collect3(out, options.onStdout);
43147
43197
  const stderr = collect3(err, options.onStderr);
43148
- const report = (message3) => stderr(encoder11.encode(`${message3}
43198
+ const report = (message3) => stderr(encoder12.encode(`${message3}
43149
43199
  `));
43150
43200
  if (!planned) {
43151
43201
  const directory2 = !missingFile && await this.directory(file, this.fs.resolvePath(cwd, file));
@@ -43186,21 +43236,20 @@ var Launcher = class {
43186
43236
  this.resetCatalogs();
43187
43237
  const req = { file: grant.file, argv: grant.argv, env: grant.env, cwd: grant.cwd };
43188
43238
  const ctx = { ppid: 0, cred: grant.cred, scope: "", grant };
43189
- const word = grant.argv[0] ?? grant.asked;
43190
- const requested = (err2) => {
43191
- if (err2 instanceof ChangedError) throw sudoFailure(err2.code, requestedText(word));
43239
+ const requested = async (err2) => {
43240
+ if (err2 instanceof ChangedError) throw sudoFailure(err2.code, await requestedText(grant.argv));
43192
43241
  throw err2;
43193
43242
  };
43194
- const planned = await this.planOne(req, ctx).catch((err2) => {
43195
- if (err2 instanceof ChangedError) requested(err2);
43243
+ const planned = await this.planOne(req, ctx).catch(async (err2) => {
43244
+ if (err2 instanceof ChangedError) return requested(err2);
43196
43245
  const code = sudoCause(err2);
43197
- if (code === "ENOENT") throw sudoFailure(code, `sudo: ${quoteWord(word)}: command not found`);
43198
- throw sudoFailure(code, `sudo: ${quoteWord(word)}: ${ERRNO_TEXT[code] ?? code}`);
43246
+ const reason = code === "ENOENT" ? "command not found" : ERRNO_TEXT[code] ?? code;
43247
+ throw sudoFailure(code, await wordDisplay(grant.argv, ": " + reason));
43199
43248
  });
43200
43249
  const pin = await this.unchanged(planned, grant.file, grant.cwd, grant).catch(requested);
43201
43250
  const fds = await this.sudoOutputs(options, caller, this.stackFor(tags, tagged.tagBase));
43202
43251
  const err = fds.get(2).file;
43203
- const report = (message3) => void Promise.resolve(err.write?.(encoder11.encode(`${message3}
43252
+ const report = (message3) => void Promise.resolve(err.write?.(encoder12.encode(`${message3}
43204
43253
  `))).catch(() => void 0);
43205
43254
  const replan = () => this.planOne(req, ctx);
43206
43255
  const recheck = this.approvedChain(planned, grant.file, grant.cwd, grant);
@@ -46826,7 +46875,7 @@ function dialStream(port, onClose) {
46826
46875
 
46827
46876
  // src/client/loopback-fetch.ts
46828
46877
  var OWN_HEADERS2 = /* @__PURE__ */ new Set(["host", "connection", "content-length", "transfer-encoding"]);
46829
- var encoder12 = new TextEncoder();
46878
+ var encoder13 = new TextEncoder();
46830
46879
  var latin13 = new TextDecoder("latin1");
46831
46880
  var ByteSource = class {
46832
46881
  buffered = new Uint8Array(0);
@@ -46844,7 +46893,7 @@ var ByteSource = class {
46844
46893
  return true;
46845
46894
  }
46846
46895
  async until(marker) {
46847
- const needle = encoder12.encode(marker);
46896
+ const needle = encoder13.encode(marker);
46848
46897
  for (; ; ) {
46849
46898
  const at = indexOf(this.buffered, needle);
46850
46899
  if (at >= 0) return this.take(at + needle.length);
@@ -46952,7 +47001,7 @@ async function requestBytes(request2) {
46952
47001
  });
46953
47002
  if (body) lines3.push(`Content-Length: ${body.length}`);
46954
47003
  lines3.push("Connection: close", "", "");
46955
- const head = encoder12.encode(lines3.join("\r\n"));
47004
+ const head = encoder13.encode(lines3.join("\r\n"));
46956
47005
  const out = new Uint8Array(head.length + (body?.length ?? 0));
46957
47006
  out.set(head);
46958
47007
  if (body) out.set(body, head.length);
@@ -47006,8 +47055,8 @@ var KernelCallError = class extends Error {
47006
47055
  this.code = code;
47007
47056
  }
47008
47057
  };
47009
- var encoder13 = new TextEncoder();
47010
- var bytesOf6 = (data) => typeof data === "string" ? encoder13.encode(data) : data;
47058
+ var encoder14 = new TextEncoder();
47059
+ var bytesOf6 = (data) => typeof data === "string" ? encoder14.encode(data) : data;
47011
47060
  var UNAVAILABLE = {
47012
47061
  manualRedirects: false,
47013
47062
  encodedBodies: false,
@@ -48305,7 +48354,7 @@ function shellFor(client2, driver, options, mountPoint) {
48305
48354
  }
48306
48355
  };
48307
48356
  async function start2(run2, input) {
48308
- const encoder14 = new TextEncoder();
48357
+ const encoder15 = new TextEncoder();
48309
48358
  driver.invalidate();
48310
48359
  try {
48311
48360
  run2.process = await client2.spawn([...shell, input.source], {
@@ -48319,7 +48368,7 @@ function shellFor(client2, driver, options, mountPoint) {
48319
48368
  });
48320
48369
  } catch (err) {
48321
48370
  const code = err.code;
48322
- run2.output("stderr", encoder14.encode(`${err instanceof Error ? err.message : String(err)}
48371
+ run2.output("stderr", encoder15.encode(`${err instanceof Error ? err.message : String(err)}
48323
48372
  `));
48324
48373
  run2.exit(code === "ENOENT" ? 127 : 126);
48325
48374
  return;
@@ -48343,7 +48392,7 @@ function shellFor(client2, driver, options, mountPoint) {
48343
48392
  async (err) => {
48344
48393
  run2.output(
48345
48394
  "stderr",
48346
- encoder14.encode(`${err instanceof Error ? err.message : String(err)}
48395
+ encoder15.encode(`${err instanceof Error ? err.message : String(err)}
48347
48396
  `)
48348
48397
  );
48349
48398
  run2.exit(-1);