@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.
@@ -3094,7 +3094,7 @@ var OpfsFs = class {
3094
3094
  }
3095
3095
  async mkdirExcl(path, owner) {
3096
3096
  if (normalizePath(path) === "/") throw fsError("EEXIST", path);
3097
- const parent = await this.locate(parentOf4(path), true);
3097
+ const parent = await this.exactly(() => this.locate(parentOf4(path), true));
3098
3098
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
3099
3099
  const dir = parent.handle;
3100
3100
  const name2 = baseOf(path);
@@ -3116,7 +3116,7 @@ var OpfsFs = class {
3116
3116
  }
3117
3117
  async createExclusive(path, owner) {
3118
3118
  if (normalizePath(path) === "/") throw fsError("EEXIST", path);
3119
- const parent = await this.locate(parentOf4(path), true);
3119
+ const parent = await this.exactly(() => this.locate(parentOf4(path), true));
3120
3120
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
3121
3121
  const dir = parent.handle;
3122
3122
  const name2 = baseOf(path);
@@ -3865,7 +3865,7 @@ var OpfsFs = class {
3865
3865
  }
3866
3866
  }
3867
3867
  async symlink(target, path, owner) {
3868
- const parent = await this.locate(parentOf4(path), true);
3868
+ const parent = await this.exactly(() => this.locate(parentOf4(path), true));
3869
3869
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
3870
3870
  const at = resolvePath(parent.path, baseOf(path));
3871
3871
  this.refuse(at);
@@ -7744,11 +7744,12 @@ function serveTransport(peer, transport, {
7744
7744
  var PASSWD = "/etc/passwd";
7745
7745
  var GROUP = "/etc/group";
7746
7746
  var DEFAULT_PASSWD = "root:x:0:0:root:/root:/bin/bash\nnobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin\n";
7747
- var DEFAULT_GROUP = "root:x:0:\nsudo:x:27:\nusers:x:100:\nnogroup:x:65534:\n";
7747
+ var DEFAULT_GROUP = "root:x:0:\ndialout:x:20:\nsudo:x:27:\nusers:x:100:\nnogroup:x:65534:\n";
7748
7748
  var NAME = /^[a-z_][a-z0-9_.-]*$/;
7749
7749
  var MAX_NAME = 255;
7750
7750
  var FIRST_UID = 1e3;
7751
7751
  var LAST_UID = 6e4;
7752
+ var MAX_GID = 4294967294;
7752
7753
  var USERS_GROUP = "users";
7753
7754
  var HOME_DIR = /^\/home\/[^/]+$/;
7754
7755
  var SYSTEM_PNPM_HOME = "/usr/local/share/pnpm";
@@ -8044,6 +8045,26 @@ var UserDb = class {
8044
8045
  const { group } = await this.tables();
8045
8046
  return parsed(group).map(({ name: name2, gid, members }) => ({ name: name2, gid, members: [...members] }));
8046
8047
  }
8048
+ addGroup(name2, gid) {
8049
+ return this.serial(async () => {
8050
+ if (typeof name2 !== "string" || name2.length > MAX_NAME || !NAME.test(name2)) {
8051
+ throw fsError("EINVAL", `not a group name: ${String(name2)}`);
8052
+ }
8053
+ if (typeof gid !== "number" || !Number.isInteger(gid) || gid < 0 || gid > MAX_GID) {
8054
+ throw fsError("EINVAL", `not a group id: ${String(gid)}`);
8055
+ }
8056
+ const { group } = await this.tables();
8057
+ const rows = parsed(group);
8058
+ const found = rows.find((g) => g.name === name2);
8059
+ if (found) return { name: found.name, gid: found.gid, members: [...found.members] };
8060
+ const taken = rows.find((g) => g.gid === gid);
8061
+ if (taken) throw fsError("EEXIST", `group id ${gid} is group ${taken.name}`);
8062
+ group.push({ name: name2, gid, members: [] });
8063
+ await this.fs.mkdir("/etc", { recursive: true });
8064
+ await this.fs.writeFile(GROUP, formatGroup(group));
8065
+ return { name: name2, gid, members: [] };
8066
+ });
8067
+ }
8047
8068
  addMember(group, user) {
8048
8069
  return this.member(group, user, true);
8049
8070
  }
@@ -8746,7 +8767,7 @@ function satisfies(version, range2) {
8746
8767
  }
8747
8768
 
8748
8769
  // src/version.ts
8749
- var KERNEL_VERSION = true ? "1.175.1" : "0.0.0-dev";
8770
+ var KERNEL_VERSION = true ? "1.176.1" : "0.0.0-dev";
8750
8771
  var OS_RELEASE = "6.0.0-slicc";
8751
8772
  function procVersion() {
8752
8773
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13387,6 +13408,7 @@ var EmbedderBroker = class {
13387
13408
  budget;
13388
13409
  open = /* @__PURE__ */ new Map();
13389
13410
  tagsOf;
13411
+ denied;
13390
13412
  constructor(users, lookup2, tagsOf2 = () => void 0, budget = EMBEDDER_BUDGET) {
13391
13413
  this.users = users;
13392
13414
  this.tagsOf = tagsOf2;
@@ -13404,7 +13426,8 @@ var EmbedderBroker = class {
13404
13426
  return this.hooks.get(client);
13405
13427
  }
13406
13428
  async allowed(policy, caller) {
13407
- if (caller.euid === 0 || caller.euid === caller.sessionUid) return true;
13429
+ if (caller.euid === 0) return true;
13430
+ if (policy.session !== false && caller.euid === caller.sessionUid) return true;
13408
13431
  if (policy.group !== void 0) {
13409
13432
  const gid = await this.lookup.groupId(policy.group);
13410
13433
  if (gid !== void 0 && (caller.egid === gid || caller.groups.includes(gid))) return true;
@@ -13420,9 +13443,22 @@ var EmbedderBroker = class {
13420
13443
  if (!hook) throw new KernelError("ENOTSUP", "no page answers requests for this session");
13421
13444
  const policy = Object.hasOwn(hook.kinds, kind) ? hook.kinds[kind] : void 0;
13422
13445
  if (!policy) throw new KernelError("ENOTSUP", `this embedder does not answer ${kind}`);
13423
- if (this.users !== "off" && !await this.allowed(policy, caller))
13424
- throw new KernelError("EACCES", `${kind} is not allowed for this user`);
13425
13446
  const tags = caller.tags;
13447
+ if (this.users !== "off" && !await this.allowed(policy, caller)) {
13448
+ try {
13449
+ this.denied?.({
13450
+ pid: caller.pid,
13451
+ uid: caller.euid,
13452
+ op: "embedder",
13453
+ path: EMBEDDER_PATH,
13454
+ errno: "EACCES",
13455
+ kind,
13456
+ ...tags?.length ? { tag: tags[0] } : {}
13457
+ });
13458
+ } catch {
13459
+ }
13460
+ throw new KernelError("EACCES", `${kind} is not allowed for this user`);
13461
+ }
13426
13462
  return {
13427
13463
  pid: caller.shownPid,
13428
13464
  uid: caller.euid,
@@ -16775,6 +16811,10 @@ var lengthOf = getter("length");
16775
16811
 
16776
16812
  // src/realm/live-vfs-fs.ts
16777
16813
  var EARLY_WHOLE_FILE = 64 * 1024;
16814
+ var createParentRefresh = 0;
16815
+ function createParentRefreshCount() {
16816
+ return createParentRefresh;
16817
+ }
16778
16818
 
16779
16819
  // src/process/process-fds.ts
16780
16820
  var REFUSED = /* @__PURE__ */ new Set([wasiErrno("EACCES"), wasiErrno("EPERM")]);
@@ -16817,6 +16857,8 @@ var SYS_TREE = {
16817
16857
  slicc_opfs_calls: (listing) => `${listing.opfsCalls ?? 0}
16818
16858
  `,
16819
16859
  slicc_opfs_ops: (listing) => `${listing.opfsOps ?? 0}
16860
+ `,
16861
+ slicc_create_parent_refresh: (_listing) => `${createParentRefreshCount()}
16820
16862
  `,
16821
16863
  slicc_meta_transactions: ({ meta }) => `${meta?.reads ?? 0} ${meta?.writes ?? 0}
16822
16864
  `,
@@ -33464,6 +33506,7 @@ var Launcher = class {
33464
33506
  (pid) => this.tagsOf(pid)
33465
33507
  );
33466
33508
  this.embedder = this.embedderBroker(options.embedder);
33509
+ this.embedder.denied = options.onDenial;
33467
33510
  this.sealed = new SealedBroker(
33468
33511
  options.sealed,
33469
33512
  this.usersMode,
@@ -36434,6 +36477,7 @@ var USERS_OPS = /* @__PURE__ */ new Set([
36434
36477
  "users-remove",
36435
36478
  "users-list",
36436
36479
  "groups-list",
36480
+ "groups-add",
36437
36481
  "groups-add-member",
36438
36482
  "groups-remove-member"
36439
36483
  ]);
@@ -36485,6 +36529,7 @@ function usersOp(l, req) {
36485
36529
  if (req.op === "users-add") return l.users.add(req.user);
36486
36530
  if (req.op === "users-remove") return l.users.remove(req.name, req.options);
36487
36531
  if (req.op === "groups-list") return l.users.groups();
36532
+ if (req.op === "groups-add") return l.users.addGroup(req.name, req.gid);
36488
36533
  if (req.op === "groups-add-member") return l.users.addMember(req.group, req.user);
36489
36534
  if (req.op === "groups-remove-member") return l.users.removeMember(req.group, req.user);
36490
36535
  return l.users.list();