Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 480616 - systemd.eclass: take care of disabling uninstalled services
Summary: systemd.eclass: take care of disabling uninstalled services
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo systemd Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-11 13:04 UTC by Pacho Ramos
Modified: 2020-02-24 16:51 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pacho Ramos gentoo-dev 2013-08-11 13:04:32 UTC
Currently, we have no way to ensure service files are disabled when the package providing them is uninstalled and, then, this leads to errors like this being shown on every boot for every no longer available unit file:
[   22.350644] systemd[1]: Cannot add dependency job for unit abrt-vmcore.service, ignoring: Unit abrt-vmcore.service failed to load: No such file or directory. See system logs and 'systemctl status abrt-vmcore.service' for details.
[   22.350655] systemd[1]: Cannot add dependency job for unit abrt-ccpp.service, ignoring: Unit abrt-ccpp.service failed to load: No such file or directory. See system logs and 'systemctl status abrt-ccpp.service' for details.
[   22.350670] systemd[1]: Cannot add dependency job for unit abrt-oops.service, ignoring: Unit abrt-oops.service failed to load: No such file or directory. See system logs and 'systemctl status abrt-oops.service' for details.
[   22.350676] systemd[1]: Cannot add dependency job for unit abrtd.service, ignoring: Unit abrtd.service failed to load: No such file or directory. See system logs and 'systemctl status abrtd.service' for details.
[   22.350682] systemd[1]: Cannot add dependency job for unit abrt-xorg.service, ignoring: Unit abrt-xorg.service failed to load: No such file or directory. See system logs and 'systemctl status abrt-xorg.service' for details.

Fedora takes care of this running disable stuff when package is removed, on Gentoo, I guess we could achieve the same exporting a pkg_postinst phase running systemctl disable (this also reminds me that we are also not running "systemctl daemon-reload" when units are modified (installed or removed). This could be achieved with a postinst phase too.

The problem is that I see no easy way to standardize that command as service files can have multiple names. 

Should we suggest upstream to have some kind of auto-disable option to disable no longer existing units?


Thanks for your suggestions and ideas
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-08-11 13:29:20 UTC
Adding postinst() and/or postrm() at this point sounds dangerous. Maybe we should just do some kind of cronish auto-cleanup in gentoo-systemd-integration?
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-08-11 13:30:54 UTC
Then, I'm not really not convinced about auto-playing with user config. If ebuild enables some service, the symlink enabling it should be removed along with the ebuild (it's owned by it). If user enables some service, I don't see 'emerge --depclean' removing it.
Comment 3 Mike Gilbert gentoo-dev 2013-08-11 15:38:47 UTC
(In reply to Michał Górny from comment #2)

I agree with this.
Comment 4 Pacho Ramos gentoo-dev 2013-08-13 13:01:02 UTC
(In reply to Michał Górny from comment #1)
> Adding postinst() and/or postrm() at this point sounds dangerous. Maybe we
> should just do some kind of cronish auto-cleanup in
> gentoo-systemd-integration?

Why would it be dangerous? In the worst case, the exported phase won't be run because some ebuilds will overwrite it (and, then, they will behave as currently until fixed)
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-08-13 15:56:54 UTC
In the worst case, it will actually override important pkg_postinst() / pkg_postrm() from some other eclass.
Comment 6 Pacho Ramos gentoo-dev 2013-08-13 18:48:27 UTC
True, for some reason I though this was the kind of eclass called in alphabetical before others... but taking care it starts by "s"... yes, it would be risky if we don't launch a systemd-r1.eclass for handling this (and the reload commands at install /removal time).

Other option would be to suggest upstream (I would report it of course) to add a command to automatically remove all *dead* symlinks, otherwise, people will need to load one command per removed .service file, that can be a bit annoying :/
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-08-13 19:53:34 UTC
But why should we do that? Does any other distro do such a thing? We don't do it for OpenRC, I doubt we should do for systemd.

One case I can think of is that temporary uninstall of a package would cause it to be disabled permanently.
Comment 8 Pacho Ramos gentoo-dev 2013-08-14 08:58:36 UTC
Fedora is doing that as can be seen in .spec files (for example abrt one). Also, this is not needed in openrc because openrc doesn't look to try to load missing init.d files, while systemd keeps trying to start missing unit files forever. 

Anyway, having an option to easily disable all dead unit files (removing dead links) could be a mid way: we would still rely on administrator doing that manually (that would solve your valid concerns), still allowing admin to easily remove all of them easily when he wants
Comment 9 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-08-14 11:14:25 UTC
Well, something that automatically fixes symlinks in /etc would be a good start. Lemme explain shortly.

systemd doesn't use symlinks through the explicit expansion. Rather, it does readlink() and uses target's basename. For example:

    acpid.service -> /usr/lib64/systemd/system/acpid.service

I probably got that due to /usr/lib being a symlink. Now when it's no longer a symlink, the path is completely invalid. Yet systemd starts acpid.service since it uses the basename and looks for it in standard directories.

Now, a stale symlinking cleaning service would drop the file. IMO we would first use a tool that would actually fix it to point to the correct location. I wonder if that's upstreamable.
Comment 10 Pacho Ramos gentoo-dev 2013-09-21 14:00:55 UTC
I talked with upstream about this and Lennart explained me that this should be solved by the equivalent of the rpm macro they are using in Fedora, in our case, with a newer eclass doing this on removal of the packages (like the case of running systemd-tmpfilesd --create that is commented in other bug report)
Comment 11 Mike Gilbert gentoo-dev 2020-02-24 16:51:51 UTC
It's been several years, and I still think this is a bad idea. Closing.