From 15bf0197c8811a6d13a212b8bed79125211dd9da Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 11 Feb 2015 13:19:43 +0000 Subject: [PATCH 4/5] Add regression test for LinuxSecurityLabel credential Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89041 --- test/dbus-daemon.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index 4516091..26786fc 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -28,6 +28,8 @@ #include "test-utils-glib.h" +#include + #ifdef DBUS_UNIX # include # include @@ -305,7 +307,8 @@ test_creds (Fixture *f, enum { SEEN_UNIX_USER = 1, SEEN_PID = 2, - SEEN_WINDOWS_SID = 4 + SEEN_WINDOWS_SID = 4, + SEEN_LINUX_SECURITY_LABEL = 8 } seen = 0; if (m == NULL) @@ -411,6 +414,27 @@ test_creds (Fixture *f, #endif seen |= SEEN_PID; } + else if (g_strcmp0 (name, "LinuxSecurityLabel") == 0) + { +#ifdef __linux__ + gchar *label; + int len; + DBusMessageIter ay_iter; + + g_assert (!(seen & SEEN_LINUX_SECURITY_LABEL)); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==, + DBUS_TYPE_ARRAY); + dbus_message_iter_recurse (&var_iter, &ay_iter); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&ay_iter), ==, + DBUS_TYPE_BYTE); + dbus_message_iter_get_fixed_array (&ay_iter, &label, &len); + g_message ("%s of this process is %s", name, label); + g_assert_cmpuint (strlen (label) + 1, ==, len); + seen |= SEEN_LINUX_SECURITY_LABEL; +#else + g_assert_not_reached (); +#endif + } dbus_message_iter_next (&arr_iter); } -- 2.1.4