X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fdbus-unit.c;h=840eaa571fe4e27cd0ebb6ed3d6e25f952e1d3e7;hb=71a6f7538199f571b92e0c9fbb5819f8ce0e0d20;hp=85125c96337d4933b7c5a9be1433a7e984adf7e0;hpb=46d95c0fe087a9a4475cae5430e9b33f6c46ff25;p=elogind.git diff --git a/src/dbus-unit.c b/src/dbus-unit.c index 85125c963..840eaa571 100644 --- a/src/dbus-unit.c +++ b/src/dbus-unit.c @@ -24,6 +24,7 @@ #include "dbus.h" #include "log.h" #include "dbus-unit.h" +#include "bus-errors.h" const char bus_unit_interface[] = BUS_UNIT_INTERFACE; @@ -285,8 +286,10 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn Job *j; int r; - if (job_type == JOB_START && u->meta.only_by_dependency) - return bus_send_error_reply(m, connection, message, NULL, -EPERM); + if (job_type == JOB_START && u->meta.only_by_dependency) { + dbus_set_error(&error, BUS_ERROR_ONLY_BY_DEPENDENCY, "Unit may be activated by dependency only."); + return bus_send_error_reply(m, connection, message, &error, -EPERM); + } if (!dbus_message_get_args( message, @@ -295,11 +298,13 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn DBUS_TYPE_INVALID)) return bus_send_error_reply(m, connection, message, &error, -EINVAL); - if ((mode = job_mode_from_string(smode)) == _JOB_MODE_INVALID) - return bus_send_error_reply(m, connection, message, NULL, -EINVAL); + if ((mode = job_mode_from_string(smode)) == _JOB_MODE_INVALID) { + dbus_set_error(&error, BUS_ERROR_INVALID_JOB_MODE, "Job mode %s is invalid.", smode); + return bus_send_error_reply(m, connection, message, &error, -EINVAL); + } - if ((r = manager_add_job(m, job_type, u, mode, true, &j)) < 0) - return bus_send_error_reply(m, connection, message, NULL, r); + if ((r = manager_add_job(m, job_type, u, mode, true, &error, &j)) < 0) + return bus_send_error_reply(m, connection, message, &error, r); if (!(reply = dbus_message_new_method_return(message))) goto oom;