summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-05-31 18:00:40 +0100
committerSimon McVittie <smcv@collabora.com>2017-06-02 10:38:30 +0100
commit36893e76c43c2e9b5283e8dce787afd4bfbd4ffb (patch)
tree9779f44d894620adb942c8d64b531503e5124c36 /test
parent520aa044643d3e9fe9b35d6aa976197cc690544f (diff)
downloaddbus-36893e76c43c2e9b5283e8dce787afd4bfbd4ffb.tar.gz
test/monitor: Assert that BecomeMonitor() on wrong object path fails
Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101256
Diffstat (limited to 'test')
-rw-r--r--test/monitor.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/monitor.c b/test/monitor.c
index 0402d4a8..71ae2ae8 100644
--- a/test/monitor.c
+++ b/test/monitor.c
@@ -601,6 +601,49 @@ test_invalid (Fixture *f,
g_assert_cmpstr (dbus_message_get_error_name (m), ==,
DBUS_ERROR_INVALID_ARGS);
+ /* Try to become a monitor but use the wrong object path - not allowed
+ * (security hardening against inappropriate XML policy rules) */
+
+ dbus_pending_call_unref (pc);
+ dbus_message_unref (m);
+
+ m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
+ "/", DBUS_INTERFACE_MONITORING, "BecomeMonitor");
+
+ if (m == NULL)
+ g_error ("OOM");
+
+ dbus_message_iter_init_append (m, &appender);
+
+ if (!dbus_message_iter_open_container (&appender, DBUS_TYPE_ARRAY, "s",
+ &array_appender))
+ g_error ("OOM");
+
+ if (!dbus_message_iter_close_container (&appender, &array_appender) ||
+ !dbus_message_iter_append_basic (&appender, DBUS_TYPE_UINT32, &zero))
+ g_error ("OOM");
+
+ if (!dbus_connection_send_with_reply (f->monitor, m, &pc,
+ DBUS_TIMEOUT_USE_DEFAULT) ||
+ pc == NULL)
+ g_error ("OOM");
+
+ dbus_message_unref (m);
+ m = NULL;
+
+ if (dbus_pending_call_get_completed (pc))
+ test_pending_call_store_reply (pc, &m);
+ else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
+ &m, NULL))
+ g_error ("OOM");
+
+ while (m == NULL)
+ test_main_context_iterate (f->ctx, TRUE);
+
+ g_assert_cmpint (dbus_message_get_type (m), ==, DBUS_MESSAGE_TYPE_ERROR);
+ g_assert_cmpstr (dbus_message_get_error_name (m), ==,
+ DBUS_ERROR_ACCESS_DENIED);
+
/* Try to become a monitor but specify a bad match rule -
* also not allowed */