@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.
@@ -3194,6 +3194,22 @@ function cString(memory, at) {
3194
3194
  function baseOf(Fs, dirfd) {
3195
3195
  return dirfd === AT_FDCWD ? Fs.cwd?.() ?? "/" : Fs.getStream?.(dirfd)?.path ?? "/";
3196
3196
  }
3197
+ function readonlyRefusal(Fs, memory, call2) {
3198
+ if (!(call2.amode & W_ACCESS)) return 0;
3199
+ try {
3200
+ const name2 = cString(memory, call2.path);
3201
+ const abs = name2.startsWith("/") ? name2 : `${baseOf(Fs, call2.dirfd)}/${name2}`;
3202
+ const follow2 = (call2.flags & AT_SYMLINK_NOFOLLOW) === 0;
3203
+ const { node } = Fs.lookupPath.call(Fs, abs, {
3204
+ follow: follow2
3205
+ });
3206
+ const bridge = node.live ? node.mount.opts.bridge : void 0;
3207
+ const stat = bridge?.stat;
3208
+ return stat?.(liveNodePath(node)).readonly ? -wasiErrno("EROFS") : 0;
3209
+ } catch {
3210
+ return 0;
3211
+ }
3212
+ }
3197
3213
  function kernelChecks(Fs, memory, call2) {
3198
3214
  const name2 = cString(memory, call2.path);
3199
3215
  const abs = name2.startsWith("/") ? name2 : `${baseOf(Fs, call2.dirfd)}/${name2}`;
@@ -3207,9 +3223,12 @@ function kernelChecks(Fs, memory, call2) {
3207
3223
  }
3208
3224
  function kernelAccess(imports, fs, memory, glue) {
3209
3225
  wrapImport(imports, "faccessat", glue, (own) => (dirfd, path, amode, flags) => {
3210
- const rc = own(dirfd, path, amode, flags);
3211
3226
  const Fs = fs();
3212
3227
  const heap = memory();
3228
+ const call2 = { dirfd, path, amode: amode & 7, flags };
3229
+ const refused = Fs?.lookupPath && heap ? readonlyRefusal(Fs, heap, call2) : 0;
3230
+ if (refused !== 0) return refused;
3231
+ const rc = own(dirfd, path, amode, flags);
3213
3232
  if (rc !== 0 || !Fs?.lookupPath || !heap) return rc;
3214
3233
  try {
3215
3234
  return kernelChecks(Fs, heap, { dirfd, path, amode: amode & 7, flags });
@@ -3228,7 +3247,7 @@ function linuxDevices(Fs) {
3228
3247
  }
3229
3248
  }
3230
3249
  }
3231
- var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, DEVICE_MODES;
3250
+ var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, W_ACCESS, DEVICE_MODES;
3232
3251
  var init_process_fds = __esm({
3233
3252
  "src/process/process-fds.ts"() {
3234
3253
  "use strict";
@@ -3287,6 +3306,7 @@ var init_process_fds = __esm({
3287
3306
  NAME = /^[a-z_][a-z0-9_-]*$/i;
3288
3307
  AT_FDCWD = -100;
3289
3308
  AT_EACCESS = 512;
3309
+ W_ACCESS = 2;
3290
3310
  DEVICE_MODES = [
3291
3311
  ["/", 493],
3292
3312
  ["/dev", 493],
@@ -6921,7 +6941,8 @@ var init_wasi_host = __esm({
6921
6941
  if (this.o.fs.owners && amode & 1) throw new WasiError("EACCES");
6922
6942
  return;
6923
6943
  }
6924
- pathOwned(path, !nofollow);
6944
+ const st = pathOwned(path, !nofollow);
6945
+ if (amode & 2 && st.readonly) throw new WasiError("EROFS");
6925
6946
  if (!this.o.fs.owners) return;
6926
6947
  const kind = flags & AT_EACCESS2 ? "eaccess" : "access";
6927
6948
  this.o.fs.access?.(path, amode & 7, kind, nofollow);