@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.
package/dist/node.js CHANGED
@@ -1076,7 +1076,18 @@ async function mustBeDir(fs, path) {
1076
1076
  async function linkOf(fs, path) {
1077
1077
  return fs.readlink?.(path).catch(() => void 0);
1078
1078
  }
1079
- async function realDir(fs, dir, budget = { hops: 0 }) {
1079
+ function realDir(fs, dir, budget = { hops: 0 }) {
1080
+ return walkDir(
1081
+ dir,
1082
+ async (next3, beforeParent) => {
1083
+ const link2 = await linkOf(fs, next3);
1084
+ if (link2 === void 0 && beforeParent) await mustBeDir(fs, next3);
1085
+ return link2;
1086
+ },
1087
+ budget
1088
+ );
1089
+ }
1090
+ async function walkDir(dir, visit, budget = { hops: 0 }) {
1080
1091
  const queue = dir.split("/").filter(Boolean);
1081
1092
  let at = "/";
1082
1093
  while (queue.length > 0) {
@@ -1087,9 +1098,8 @@ async function realDir(fs, dir, budget = { hops: 0 }) {
1087
1098
  continue;
1088
1099
  }
1089
1100
  const next3 = at === "/" ? `/${part}` : `${at}/${part}`;
1090
- const link2 = await linkOf(fs, next3);
1101
+ const link2 = await visit(next3, queue.find((p) => p !== ".") === "..");
1091
1102
  if (link2 === void 0) {
1092
- if (queue.find((p) => p !== ".") === "..") await mustBeDir(fs, next3);
1093
1103
  at = next3;
1094
1104
  continue;
1095
1105
  }
@@ -1338,6 +1348,20 @@ function ttyOpenable(g, tty) {
1338
1348
  if (!g || !tty.owner || permits(g.cred, tty.owner, R_OK | W_OK, false)) return;
1339
1349
  deny(g, "open", tty.name ?? "/dev/tty");
1340
1350
  }
1351
+ async function execDirectory(fs, dir, g) {
1352
+ const visit = async (path) => {
1353
+ const st = await fs.lstat(path);
1354
+ if (st.isSymbolicLink) {
1355
+ if (g && !trustedLink(permOf(st), g.links)) deny(g, "exec", path);
1356
+ return fs.readlink(path);
1357
+ }
1358
+ if (!st.isDirectory) throw refused(path, "ENOTDIR");
1359
+ if (g && !permits(g.cred, permOf(st), X_OK)) deny(g, "exec", path);
1360
+ return void 0;
1361
+ };
1362
+ await visit("/");
1363
+ return walkDir(dir, visit);
1364
+ }
1341
1365
  async function need(g, op, path, want2, options = {}, shown2 = path) {
1342
1366
  if (want2 & W_OK && shown2 === path) await fence(g, op, path);
1343
1367
  const walked2 = await access(g.fs, g.cred, path, want2, linked(g, options));
@@ -7514,7 +7538,7 @@ function satisfies(version, range2) {
7514
7538
  }
7515
7539
 
7516
7540
  // src/version.ts
7517
- var KERNEL_VERSION = true ? "1.195.7" : "0.0.0-dev";
7541
+ var KERNEL_VERSION = true ? "1.195.8" : "0.0.0-dev";
7518
7542
  var OS_RELEASE = "6.0.0-slicc";
7519
7543
  function procVersion() {
7520
7544
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -37169,9 +37193,7 @@ var Launcher = class {
37169
37193
  const path = file.startsWith("/") ? file : `${cwd}/${file}`;
37170
37194
  const slash = path.lastIndexOf("/");
37171
37195
  const dir = path.slice(0, slash);
37172
- const walked2 = g && await need(g, "exec", dir, X_OK, { directory: true });
37173
- const real = walked2 && walked2.denied === void 0 ? walked2.path : await physicalPathAsync(this.base, dir);
37174
- return joinName(real, path.slice(slash + 1));
37196
+ return joinName(await execDirectory(this.fs, dir, g), path.slice(slash + 1));
37175
37197
  }
37176
37198
  async ticketFile(req, fds) {
37177
37199
  if (req.file.startsWith("/")) return physicalPathAsync(this.base, req.file);
@@ -39273,8 +39295,8 @@ var Launcher = class {
39273
39295
  const scope = account.uid === 0 ? "" : pnpmHomeOf(account, this.pnpmHome);
39274
39296
  const start2 = dir ?? "/";
39275
39297
  const cwd = await physicalPathAsync(this.base, start2.startsWith("/") ? start2 : `/${start2}`);
39276
- await this.enterable(this.execGuard(credOf(account), 0, tag), cwd);
39277
- const file = await this.execFile(argv[0] ?? "", cwd, this.execGuard(credOf(account), 0, tag));
39298
+ const guard2 = this.execGuard(credOf(account), 0, tag);
39299
+ await this.enterable(guard2, cwd);
39278
39300
  if (!await this.base.exists(cwd)) {
39279
39301
  if (missing6 === "error")
39280
39302
  throw Object.assign(new Error(`cannot change to ${cwd}: No such file or directory`), {
@@ -39282,6 +39304,14 @@ var Launcher = class {
39282
39304
  });
39283
39305
  await this.stackFor(tags, base).fs.mkdir(cwd, { recursive: true });
39284
39306
  }
39307
+ const asked = argv[0] ?? "";
39308
+ let file;
39309
+ try {
39310
+ file = await this.execFile(asked, cwd, guard2);
39311
+ } catch (err) {
39312
+ if (codeOf9(err) !== "ENOENT" && codeOf9(err) !== "ENOTDIR") throw err;
39313
+ return { cwd, file: asked, planned: void 0, missingFile: true };
39314
+ }
39285
39315
  const plan = async () => {
39286
39316
  const found = await this.plan(file, argv, cwd, scope, void 0, false, credOf(account));
39287
39317
  await this.mayExec(credOf(account), { file, cwd, pid: 0, tag }, found);
@@ -39357,7 +39387,7 @@ var Launcher = class {
39357
39387
  const missing6 = cwdMissingOption(options.cwdMissing);
39358
39388
  const { tags } = tagged;
39359
39389
  const account = await this.account(options.user);
39360
- const { cwd, file, planned } = await this.starting(
39390
+ const { cwd, file, planned, missingFile } = await this.starting(
39361
39391
  argv,
39362
39392
  options.cwd,
39363
39393
  account,
@@ -39378,7 +39408,7 @@ var Launcher = class {
39378
39408
  const report = (message3) => stderr(encoder10.encode(`${message3}
39379
39409
  `));
39380
39410
  if (!planned) {
39381
- const directory = await this.directory(file, this.fs.resolvePath(cwd, file));
39411
+ const directory = !missingFile && await this.directory(file, this.fs.resolvePath(cwd, file));
39382
39412
  report(`${file}: ${directory ? "Is a directory" : "command not found"}`);
39383
39413
  const status2 = directory ? NOT_EXECUTABLE : NOT_FOUND;
39384
39414
  return { status: status2, stdout: concat7(out), stderr: concat7(err) };