summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-17 14:03:13 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-17 17:32:49 +0100
commit06cc6afa047deb56318ce424804bb04c4f690b30 (patch)
tree08028ebebfa39fb6cf8fc5d94505e95c87f36d08 /src/core
parentd1fcdcd87a4f0ffebfc98f404a7eae477dc3fd86 (diff)
core: generate nice error messages for auxiliary transient units, too
Let's move the validation checks into the loop that sets up the main and auxiliary transient units, so that we can generate pretty error messages for all units a transient unit transaction generates, not just for the main unit.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dbus-manager.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 67e4e8b218..51ee5817eb 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -644,6 +644,7 @@ static int transient_unit_from_message(
Unit **unit,
sd_bus_error *error) {
+ UnitType t;
Unit *u;
int r;
@@ -651,6 +652,13 @@ static int transient_unit_from_message(
assert(message);
assert(name);
+ t = unit_name_to_type(name);
+ if (t < 0)
+ return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit name or type.");
+
+ if (!unit_vtable[t]->can_transient)
+ return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit type %s does not support transient units.", unit_type_to_string(t));
+
r = manager_load_unit(m, name, NULL, error, &u);
if (r < 0)
return r;
@@ -735,7 +743,6 @@ static int method_start_transient_unit(sd_bus_message *message, void *userdata,
const char *name, *smode;
Manager *m = userdata;
JobMode mode;
- UnitType t;
Unit *u;
int r;
@@ -750,13 +757,6 @@ static int method_start_transient_unit(sd_bus_message *message, void *userdata,
if (r < 0)
return r;
- t = unit_name_to_type(name);
- if (t < 0)
- return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit type.");
-
- if (!unit_vtable[t]->can_transient)
- return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unit type %s does not support transient units.", unit_type_to_string(t));
-
mode = job_mode_from_string(smode);
if (mode < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Job mode %s is invalid.", smode);