@ai-ecoverse/slicc-kernel 1.176.1 → 1.176.2

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.
@@ -5580,14 +5580,21 @@ async function ownerOnly(g, op, path, follow2) {
5580
5580
  return walked;
5581
5581
  }
5582
5582
  async function chmodMode(g, path, mode) {
5583
- const perm = (await ownerOnly(g, "chmod", path, true)).perm;
5584
- if (!g.dac.enforcing || !perm || g.cred.euid === 0 || inGroup(g.cred, perm.gid)) return mode;
5583
+ const walked = await need(g, "chmod", path, 0, { follow: true });
5584
+ const perm = walked.perm;
5585
+ const st = await g.fs.stat(walked.path).catch(() => void 0);
5586
+ if (!st?.fat && perm && g.cred.euid !== 0 && perm.uid !== g.cred.euid) {
5587
+ if (await present(g.fs, walked.path, false)) deny(g, "chmod", path, "EPERM");
5588
+ }
5589
+ if (!g.dac.enforcing || !perm || g.cred.euid === 0 || st?.fat || inGroup(g.cred, perm.gid)) {
5590
+ return mode;
5591
+ }
5585
5592
  return mode & ~S_ISGID3;
5586
5593
  }
5587
5594
  function heldChmodMode(g, path, st, mode) {
5588
5595
  const perm = permOf(st);
5589
- if (g.cred.euid !== 0 && perm.uid !== g.cred.euid) deny(g, "fchmod", path, "EPERM");
5590
- if (!g.dac.enforcing || g.cred.euid === 0 || inGroup(g.cred, perm.gid)) return mode;
5596
+ if (!st.fat && g.cred.euid !== 0 && perm.uid !== g.cred.euid) deny(g, "fchmod", path, "EPERM");
5597
+ if (!g.dac.enforcing || g.cred.euid === 0 || st.fat || inGroup(g.cred, perm.gid)) return mode;
5591
5598
  return mode & ~S_ISGID3;
5592
5599
  }
5593
5600
  function heldRetimable(g, path, st, now) {
@@ -8767,7 +8774,7 @@ function satisfies(version, range2) {
8767
8774
  }
8768
8775
 
8769
8776
  // src/version.ts
8770
- var KERNEL_VERSION = true ? "1.176.1" : "0.0.0-dev";
8777
+ var KERNEL_VERSION = true ? "1.176.2" : "0.0.0-dev";
8771
8778
  var OS_RELEASE = "6.0.0-slicc";
8772
8779
  function procVersion() {
8773
8780
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13912,10 +13919,15 @@ var DriverConnection = class _DriverConnection {
13912
13919
  // src/mount/mount-fs.ts
13913
13920
  var S_ISGID4 = 1024;
13914
13921
  var ID = /^\d{1,10}$/;
13922
+ var MASK = /^0*[0-7]{1,4}$/;
13915
13923
  var MAX_ID2 = 4294967294;
13916
13924
  function idOption(value2) {
13917
13925
  return value2 === void 0 ? 0 : Number(value2);
13918
13926
  }
13927
+ function maskOption(value2) {
13928
+ if (value2 === void 0) return void 0;
13929
+ return Number.parseInt(value2, 8) & 511;
13930
+ }
13919
13931
  function checkIds(options) {
13920
13932
  for (const key of ["uid", "gid"]) {
13921
13933
  const value2 = options[key];
@@ -13923,6 +13935,27 @@ function checkIds(options) {
13923
13935
  if (!ID.test(value2) || Number(value2) > MAX_ID2) throw errnoError("EINVAL", `${key}=${value2}`);
13924
13936
  }
13925
13937
  }
13938
+ function checkMasks(options) {
13939
+ for (const key of ["umask", "fmask", "dmask"]) {
13940
+ const value2 = options[key];
13941
+ if (value2 === void 0) continue;
13942
+ if (!MASK.test(value2) || Number.parseInt(value2, 8) > 511) {
13943
+ throw errnoError("EINVAL", `${key}=${value2}`);
13944
+ }
13945
+ }
13946
+ }
13947
+ function modeOf(attr2, mount) {
13948
+ const type = attr2.kind === "directory" ? 16384 : attr2.kind === "symlink" ? 40960 : attr2.kind === "fifo" ? 4096 : 32768;
13949
+ const fallback = type | (attr2.kind === "directory" ? 493 : attr2.kind === "symlink" ? 511 : 420);
13950
+ if (mount.caps.owners) return attr2.mode ?? fallback;
13951
+ const umask = maskOption(mount.options.umask);
13952
+ const fmask = maskOption(mount.options.fmask) ?? umask;
13953
+ const dmask = maskOption(mount.options.dmask) ?? umask;
13954
+ const mask = attr2.kind === "directory" ? dmask : fmask;
13955
+ if (mask === void 0) return attr2.mode ?? fallback;
13956
+ const base = attr2.kind === "directory" || attr2.kind === "symlink" ? 511 : 438;
13957
+ return type | base & ~mask;
13958
+ }
13926
13959
  var MAX_LINKS7 = 40;
13927
13960
  var STALE_RETRIES = 3;
13928
13961
  var SETTLE_ROUNDS = 4;
@@ -14189,14 +14222,13 @@ function inodeless(mount, attr2) {
14189
14222
  }
14190
14223
  function statOf2(attr2, path, mount) {
14191
14224
  const mtime = new Date(attr2.mtime);
14192
- const fallback = attr2.kind === "directory" ? 16877 : attr2.kind === "symlink" ? 41471 : attr2.kind === "fifo" ? 4516 : 33188;
14193
14225
  return {
14194
14226
  isFile: attr2.kind === "file",
14195
14227
  isDirectory: attr2.kind === "directory",
14196
14228
  isSymbolicLink: attr2.kind === "symlink",
14197
14229
  ...attr2.kind === "fifo" ? { isFifo: true } : {},
14198
14230
  size: attr2.size,
14199
- mode: attr2.mode ?? fallback,
14231
+ mode: modeOf(attr2, mount),
14200
14232
  mtime,
14201
14233
  atime: attr2.atime === void 0 ? mtime : new Date(attr2.atime),
14202
14234
  ctime: mtime,
@@ -14210,7 +14242,8 @@ function statOf2(attr2, path, mount) {
14210
14242
  ...attr2.etag !== void 0 ? { version: attr2.etag } : {},
14211
14243
  ...mount.owners ? {
14212
14244
  uid: (mount.caps.owners ? attr2.uid : void 0) ?? idOption(mount.options.uid),
14213
- gid: (mount.caps.owners ? attr2.gid : void 0) ?? idOption(mount.options.gid)
14245
+ gid: (mount.caps.owners ? attr2.gid : void 0) ?? idOption(mount.options.gid),
14246
+ ...!mount.caps.owners && !mount.caps.chmod && (mount.options.umask !== void 0 || mount.options.fmask !== void 0 || mount.options.dmask !== void 0) ? { fat: true } : {}
14214
14247
  } : {}
14215
14248
  };
14216
14249
  }
@@ -14317,6 +14350,7 @@ var MountTable = class {
14317
14350
  if (!st.isDirectory) throw errnoError("ENOTDIR", target);
14318
14351
  const options = { ...spec.options };
14319
14352
  if (this.deps.owners) checkIds(options);
14353
+ checkMasks(options);
14320
14354
  const maxFile = options.maxfile !== void 0 ? parseSize(options.maxfile) : void 0;
14321
14355
  const opened2 = await this.deps.open(spec.type, { ...spec, target, options });
14322
14356
  let mounted;
@@ -24451,7 +24485,7 @@ function headEnd2(bytes) {
24451
24485
  }
24452
24486
  return -1;
24453
24487
  }
24454
- function modeOf(start2) {
24488
+ function modeOf2(start2) {
24455
24489
  const sniffs = [
24456
24490
  ["http1", sniffHttp1(start2)],
24457
24491
  ["smtp", sniffSmtp(start2)],
@@ -24560,7 +24594,7 @@ var SessionWriter = class {
24560
24594
  joined5.set(bytes, this.buffer.length);
24561
24595
  this.buffer.fill(0);
24562
24596
  this.buffer = joined5;
24563
- if (this.mode === "sniff") this.mode = modeOf(latin12(joined5.subarray(0, 8))) ?? "sniff";
24597
+ if (this.mode === "sniff") this.mode = modeOf2(latin12(joined5.subarray(0, 8))) ?? "sniff";
24564
24598
  if (this.mode === "pg" && !this.sawPg) {
24565
24599
  this.sawPg = true;
24566
24600
  if (!this.s.verified) void this.proof("pg");