@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.
package/dist/node.js CHANGED
@@ -876,14 +876,21 @@ async function ownerOnly(g, op, path, follow2) {
876
876
  return walked;
877
877
  }
878
878
  async function chmodMode(g, path, mode) {
879
- const perm = (await ownerOnly(g, "chmod", path, true)).perm;
880
- if (!g.dac.enforcing || !perm || g.cred.euid === 0 || inGroup(g.cred, perm.gid)) return mode;
879
+ const walked = await need(g, "chmod", path, 0, { follow: true });
880
+ const perm = walked.perm;
881
+ const st = await g.fs.stat(walked.path).catch(() => void 0);
882
+ if (!st?.fat && perm && g.cred.euid !== 0 && perm.uid !== g.cred.euid) {
883
+ if (await present(g.fs, walked.path, false)) deny(g, "chmod", path, "EPERM");
884
+ }
885
+ if (!g.dac.enforcing || !perm || g.cred.euid === 0 || st?.fat || inGroup(g.cred, perm.gid)) {
886
+ return mode;
887
+ }
881
888
  return mode & ~S_ISGID2;
882
889
  }
883
890
  function heldChmodMode(g, path, st, mode) {
884
891
  const perm = permOf(st);
885
- if (g.cred.euid !== 0 && perm.uid !== g.cred.euid) deny(g, "fchmod", path, "EPERM");
886
- if (!g.dac.enforcing || g.cred.euid === 0 || inGroup(g.cred, perm.gid)) return mode;
892
+ if (!st.fat && g.cred.euid !== 0 && perm.uid !== g.cred.euid) deny(g, "fchmod", path, "EPERM");
893
+ if (!g.dac.enforcing || g.cred.euid === 0 || st.fat || inGroup(g.cred, perm.gid)) return mode;
887
894
  return mode & ~S_ISGID2;
888
895
  }
889
896
  function heldRetimable(g, path, st, now) {
@@ -3702,7 +3709,7 @@ function satisfies(version, range2) {
3702
3709
  }
3703
3710
 
3704
3711
  // src/version.ts
3705
- var KERNEL_VERSION = true ? "1.176.1" : "0.0.0-dev";
3712
+ var KERNEL_VERSION = true ? "1.176.2" : "0.0.0-dev";
3706
3713
  var OS_RELEASE = "6.0.0-slicc";
3707
3714
  function procVersion() {
3708
3715
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -9599,10 +9606,15 @@ var DriverConnection = class _DriverConnection {
9599
9606
  // src/mount/mount-fs.ts
9600
9607
  var S_ISGID3 = 1024;
9601
9608
  var ID = /^\d{1,10}$/;
9609
+ var MASK = /^0*[0-7]{1,4}$/;
9602
9610
  var MAX_ID2 = 4294967294;
9603
9611
  function idOption(value2) {
9604
9612
  return value2 === void 0 ? 0 : Number(value2);
9605
9613
  }
9614
+ function maskOption(value2) {
9615
+ if (value2 === void 0) return void 0;
9616
+ return Number.parseInt(value2, 8) & 511;
9617
+ }
9606
9618
  function checkIds(options) {
9607
9619
  for (const key of ["uid", "gid"]) {
9608
9620
  const value2 = options[key];
@@ -9610,6 +9622,27 @@ function checkIds(options) {
9610
9622
  if (!ID.test(value2) || Number(value2) > MAX_ID2) throw errnoError("EINVAL", `${key}=${value2}`);
9611
9623
  }
9612
9624
  }
9625
+ function checkMasks(options) {
9626
+ for (const key of ["umask", "fmask", "dmask"]) {
9627
+ const value2 = options[key];
9628
+ if (value2 === void 0) continue;
9629
+ if (!MASK.test(value2) || Number.parseInt(value2, 8) > 511) {
9630
+ throw errnoError("EINVAL", `${key}=${value2}`);
9631
+ }
9632
+ }
9633
+ }
9634
+ function modeOf(attr2, mount) {
9635
+ const type = attr2.kind === "directory" ? 16384 : attr2.kind === "symlink" ? 40960 : attr2.kind === "fifo" ? 4096 : 32768;
9636
+ const fallback = type | (attr2.kind === "directory" ? 493 : attr2.kind === "symlink" ? 511 : 420);
9637
+ if (mount.caps.owners) return attr2.mode ?? fallback;
9638
+ const umask = maskOption(mount.options.umask);
9639
+ const fmask = maskOption(mount.options.fmask) ?? umask;
9640
+ const dmask = maskOption(mount.options.dmask) ?? umask;
9641
+ const mask = attr2.kind === "directory" ? dmask : fmask;
9642
+ if (mask === void 0) return attr2.mode ?? fallback;
9643
+ const base = attr2.kind === "directory" || attr2.kind === "symlink" ? 511 : 438;
9644
+ return type | base & ~mask;
9645
+ }
9613
9646
  var MAX_LINKS5 = 40;
9614
9647
  var STALE_RETRIES = 3;
9615
9648
  var SETTLE_ROUNDS = 4;
@@ -9876,14 +9909,13 @@ function inodeless(mount, attr2) {
9876
9909
  }
9877
9910
  function statOf2(attr2, path, mount) {
9878
9911
  const mtime = new Date(attr2.mtime);
9879
- const fallback = attr2.kind === "directory" ? 16877 : attr2.kind === "symlink" ? 41471 : attr2.kind === "fifo" ? 4516 : 33188;
9880
9912
  return {
9881
9913
  isFile: attr2.kind === "file",
9882
9914
  isDirectory: attr2.kind === "directory",
9883
9915
  isSymbolicLink: attr2.kind === "symlink",
9884
9916
  ...attr2.kind === "fifo" ? { isFifo: true } : {},
9885
9917
  size: attr2.size,
9886
- mode: attr2.mode ?? fallback,
9918
+ mode: modeOf(attr2, mount),
9887
9919
  mtime,
9888
9920
  atime: attr2.atime === void 0 ? mtime : new Date(attr2.atime),
9889
9921
  ctime: mtime,
@@ -9897,7 +9929,8 @@ function statOf2(attr2, path, mount) {
9897
9929
  ...attr2.etag !== void 0 ? { version: attr2.etag } : {},
9898
9930
  ...mount.owners ? {
9899
9931
  uid: (mount.caps.owners ? attr2.uid : void 0) ?? idOption(mount.options.uid),
9900
- gid: (mount.caps.owners ? attr2.gid : void 0) ?? idOption(mount.options.gid)
9932
+ gid: (mount.caps.owners ? attr2.gid : void 0) ?? idOption(mount.options.gid),
9933
+ ...!mount.caps.owners && !mount.caps.chmod && (mount.options.umask !== void 0 || mount.options.fmask !== void 0 || mount.options.dmask !== void 0) ? { fat: true } : {}
9901
9934
  } : {}
9902
9935
  };
9903
9936
  }
@@ -10004,6 +10037,7 @@ var MountTable = class {
10004
10037
  if (!st.isDirectory) throw errnoError("ENOTDIR", target);
10005
10038
  const options = { ...spec.options };
10006
10039
  if (this.deps.owners) checkIds(options);
10040
+ checkMasks(options);
10007
10041
  const maxFile = options.maxfile !== void 0 ? parseSize(options.maxfile) : void 0;
10008
10042
  const opened2 = await this.deps.open(spec.type, { ...spec, target, options });
10009
10043
  let mounted;
@@ -20355,7 +20389,7 @@ function headEnd2(bytes) {
20355
20389
  }
20356
20390
  return -1;
20357
20391
  }
20358
- function modeOf(start2) {
20392
+ function modeOf2(start2) {
20359
20393
  const sniffs = [
20360
20394
  ["http1", sniffHttp1(start2)],
20361
20395
  ["smtp", sniffSmtp(start2)],
@@ -20464,7 +20498,7 @@ var SessionWriter = class {
20464
20498
  joined5.set(bytes, this.buffer.length);
20465
20499
  this.buffer.fill(0);
20466
20500
  this.buffer = joined5;
20467
- if (this.mode === "sniff") this.mode = modeOf(latin12(joined5.subarray(0, 8))) ?? "sniff";
20501
+ if (this.mode === "sniff") this.mode = modeOf2(latin12(joined5.subarray(0, 8))) ?? "sniff";
20468
20502
  if (this.mode === "pg" && !this.sawPg) {
20469
20503
  this.sawPg = true;
20470
20504
  if (!this.s.verified) void this.proof("pg");