Skip to content

fix: secureblue-unbound-key systemd unit#1967

Merged
EsseLowNitro merged 6 commits intosecureblue:livefrom
pxlkng:fix/secureblue-unbound-key-symlink
Feb 23, 2026
Merged

fix: secureblue-unbound-key systemd unit#1967
EsseLowNitro merged 6 commits intosecureblue:livefrom
pxlkng:fix/secureblue-unbound-key-symlink

Conversation

@pxlkng
Copy link
Copy Markdown
Collaborator

@pxlkng pxlkng commented Feb 23, 2026

The secureblue-unbound-key.service systemd unit is currently broken in two ways:

  • The ConditionPathExists precondition only works on files and ignores symlinks.
    Edit: ConditionPathExists does work on symlinks, but doesn't in this case due to SELinux.
    /var/lib/unbound/root.key can be a symlink (e.g. on a fresh securecore install) so this PR reworks this to use ExecCondition with a negated test call instead additionally, which does work on symlinks.
  • Both /usr/etc/unbound/dnssec-root.key and /etc/unbound/dnssec-root.key are identical symlinks, pointing to ../../usr/share/dns-root-data/root.key. Due to the path being relative and only going back two folders, the symlink in /usr/etc/unbound/ is broken and leads to the copy operation failing. This PR switches to using the working one in /etc/unbound/ instead.

The symlinks under /usr/etc/unbound/ and /etc/unbound/ are identical, but due to the symlink being relative, only the version in /etc/unbound/ points to valid path.
ConditionPathExists only checks for files and ignores symlinks, but /var/lib/unbound/root.key can also exist as a symlink. This commit reworks the check to use ExecCondition instead and use test -e, which also works on symlinks.
EsseLowNitro
EsseLowNitro previously approved these changes Feb 23, 2026
Copy link
Copy Markdown
Collaborator

@HastD HastD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ConditionPathExists precondition only works on files and ignores symlinks.

That's not actually true, as documented here:

Except for ConditionPathIsSymbolicLink=, all path checks follow symlinks.

So are you sure that's actually the issue? Another possibility is that the system service manager might be failing to follow the symlink due to SELinux. (I actually just ran into this with Homebrew; see secureblue/homebrew#16.)

In any case, I recommend keeping the negated ConditionPathExists check as it will avoid having to run the service at all if it detects the path does exist, and the failure mode (if it incorrectly fails to detect the path for whatever reason) would be to run the service and be stopped by the ExecCondition you added, which is fine.

This does indeed work on symlinks; The actual reason for it not working in this case was SELinux. Add this back as a more efficient case on files, and keep the ExecCondition as a failsafe for symlinks.
@pxlkng
Copy link
Copy Markdown
Collaborator Author

pxlkng commented Feb 23, 2026

So are you sure that's actually the issue? Another possibility is that the system service manager might be failing to follow the symlink due to SELinux. (I actually just ran into this with Homebrew; see secureblue/homebrew#16.)

Oh, interesting!

When I did my testing and initially looked into this issue, I noticed that on a fresh securecore install the service ran, even though the file existed in form of a symlink. After I tested the same with a file in its place and saw it correctly skipped, I (in hindsight falsely) drew my conclusion that this option just doesn't work on symlinks.

But you were right indeed. After testing with setenforce 0 I can confirm this was due to SELinux.

As per your suggestion I added the ConditionPathExists line back with f8727f2.

@EsseLowNitro EsseLowNitro merged commit a748f02 into secureblue:live Feb 23, 2026
11 checks passed
@HastD HastD removed the Pending CI label Feb 23, 2026
PhysicsIsAwesome pushed a commit to PhysicsIsAwesome/secureblue that referenced this pull request Mar 1, 2026
* fix: use correct symlink for secureblue-unbound-key unit

The symlinks under /usr/etc/unbound/ and /etc/unbound/ are identical, but due to the symlink being relative, only the version in /etc/unbound/ points to valid path.

* fix: rework secureblue-unbound-key execution condition

ConditionPathExists only checks for files and ignores symlinks, but /var/lib/unbound/root.key can also exist as a symlink. This commit reworks the check to use ExecCondition instead and use test -e, which also works on symlinks.

* fix: change RequiresMountsFor as well

* chore: add ConditionPathExists back

This does indeed work on symlinks; The actual reason for it not working in this case was SELinux. Add this back as a more efficient case on files, and keep the ExecCondition as a failsafe for symlinks.
PhysicsIsAwesome pushed a commit to PhysicsIsAwesome/secureblue that referenced this pull request Mar 1, 2026
* fix: use correct symlink for secureblue-unbound-key unit

The symlinks under /usr/etc/unbound/ and /etc/unbound/ are identical, but due to the symlink being relative, only the version in /etc/unbound/ points to valid path.

* fix: rework secureblue-unbound-key execution condition

ConditionPathExists only checks for files and ignores symlinks, but /var/lib/unbound/root.key can also exist as a symlink. This commit reworks the check to use ExecCondition instead and use test -e, which also works on symlinks.

* fix: change RequiresMountsFor as well

* chore: add ConditionPathExists back

This does indeed work on symlinks; The actual reason for it not working in this case was SELinux. Add this back as a more efficient case on files, and keep the ExecCondition as a failsafe for symlinks.
RKNF404 pushed a commit to RKNF404/secureblue that referenced this pull request Mar 1, 2026
* fix: use correct symlink for secureblue-unbound-key unit

The symlinks under /usr/etc/unbound/ and /etc/unbound/ are identical, but due to the symlink being relative, only the version in /etc/unbound/ points to valid path.

* fix: rework secureblue-unbound-key execution condition

ConditionPathExists only checks for files and ignores symlinks, but /var/lib/unbound/root.key can also exist as a symlink. This commit reworks the check to use ExecCondition instead and use test -e, which also works on symlinks.

* fix: change RequiresMountsFor as well

* chore: add ConditionPathExists back

This does indeed work on symlinks; The actual reason for it not working in this case was SELinux. Add this back as a more efficient case on files, and keep the ExecCondition as a failsafe for symlinks.
PhysicsIsAwesome pushed a commit to PhysicsIsAwesome/secureblue that referenced this pull request Mar 1, 2026
* fix: use correct symlink for secureblue-unbound-key unit

The symlinks under /usr/etc/unbound/ and /etc/unbound/ are identical, but due to the symlink being relative, only the version in /etc/unbound/ points to valid path.

* fix: rework secureblue-unbound-key execution condition

ConditionPathExists only checks for files and ignores symlinks, but /var/lib/unbound/root.key can also exist as a symlink. This commit reworks the check to use ExecCondition instead and use test -e, which also works on symlinks.

* fix: change RequiresMountsFor as well

* chore: add ConditionPathExists back

This does indeed work on symlinks; The actual reason for it not working in this case was SELinux. Add this back as a more efficient case on files, and keep the ExecCondition as a failsafe for symlinks.
PhysicsIsAwesome pushed a commit to PhysicsIsAwesome/secureblue that referenced this pull request Mar 4, 2026
* fix: use correct symlink for secureblue-unbound-key unit

The symlinks under /usr/etc/unbound/ and /etc/unbound/ are identical, but due to the symlink being relative, only the version in /etc/unbound/ points to valid path.

* fix: rework secureblue-unbound-key execution condition

ConditionPathExists only checks for files and ignores symlinks, but /var/lib/unbound/root.key can also exist as a symlink. This commit reworks the check to use ExecCondition instead and use test -e, which also works on symlinks.

* fix: change RequiresMountsFor as well

* chore: add ConditionPathExists back

This does indeed work on symlinks; The actual reason for it not working in this case was SELinux. Add this back as a more efficient case on files, and keep the ExecCondition as a failsafe for symlinks.
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.

4 participants