From: Zbigniew Jędrzejewski-Szmek Date: Sat, 22 Aug 2020 09:58:15 +0000 (+0200) Subject: shared/install: fix preset operations for non-service instantiated units X-Git-Tag: v246.3~4 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=ba6e7f7c46d916a7eacddc17edb8be3e4f4dd67e;p=systemd%2F.git shared/install: fix preset operations for non-service instantiated units Fixes https://github.com/coreos/ignition/issues/1064. (cherry picked from commit 47ab95fe4315b3f7ee5a3694460a744bb88c52fd) --- diff --git a/src/shared/install.c b/src/shared/install.c index 3d19387504..289a683bbe 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -3055,20 +3055,17 @@ static int pattern_match_multiple_instances( /* Compose a list of specified instances when unit name is a template */ if (unit_name_is_valid(unit_name, UNIT_NAME_TEMPLATE)) { - _cleanup_free_ char *prefix = NULL; _cleanup_strv_free_ char **out_strv = NULL; - char **iter; - - r = unit_name_to_prefix(unit_name, &prefix); - if (r < 0) - return r; + char **iter; STRV_FOREACH(iter, rule.instances) { _cleanup_free_ char *name = NULL; - r = unit_name_build(prefix, *iter, ".service", &name); + + r = unit_name_replace_instance(unit_name, *iter, &name); if (r < 0) return r; - r = strv_extend(&out_strv, name); + + r = strv_consume(&out_strv, TAKE_PTR(name)); if (r < 0) return r; }