From e0e395994fef65c8d31147b6d92feaa47a4f776d Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 6 Aug 2014 17:01:36 +0100 Subject: [PATCH 1/3] config: add new limit: max_connections_per_process dbus-daemon already has the following limits: - max_completed_connections: (default|system bus)=2048 (session bus)=100000 - max_connections_per_user: (default|system bus)=256 (session bus)=100000 This patch adds a new limit: - max_connections_per_process: (default|system bus)=8 (session bus)=8 Most applications should have only one connection to the bus. But sometimes, a process could legitimately create a few connections to the bus: it happens in an applications with plugins written with different dbus bindings such as libdbus and Qt D-Bus linked in the same process. But there are no good reasons for a process to have plenty of connections. https://bugs.freedesktop.org/show_bug.cgi?id=82346 --- bus/bus.c | 6 ++++++ bus/bus.h | 2 ++ bus/config-parser.c | 8 ++++++++ bus/session.conf.in | 1 + doc/dbus-daemon.1.xml.in | 2 ++ 5 files changed, 19 insertions(+) diff --git a/bus/bus.c b/bus/bus.c index a514e31..edce063 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -1255,6 +1255,12 @@ bus_context_get_max_connections_per_user (BusContext *context) } int +bus_context_get_max_connections_per_process (BusContext *context) +{ + return context->limits.max_connections_per_process; +} + +int bus_context_get_max_pending_activations (BusContext *context) { return context->limits.max_pending_activations; diff --git a/bus/bus.h b/bus/bus.h index 3597884..2c4cec3 100644 --- a/bus/bus.h +++ b/bus/bus.h @@ -57,6 +57,7 @@ typedef struct int max_completed_connections; /**< Max number of authorized connections */ int max_incomplete_connections; /**< Max number of incomplete connections */ int max_connections_per_user; /**< Max number of connections auth'd as same user */ + int max_connections_per_process; /**< Max number of connections per process */ int max_pending_activations; /**< Max number of pending activations for the entire bus */ int max_services_per_connection; /**< Max number of owned services for a single connection */ int max_match_rules_per_connection; /**< Max number of match rules for a single connection */ @@ -109,6 +110,7 @@ int bus_context_get_auth_timeout (BusContext int bus_context_get_max_completed_connections (BusContext *context); int bus_context_get_max_incomplete_connections (BusContext *context); int bus_context_get_max_connections_per_user (BusContext *context); +int bus_context_get_max_connections_per_process (BusContext *context); int bus_context_get_max_pending_activations (BusContext *context); int bus_context_get_max_services_per_connection (BusContext *context); int bus_context_get_max_match_rules_per_connection (BusContext *context); diff --git a/bus/config-parser.c b/bus/config-parser.c index a6a8e1c..781d857 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -442,6 +442,7 @@ bus_config_parser_new (const DBusString *basedir, parser->limits.max_incomplete_connections = 64; parser->limits.max_connections_per_user = 256; + parser->limits.max_connections_per_process = 8; /* Note that max_completed_connections / max_connections_per_user * is the number of users that would have to work together to @@ -1926,6 +1927,12 @@ set_limit (BusConfigParser *parser, must_be_int = TRUE; parser->limits.max_connections_per_user = value; } + else if (strcmp (name, "max_connections_per_process") == 0) + { + must_be_positive = TRUE; + must_be_int = TRUE; + parser->limits.max_connections_per_process = value; + } else if (strcmp (name, "max_pending_service_starts") == 0) { must_be_positive = TRUE; @@ -3111,6 +3118,7 @@ limits_equal (const BusLimits *a, || a->max_completed_connections == b->max_completed_connections || a->max_incomplete_connections == b->max_incomplete_connections || a->max_connections_per_user == b->max_connections_per_user + || a->max_connections_per_process == b->max_connections_per_process || a->max_pending_activations == b->max_pending_activations || a->max_services_per_connection == b->max_services_per_connection || a->max_match_rules_per_connection == b->max_match_rules_per_connection diff --git a/bus/session.conf.in b/bus/session.conf.in index 74d9d1f..cd799f7 100644 --- a/bus/session.conf.in +++ b/bus/session.conf.in @@ -55,6 +55,7 @@ 100000 10000 100000 + 8 10000 50000 50000 diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in index 7b7f4a1..af8ba9f 100644 --- a/doc/dbus-daemon.1.xml.in +++ b/doc/dbus-daemon.1.xml.in @@ -533,6 +533,8 @@ Available limit names are: connections "max_connections_per_user" : max number of completed connections from the same user + "max_connections_per_process": max number of completed connections from + the same process "max_pending_service_starts" : max number of service launches in progress at the same time "max_names_per_connection" : max number of names a single -- 1.8.5.3