@ai-ecoverse/slicc-kernel 1.196.28 → 1.196.29

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.
@@ -5241,7 +5241,7 @@ function satisfies(version, range2) {
5241
5241
  }
5242
5242
 
5243
5243
  // src/version.ts
5244
- var KERNEL_VERSION = true ? "1.196.28" : "0.0.0-dev";
5244
+ var KERNEL_VERSION = true ? "1.196.29" : "0.0.0-dev";
5245
5245
  var OS_RELEASE = "6.0.0-slicc";
5246
5246
  function procVersion() {
5247
5247
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -20300,25 +20300,41 @@ var Sudo = class {
20300
20300
  else if (part !== ".") at = joinName(at, part);
20301
20301
  }
20302
20302
  }
20303
- async trustedThrough(path, destination, fs = this.o.fs, uid = 0) {
20304
- if (!heldBy(await fs.lstat("/").catch(() => void 0), uid)) return false;
20303
+ trustedThrough(path, destination, fs = this.o.fs, uid = 0) {
20304
+ return this.heldRoute(path, fs, { uid, destination });
20305
+ }
20306
+ async heldRoute(path, fs, {
20307
+ uid = 0,
20308
+ destination,
20309
+ allowMissing = false
20310
+ }) {
20311
+ const root = await fs.lstat("/").catch(() => void 0);
20312
+ if (!root?.isDirectory || !heldBy(root, uid)) return false;
20305
20313
  const queue = path.split("/").filter(Boolean);
20306
20314
  const done4 = [];
20307
20315
  for (let hops = 0; queue.length > 0; ) {
20308
20316
  const part = queue.shift();
20309
- if (part === "." || part === "..") {
20310
- if (part === "..") done4.pop();
20317
+ if (part === ".") continue;
20318
+ if (part === "..") {
20319
+ done4.pop();
20311
20320
  continue;
20312
20321
  }
20313
20322
  const at = `/${[...done4, part].join("/")}`;
20314
- const st = await fs.lstat(at).catch(() => void 0);
20323
+ let st;
20324
+ try {
20325
+ st = await fs.lstat(at);
20326
+ } catch (err) {
20327
+ return allowMissing && err?.code === "ENOENT" && !queue.includes("..");
20328
+ }
20315
20329
  if (!heldBy(st, uid)) return false;
20316
- if (!st?.isSymbolicLink) {
20330
+ if (!st.isSymbolicLink) {
20331
+ if (queue.length && !st.isDirectory) return false;
20317
20332
  done4.push(part);
20318
20333
  continue;
20319
20334
  }
20320
20335
  if (++hops > MAX_LINKS) return false;
20321
- const target = await fs.readlink(at);
20336
+ const target = await fs.readlink(at).catch(() => void 0);
20337
+ if (!target) return false;
20322
20338
  if (target.startsWith("/")) done4.length = 0;
20323
20339
  queue.unshift(...target.split("/").filter(Boolean));
20324
20340
  }
@@ -20494,7 +20510,7 @@ var Sudo = class {
20494
20510
  {
20495
20511
  real: (at) => this.real(at),
20496
20512
  trusted: (at) => this.trustedThrough(at, void 0, fs),
20497
- trustedEnvPath: (at) => this.trusted(at, true),
20513
+ trustedEnvPath: (at) => this.heldRoute(at, this.o.fs, { allowMissing: true }),
20498
20514
  read: (at) => fs.readFileBuffer(at)
20499
20515
  },
20500
20516
  snapshots
@@ -20512,7 +20528,7 @@ var Sudo = class {
20512
20528
  const { path } = rule2.cmnd;
20513
20529
  reads.resetSelection();
20514
20530
  const bound3 = await this.bound(path, "/", path, pid, reads);
20515
- if (bound3) return Object.keys(bound3.hashes).length > 0;
20531
+ if (bound3) return bound3.writableEnvPath === true || Object.keys(bound3.hashes).length > 0;
20516
20532
  return !await this.trusted(path, true);
20517
20533
  }
20518
20534
  async searched(fs, cred, path) {