core: use id unit when retrieving unit file state (#8038)
authorFranck Bui <fbui@suse.com>
Wed, 7 Feb 2018 13:08:02 +0000 (14:08 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Feb 2018 13:08:02 +0000 (14:08 +0100)
commit9ea3a0e702e741e5a6015093dd02a2374722a62d
tree0aea43e0859ac08fa35b4757bcd3126659a86abd
parenta166e13771f308973d7b7221abd65fdd90f42c61
core: use id unit when retrieving unit file state (#8038)

Previous code was using the basename(id->fragment_path) which returned
incorrect result if the unit was an instance.

For example, assuming that no instances of "template" have been created so far:

 $ systemctl enable template@1
 Created symlink from /etc/systemd/system/multi-user.target.wants/template@1.service to /usr/lib/systemd/system/template@.service.

 $ systemctl is-enabled template@3.service
 disabled

 $ systemctl status template@3.service
 ● template@3.service - openQA Worker #3
    Loaded: loaded (/usr/lib/systemd/system/template@.service; enabled; vendor preset: disabled)
    [...]

Here the unit file states reported by "status" and "is-enabled" were different.
src/core/unit.c