Skip to content

Commit

Permalink
shared/install: fix preset operations for non-service instantiated units
Browse files Browse the repository at this point in the history
Fixes coreos/ignition#1064.

(cherry picked from commit 47ab95f)
(cherry picked from commit ba6e7f7)
  • Loading branch information
keszybz committed Sep 20, 2020
1 parent c116a08 commit 79638f6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/shared/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -3040,20 +3040,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;
}
Expand Down

0 comments on commit 79638f6

Please sign in to comment.