]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/install: fix preset operations for non-service instantiated units 16816/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 22 Aug 2020 09:58:15 +0000 (11:58 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 22 Aug 2020 10:00:19 +0000 (12:00 +0200)
Fixes https://github.com/coreos/ignition/issues/1064.

src/shared/install.c

index b08dc241e0b3050c4af7e6bf661e9bf47a2c8388..0f21cdc3f7730b838ab9eae455af563c4f2688df 100644 (file)
@@ -3050,20 +3050,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;
                 }