If a unit contains only Also=, with no Alias= or WantedBy=, it shouldn't be reported as static. If any target unit specified in Also= is enabled or disabled, report this unit as enabled or disabled as well.
https://bugzilla.redhat.com/show_bug.cgi?id=864298 --- src/shared/install.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/shared/install.c b/src/shared/install.c index cab93e8..781832f 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1874,8 +1874,29 @@ UnitFileState unit_file_get_state( return r; else if (r > 0) return UNIT_FILE_DISABLED; - else if (r == 0) + else if (r == 0) { + _cleanup_(install_context_done) InstallContext c = {}; + InstallInfo info = {}, *tmp; + Iterator it; + const char *key; + + (void) unit_file_load(&c, &info, path, root_dir, true, true); + + /* At this point, the unit contains only Also=, no Alias= or WantedBy= are specified. + It can be enabled/disabled through any of the Also= targets, we should check + if they're enabled/disabled. */ + if (c.will_install) { + ORDERED_HASHMAP_FOREACH_KEY(tmp, key, c.will_install, it) { + r = find_symlinks_in_scope(scope, root_dir, key, &state); + if (r < 0) + return r; + else if (r > 0) + return state; + } + return UNIT_FILE_DISABLED; + } return UNIT_FILE_STATIC; + } } return r < 0 ? r : state; -- 1.9.3 _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
