#1087031 deb-systemd-helper is-enabled returns wrong result if dependent services are disabled #1087031
- Package:
- init-system-helpers
- Source:
- init-system-helpers
- Submitter:
- Marco Schmidt
- Date:
- 2024-11-16 14:48:02 UTC
- Severity:
- normal
- Tags:
Hello, Using "deb-systemd-helper is-enabled xxx.servce" answers "disabled" even if the service is enabled. To check if a service is enabled, the script gets all (closure) dependent services (via Wantedby, RequiredBy, Also, Alias, ...) and checks if the filesystem link is found in /etc/systemd/system/xxx.wants. Unfortunately this does not work, if a dependent (also) service is not enabled. I know, it is strange to have dependent services not enabled. In systemd there are several dependencies with different meanings. https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html Especially the "Also" option is going only in one directrection. If the service containing the "Also" is enabled, the services under "Also" are enabled, too. But not the other way around. The services under "Also" are not needed. Example: I saw this with "systemd-networkd.service", which contains "Also=systemd-network-generator.service" and this contains "WantedBy=sysinit.target". The "deb-systemd-helper" script checks if "systemd-network-generator.service" is in "etc/systemd/system/sysinit.target.wants/" which is not the case, because "systemd-network-generator" is not enabled. The "systemctl is-enabled systemd-networkd.service" returns "enabled" as expected. Of course "systemd-network-generator" can be enabled, but it is not needed to have "systemd-networkd.service". Thanks for taking the time to think about this! Greetings ... Marco
Control: tags -1 moreinfo not enabled. https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html In which package's maintainer script is this a problem?
Hello Luca, Thanks for looking into it and sorry for the delay. As mentioned in my report it is in the script "deb-systemd-helper" in the Debian package "init-system-helpers". Via git you can find the newest version under this link. https://salsa.debian.org/debian/init-system-helpers/-/blob/master/script/deb-systemd-helper In line 614 it calls "all_links_installed", which calls in line 289 the function "get_link_closure". In "get_link_closure" it loops recursively over all systemd services referenced via "Wanted-By", "Required-by", "Also" and "Alias". I think the "Also" is not correct, because "Also" says, if you start this service start the also-service, too. But the also-service does not need to be active to mark a service as active. Hope this helps further. As I am a sysadmin I can read/debug code, but are not able to provide a stable solution. Quick and dirty I would ask "systemctl is-enabled" instead of checking the links. https://github.com/systemd/systemd/blob/main/src/systemctl/systemctl-is-enabled.c Greetings ... Marco Am Fr., 8. Nov. 2024 um 20:33 Uhr schrieb Luca Boccassi <bluca@debian.org>: