X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fdbus.c;h=ae259c37d646f8f9e0c1aadc6bab59cc941b414d;hb=f5b51ea7fcb0b6380c3ceb4d4f3f22f647c6fd32;hp=e7cf93dc6c3eecb6fc0b666b7a24cbb3d8b50b58;hpb=1d22e9068c52c1cf935bcdff70b9b9654e3c939e;p=elogind.git diff --git a/src/core/dbus.c b/src/core/dbus.c index e7cf93dc6..ae259c37d 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -20,7 +20,6 @@ ***/ #include -#include #include #include @@ -44,7 +43,7 @@ #include "bus-internal.h" #include "selinux-access.h" -#define CONNECTIONS_MAX 512 +#define CONNECTIONS_MAX 4096 static void destroy_bus(Manager *m, sd_bus **bus); @@ -89,15 +88,19 @@ static int signal_agent_released(sd_bus *bus, sd_bus_message *message, void *use manager_notify_cgroup_empty(m, cgroup); - if (m->running_as == SYSTEMD_SYSTEM && m->system_bus) { - /* If we are running as system manager, forward the - * message to the system bus */ + /* only forward to system bus if running as system instance */ + if (m->running_as != SYSTEMD_SYSTEM || !m->system_bus) + return 0; - r = sd_bus_send(m->system_bus, message, NULL); - if (r < 0) - log_warning_errno(r, "Failed to forward Released message: %m"); - } + r = sd_bus_message_rewind(message, 1); + if (r < 0) + goto exit; + + r = sd_bus_send(m->system_bus, message, NULL); +exit: + if (r < 0) + log_warning_errno(r, "Failed to forward Released message: %m"); return 0; } @@ -849,22 +852,19 @@ static int bus_setup_system(Manager *m, sd_bus *bus) { assert(m); assert(bus); - if (m->running_as == SYSTEMD_SYSTEM) - return 0; - - /* If we are a user instance we get the Released message via - * the system bus */ - r = sd_bus_add_match( - bus, - NULL, - "type='signal'," - "interface='org.freedesktop.systemd1.Agent'," - "member='Released'," - "path='/org/freedesktop/systemd1/agent'", - signal_agent_released, m); - - if (r < 0) - log_warning_errno(r, "Failed to register Released match on system bus: %m"); + /* On kdbus or if we are a user instance we get the Released message via the system bus */ + if (m->running_as == SYSTEMD_USER || m->kdbus_fd >= 0) { + r = sd_bus_add_match( + bus, + NULL, + "type='signal'," + "interface='org.freedesktop.systemd1.Agent'," + "member='Released'," + "path='/org/freedesktop/systemd1/agent'", + signal_agent_released, m); + if (r < 0) + log_warning_errno(r, "Failed to register Released match on system bus: %m"); + } log_debug("Successfully connected to system bus."); return 0;