fix: loadRouters preserves API-registered routers; install.mjs chowns root

Two related fixes:

1. core/router-loader.loadRouters() previously called map.clear() before
   scanning routersDir, which wiped routers registered via
   __prismFacet.addRouter (the cross-plugin API). Now: track which
   entries in the map came from a file vs API (filePath sentinel),
   only delete file-based ones that disappeared between loads. External
   routers are never touched.

2. scripts/install.mjs: chown installed plugin files to root when the
   installer is running as root. openclaw 2026.5+ blocks plugins whose
   files are owned by non-root; rsync/tar from a developer laptop
   silently broke prism-facet on the next gateway restart. Matches the
   Meridian + ClawPrompts install.mjs fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
h z
2026-05-25 10:31:18 +01:00
parent cfd2ec445b
commit 6dca427187
2 changed files with 37 additions and 1 deletions

View File

@@ -130,6 +130,24 @@ function copyDirRecursive(src, dest, excludeExts = []) {
fs.copyFileSync(srcPath, destPath);
}
}
// openclaw 2026.5+ refuses to load plugins whose files are owned by
// non-root ("suspicious ownership"). fs.copyFileSync preserves source
// ownership, so rsync/tar from a developer laptop (uid 1000) breaks
// the plugin on next gateway restart. Force chown to root when we
// can (root-only); silently skip otherwise (dev mode under
// unprivileged user — uid checks don't apply there).
try {
if (process.getuid && process.getuid() === 0) chownRecursive(dest);
} catch {}
}
function chownRecursive(dir) {
fs.chownSync(dir, 0, 0);
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const p = path.join(dir, entry.name);
if (entry.isDirectory()) chownRecursive(p);
else fs.chownSync(p, 0, 0);
}
}
switch (action) {