cretead more paths were openclaw find settings

This commit is contained in:
2026-03-14 16:58:58 +01:00
parent 1d48dbe7d5
commit c23e4ff1ad
2 changed files with 55 additions and 17 deletions
+34 -15
View File
@@ -1423,13 +1423,28 @@ async function handleListPermissions(clientWs) {
try {
log("info", "server", "Lade Tool-Berechtigungen...");
// Alle moeglichen Settings-Dateien pruefen (Debug-Info)
let allPaths = "";
try {
allPaths = await dockerExec("aria-core", `
for f in ${OPENCLAW_SETTINGS_PATHS.join(" ")}; do
if [ -f "$f" ]; then
echo "EXISTS: $f ($(wc -c < "$f") bytes)"
else
echo "MISSING: $f"
fi
done
`.trim());
} catch {}
const settingsPath = await findSettingsFile();
let settings = {};
let rawContent = "";
let info = "";
try {
const raw = await dockerExec("aria-core", `cat '${settingsPath}' 2>/dev/null || echo '{}'`);
settings = JSON.parse(raw.trim() || "{}");
rawContent = await dockerExec("aria-core", `cat '${settingsPath}' 2>/dev/null || echo '{}'`);
settings = JSON.parse(rawContent.trim() || "{}");
info = `Geladen aus: ${settingsPath}`;
} catch (e) {
info = `Settings-Datei nicht lesbar (${settingsPath}) — Default-Berechtigungen`;
@@ -1446,8 +1461,10 @@ async function handleListPermissions(clientWs) {
permissions,
settingsPath,
info,
debug: { allPaths: allPaths.trim(), rawKeys: Object.keys(settings).join(", ") },
}));
log("info", "server", `Berechtigungen geladen (${allowedTools.length} Tools explizit erlaubt)`);
log("info", "server", `Berechtigungen geladen (${allowedTools.length} Tools explizit erlaubt) aus ${settingsPath}`);
if (allPaths) log("info", "server", `Settings-Dateien:\n${allPaths}`);
} catch (err) {
log("error", "server", `Berechtigungen laden fehlgeschlagen: ${err.message}`);
clientWs.send(JSON.stringify({ type: "permissions_list", error: err.message, allowedTools: [], permissions: {} }));
@@ -1460,21 +1477,23 @@ async function handleSavePermissions(clientWs, allowedTools) {
return;
}
try {
const settingsPath = await findSettingsFile();
log("info", "server", `Speichere ${allowedTools.length} Tool-Berechtigungen in ${settingsPath}`);
log("info", "server", `Speichere ${allowedTools.length} Tool-Berechtigungen in alle Settings-Pfade`);
// Bestehende Settings lesen und mergen
// Schreiben in ALLE moeglichen Pfade damit OpenClaw es sicher findet
const script = [
'const fs=require("fs");',
`const f="${settingsPath}";`,
'const fs=require("fs");const path=require("path");',
`const paths=${JSON.stringify(OPENCLAW_SETTINGS_PATHS)};`,
`const tools=${JSON.stringify(allowedTools)};`,
'let s={};try{s=JSON.parse(fs.readFileSync(f,"utf8"));}catch(e){}',
's.allowedTools=tools;',
`const dir=f.substring(0,f.lastIndexOf("/"));`,
'try{fs.mkdirSync(dir,{recursive:true});}catch(e){}',
'fs.writeFileSync(f,JSON.stringify(s,null,2));',
// Verify: zuruecklesen und pruefen
'const v=JSON.parse(fs.readFileSync(f,"utf8"));',
'for(const f of paths){',
'let s={};try{s=JSON.parse(fs.readFileSync(f,"utf8"));}catch(e){}',
's.allowedTools=tools;',
'const dir=path.dirname(f);',
'try{fs.mkdirSync(dir,{recursive:true});}catch(e){}',
'fs.writeFileSync(f,JSON.stringify(s,null,2));',
'}',
// Verify: ersten Pfad zuruecklesen
`const v=JSON.parse(fs.readFileSync(paths[0],"utf8"));`,
'process.stdout.write(JSON.stringify(v.allowedTools||[]));',
].join("");
const b64 = Buffer.from(script).toString("base64");
@@ -1501,7 +1520,7 @@ async function handleSavePermissions(clientWs, allowedTools) {
clientWs.send(JSON.stringify({
type: "permissions_saved", ok: true,
info: `${allowedTools.length} Tools gespeichert und verifiziert in ${settingsPath}`,
info: `${allowedTools.length} Tools gespeichert und verifiziert (alle ${OPENCLAW_SETTINGS_PATHS.length} Pfade)`,
needsRestart: true,
}));
log("info", "server", `Berechtigungen gespeichert und verifiziert (${allowedTools.length} Tools)`);