From 6ebdc5126fdc947d39af83714f98ee6f16beb2d9 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 1 Oct 2026 22:12:37 +0200 Subject: [PATCH] Docker stacks: show .env variables when editing a stack whose .env was written via sudo (root-owned, mode 600); reading now retries with sudo instead of silently showing an empty .env, which also deleted the file on the next save Co-Authored-By: Claude Opus 5.5 --- src/main/docker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/docker.js b/src/main/docker.js index 4a1ff3d..76df610 100644 --- a/src/main/docker.js +++ b/src/main/docker.js @@ -164,7 +164,10 @@ class DockerManager { async readStack(id, file) { const s = this.get(id); const f = absPath(file); - const r = await this.sh(s, `cat ${q(f)} && printf '\\n\\0' && { cat ${q(dirname(f) + '/.env')} 2>/dev/null || true; }`); + // .env wird mit umask 077 geschrieben – beim Speichern per sudo gehört sie root. Dann scheitert cat mit + // „Permission denied“ und sh() wiederholt das Lesen per sudo (vorher wurde der Fehler verschluckt). + const env = q(dirname(f) + '/.env'); + const r = await this.sh(s, `cat ${q(f)} && printf '\\n\\0' && { [ ! -e ${env} ] || cat ${env}; }`); if (r.code) throw new Error(lastLine(r.err) || i18n.t('Could not read {file}', { file: f })); const i = r.out.lastIndexOf('\n\0'); return { compose: r.out.slice(0, i), env: r.out.slice(i + 2) };