@ai-ecoverse/slicc-kernel 1.195.7 → 1.195.8

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.
@@ -5562,7 +5562,18 @@ async function mustBeDir(fs, path) {
5562
5562
  async function linkOf(fs, path) {
5563
5563
  return fs.readlink?.(path).catch(() => void 0);
5564
5564
  }
5565
- async function realDir(fs, dir, budget = { hops: 0 }) {
5565
+ function realDir(fs, dir, budget = { hops: 0 }) {
5566
+ return walkDir(
5567
+ dir,
5568
+ async (next3, beforeParent) => {
5569
+ const link2 = await linkOf(fs, next3);
5570
+ if (link2 === void 0 && beforeParent) await mustBeDir(fs, next3);
5571
+ return link2;
5572
+ },
5573
+ budget
5574
+ );
5575
+ }
5576
+ async function walkDir(dir, visit, budget = { hops: 0 }) {
5566
5577
  const queue = dir.split("/").filter(Boolean);
5567
5578
  let at = "/";
5568
5579
  while (queue.length > 0) {
@@ -5573,9 +5584,8 @@ async function realDir(fs, dir, budget = { hops: 0 }) {
5573
5584
  continue;
5574
5585
  }
5575
5586
  const next3 = at === "/" ? `/${part}` : `${at}/${part}`;
5576
- const link2 = await linkOf(fs, next3);
5587
+ const link2 = await visit(next3, queue.find((p) => p !== ".") === "..");
5577
5588
  if (link2 === void 0) {
5578
- if (queue.find((p) => p !== ".") === "..") await mustBeDir(fs, next3);
5579
5589
  at = next3;
5580
5590
  continue;
5581
5591
  }
@@ -5824,6 +5834,20 @@ function ttyOpenable(g, tty) {
5824
5834
  if (!g || !tty.owner || permits(g.cred, tty.owner, R_OK | W_OK, false)) return;
5825
5835
  deny(g, "open", tty.name ?? "/dev/tty");
5826
5836
  }
5837
+ async function execDirectory(fs, dir, g) {
5838
+ const visit = async (path) => {
5839
+ const st = await fs.lstat(path);
5840
+ if (st.isSymbolicLink) {
5841
+ if (g && !trustedLink(permOf(st), g.links)) deny(g, "exec", path);
5842
+ return fs.readlink(path);
5843
+ }
5844
+ if (!st.isDirectory) throw refused(path, "ENOTDIR");
5845
+ if (g && !permits(g.cred, permOf(st), X_OK)) deny(g, "exec", path);
5846
+ return void 0;
5847
+ };
5848
+ await visit("/");
5849
+ return walkDir(dir, visit);
5850
+ }
5827
5851
  async function need(g, op, path, want2, options = {}, shown2 = path) {
5828
5852
  if (want2 & W_OK && shown2 === path) await fence(g, op, path);
5829
5853
  const walked2 = await access(g.fs, g.cred, path, want2, linked(g, options));
@@ -9280,7 +9304,7 @@ function satisfies(version, range2) {
9280
9304
  }
9281
9305
 
9282
9306
  // src/version.ts
9283
- var KERNEL_VERSION = true ? "1.195.7" : "0.0.0-dev";
9307
+ var KERNEL_VERSION = true ? "1.195.8" : "0.0.0-dev";
9284
9308
  var OS_RELEASE = "6.0.0-slicc";
9285
9309
  function procVersion() {
9286
9310
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -37206,9 +37230,7 @@ var Launcher = class {
37206
37230
  const path = file.startsWith("/") ? file : `${cwd}/${file}`;
37207
37231
  const slash = path.lastIndexOf("/");
37208
37232
  const dir = path.slice(0, slash);
37209
- const walked2 = g && await need(g, "exec", dir, X_OK, { directory: true });
37210
- const real = walked2 && walked2.denied === void 0 ? walked2.path : await physicalPathAsync(this.base, dir);
37211
- return joinName(real, path.slice(slash + 1));
37233
+ return joinName(await execDirectory(this.fs, dir, g), path.slice(slash + 1));
37212
37234
  }
37213
37235
  async ticketFile(req, fds) {
37214
37236
  if (req.file.startsWith("/")) return physicalPathAsync(this.base, req.file);
@@ -39310,8 +39332,8 @@ var Launcher = class {
39310
39332
  const scope = account.uid === 0 ? "" : pnpmHomeOf(account, this.pnpmHome);
39311
39333
  const start2 = dir ?? "/";
39312
39334
  const cwd = await physicalPathAsync(this.base, start2.startsWith("/") ? start2 : `/${start2}`);
39313
- await this.enterable(this.execGuard(credOf(account), 0, tag), cwd);
39314
- const file = await this.execFile(argv[0] ?? "", cwd, this.execGuard(credOf(account), 0, tag));
39335
+ const guard2 = this.execGuard(credOf(account), 0, tag);
39336
+ await this.enterable(guard2, cwd);
39315
39337
  if (!await this.base.exists(cwd)) {
39316
39338
  if (missing6 === "error")
39317
39339
  throw Object.assign(new Error(`cannot change to ${cwd}: No such file or directory`), {
@@ -39319,6 +39341,14 @@ var Launcher = class {
39319
39341
  });
39320
39342
  await this.stackFor(tags, base).fs.mkdir(cwd, { recursive: true });
39321
39343
  }
39344
+ const asked = argv[0] ?? "";
39345
+ let file;
39346
+ try {
39347
+ file = await this.execFile(asked, cwd, guard2);
39348
+ } catch (err) {
39349
+ if (codeOf8(err) !== "ENOENT" && codeOf8(err) !== "ENOTDIR") throw err;
39350
+ return { cwd, file: asked, planned: void 0, missingFile: true };
39351
+ }
39322
39352
  const plan = async () => {
39323
39353
  const found = await this.plan(file, argv, cwd, scope, void 0, false, credOf(account));
39324
39354
  await this.mayExec(credOf(account), { file, cwd, pid: 0, tag }, found);
@@ -39394,7 +39424,7 @@ var Launcher = class {
39394
39424
  const missing6 = cwdMissingOption(options.cwdMissing);
39395
39425
  const { tags } = tagged;
39396
39426
  const account = await this.account(options.user);
39397
- const { cwd, file, planned } = await this.starting(
39427
+ const { cwd, file, planned, missingFile } = await this.starting(
39398
39428
  argv,
39399
39429
  options.cwd,
39400
39430
  account,
@@ -39415,7 +39445,7 @@ var Launcher = class {
39415
39445
  const report = (message3) => stderr(encoder10.encode(`${message3}
39416
39446
  `));
39417
39447
  if (!planned) {
39418
- const directory = await this.directory(file, this.fs.resolvePath(cwd, file));
39448
+ const directory = !missingFile && await this.directory(file, this.fs.resolvePath(cwd, file));
39419
39449
  report(`${file}: ${directory ? "Is a directory" : "command not found"}`);
39420
39450
  const status2 = directory ? NOT_EXECUTABLE : NOT_FOUND;
39421
39451
  return { status: status2, stdout: concat7(out), stderr: concat7(err) };