@ai-ecoverse/slicc-kernel 1.77.0 → 1.77.1

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.
@@ -2639,7 +2639,8 @@ var init_wasi_host = __esm({
2639
2639
  if (this.o.fs.owners && amode & 1) throw new WasiError("EACCES");
2640
2640
  return;
2641
2641
  }
2642
- pathOwned(path, !nofollow);
2642
+ const st = pathOwned(path, !nofollow);
2643
+ if (amode & 2 && st.readonly) throw new WasiError("EROFS");
2643
2644
  if (!this.o.fs.owners) return;
2644
2645
  const kind = flags & AT_EACCESS ? "eaccess" : "access";
2645
2646
  this.o.fs.access?.(path, amode & 7, kind, nofollow);
@@ -8646,6 +8647,22 @@ function cString(memory, at) {
8646
8647
  function baseOf(Fs, dirfd) {
8647
8648
  return dirfd === AT_FDCWD ? Fs.cwd?.() ?? "/" : Fs.getStream?.(dirfd)?.path ?? "/";
8648
8649
  }
8650
+ function readonlyRefusal(Fs, memory, call2) {
8651
+ if (!(call2.amode & W_ACCESS)) return 0;
8652
+ try {
8653
+ const name2 = cString(memory, call2.path);
8654
+ const abs = name2.startsWith("/") ? name2 : `${baseOf(Fs, call2.dirfd)}/${name2}`;
8655
+ const follow2 = (call2.flags & AT_SYMLINK_NOFOLLOW2) === 0;
8656
+ const { node } = Fs.lookupPath.call(Fs, abs, {
8657
+ follow: follow2
8658
+ });
8659
+ const bridge = node.live ? node.mount.opts.bridge : void 0;
8660
+ const stat = bridge?.stat;
8661
+ return stat?.(liveNodePath(node)).readonly ? -wasiErrno("EROFS") : 0;
8662
+ } catch {
8663
+ return 0;
8664
+ }
8665
+ }
8649
8666
  function kernelChecks(Fs, memory, call2) {
8650
8667
  const name2 = cString(memory, call2.path);
8651
8668
  const abs = name2.startsWith("/") ? name2 : `${baseOf(Fs, call2.dirfd)}/${name2}`;
@@ -8659,9 +8676,12 @@ function kernelChecks(Fs, memory, call2) {
8659
8676
  }
8660
8677
  function kernelAccess(imports, fs, memory, glue) {
8661
8678
  wrapImport(imports, "faccessat", glue, (own) => (dirfd, path, amode, flags) => {
8662
- const rc = own(dirfd, path, amode, flags);
8663
8679
  const Fs = fs();
8664
8680
  const heap = memory();
8681
+ const call2 = { dirfd, path, amode: amode & 7, flags };
8682
+ const refused2 = Fs?.lookupPath && heap ? readonlyRefusal(Fs, heap, call2) : 0;
8683
+ if (refused2 !== 0) return refused2;
8684
+ const rc = own(dirfd, path, amode, flags);
8665
8685
  if (rc !== 0 || !Fs?.lookupPath || !heap) return rc;
8666
8686
  try {
8667
8687
  return kernelChecks(Fs, heap, { dirfd, path, amode: amode & 7, flags });
@@ -8680,7 +8700,7 @@ function linuxDevices(Fs) {
8680
8700
  }
8681
8701
  }
8682
8702
  }
8683
- var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY4, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, DEVICE_MODES;
8703
+ var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY4, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, W_ACCESS, DEVICE_MODES;
8684
8704
  var init_process_fds = __esm({
8685
8705
  "src/process/process-fds.ts"() {
8686
8706
  "use strict";
@@ -8739,6 +8759,7 @@ var init_process_fds = __esm({
8739
8759
  NAME = /^[a-z_][a-z0-9_-]*$/i;
8740
8760
  AT_FDCWD = -100;
8741
8761
  AT_EACCESS2 = 512;
8762
+ W_ACCESS = 2;
8742
8763
  DEVICE_MODES = [
8743
8764
  ["/", 493],
8744
8765
  ["/dev", 493],