Skip to content

fix(actions): backup_reload refused units added with systemctl link - #154

Merged
jamesconwaydev merged 2 commits into
mainfrom
fix/backup-linked-unit
Nov 15, 2026
Merged

jamesconwaydev merged 2 commits into
mainfrom
fix/backup-linked-unit

Conversation

@jamesconwaydev

Copy link
Copy Markdown
Owner

A unit added with systemctl link /opt/app/app.service gets a symlink in /etc/systemd/system, and systemd reports that symlink as FragmentPath. I checked on the Rocky 10 test host:

Created symlink '/etc/systemd/system/sv2-linktest.service' → '/opt/sv2linktest/sv2-linktest.service'.
FragmentPath=/etc/systemd/system/sv2-linktest.service

Since #144 the backup opens every file with O_NOFOLLOW, so backup_reload failed before the reload on every linked unit.

This resolves the fragment and drop-in paths systemd reports, and only those. Policy paths still refuse a symlink, and the final open still uses O_NOFOLLOW. Restore treats the resolved file like any file outside /etc/systemd/system: skipped if unchanged, and a refusal naming it if it changed.

The new test fails on main and passes here. CHANGELOG and docs/actions-and-safety.md updated.

`systemctl link /opt/app/app.service` leaves a symlink in
/etc/systemd/system, and systemd reports that symlink as FragmentPath
(checked on Rocky 10, systemd 257). The backup opens every file with
O_NOFOLLOW, so the action failed before the reload on every linked unit.

Resolve the fragment and drop-in paths systemd reports before copying.
Policy `paths` keep the no-symlink rule, and the final open still uses
O_NOFOLLOW, so a service that owns the target's directory can't swap
the file for a link.

Signed-off-by: James Conway <148910373+jamesconwaydev@users.noreply.github.com>
Signed-off-by: James Conway <148910373+jamesconwaydev@users.noreply.github.com>
@jamesconwaydev
jamesconwaydev merged commit 8dca0ab into main Nov 15, 2026
7 checks passed
@jamesconwaydev
jamesconwaydev deleted the fix/backup-linked-unit branch November 15, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant