diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 73f739b12dcf6..20156c58f59fe 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -957,7 +957,7 @@ static int transient_unit_from_message( if (!unit_is_pristine(u)) return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, - "Unit %s already exists.", name); + "Unit %s was already loaded or has a fragment file.", name); /* OK, the unit failed to load and is unreferenced, now let's * fill in the transient data instead */ diff --git a/src/core/unit.c b/src/core/unit.c index 5016114cb470b..d0f71886132f5 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4844,16 +4844,18 @@ int unit_fail_if_noncanonical(Unit *u, const char* where) { bool unit_is_pristine(Unit *u) { assert(u); - /* Check if the unit already exists or is already around, - * in a number of different ways. Note that to cater for unit - * types such as slice, we are generally fine with units that - * are marked UNIT_LOADED even though nothing was actually - * loaded, as those unit types don't require a file on disk. */ + /* Check if the unit already exists or is already around, in a number of different ways. Note that to + * cater for unit types such as slice, we are generally fine with units that are marked UNIT_LOADED + * even though nothing was actually loaded, as those unit types don't require a file on disk. + * + * Note that we don't check for drop-ins here, because we allow drop-ins for transient units + * identically to non-transient units, both unit-specific and hierarchical. E.g. for a-b-c.service: + * service.d/….conf, a-.service.d/….conf, a-b-.service.d/….conf, a-b-c.service.d/….conf. + */ return IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_LOADED) && !u->fragment_path && !u->source_path && - strv_isempty(u->dropin_paths) && !u->job && !u->merged_into; }