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.
This commit is contained in:
parent
20a5bcedad
commit
8204b54051
1 changed files with 1 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue