X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fdbus.c;h=48051f25fb76f79ebfa93def6153f371d0f346c7;hb=550c4dcc4184d5c4d55d3786b66797e5fb99c30a;hp=8c969eab630c6879968a38b3e5a36c19d6cab475;hpb=8f6df3fa98ee74eaf5c34dddd272d2e3c10c3c27;p=elogind.git diff --git a/src/dbus.c b/src/dbus.c index 8c969eab6..48051f25f 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -401,7 +401,7 @@ static DBusHandlerResult api_bus_message_filter(DBusConnection *connection, DBus if (r < 0) { const char *id, *text; - log_warning("D-Bus activation failed for %s: %s", name, strerror(-r)); + 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; @@ -464,7 +464,9 @@ static DBusHandlerResult system_bus_message_filter(DBusConnection *connection, D log_debug("System D-Bus connection terminated."); bus_done_system(m); - } else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Agent", "Released")) { + } else if (m->running_as != MANAGER_SYSTEM && + dbus_message_is_signal(message, "org.freedesktop.systemd1.Agent", "Released")) { + const char *cgroup; if (!dbus_message_get_args(message, &error, @@ -498,7 +500,9 @@ static DBusHandlerResult private_bus_message_filter(DBusConnection *connection, if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) shutdown_connection(m, connection); - else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Agent", "Released")) { + else if (m->running_as == MANAGER_SYSTEM && + dbus_message_is_signal(message, "org.freedesktop.systemd1.Agent", "Released")) { + const char *cgroup; if (!dbus_message_get_args(message, &error, @@ -507,6 +511,12 @@ static DBusHandlerResult private_bus_message_filter(DBusConnection *connection, log_error("Failed to parse Released message: %s", error.message); else cgroup_notify_empty(m, cgroup); + + /* Forward the message to the system bus, so that user + * instances are notified as well */ + + if (m->system_bus) + dbus_connection_send(m->system_bus, message, NULL); } dbus_error_free(&error); @@ -808,17 +818,19 @@ static int bus_init_system(Manager *m) { goto fail; } - dbus_bus_add_match(m->system_bus, - "type='signal'," - "interface='org.freedesktop.systemd1.Agent'," - "member='Released'," - "path='/org/freedesktop/systemd1/agent'", - &error); - - if (dbus_error_is_set(&error)) { - log_error("Failed to register match: %s", error.message); - r = -EIO; - goto fail; + if (m->running_as != MANAGER_SYSTEM) { + dbus_bus_add_match(m->system_bus, + "type='signal'," + "interface='org.freedesktop.systemd1.Agent'," + "member='Released'," + "path='/org/freedesktop/systemd1/agent'", + &error); + + if (dbus_error_is_set(&error)) { + log_error("Failed to register match: %s", error.message); + r = -EIO; + goto fail; + } } if (m->api_bus != m->system_bus) { @@ -852,7 +864,7 @@ static int bus_init_api(Manager *m) { if (m->running_as == MANAGER_SYSTEM && m->system_bus) m->api_bus = m->system_bus; else { - if (!(m->api_bus = dbus_bus_get_private(m->running_as == MANAGER_SESSION ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error))) { + if (!(m->api_bus = dbus_bus_get_private(m->running_as == MANAGER_USER ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error))) { log_debug("Failed to get API D-Bus connection, retrying later: %s", error.message); r = 0; goto fail; @@ -986,7 +998,7 @@ int bus_init(Manager *m) { } if (m->subscribed_data_slot < 0) - if (!dbus_pending_call_allocate_data_slot(&m->subscribed_data_slot)) { + if (!dbus_connection_allocate_data_slot(&m->subscribed_data_slot)) { log_error("Not enough memory"); return -ENOMEM; } @@ -1098,7 +1110,7 @@ void bus_done(Manager *m) { dbus_pending_call_free_data_slot(&m->name_data_slot); if (m->subscribed_data_slot >= 0) - dbus_pending_call_free_data_slot(&m->subscribed_data_slot); + dbus_connection_free_data_slot(&m->subscribed_data_slot); } static void query_pid_pending_cb(DBusPendingCall *pending, void *userdata) {