- dbus_error_init(&error);
-
- if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL ||
- dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_SIGNAL)
- log_debug("Got D-Bus request: %s.%s() on %s",
- dbus_message_get_interface(message),
- dbus_message_get_member(message),
- dbus_message_get_path(message));
-
- if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
- log_debug("API D-Bus connection terminated.");
- bus_done_api(m);
-
- } else if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
- const char *name, *old_owner, *new_owner;
-
- if (!dbus_message_get_args(message, &error,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &old_owner,
- DBUS_TYPE_STRING, &new_owner,
- DBUS_TYPE_INVALID))
- log_error("Failed to parse NameOwnerChanged message: %s", bus_error_message(&error));
- else {
- if (set_remove(BUS_CONNECTION_SUBSCRIBED(m, connection), (char*) name))
- log_debug("Subscription client vanished: %s (left: %u)", name, set_size(BUS_CONNECTION_SUBSCRIBED(m, connection)));
-
- if (old_owner[0] == 0)
- old_owner = NULL;
-
- if (new_owner[0] == 0)
- new_owner = NULL;
-
- manager_dispatch_bus_name_owner_changed(m, name, old_owner, new_owner);
- }
- } else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Activator", "ActivationRequest")) {
- const char *name;
-
- if (!dbus_message_get_args(message, &error,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_INVALID))
- log_error("Failed to parse ActivationRequest message: %s", bus_error_message(&error));
- else {
- int r;
- Unit *u;
-
- log_debug("Got D-Bus activation request for %s", name);
-
- if (manager_unit_pending_inactive(m, SPECIAL_DBUS_SERVICE) ||
- manager_unit_pending_inactive(m, SPECIAL_DBUS_SOCKET)) {
- r = -EADDRNOTAVAIL;
- dbus_set_error(&error, BUS_ERROR_SHUTTING_DOWN, "Refusing activation, D-Bus is shutting down.");
- } else {
- r = manager_load_unit(m, name, NULL, &error, &u);
-
- if (r >= 0 && u->refuse_manual_start)
- r = -EPERM;
-
- if (r >= 0)
- r = manager_add_job(m, JOB_START, u, JOB_REPLACE, true, &error, NULL);
- }
-
- if (r < 0) {
- const char *id, *text;
-
- log_debug("D-Bus activation failed for %s: %s", name, strerror(-r));
-
- if (!(reply = dbus_message_new_signal("/org/freedesktop/systemd1", "org.freedesktop.systemd1.Activator", "ActivationFailure")))
- goto oom;
-
- id = error.name ? error.name : bus_errno_to_dbus(r);
- text = bus_error(&error, r);
-
- if (!dbus_message_set_destination(reply, DBUS_SERVICE_DBUS) ||
- !dbus_message_append_args(reply,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &id,
- DBUS_TYPE_STRING, &text,
- DBUS_TYPE_INVALID))
- goto oom;
- }