Skip to content

File deploy writes are not atomic and never apply mode, owner or group on redeploy #498

Description

@retr0h

In internal/provider/file/deploy.go (used by the cron, service and certificate providers):

  • WriteFile truncates the target in place, so a crash mid-write leaves a partial config, unit or certificate on disk.
  • os.WriteFile does not change permissions of an existing file, so a changed Mode is never applied, and the SHA-match shortcut only compares content.
  • DeployRequest.Owner and Group are stored in the file state but never applied; the file package has no chown.

internal/provider/node/user/debian_ssh_key.go uses the same non-atomic pattern for authorized_keys.

Fix: write to a temp file in the same directory, set mode (and owner/group when given), then rename. Apply mode, owner and group even when the content hash matches, or remove Owner/Group from the API if they will not be supported.


Found in the September 2026 codebase review. Tracked in the review tracking issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingkind/go

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions