Skip to content

Commit e450032

Browse files
committed
core/load-droping: avoid oom warning when the unit symlink is not a template
unit_name_template returns -EINVAL if the unit name is not a template, but the code assumed that OOM is the only failure mode. Fix that to emit the warning if a non-template unit is encountered (because in this case we expect the name to match exactly), and just skip the warning on other errors (presumably oom). Fixes systemd#5543.
1 parent 4417e1a commit e450032

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/core/load-dropin.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ static bool unit_name_compatible(const char *a, const char *b) {
3838
return true;
3939

4040
r = unit_name_template(a, &prefix);
41-
if (r < 0) {
42-
log_oom();
41+
if (r == -EINVAL)
42+
/* not a template */
43+
return false;
44+
if (r < 0)
45+
/* oom, or some other failure. Just skip the warning. */
4346
return true;
44-
}
4547

4648
/* an instance name points to a target that is just the template name */
4749
if (streq(prefix, b))

0 commit comments

Comments
 (0)