On Wed, 2018-01-10 at 12:23 +0100, Michael Biebl wrote: > Am 10.01.2018 um 09:57 schrieb Cyrill Troxler: > > 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@.socket > > # service cron start > > Failed to get properties: Unit name test@.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. > > Afaics the problem is that you created an invalid (empty) .socket > template file. > The problem with list-units afair was, that it only shows units which > are currently in memory. > >
I stumbled onto this with a valid .socket template. The issue is that `systemctl -p Triggers show $unit` happens with the name of the template because `list-unit-files` does not show any of the instances spawned by templates. For reference, here's a valid template that I've tried: ``` # /etc/systemd/system/test@.socket [Unit] Description=Test Socket %i [Socket] ListenStream=127.0.0.1:1234 [Install] WantedBy=sockets.target ``` If `list-units` only shows units which are in memory, is that not what we want anyway? Or is it possible to start/stop units which are not in memory? With `list-units` and `--all` it would also show inactive ones. Cyrill