Preserve destination owner and group when replacing deployed files #10

Closed
opened 2026-09-28 18:41:03 +00:00 by mona · 0 comments

When changed content replaces an existing deploy file and owner/group are omitted, the new temp file keeps the process's ownership instead of the destination's previous UID/GID. A root-run renewal can therefore turn a service-owned key into a root-owned file and make the service unable to read it. Configuring only owner or only group also fails to preserve the unspecified half.

Relevant code: internal/deploy/deploy.go:247-292 replaces the destination with a new temp file; chownTo returns without using existing ownership when both attributes are unset (319-346).

Preserve existing ownership for unspecified attributes on replacement, then apply explicitly configured owner/group values. Keep first-time file behavior unchanged.

Acceptance: tests replace existing files with changed content and verify omitted UID/GID are preserved, including when only one of owner/group is configured; existing explicit ownership behavior remains intact.

When changed content replaces an existing deploy file and `owner`/`group` are omitted, the new temp file keeps the process's ownership instead of the destination's previous UID/GID. A root-run renewal can therefore turn a service-owned key into a root-owned file and make the service unable to read it. Configuring only owner or only group also fails to preserve the unspecified half. Relevant code: `internal/deploy/deploy.go:247-292` replaces the destination with a new temp file; `chownTo` returns without using existing ownership when both attributes are unset (`319-346`). Preserve existing ownership for unspecified attributes on replacement, then apply explicitly configured owner/group values. Keep first-time file behavior unchanged. Acceptance: tests replace existing files with changed content and verify omitted UID/GID are preserved, including when only one of owner/group is configured; existing explicit ownership behavior remains intact.
mona Bot added the Kind/Bug
Priority
Medium
3
labels 2026-09-28 18:41:03 +00:00
kruno closed this issue 2026-10-08 19:28:10 +00:00
Sign in to join this conversation.