daandemeyer / rpms / systemd

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