@ai-ecoverse/slicc-kernel 1.61.2 → 1.62.0

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.
@@ -3151,6 +3151,12 @@ function importsContext({
3151
3151
  if (path === void 0) throw new WasiError("EBADF");
3152
3152
  return path;
3153
3153
  };
3154
+ const owners = fs.owners === true;
3155
+ const live = () => {
3156
+ if (!owners) return { uid: UID, gid: UID };
3157
+ const cred = call2({ op: "proc-cred" });
3158
+ return { uid: cred.euid, gid: cred.egid };
3159
+ };
3154
3160
  const fds = {
3155
3161
  open(path, o = {}) {
3156
3162
  const abs = host.fds.resolve(3, path);
@@ -3171,7 +3177,7 @@ function importsContext({
3171
3177
  const path = pathOf(fd);
3172
3178
  if (path === void 0) {
3173
3179
  const kind = e.type === "device" ? "device" : "stream";
3174
- return { kind, mode: kind === "device" ? 8630 : 4480, uid: UID, gid: UID, size: 0 };
3180
+ return { kind, mode: kind === "device" ? 8630 : 4480, ...live(), size: 0 };
3175
3181
  }
3176
3182
  host.fds.flushPath(path);
3177
3183
  const s = fs.stat(path);
@@ -3179,8 +3185,7 @@ function importsContext({
3179
3185
  kind: s.isDirectory ? "dir" : "file",
3180
3186
  path,
3181
3187
  mode: s.mode ?? (s.isDirectory ? 16877 : 33188),
3182
- uid: UID,
3183
- gid: UID,
3188
+ ...s.uid !== void 0 && s.gid !== void 0 ? { uid: s.uid, gid: s.gid } : live(),
3184
3189
  size: s.size,
3185
3190
  ...s.ino !== void 0 ? { ino: s.ino } : {},
3186
3191
  ...s.mtimeMs !== void 0 ? { mtimeMs: s.mtimeMs } : {}
@@ -3203,7 +3208,7 @@ function importsContext({
3203
3208
  call2({ op: "unlock", path: requirePath(fd) });
3204
3209
  }
3205
3210
  };
3206
- return {
3211
+ const ctx = {
3207
3212
  memory,
3208
3213
  instance,
3209
3214
  tid,
@@ -3242,6 +3247,11 @@ function importsContext({
3242
3247
  },
3243
3248
  errno: (err) => wasiErrnoOf(code(err))
3244
3249
  };
3250
+ if (!owners) return ctx;
3251
+ return Object.defineProperties(ctx, {
3252
+ uid: { get: () => live().uid, enumerable: true },
3253
+ gid: { get: () => live().gid, enumerable: true }
3254
+ });
3245
3255
  }
3246
3256
  function processes(host, call2, inThread) {
3247
3257
  const close = (fd) => void call2({ op: "fd-close", fd });