summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2016-07-01 13:17:23 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2016-07-01 13:57:56 +0100
commit88d28d67fd21643fd5c1aeb382882c6e39e5a678 (patch)
treec669c2c6a5afb44e5ad596aecb3efddd223bf13b
parent0d86e8a2e806de7b4fc5c05b9e7d96dda8e9620e (diff)
dbus-daemon test: exercise max_names_per_connection limitlog-exceeded-limits-80559
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=86442 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--test/Makefile.am1
-rw-r--r--test/data/valid-config-files/max-names-per-connection.conf.in18
-rw-r--r--test/dbus-daemon.c47
3 files changed, 66 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 616968b3..e344e547 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -314,6 +314,7 @@ in_data = \
data/valid-config-files/max-completed-connections.conf.in \
data/valid-config-files/max-connections-per-user.conf.in \
data/valid-config-files/max-match-rules-per-connection.conf.in \
+ data/valid-config-files/max-names-per-connection.conf.in \
data/valid-config-files/max-replies-per-connection.conf.in \
data/valid-config-files/multi-user.conf.in \
data/valid-config-files/systemd-activation.conf.in \
diff --git a/test/data/valid-config-files/max-names-per-connection.conf.in b/test/data/valid-config-files/max-names-per-connection.conf.in
new file mode 100644
index 00000000..186ed7b7
--- /dev/null
+++ b/test/data/valid-config-files/max-names-per-connection.conf.in
@@ -0,0 +1,18 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <!-- Our well-known bus type, don't change this -->
+ <type>session</type>
+ <listen>@TEST_LISTEN@</listen>
+
+ <policy context="default">
+ <!-- Allow everything to be sent -->
+ <allow send_destination="*" eavesdrop="true"/>
+ <!-- Allow everything to be received -->
+ <allow eavesdrop="true"/>
+ <!-- Allow anyone to own anything -->
+ <allow own="*"/>
+ </policy>
+
+ <limit name="max_names_per_connection">4</limit>
+</busconfig>
diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c
index 9fdfe773..0ca6574b 100644
--- a/test/dbus-daemon.c
+++ b/test/dbus-daemon.c
@@ -875,6 +875,45 @@ test_max_match_rules_per_connection (Fixture *f,
}
static void
+test_max_names_per_connection (Fixture *f,
+ gconstpointer context)
+{
+ DBusError error = DBUS_ERROR_INIT;
+ int ret;
+
+ if (f->skip)
+ return;
+
+ /* The limit in the configuration file is set to 4, but we only own 3
+ * names here - remember that the unique name is a name too. */
+
+ ret = dbus_bus_request_name (f->left_conn, "com.example.C1", 0, &error);
+ test_assert_no_error (&error);
+ g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
+
+ ret = dbus_bus_request_name (f->left_conn, "com.example.C2", 0, &error);
+ test_assert_no_error (&error);
+ g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
+
+ ret = dbus_bus_request_name (f->left_conn, "com.example.C3", 0, &error);
+ test_assert_no_error (&error);
+ g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
+
+ ret = dbus_bus_request_name (f->left_conn, "com.example.C4", 0, &error);
+ g_assert_cmpstr (error.name, ==, DBUS_ERROR_LIMITS_EXCEEDED);
+ dbus_error_free (&error);
+ g_assert_cmpint (ret, ==, -1);
+
+ ret = dbus_bus_release_name (f->left_conn, "com.example.C3", &error);
+ test_assert_no_error (&error);
+ g_assert_cmpint (ret, ==, DBUS_RELEASE_NAME_REPLY_RELEASED);
+
+ ret = dbus_bus_request_name (f->left_conn, "com.example.C4", 0, &error);
+ test_assert_no_error (&error);
+ g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
+}
+
+static void
teardown (Fixture *f,
gconstpointer context G_GNUC_UNUSED)
{
@@ -978,6 +1017,11 @@ static Config max_match_rules_per_connection_config = {
SPECIFY_ADDRESS
};
+static Config max_names_per_connection_config = {
+ NULL, 1, "valid-config-files/max-names-per-connection.conf",
+ SPECIFY_ADDRESS
+};
+
int
main (int argc,
char **argv)
@@ -1007,6 +1051,9 @@ main (int argc,
g_test_add ("/limits/max-match-rules-per-connection", Fixture,
&max_match_rules_per_connection_config,
setup, test_max_match_rules_per_connection, teardown);
+ g_test_add ("/limits/max-names-per-connection", Fixture,
+ &max_names_per_connection_config,
+ setup, test_max_names_per_connection, teardown);
#ifdef DBUS_UNIX
/* We can't test this in loopback.c with the rest of unix:runtime=yes,
* because dbus_bus_get[_private] is the only way to use the default,