diff --git a/src/core/manager.c b/src/core/manager.c index cff38e28de..8b818bec91 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2319,7 +2319,10 @@ int manager_load_unit_from_dbus_path(Manager *m, const char *s, sd_bus_error *e, return sd_bus_error_setf(e, BUS_ERROR_NO_UNIT_FOR_INVOCATION_ID, "No unit with the specified invocation ID " SD_ID128_FORMAT_STR " known.", SD_ID128_FORMAT_VAL(invocation_id)); } - /* If this didn't work, we use the suffix as unit name. */ + /* If this didn't work, we check if this is a unit name */ + if (!unit_name_is_valid(n, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE)) + return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is neither a valid invocation ID nor unit name.", n); + r = manager_load_unit(m, n, NULL, e, &u); if (r < 0) return r; diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index b6f5afe1b3..98911d5203 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -974,8 +974,10 @@ static int process_introspect( /* Nothing?, let's see if we exist at all, and if not * refuse to do anything */ r = bus_node_exists(bus, n, m->path, require_fallback); - if (r <= 0) + if (r <= 0) { + r = bus_maybe_reply_error(m, r, &error); goto finish; + } if (bus->nodes_modified) { r = 0; goto finish; @@ -1199,7 +1201,7 @@ static int process_get_managed_objects( r = get_child_nodes(bus, m->path, n, CHILDREN_RECURSIVE, &s, &error); if (r < 0) - return r; + return bus_maybe_reply_error(m, r, &error); if (bus->nodes_modified) return 0; @@ -1214,7 +1216,7 @@ static int process_get_managed_objects( SET_FOREACH(path, s, i) { r = object_manager_serialize_path_and_fallbacks(bus, reply, path, &error); if (r < 0) - return r; + return bus_maybe_reply_error(m, r, &error); if (bus->nodes_modified) return 0; @@ -1344,7 +1346,7 @@ static int object_find_and_run( if (!*found_object) { r = bus_node_exists(bus, n, m->path, require_fallback); if (r < 0) - return r; + return bus_maybe_reply_error(m, r, NULL); if (bus->nodes_modified) return 0; if (r > 0)