From 8204b540515e4542cf921bc60b37d91f805ac53c Mon Sep 17 00:00:00 2001 From: rcourtman Date: Fri, 14 Nov 2025 23:21:46 +0000 Subject: [PATCH] Fix permission denied error when updating allowed_nodes The update_allowed_nodes function was changing ownership of the temp file before all writes were complete, causing 'Permission denied' errors when appending the allowed_nodes section. Root cause: - mktemp creates file owned by script runner (root) - chown changed ownership to pulse-sensor-proxy:pulse-sensor-proxy - Subsequent append (>>) failed because root can't write to the file Fix: Defer chown until after all writes complete and file is moved to final location. Ownership is still correctly set on the final config file. --- scripts/install-sensor-proxy.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/install-sensor-proxy.sh b/scripts/install-sensor-proxy.sh index 28860b1..bf788f4 100755 --- a/scripts/install-sensor-proxy.sh +++ b/scripts/install-sensor-proxy.sh @@ -120,13 +120,11 @@ update_allowed_nodes() { } ' "$config_file" > "$tmp_config" - # Preserve file permissions + # Preserve file permissions (but defer ownership change until after all writes) chmod --reference="$config_file" "$tmp_config" 2>/dev/null || chmod 0644 "$tmp_config" - chown --reference="$config_file" "$tmp_config" 2>/dev/null || true else touch "$tmp_config" chmod 0644 "$tmp_config" - chown pulse-sensor-proxy:pulse-sensor-proxy "$tmp_config" 2>/dev/null || true fi # Append new allowed_nodes section