wrappers/internal: Disable and re-enable daemons to refresh XXX.wants#16685
Open
sergio-costas wants to merge 1 commit intocanonical:masterfrom
Open
Conversation
If the `WantedBy` entry in the `Install` section of a .service file changes from `default` to `graphical-session`, the soft link at `/etc/systemd/user/default.target.wants` must be deleted and a new one at `/etc/systemd/user/graphical-session.target.wants` must be created for those user daemons that have changed. But this must be done only to those daemons that are enabled, to avoid enabling daemons that the user manually disabled. This can happen in two cases: * snapd is updated from the old versions that didn't support `graphical-session` target to a new version that supports it, so all the currently user services already installed will have their .service files updated with the new WantedBy entry. * a snap with an user service is updated, and the new version have added or removed the `desktop` plug in any of the user services. In both cases, a `systemctl --user reenable SERVICE-NAME` must be run to update the symlinks at `/etc/systemd/user/default.target.wants` and `/etc/systemd/user/graphical-session.target.wants` folders, but only if it is globally enabled. That command removes the symlinks at the wrong places and re-creates them in the right places. This patch does that, but only for globally-enabled (preset) user daemons. Locally-enabled daemons (thus, with their symlinks placed at $HOME/.config/systemd/user/XXXXX.target.wants`) aren't modified. That is a task for another PR.
This was referenced Feb 27, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #16685 +/- ##
==========================================
+ Coverage 77.52% 77.56% +0.03%
==========================================
Files 1359 1353 -6
Lines 187225 187212 -13
Branches 2446 2446
==========================================
+ Hits 145152 145205 +53
+ Misses 33298 33241 -57
+ Partials 8775 8766 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Fri Feb 27 10:42:22 UTC 2026 Failures:Executing:
Restoring:
Skipped tests from snapd-testing-skip
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the first of three PRs to replace #16601
If the
WantedByentry in theInstallsection of a .service file changes fromdefaulttographical-session, the soft link at/etc/systemd/user/default.target.wantsmust be deleted and a new one at/etc/systemd/user/graphical-session.target.wantsmust be created for those user daemons that have changed. But this must be done only to those daemons that are enabled, to avoid enabling daemons that the user manually disabled.This can happen in two cases:
graphical-sessiontarget to a new version that supports it, so all the currently user services already installed will have their .service files updated with the new WantedBy entry.desktopplug in any of the user services.In both cases, a
systemctl --user reenable SERVICE-NAMEmust be run to update the symlinks at/etc/systemd/user/default.target.wantsand/etc/systemd/user/graphical-session.target.wantsfolders, but only if it is globally enabled. That command removes the symlinks at the wrong places and re-creates them in the right places.This patch does that, but only for globally-enabled (preset) user daemons. Locally-enabled daemons (thus, with their symlinks placed at $HOME/.config/systemd/user/XXXXX.target.wants`) aren't modified. That is a task for another PR.
Thanks for helping us make a better snapd!
Have you signed the license agreement and read the contribution guide?