Bug#886812: service: start/stop tries to use invalid systemd units when using socket templates

Cyrill Troxler cyrill at nine.ch
Wed Jan 10 08:57:39 GMT 2018


Package: init-system-helpers
Version: 1.48

I stumbled upon a issue with the start/stop triggers when using systemd
 socket templates on Debian stretch. I started getting unrelated error
messages when entering `service some_service start` on a system which
has a systemd socket template defined. The issue is quite easy to
replicate:

```
# touch /etc/systemd/system/test at .socket
# service cron start
Failed to get properties: Unit name test at .socket is not valid.
```

I have tracked down the issue to line 205 in /usr/sbin/service. (line
182 in 1.51)
```
for unit in $(systemctl list-unit-files --full --type=socket
2>/dev/null | sed -ne 's/\.socket\s*[a-z]*\s*$/.socket/p'); do
    if [ "$(systemctl -p Triggers show $unit)"

```
Here it gets all unit files and then tries to show get the Triggers of
that unit. This not only causes the error message shown above, it also
causes not stopping the actual socket units like it is described in the
comment above line 205. The issue could be solved by using `list-units` 
instead of `list-unit-files` because `list-units` will only list actual
socket units and not their templates.

Tested on Debian GNU/Linux 9.3 kernel 4.9.65-3+deb9u2.



More information about the Pkg-systemd-maintainers mailing list