diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-04-29 17:31:02 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-04-29 17:31:02 +0200 |
commit | 934e749e18bc0641a3dc8d83c4f16a2ba4c8d966 (patch) | |
tree | f780c46a7eef0357298cd0037f001f26238cdee0 | |
parent | 313fe66fbd0cd3d62566edece7944d6cf45b1b21 (diff) |
core: refuse merging on units when the unit type does not support alias
The concept of merging units exists so that we can create Unit objects for a
number of names early, and then load them only later, possibly merging units
which then turn out to be symlinked to other names. This of course only makes
sense for unit types where multiple names per unit are supported. For all
others, let's refuse the merge operation early.
-rw-r--r-- | src/core/unit.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index cb79c7c6b1..4a129ffd5e 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -720,6 +720,9 @@ int unit_merge(Unit *u, Unit *other) { if (!u->instance != !other->instance) return -EINVAL; + if (UNIT_VTABLE(u)->no_alias) /* Merging only applies to unit names that support aliases */ + return -EEXIST; + if (other->load_state != UNIT_STUB && other->load_state != UNIT_NOT_FOUND) return -EEXIST; @@ -776,9 +779,9 @@ int unit_merge(Unit *u, Unit *other) { } int unit_merge_by_name(Unit *u, const char *name) { + _cleanup_free_ char *s = NULL; Unit *other; int r; - _cleanup_free_ char *s = NULL; assert(u); assert(name); |