mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-02-27 04:45:22 +00:00
Replace unsafe `echo "$(sed ...)" > $FILE` with atomic temp-file write. The current pattern reads a file with sed inside a command substitution, then writes the result back via echo redirection. If sed reads an empty or momentarily unreadable file (e.g., NFS transient issue during container recreation by Watchtower or similar tools), it produces no output. The echo then writes exactly 1 byte (a newline) to the config file, silently destroying its contents. The fix writes sed output to a temp file first, checks it's non-empty with `[ -s ]`, then atomically replaces the original via `mv`. If sed produces empty output, the original file is preserved and a warning is logged to stderr.