@ai-ecoverse/slicc-kernel 1.175.1 → 1.176.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.
package/dist/node.js CHANGED
@@ -3702,7 +3702,7 @@ function satisfies(version, range2) {
3702
3702
  }
3703
3703
 
3704
3704
  // src/version.ts
3705
- var KERNEL_VERSION = true ? "1.175.1" : "0.0.0-dev";
3705
+ var KERNEL_VERSION = true ? "1.176.1" : "0.0.0-dev";
3706
3706
  var OS_RELEASE = "6.0.0-slicc";
3707
3707
  function procVersion() {
3708
3708
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -9064,6 +9064,7 @@ var EmbedderBroker = class {
9064
9064
  budget;
9065
9065
  open = /* @__PURE__ */ new Map();
9066
9066
  tagsOf;
9067
+ denied;
9067
9068
  constructor(users, lookup4, tagsOf2 = () => void 0, budget = EMBEDDER_BUDGET) {
9068
9069
  this.users = users;
9069
9070
  this.tagsOf = tagsOf2;
@@ -9081,7 +9082,8 @@ var EmbedderBroker = class {
9081
9082
  return this.hooks.get(client);
9082
9083
  }
9083
9084
  async allowed(policy, caller) {
9084
- if (caller.euid === 0 || caller.euid === caller.sessionUid) return true;
9085
+ if (caller.euid === 0) return true;
9086
+ if (policy.session !== false && caller.euid === caller.sessionUid) return true;
9085
9087
  if (policy.group !== void 0) {
9086
9088
  const gid = await this.lookup.groupId(policy.group);
9087
9089
  if (gid !== void 0 && (caller.egid === gid || caller.groups.includes(gid))) return true;
@@ -9097,9 +9099,22 @@ var EmbedderBroker = class {
9097
9099
  if (!hook) throw new KernelError("ENOTSUP", "no page answers requests for this session");
9098
9100
  const policy = Object.hasOwn(hook.kinds, kind) ? hook.kinds[kind] : void 0;
9099
9101
  if (!policy) throw new KernelError("ENOTSUP", `this embedder does not answer ${kind}`);
9100
- if (this.users !== "off" && !await this.allowed(policy, caller))
9101
- throw new KernelError("EACCES", `${kind} is not allowed for this user`);
9102
9102
  const tags = caller.tags;
9103
+ if (this.users !== "off" && !await this.allowed(policy, caller)) {
9104
+ try {
9105
+ this.denied?.({
9106
+ pid: caller.pid,
9107
+ uid: caller.euid,
9108
+ op: "embedder",
9109
+ path: EMBEDDER_PATH,
9110
+ errno: "EACCES",
9111
+ kind,
9112
+ ...tags?.length ? { tag: tags[0] } : {}
9113
+ });
9114
+ } catch {
9115
+ }
9116
+ throw new KernelError("EACCES", `${kind} is not allowed for this user`);
9117
+ }
9103
9118
  return {
9104
9119
  pid: caller.shownPid,
9105
9120
  uid: caller.euid,
@@ -9142,7 +9157,8 @@ function kindsOf(hook) {
9142
9157
  kind,
9143
9158
  {
9144
9159
  ...policy?.group !== void 0 ? { group: String(policy.group) } : {},
9145
- ...policy?.users ? { users: [...policy.users] } : {}
9160
+ ...policy?.users ? { users: [...policy.users] } : {},
9161
+ ...policy?.session === false ? { session: false } : {}
9146
9162
  }
9147
9163
  ])
9148
9164
  );
@@ -12482,6 +12498,10 @@ var lengthOf = getter("length");
12482
12498
 
12483
12499
  // src/realm/live-vfs-fs.ts
12484
12500
  var EARLY_WHOLE_FILE = 64 * 1024;
12501
+ var createParentRefresh = 0;
12502
+ function createParentRefreshCount() {
12503
+ return createParentRefresh;
12504
+ }
12485
12505
 
12486
12506
  // src/process/process-fds.ts
12487
12507
  var REFUSED = /* @__PURE__ */ new Set([wasiErrno("EACCES"), wasiErrno("EPERM")]);
@@ -12524,6 +12544,8 @@ var SYS_TREE = {
12524
12544
  slicc_opfs_calls: (listing) => `${listing.opfsCalls ?? 0}
12525
12545
  `,
12526
12546
  slicc_opfs_ops: (listing) => `${listing.opfsOps ?? 0}
12547
+ `,
12548
+ slicc_create_parent_refresh: (_listing) => `${createParentRefreshCount()}
12527
12549
  `,
12528
12550
  slicc_meta_transactions: ({ meta }) => `${meta?.reads ?? 0} ${meta?.writes ?? 0}
12529
12551
  `,
@@ -15429,11 +15451,12 @@ function parsePolicy(text, file) {
15429
15451
  var PASSWD = "/etc/passwd";
15430
15452
  var GROUP = "/etc/group";
15431
15453
  var DEFAULT_PASSWD = "root:x:0:0:root:/root:/bin/bash\nnobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin\n";
15432
- var DEFAULT_GROUP = "root:x:0:\nsudo:x:27:\nusers:x:100:\nnogroup:x:65534:\n";
15454
+ var DEFAULT_GROUP = "root:x:0:\ndialout:x:20:\nsudo:x:27:\nusers:x:100:\nnogroup:x:65534:\n";
15433
15455
  var NAME3 = /^[a-z_][a-z0-9_.-]*$/;
15434
15456
  var MAX_NAME = 255;
15435
15457
  var FIRST_UID = 1e3;
15436
15458
  var LAST_UID = 6e4;
15459
+ var MAX_GID = 4294967294;
15437
15460
  var USERS_GROUP = "users";
15438
15461
  var HOME_DIR = /^\/home\/[^/]+$/;
15439
15462
  var SYSTEM_PNPM_HOME = "/usr/local/share/pnpm";
@@ -15729,6 +15752,26 @@ var UserDb = class {
15729
15752
  const { group } = await this.tables();
15730
15753
  return parsed(group).map(({ name: name2, gid, members }) => ({ name: name2, gid, members: [...members] }));
15731
15754
  }
15755
+ addGroup(name2, gid) {
15756
+ return this.serial(async () => {
15757
+ if (typeof name2 !== "string" || name2.length > MAX_NAME || !NAME3.test(name2)) {
15758
+ throw fsError("EINVAL", `not a group name: ${String(name2)}`);
15759
+ }
15760
+ if (typeof gid !== "number" || !Number.isInteger(gid) || gid < 0 || gid > MAX_GID) {
15761
+ throw fsError("EINVAL", `not a group id: ${String(gid)}`);
15762
+ }
15763
+ const { group } = await this.tables();
15764
+ const rows = parsed(group);
15765
+ const found = rows.find((g) => g.name === name2);
15766
+ if (found) return { name: found.name, gid: found.gid, members: [...found.members] };
15767
+ const taken = rows.find((g) => g.gid === gid);
15768
+ if (taken) throw fsError("EEXIST", `group id ${gid} is group ${taken.name}`);
15769
+ group.push({ name: name2, gid, members: [] });
15770
+ await this.fs.mkdir("/etc", { recursive: true });
15771
+ await this.fs.writeFile(GROUP, formatGroup(group));
15772
+ return { name: name2, gid, members: [] };
15773
+ });
15774
+ }
15732
15775
  addMember(group, user) {
15733
15776
  return this.member(group, user, true);
15734
15777
  }
@@ -29159,7 +29202,7 @@ var OpfsFs = class {
29159
29202
  }
29160
29203
  async mkdirExcl(path, owner) {
29161
29204
  if (normalizePath(path) === "/") throw fsError("EEXIST", path);
29162
- const parent = await this.locate(parentOf9(path), true);
29205
+ const parent = await this.exactly(() => this.locate(parentOf9(path), true));
29163
29206
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
29164
29207
  const dir = parent.handle;
29165
29208
  const name2 = baseOf3(path);
@@ -29181,7 +29224,7 @@ var OpfsFs = class {
29181
29224
  }
29182
29225
  async createExclusive(path, owner) {
29183
29226
  if (normalizePath(path) === "/") throw fsError("EEXIST", path);
29184
- const parent = await this.locate(parentOf9(path), true);
29227
+ const parent = await this.exactly(() => this.locate(parentOf9(path), true));
29185
29228
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
29186
29229
  const dir = parent.handle;
29187
29230
  const name2 = baseOf3(path);
@@ -29930,7 +29973,7 @@ var OpfsFs = class {
29930
29973
  }
29931
29974
  }
29932
29975
  async symlink(target, path, owner) {
29933
- const parent = await this.locate(parentOf9(path), true);
29976
+ const parent = await this.exactly(() => this.locate(parentOf9(path), true));
29934
29977
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
29935
29978
  const at = resolvePath(parent.path, baseOf3(path));
29936
29979
  this.refuse(at);
@@ -32360,6 +32403,7 @@ var Launcher = class {
32360
32403
  (pid) => this.tagsOf(pid)
32361
32404
  );
32362
32405
  this.embedder = this.embedderBroker(options.embedder);
32406
+ this.embedder.denied = options.onDenial;
32363
32407
  this.sealed = new SealedBroker(
32364
32408
  options.sealed,
32365
32409
  this.usersMode,
@@ -37686,6 +37730,7 @@ async function createNodeKernel(options = {}) {
37686
37730
  },
37687
37731
  groups: {
37688
37732
  list: () => guard2(() => launcher.users.groups()),
37733
+ add: (name2, options2) => guard2(() => launcher.users.addGroup(name2, options2?.gid)),
37689
37734
  addMember: (group, user) => guard2(() => launcher.users.addMember(group, user)),
37690
37735
  removeMember: (group, user) => guard2(() => launcher.users.removeMember(group, user))
37691
37736
  },