[glib] Check that credentials pass through D-Bus on supported platforms



commit 2fe36a22388216a04dfd74a59a72d8636c1098e4
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Thu Nov 8 14:09:23 2012 +0000

    Check that credentials pass through D-Bus on supported platforms
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=687920

 gio/tests/gdbus-peer.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index cc32261..799c673 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -45,6 +45,13 @@
 #include <errno.h>
 #endif
 
+#if (defined(__linux__) || \
+  defined(__FreeBSD__) || \
+  defined(__FreeBSD_kernel__) || \
+  defined(__OpenBSD__))
+#define SHOULD_HAVE_CREDENTIALS_PASSING
+#endif
+
 #include "gdbus-tests.h"
 
 #include "gdbus-example-objectmanager-generated.h"
@@ -303,6 +310,20 @@ on_new_connection (GDBusServer *server,
 
   g_ptr_array_add (data->current_connections, g_object_ref (connection));
 
+#ifdef SHOULD_HAVE_CREDENTIALS_PASSING
+    {
+      GCredentials *credentials;
+
+      credentials = g_dbus_connection_get_peer_credentials (connection);
+
+      g_assert (credentials != NULL);
+      g_assert_cmpuint (g_credentials_get_unix_user (credentials, NULL), ==,
+                        getuid ());
+      g_assert_cmpuint (g_credentials_get_unix_pid (credentials, NULL), ==,
+                        getpid ());
+    }
+#endif
+
   /* export object on the newly established connection */
   error = NULL;
   reg_id = g_dbus_connection_register_object (connection,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]