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 <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -164,7 +164,10 @@ class DockerManager {
|
|||||||
async readStack(id, file) {
|
async readStack(id, file) {
|
||||||
const s = this.get(id);
|
const s = this.get(id);
|
||||||
const f = absPath(file);
|
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 }));
|
if (r.code) throw new Error(lastLine(r.err) || i18n.t('Could not read {file}', { file: f }));
|
||||||
const i = r.out.lastIndexOf('\n\0');
|
const i = r.out.lastIndexOf('\n\0');
|
||||||
return { compose: r.out.slice(0, i), env: r.out.slice(i + 2) };
|
return { compose: r.out.slice(0, i), env: r.out.slice(i + 2) };
|
||||||
|
|||||||
Reference in New Issue
Block a user