From 9ea3a0e702e741e5a6015093dd02a2374722a62d Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Wed, 7 Feb 2018 14:08:02 +0100 Subject: [PATCH] core: use id unit when retrieving unit file state (#8038) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/unit.c b/src/core/unit.c index 5a17efdbcbb..9a57bcfb4b3 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -3965,7 +3965,7 @@ UnitFileState unit_get_unit_file_state(Unit *u) { r = unit_file_get_state( u->manager->unit_file_scope, NULL, - basename(u->fragment_path), + u->id, &u->unit_file_state); if (r < 0) u->unit_file_state = UNIT_FILE_BAD;