Skip to content

Consider aliases in /usr when disabling units - #14156

Merged
keszybz merged 3 commits into
systemd:masterfrom
fbuihuu:deal-with-aliases-when-disabling
Feb 6, 2020
Merged

keszybz merged 3 commits into
systemd:masterfrom
fbuihuu:deal-with-aliases-when-disabling

Conversation

@fbuihuu

@fbuihuu fbuihuu commented Nov 26, 2019

Copy link
Copy Markdown
Contributor

No description provided.

@fbuihuu

fbuihuu commented Nov 27, 2019

Copy link
Copy Markdown
Contributor Author

So test-install-root unit test is now failing due to the fact that broken symlinks in the config paths are no more allowed.

This can be fixed easily by using CHASE_NONEXISTENT flag with chase_symlinks() but on the other hand I'm wondering if we really should allow such dangling symlinks...

For instance the test creates the following dangling enablement symlink:

/tmp/rootMQHOvY/etc/systemd/system/multi-user.target.wants/a.service -> /usr/lib/systemd/system/a.service

and the current code accepts it even if /usr/lib/systemd/system/a.service points to nowhere. If we're only interested in the generic name "a.service", wouldn't it have been better to use a symlink pointing to itself rather than allowing such dangling symlink ?

@fbuihuu fbuihuu changed the title Deal with aliases when disabling Deal with aliases in /usr when disabling Nov 28, 2019
@fbuihuu fbuihuu changed the title Deal with aliases in /usr when disabling Consider aliases in /usr when disabling units Nov 28, 2019
@fbuihuu

fbuihuu commented Dec 9, 2019

Copy link
Copy Markdown
Contributor Author

@keszybz could you please have a look ?

@poettering poettering mentioned this pull request Jan 9, 2020
@keszybz

keszybz commented Jan 10, 2020

Copy link
Copy Markdown
Member

This can be fixed easily by using CHASE_NONEXISTENT flag with chase_symlinks() but on the other hand I'm wondering if we really should allow such dangling symlinks...

That is explicitly allowed and we must accept such symlinks. In particular, it is totally OK to create a symlink to a unit file in /etc, and than have that file moved to /usr/lib.

Apart from that, I think the changes in this PR are good.

@fbuihuu

fbuihuu commented Jan 10, 2020

Copy link
Copy Markdown
Contributor Author

That is explicitly allowed and we must accept such symlinks. In particular, it is totally OK to create a symlink to a unit file in /etc, and than have that file moved to /usr/lib.

Fair enough.

I'm still wondering why we use (potentially dangling) symlinks in *.wants/ or *.requires/... empty files would have been less ambiguous IMHO.

… a unit

It might be needed to follow symlinks more deeply when we're looking for
enablement symlinks pointing to the removed service.

Let's consider the case where service 'old' is being renamed 'new' (will happen
most likely during package upgrade). Before the service is going to be renamed,
there's the following enablement symlink:

 /etc/systemd/system/multi-user.target.wants/old.service -> /usr/lib/systemd/system/old.service

In order to rename 'old' into 'new' and transparently restart the service, the
old name is still provided as a 'static' alias for the new service. This should
also help keeping backward compatibilities since the old name might still be
embedded in unit files, scripts, generators and such.

Hence after the package is upgraded, the following symlinks including the
enablement symlink are present:

 /usr/lib/systemd/system/old.service -> new.service
 /etc/systemd/system/multi-user.target.wants/old.service -> /usr/lib/systemd/system/old.service

If later the user decides to disable the service, we should figure out that the
enablement symlink (which still has the old name) is actually referring to 'new'
(indirectly) even if it points to the alias.
@fbuihuu
fbuihuu force-pushed the deal-with-aliases-when-disabling branch from a0ee79d to 972f317 Compare January 10, 2020 13:29
@keszybz

keszybz commented Jan 10, 2020

Copy link
Copy Markdown
Member

I'm still wondering why we use (potentially dangling) symlinks in *.wants/ or *.requires/... empty files would have been less ambiguous IMHO.

Because empty files mean masking, and this would be very confusing. Things are as they are, a clean design from scratch would probably be different.

@fbuihuu

fbuihuu commented Jan 21, 2020

Copy link
Copy Markdown
Contributor Author

@keszybz any chance you can review this one ? Thanks.

@keszybz

keszybz commented Feb 6, 2020

Copy link
Copy Markdown
Member

LGTM.

@keszybz
keszybz merged commit 5650ec7 into systemd:master Feb 6, 2020
@fbuihuu
fbuihuu deleted the deal-with-aliases-when-disabling branch May 5, 2020 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants