@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.
@@ -1746,7 +1746,18 @@ async function mustBeDir(fs, path) {
1746
1746
  async function linkOf(fs, path) {
1747
1747
  return fs.readlink?.(path).catch(() => void 0);
1748
1748
  }
1749
- async function realDir(fs, dir, budget = { hops: 0 }) {
1749
+ function realDir(fs, dir, budget = { hops: 0 }) {
1750
+ return walkDir(
1751
+ dir,
1752
+ async (next3, beforeParent) => {
1753
+ const link2 = await linkOf(fs, next3);
1754
+ if (link2 === void 0 && beforeParent) await mustBeDir(fs, next3);
1755
+ return link2;
1756
+ },
1757
+ budget
1758
+ );
1759
+ }
1760
+ async function walkDir(dir, visit, budget = { hops: 0 }) {
1750
1761
  const queue = dir.split("/").filter(Boolean);
1751
1762
  let at = "/";
1752
1763
  while (queue.length > 0) {
@@ -1757,9 +1768,8 @@ async function realDir(fs, dir, budget = { hops: 0 }) {
1757
1768
  continue;
1758
1769
  }
1759
1770
  const next3 = at === "/" ? `/${part}` : `${at}/${part}`;
1760
- const link2 = await linkOf(fs, next3);
1771
+ const link2 = await visit(next3, queue.find((p) => p !== ".") === "..");
1761
1772
  if (link2 === void 0) {
1762
- if (queue.find((p) => p !== ".") === "..") await mustBeDir(fs, next3);
1763
1773
  at = next3;
1764
1774
  continue;
1765
1775
  }
@@ -2008,6 +2018,20 @@ function ttyOpenable(g, tty) {
2008
2018
  if (!g || !tty.owner || permits(g.cred, tty.owner, R_OK | W_OK, false)) return;
2009
2019
  deny(g, "open", tty.name ?? "/dev/tty");
2010
2020
  }
2021
+ async function execDirectory(fs, dir, g) {
2022
+ const visit = async (path) => {
2023
+ const st = await fs.lstat(path);
2024
+ if (st.isSymbolicLink) {
2025
+ if (g && !trustedLink(permOf(st), g.links)) deny(g, "exec", path);
2026
+ return fs.readlink(path);
2027
+ }
2028
+ if (!st.isDirectory) throw refused(path, "ENOTDIR");
2029
+ if (g && !permits(g.cred, permOf(st), X_OK)) deny(g, "exec", path);
2030
+ return void 0;
2031
+ };
2032
+ await visit("/");
2033
+ return walkDir(dir, visit);
2034
+ }
2011
2035
  async function need(g, op, path, want2, options = {}, shown2 = path) {
2012
2036
  if (want2 & W_OK && shown2 === path) await fence(g, op, path);
2013
2037
  const walked2 = await access(g.fs, g.cred, path, want2, linked(g, options));
@@ -5109,7 +5133,7 @@ function satisfies(version, range2) {
5109
5133
  }
5110
5134
 
5111
5135
  // src/version.ts
5112
- var KERNEL_VERSION = true ? "1.195.7" : "0.0.0-dev";
5136
+ var KERNEL_VERSION = true ? "1.195.8" : "0.0.0-dev";
5113
5137
  var OS_RELEASE = "6.0.0-slicc";
5114
5138
  function procVersion() {
5115
5139
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -36789,9 +36813,7 @@ var Launcher = class {
36789
36813
  const path = file.startsWith("/") ? file : `${cwd}/${file}`;
36790
36814
  const slash = path.lastIndexOf("/");
36791
36815
  const dir = path.slice(0, slash);
36792
- const walked2 = g && await need(g, "exec", dir, X_OK, { directory: true });
36793
- const real2 = walked2 && walked2.denied === void 0 ? walked2.path : await physicalPathAsync(this.base, dir);
36794
- return joinName(real2, path.slice(slash + 1));
36816
+ return joinName(await execDirectory(this.fs, dir, g), path.slice(slash + 1));
36795
36817
  }
36796
36818
  async ticketFile(req, fds) {
36797
36819
  if (req.file.startsWith("/")) return physicalPathAsync(this.base, req.file);
@@ -38893,8 +38915,8 @@ var Launcher = class {
38893
38915
  const scope = account.uid === 0 ? "" : pnpmHomeOf(account, this.pnpmHome);
38894
38916
  const start2 = dir ?? "/";
38895
38917
  const cwd = await physicalPathAsync(this.base, start2.startsWith("/") ? start2 : `/${start2}`);
38896
- await this.enterable(this.execGuard(credOf(account), 0, tag), cwd);
38897
- const file = await this.execFile(argv[0] ?? "", cwd, this.execGuard(credOf(account), 0, tag));
38918
+ const guard2 = this.execGuard(credOf(account), 0, tag);
38919
+ await this.enterable(guard2, cwd);
38898
38920
  if (!await this.base.exists(cwd)) {
38899
38921
  if (missing6 === "error")
38900
38922
  throw Object.assign(new Error(`cannot change to ${cwd}: No such file or directory`), {
@@ -38902,6 +38924,14 @@ var Launcher = class {
38902
38924
  });
38903
38925
  await this.stackFor(tags, base).fs.mkdir(cwd, { recursive: true });
38904
38926
  }
38927
+ const asked = argv[0] ?? "";
38928
+ let file;
38929
+ try {
38930
+ file = await this.execFile(asked, cwd, guard2);
38931
+ } catch (err) {
38932
+ if (codeOf8(err) !== "ENOENT" && codeOf8(err) !== "ENOTDIR") throw err;
38933
+ return { cwd, file: asked, planned: void 0, missingFile: true };
38934
+ }
38905
38935
  const plan = async () => {
38906
38936
  const found = await this.plan(file, argv, cwd, scope, void 0, false, credOf(account));
38907
38937
  await this.mayExec(credOf(account), { file, cwd, pid: 0, tag }, found);
@@ -38977,7 +39007,7 @@ var Launcher = class {
38977
39007
  const missing6 = cwdMissingOption(options.cwdMissing);
38978
39008
  const { tags } = tagged;
38979
39009
  const account = await this.account(options.user);
38980
- const { cwd, file, planned } = await this.starting(
39010
+ const { cwd, file, planned, missingFile } = await this.starting(
38981
39011
  argv,
38982
39012
  options.cwd,
38983
39013
  account,
@@ -38998,7 +39028,7 @@ var Launcher = class {
38998
39028
  const report = (message3) => stderr(encoder10.encode(`${message3}
38999
39029
  `));
39000
39030
  if (!planned) {
39001
- const directory2 = await this.directory(file, this.fs.resolvePath(cwd, file));
39031
+ const directory2 = !missingFile && await this.directory(file, this.fs.resolvePath(cwd, file));
39002
39032
  report(`${file}: ${directory2 ? "Is a directory" : "command not found"}`);
39003
39033
  const status2 = directory2 ? NOT_EXECUTABLE : NOT_FOUND;
39004
39034
  return { status: status2, stdout: concat7(out), stderr: concat7(err) };