richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
21255d
From db2816ee32fc81ba339175469e46b5dca7af8833 Mon Sep 17 00:00:00 2001
21255d
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
21255d
Date: Sat, 22 Aug 2020 11:58:15 +0200
21255d
Subject: [PATCH] shared/install: fix preset operations for non-service
21255d
 instantiated units
21255d
21255d
Fixes https://github.com/coreos/ignition/issues/1064.
21255d
21255d
(cherry picked from commit 47ab95fe4315b3f7ee5a3694460a744bb88c52fd)
21255d
21255d
Related: #1812972
21255d
---
21255d
 src/shared/install.c | 13 +++++--------
21255d
 1 file changed, 5 insertions(+), 8 deletions(-)
21255d
21255d
diff --git a/src/shared/install.c b/src/shared/install.c
21255d
index 263b239f10..c2847df3f8 100644
21255d
--- a/src/shared/install.c
21255d
+++ b/src/shared/install.c
21255d
@@ -2937,20 +2937,17 @@ static int pattern_match_multiple_instances(
21255d
 
21255d
         /* Compose a list of specified instances when unit name is a template  */
21255d
         if (unit_name_is_valid(unit_name, UNIT_NAME_TEMPLATE)) {
21255d
-                _cleanup_free_ char *prefix = NULL;
21255d
                 _cleanup_strv_free_ char **out_strv = NULL;
21255d
-                char **iter;
21255d
-
21255d
-                r = unit_name_to_prefix(unit_name, &prefix);
21255d
-                if (r < 0)
21255d
-                        return r;
21255d
 
21255d
+                char **iter;
21255d
                 STRV_FOREACH(iter, rule.instances) {
21255d
                         _cleanup_free_ char *name = NULL;
21255d
-                        r = unit_name_build(prefix, *iter, ".service", &name);
21255d
+
21255d
+                        r = unit_name_replace_instance(unit_name, *iter, &name);
21255d
                         if (r < 0)
21255d
                                 return r;
21255d
-                        r = strv_extend(&out_strv, name);
21255d
+
21255d
+                        r = strv_consume(&out_strv, TAKE_PTR(name));
21255d
                         if (r < 0)
21255d
                                 return r;
21255d
                 }