Commit 398ef8ba authored by Lennart Poettering's avatar Lennart Poettering
Browse files

dbus: make errors reported via D-Bus more useful

parent 2105e76a
......@@ -311,7 +311,8 @@ EXTRA_DIST += \
src/initreq.h \
src/sd-daemon.h \
src/special.h \
src/dbus-common.h
src/dbus-common.h \
src/bus-errors.h
MANPAGES = \
man/systemd.1 \
......
......@@ -35,6 +35,7 @@
#include "load-dropin.h"
#include "unit-name.h"
#include "dbus-automount.h"
#include "bus-errors.h"
static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
[AUTOMOUNT_DEAD] = UNIT_INACTIVE,
......@@ -533,10 +534,13 @@ fail:
static void automount_enter_runnning(Automount *a) {
int r;
struct stat st;
DBusError error;
assert(a);
assert(a->mount);
dbus_error_init(&error);
mkdir_p(a->where, a->directory_mode);
/* Before we do anything, let's see if somebody is playing games with us? */
......@@ -547,8 +551,8 @@ static void automount_enter_runnning(Automount *a) {
if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id)
log_info("%s's automount point already active?", a->meta.id);
else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT(a->mount), JOB_REPLACE, true, NULL)) < 0) {
log_warning("%s failed to queue mount startup job: %s", a->meta.id, strerror(-r));
else if ((r = manager_add_job(a->meta.manager, JOB_START, UNIT(a->mount), JOB_REPLACE, true, &error, NULL)) < 0) {
log_warning("%s failed to queue mount startup job: %s", a->meta.id, bus_error(&error, r));
goto fail;
}
......@@ -557,6 +561,7 @@ static void automount_enter_runnning(Automount *a) {
fail:
automount_enter_dead(a, false);
dbus_error_free(&error);
}
static int automount_start(Unit *u) {
......
......@@ -25,6 +25,7 @@
#include "log.h"
#include "dbus-manager.h"
#include "strv.h"
#include "bus-errors.h"
#define BUS_MANAGER_INTERFACE \
" <interface name=\"org.freedesktop.systemd1.Manager\">\n" \
......@@ -254,8 +255,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if (!(u = manager_get_unit(m, name)))
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
if (!(u = manager_get_unit(m, name))) {
dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name);
return bus_send_error_reply(m, connection, message, &error, -ENOENT);
}
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -280,8 +283,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if ((r = manager_load_unit(m, name, NULL, &u)) < 0)
return bus_send_error_reply(m, connection, message, NULL, r);
if ((r = manager_load_unit(m, name, NULL, &error, &u)) < 0)
return bus_send_error_reply(m, connection, message, &error, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -316,8 +319,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if (!(j = manager_get_job(m, id)))
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
if (!(j = manager_get_job(m, id))) {
dbus_set_error(&error, BUS_ERROR_NO_SUCH_JOB, "Job %u does not exist.", (unsigned) id);
return bus_send_error_reply(m, connection, message, &error, -ENOENT);
}
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -496,8 +501,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Unsubscribe")) {
char *client;
if (!(client = set_remove(BUS_CONNECTION_SUBSCRIBED(m, connection), (char*) message_get_sender_with_fallback(message))))
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
if (!(client = set_remove(BUS_CONNECTION_SUBSCRIBED(m, connection), (char*) message_get_sender_with_fallback(message)))) {
dbus_set_error(&error, BUS_ERROR_NOT_SUBSCRIBED, "Client is not subscribed.");
return bus_send_error_reply(m, connection, message, &error, -ENOENT);
}
free(client);
......@@ -548,8 +555,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
if (name && name[0] == 0)
name = NULL;
if ((r = snapshot_create(m, name, cleanup, &s)) < 0)
return bus_send_error_reply(m, connection, message, NULL, r);
if ((r = snapshot_create(m, name, cleanup, &error, &s)) < 0)
return bus_send_error_reply(m, connection, message, &error, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -648,8 +655,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Exit")) {
if (m->running_as == MANAGER_SYSTEM)
return bus_send_error_reply(m, connection, message, NULL, -ENOTSUP);
if (m->running_as == MANAGER_SYSTEM) {
dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Exit is only supported for session managers.");
return bus_send_error_reply(m, connection, message, &error, -ENOTSUP);
}
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -720,17 +729,21 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
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_load_unit(m, name, NULL, &u)) < 0)
return bus_send_error_reply(m, connection, message, NULL, r);
if ((r = manager_load_unit(m, name, NULL, &error, &u)) < 0)
return bus_send_error_reply(m, connection, message, &error, 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 ((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 (!(j->bus_client = strdup(message_get_sender_with_fallback(message))))
goto oom;
......
......@@ -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;
......
......@@ -42,6 +42,7 @@
#include "dbus-swap.h"
#include "dbus-timer.h"
#include "dbus-path.h"
#include "bus-errors.h"
#define CONNECTIONS_MAX 52
......@@ -380,13 +381,13 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus
log_debug("Got D-Bus activation request for %s", name);
r = manager_load_unit(m, name, NULL, &u);
r = manager_load_unit(m, name, NULL, &error, &u);
if (r >= 0 && u->meta.only_by_dependency)
r = -EPERM;
if (r >= 0)
r = manager_add_job(m, JOB_START, u, JOB_REPLACE, true, NULL);
r = manager_add_job(m, JOB_START, u, JOB_REPLACE, true, &error, NULL);
if (r < 0) {
const char *id, *text;
......@@ -396,8 +397,8 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus
if (!(reply = dbus_message_new_signal("/org/freedesktop/systemd1", "org.freedesktop.systemd1.Activator", "ActivationFailure")))
goto oom;
id = error_to_dbus(r);
text = strerror(-r);
id = error.name ? error.name : error_to_dbus(r);
text = bus_error(&error, r);
if (!dbus_message_set_destination(reply, DBUS_SERVICE_DBUS) ||
!dbus_message_append_args(reply,
......@@ -1324,13 +1325,13 @@ static const char *error_to_dbus(int error) {
return DBUS_ERROR_FAILED;
}
DBusHandlerResult bus_send_error_reply(Manager *m, DBusConnection *c, DBusMessage *message, DBusError *bus_error, int error) {
DBusHandlerResult bus_send_error_reply(Manager *m, DBusConnection *c, DBusMessage *message, DBusError *berror, int error) {
DBusMessage *reply = NULL;
const char *name, *text;
if (bus_error && dbus_error_is_set(bus_error)) {
name = bus_error->name;
text = bus_error->message;
if (berror && dbus_error_is_set(berror)) {
name = berror->name;
text = berror->message;
} else {
name = error_to_dbus(error);
text = strerror(-error);
......@@ -1344,8 +1345,8 @@ DBusHandlerResult bus_send_error_reply(Manager *m, DBusConnection *c, DBusMessag
dbus_message_unref(reply);
if (bus_error)
dbus_error_free(bus_error);
if (berror)
dbus_error_free(berror);
return DBUS_HANDLER_RESULT_HANDLED;
......@@ -1353,8 +1354,8 @@ oom:
if (reply)
dbus_message_unref(reply);
if (bus_error)
dbus_error_free(bus_error);
if (berror)
dbus_error_free(berror);
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
......
......@@ -39,6 +39,7 @@
#include "securebits.h"
#include "missing.h"
#include "unit-name.h"
#include "bus-errors.h"
#define COMMENTS "#;\n"
......@@ -1057,14 +1058,23 @@ static int config_parse_timer_unit(
Timer *t = data;
int r;
DBusError error;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
dbus_error_init(&error);
if (endswith(rvalue, ".timer")) {
log_error("[%s:%u] Unit cannot be of type timer: %s", filename, line, rvalue);
return -EINVAL;
}
if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, &t->unit)) < 0) {
log_error("[%s:%u] Failed to load unit: %s", filename, line, rvalue);
if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, NULL, &t->unit)) < 0) {
log_error("[%s:%u] Failed to load unit %s: %s", filename, line, rvalue, bus_error(&error, r));
dbus_error_free(&error);
return r;
}
......@@ -1128,14 +1138,23 @@ static int config_parse_path_unit(
Path *t = data;
int r;
DBusError error;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
dbus_error_init(&error);
if (endswith(rvalue, ".path")) {
log_error("[%s:%u] Unit cannot be of type path: %s", filename, line, rvalue);
return -EINVAL;
}
if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, &t->unit)) < 0) {
log_error("[%s:%u] Failed to load unit: %s", filename, line, rvalue);
if ((r = manager_load_unit(t->meta.manager, rvalue, NULL, &error, &t->unit)) < 0) {
log_error("[%s:%u] Failed to load unit %s: %s", filename, line, rvalue, bus_error(&error, r));
dbus_error_free(&error);
return r;
}
......
......@@ -43,6 +43,7 @@
#include "fdset.h"
#include "special.h"
#include "conf-parser.h"
#include "bus-errors.h"
static enum {
ACTION_RUN,
......@@ -963,14 +964,20 @@ int main(int argc, char *argv[]) {
fclose(serialization);
serialization = NULL;
} else {
DBusError error;
dbus_error_init(&error);
log_debug("Activating default unit: %s", arg_default_unit);
if ((r = manager_load_unit(m, arg_default_unit, NULL, &target)) < 0) {
log_error("Failed to load default target: %s", strerror(-r));
if ((r = manager_load_unit(m, arg_default_unit, NULL, &error, &target)) < 0) {
log_error("Failed to load default target: %s", bus_error(&error, r));
dbus_error_free(&error);
log_info("Trying to load rescue target...");
if ((r = manager_load_unit(m, SPECIAL_RESCUE_TARGET, NULL, &target)) < 0) {
log_error("Failed to load rescue target: %s", strerror(-r));
if ((r = manager_load_unit(m, SPECIAL_RESCUE_TARGET, NULL, &error, &target)) < 0) {
log_error("Failed to load rescue target: %s", bus_error(&error, r));
dbus_error_free(&error);
goto finish;
}
}
......@@ -980,8 +987,9 @@ int main(int argc, char *argv[]) {
manager_dump_units(m, stdout, "\t");
}
if ((r = manager_add_job(m, JOB_START, target, JOB_REPLACE, false, &job)) < 0) {
log_error("Failed to start default target: %s", strerror(-r));
if ((r = manager_add_job(m, JOB_START, target, JOB_REPLACE, false, &error, &job)) < 0) {
log_error("Failed to start default target: %s", bus_error(&error, r));
dbus_error_free(&error);
goto finish;
}
......
......@@ -53,6 +53,7 @@
#include "missing.h"
#include "path-lookup.h"
#include "special.h"
#include "bus-errors.h"
/* As soon as 16 units are in our GC queue, make sure to run a gc sweep */
#define GC_QUEUE_ENTRIES_MAX 16
......@@ -697,7 +698,7 @@ static int delete_one_unmergeable_job(Manager *m, Job *j) {
return -EINVAL;
}
static int transaction_merge_jobs(Manager *m) {
static int transaction_merge_jobs(Manager *m, DBusError *e) {
Job *j;
Iterator i;
int r;
......@@ -726,6 +727,8 @@ static int transaction_merge_jobs(Manager *m) {
return -EAGAIN;
/* We couldn't merge anything. Failure */
dbus_set_error(e, BUS_ERROR_TRANSACTION_JOBS_CONFLICTING, "Transaction contains conflicting jobs '%s' and '%s' for %s. Probably contradicting requirement dependencies configured.",
job_type_to_string(t), job_type_to_string(k->type), k->unit->meta.id);
return r;
}
}
......@@ -812,7 +815,7 @@ static bool unit_matters_to_anchor(Unit *u, Job *j) {
return false;
}
static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned generation) {
static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned generation, DBusError *e) {
Iterator i;
Unit *u;
int r;
......@@ -863,6 +866,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
log_error("Unable to break cycle");
dbus_set_error(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC, "Transaction order is cyclic. See logs for details.");
return -ENOEXEC;
}
......@@ -887,7 +891,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
if (!(o = u->meta.job))
continue;
if ((r = transaction_verify_order_one(m, o, j, generation)) < 0)
if ((r = transaction_verify_order_one(m, o, j, generation, e)) < 0)
return r;
}
......@@ -898,7 +902,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
return 0;
}
static int transaction_verify_order(Manager *m, unsigned *generation) {
static int transaction_verify_order(Manager *m, unsigned *generation, DBusError *e) {
Job *j;
int r;
Iterator i;
......@@ -913,7 +917,7 @@ static int transaction_verify_order(Manager *m, unsigned *generation) {
g = (*generation)++;
HASHMAP_FOREACH(j, m->transaction_jobs, i)
if ((r = transaction_verify_order_one(m, j, NULL, g)) < 0)
if ((r = transaction_verify_order_one(m, j, NULL, g, e)) < 0)
return r;
return 0;
......@@ -945,7 +949,7 @@ static void transaction_collect_garbage(Manager *m) {
} while (again);
}
static int transaction_is_destructive(Manager *m) {
static int transaction_is_destructive(Manager *m, DBusError *e) {
Iterator i;
Job *j;
......@@ -962,8 +966,11 @@ static int transaction_is_destructive(Manager *m) {
if (j->unit->meta.job &&
j->unit->meta.job != j &&
!job_type_is_superset(j->type, j->unit->meta.job->type))
!job_type_is_superset(j->type, j->unit->meta.job->type)) {
dbus_set_error(e, BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE, "Transaction is destructive.");
return -EEXIST;
}
}
return 0;
......@@ -1080,7 +1087,7 @@ rollback:
return r;
}
static int transaction_activate(Manager *m, JobMode mode) {
static int transaction_activate(Manager *m, JobMode mode, DBusError *e) {
int r;
unsigned generation = 1;
......@@ -1107,11 +1114,11 @@ static int transaction_activate(Manager *m, JobMode mode) {
/* Fifth step: verify order makes sense and correct
* cycles if necessary and possible */
if ((r = transaction_verify_order(m, &generation)) >= 0)
if ((r = transaction_verify_order(m, &generation, e)) >= 0)
break;
if (r != -EAGAIN) {
log_warning("Requested transaction contains an unfixable cyclic ordering dependency: %s", strerror(-r));
log_warning("Requested transaction contains an unfixable cyclic ordering dependency: %s", bus_error(e, r));
goto rollback;
}
......@@ -1123,11 +1130,11 @@ static int transaction_activate(Manager *m, JobMode mode) {
/* Sixth step: let's drop unmergeable entries if
* necessary and possible, merge entries we can
* merge */
if ((r = transaction_merge_jobs(m)) >= 0)
if ((r = transaction_merge_jobs(m, e)) >= 0)
break;
if (r != -EAGAIN) {
log_warning("Requested transaction contains unmergable jobs: %s", strerror(-r));
log_warning("Requested transaction contains unmergable jobs: %s", bus_error(e, r));
goto rollback;
}
......@@ -1144,8 +1151,8 @@ static int transaction_activate(Manager *m, JobMode mode) {
/* Ninth step: check whether we can actually apply this */
if (mode == JOB_FAIL)
if ((r = transaction_is_destructive(m)) < 0) {
log_notice("Requested transaction contradicts existing jobs: %s", strerror(-r));
if ((r = transaction_is_destructive(m, e)) < 0) {
log_notice("Requested transaction contradicts existing jobs: %s", bus_error(e, r));
goto rollback;
}
......@@ -1253,6 +1260,7 @@ static int transaction_add_job_and_dependencies(
Job *by,
bool matters,
bool override,
DBusError *e,
Job **_ret) {
Job *ret;
Iterator i;
......@@ -1264,11 +1272,15 @@ static int transaction_add_job_and_dependencies(
assert(type < _JOB_TYPE_MAX);
assert(unit);
if (unit->meta.load_state != UNIT_LOADED)
if (unit->meta.load_state != UNIT_LOADED) {
dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s failed to load.", unit->meta.id);
return -EINVAL;
}
if (!unit_job_is_applicable(unit, type))
if (!unit_job_is_applicable(unit, type)) {
dbus_set_error(e, BUS_ERROR_JOB_TYPE_NOT_APPLICABLE, "Job type %s is not applicable for unit %s.", job_type_to_string(type), unit->meta.id);
return -EBADR;
}
/* First add the job. */
if (!(ret = transaction_add_one_job(m, type, unit, override, &is_new)))
......@@ -1282,33 +1294,33 @@ static int transaction_add_job_and_dependencies(
/* Finally, recursively add in all dependencies. */
if (type == JOB_START || type == JOB_RELOAD_OR_START) {
SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRES], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, true, override, NULL)) < 0 && r != -EBADR)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, true, override, e, NULL)) < 0 && r != -EBADR)
goto fail;
SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRES_OVERRIDABLE], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, !override, override, NULL)) < 0 && r != -EBADR)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, !override, override, e, NULL)) < 0 && r != -EBADR)
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, strerror(-r));
SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_WANTS], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, false, false, NULL)) < 0)
if ((r = transaction_add_job_and_dependencies(m, JOB_START, dep, ret, false, false, e, NULL)) < 0)
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, strerror(-r));
SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUISITE], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, true, override, NULL)) < 0 && r != -EBADR)
if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, true, override, e, NULL)) < 0 && r != -EBADR)
goto fail;
SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUISITE_OVERRIDABLE], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, !override, override, NULL)) < 0 && r != -EBADR)
if ((r = transaction_add_job_and_dependencies(m, JOB_VERIFY_ACTIVE, dep, ret, !override, override, e, NULL)) < 0 && r != -EBADR)
log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->meta.id, strerror(-r));
SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_CONFLICTS], i)
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, true, override, NULL)) < 0 && r != -EBADR)
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, dep, ret, true, override, e, NULL)) < 0 && r != -EBADR)
goto fail;
} else if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
SET_FOREACH(dep, ret->unit->meta.dependencies[UNIT_REQUIRED_BY], i)
if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, NULL)) < 0 && r != -EBADR)
if ((r = transaction_add_job_and_dependencies(m, type, dep, ret, true, override, e, NULL)) < 0 && r != -EBADR)
goto fail;
}
......@@ -1349,14 +1361,14 @@ static int transaction_add_isolate_jobs(Manager *m) {
if (hashmap_get(m->transaction_jobs, u))
continue;
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, u, NULL, true, false, NULL)) < 0)
if ((r = transaction_add_job_and_dependencies(m, JOB_STOP, u, NULL, true, false, NULL, NULL)) < 0)
log_warning("Cannot add isolate job for unit %s, ignoring: %s", u->meta.id, strerror(-r));
}
return 0;
}
int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool override, Job **_ret) {
int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool override, DBusError *e, Job **_ret) {
int r;
Job *ret;
......@@ -1365,12 +1377,14 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool ove
assert(unit);
assert(mode < _JOB_MODE_MAX);
if (mode == JOB_ISOLATE && type != JOB_START)
if (mode == JOB_ISOLATE && type != JOB_START) {
dbus_set_error(e, BUS_ERROR_INVALID_JOB_MODE