1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

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.
This commit is contained in:
Lennart Poettering 2016-04-29 17:31:02 +02:00
parent 313fe66fbd
commit 934e749e18

View File

@ -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);