@ai-ecoverse/slicc-kernel 1.63.0 → 1.64.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.
package/dist/node.js CHANGED
@@ -3030,6 +3030,9 @@ var OpfsFs = class {
3030
3030
  trackOwners() {
3031
3031
  this.owners = true;
3032
3032
  }
3033
+ async hasOwner(path) {
3034
+ return ownOf((await this.meta.get([path]))[0]) !== void 0;
3035
+ }
3033
3036
  async ancestry(path) {
3034
3037
  const entries = await this.meta.get(chain(path));
3035
3038
  const out = [];
@@ -3801,8 +3804,10 @@ var UnlinkedKeeper = class {
3801
3804
  count = 0;
3802
3805
  links = /* @__PURE__ */ new Map();
3803
3806
  linked = /* @__PURE__ */ new Map();
3807
+ dirOwner;
3804
3808
  constructor(fs, holders, rootOf, options = {}) {
3805
3809
  const { locks, owner } = options;
3810
+ this.dirOwner = options.dirOwner;
3806
3811
  this.fs = fs;
3807
3812
  this.holders = holders;
3808
3813
  this.rootOf = rootOf;
@@ -3913,7 +3918,8 @@ var UnlinkedKeeper = class {
3913
3918
  const dir = dirOf(this.rootOf(path));
3914
3919
  const hidden = `${dir}/${this.instance}.${++this.count}`;
3915
3920
  try {
3916
- await this.fs.mkdir(dir, { recursive: true });
3921
+ const owner = this.dirOwner;
3922
+ await this.fs.mkdir(dir, { recursive: true, ...owner ? { owner } : {} });
3917
3923
  await this.fs.rename(path, hidden);
3918
3924
  await this.linkedName(hidden);
3919
3925
  return hidden;
@@ -5071,6 +5077,7 @@ function withCommandDirs(fs, names, userDir = async () => void 0, owners = false
5071
5077
  ...fs.realpath ? { realpath: fs.realpath.bind(fs) } : {},
5072
5078
  ...fs.chown ? { chown: fs.chown.bind(fs) } : {},
5073
5079
  ...fs.ancestry ? { ancestry: fs.ancestry.bind(fs) } : {},
5080
+ ...fs.hasOwner ? { hasOwner: fs.hasOwner.bind(fs) } : {},
5074
5081
  chmod: (path, mode) => fs.chmod(path, mode),
5075
5082
  utimes: (path, atime, mtime) => fs.utimes(path, atime, mtime),
5076
5083
  lutimes: (path, atime, mtime) => lutimesOf(fs, path, atime, mtime),
@@ -6442,6 +6449,10 @@ var MountFs = class {
6442
6449
  if (this.at(real)) throw errnoError("ENOSYS", path);
6443
6450
  return real;
6444
6451
  }
6452
+ async hasOwner(path) {
6453
+ if (this.at(path)) return true;
6454
+ return await this.base.hasOwner?.(path) ?? true;
6455
+ }
6445
6456
  async ancestry(path) {
6446
6457
  const names = chain(normalizePath(path));
6447
6458
  const first = names.findIndex((name2) => this.at(name2));
@@ -14002,6 +14013,16 @@ var NOT_FOUND = 127;
14002
14013
  var DECIDE_MS = 100;
14003
14014
  var INIT_PID = 1;
14004
14015
  var SHARED_DIRS = ["/tmp", "/home"];
14016
+ var LAYOUT = [
14017
+ ["/", 493],
14018
+ ["/root", 448],
14019
+ ["/home", 493],
14020
+ ["/etc", 493],
14021
+ [PASSWD, 420],
14022
+ [GROUP, 420],
14023
+ ["/usr", 493],
14024
+ ["/usr/local", 493]
14025
+ ];
14005
14026
  var encoder3 = new TextEncoder();
14006
14027
  var USERS_MODES = ["off", "report", "enforce"];
14007
14028
  function usersMode(mode = "off") {
@@ -14195,7 +14216,8 @@ var Launcher = class {
14195
14216
  {
14196
14217
  locks: webLocks(),
14197
14218
  busy: (path) => [...this.openFiles].some((nodes) => nodes.holds(path)),
14198
- owner: options.unlinkOwner
14219
+ owner: options.unlinkOwner,
14220
+ ...this.owners ? { dirOwner: { uid: 0, gid: 0, mode: 448 } } : {}
14199
14221
  }
14200
14222
  );
14201
14223
  this.fs = this.unlinked.wrap(keepingOpen(fs, this.nodes));
@@ -14820,6 +14842,24 @@ var Launcher = class {
14820
14842
  await this.provisionPnpmHome();
14821
14843
  return entry;
14822
14844
  }
14845
+ async stampLayout() {
14846
+ const layout = [
14847
+ ...LAYOUT,
14848
+ [this.modulesDir, 493],
14849
+ [this.pnpmHome, 493],
14850
+ [`/${UNLINKED_DIR}`, 448]
14851
+ ];
14852
+ for (const [path, mode] of layout) {
14853
+ const real = await this.realLayoutPath(path);
14854
+ const fresh = real !== void 0 && !await this.base.hasOwner?.(real);
14855
+ if (fresh) await this.base.chown?.(real, { uid: 0, gid: 0, mode, follow: false });
14856
+ }
14857
+ }
14858
+ async realLayoutPath(path) {
14859
+ if (!await this.base.exists(path)) return void 0;
14860
+ if (path === "/") return path;
14861
+ return joinName(await realDir(this.base, parentOf(path)), baseName(path));
14862
+ }
14823
14863
  async provisionPnpmHome() {
14824
14864
  await this.base.mkdir(this.pnpmHome, { recursive: true }).catch(() => void 0);
14825
14865
  }
@@ -14893,6 +14933,7 @@ var Launcher = class {
14893
14933
  if (this.owners) await this.base.chmod("/tmp", 1023);
14894
14934
  await this.provisionPnpmHome();
14895
14935
  await this.users.ensure();
14936
+ if (this.owners) await this.stampLayout();
14896
14937
  await writeCaFile(this.base, this.ca).catch(() => void 0);
14897
14938
  this.fstab = this.mountFstab();
14898
14939
  }