]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: return a friendlier error for a dbus path referring to a non-existent unit 6164/head
authorLennart Poettering <lennart@poettering.net>
Wed, 21 Jun 2017 18:45:23 +0000 (20:45 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 23 Jun 2017 00:54:54 +0000 (20:54 -0400)
See: #6059

src/core/manager.c

index cff38e28deaf4479761532def049f10ed7579b0e..8b818bec91aa98dc6832d811eace3b445ced8d52 100644 (file)
@@ -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;