From 352ca662eb97c6bef90ecb99666d2615283198e3 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 24 Aug 2013 15:01:54 +0200 Subject: [PATCH 1/3] Add testcase for windows sid to test-dbus-daemon. --- dbus/dbus-sysdeps-win.c | 2 +- dbus/dbus-sysdeps-win.h | 1 + test/dbus-daemon.c | 29 +++++++++++++++++++++++++++-- 3 Dateien geändert, 29 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index efeb2a6..a63de7e 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -979,7 +979,7 @@ static BOOL is_winxp_sp3_or_lower() * @param process_id the process id for which the sid should be returned * @returns process sid */ -static dbus_bool_t +dbus_bool_t _dbus_getsid(char **sid, dbus_pid_t process_id) { HANDLE process_token = INVALID_HANDLE_VALUE; diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index 7cb1b6f..05d654e 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -88,6 +88,7 @@ dbus_bool_t _dbus_get_install_root(char *prefix, int len); void _dbus_threads_windows_init_global (void); void _dbus_threads_windows_ensure_ctor_linked (void); +dbus_bool_t _dbus_getsid(char **sid, dbus_pid_t process_id); #endif /** @} end of sysdeps-win.h */ diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index 69b6791..6d23245 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -34,6 +34,9 @@ #include #ifdef DBUS_WIN +#define DBUS_INSIDE_DBUS_H +#include + # include # include #else @@ -78,8 +81,12 @@ spawn_dbus_daemon (gchar *binary, gchar *argv[] = { binary, configuration, +#ifdef DBUS_WIN + "--print-address", /* stdout */ +#else "--nofork", "--print-address=1", /* stdout */ +#endif NULL }; @@ -401,6 +408,26 @@ test_creds (Fixture *f, g_assert_not_reached (); #endif } + else if (g_strcmp0 (name, "WindowsSID") == 0) + { +#ifdef G_OS_WIN32 + gchar *sid; + guint32 result; + char *self_sid; + + g_assert (!(seen & SEEN_WINDOWS_SID)); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==, + DBUS_TYPE_STRING); + dbus_message_iter_get_basic (&var_iter, &sid); + g_message ("%s of this process is %s", name, sid); + if (_dbus_getsid (&self_sid, 0)) + result = strcmp (self_sid, sid); + g_assert_cmpuint (result, ==, 0); + seen |= SEEN_WINDOWS_SID; +#else + g_assert_not_reached (); +#endif + } else if (g_strcmp0 (name, "ProcessID") == 0) { guint32 u32; @@ -429,9 +456,7 @@ test_creds (Fixture *f, #endif #ifdef G_OS_WIN32 - /* FIXME: when implemented: g_assert (seen & SEEN_WINDOWS_SID); - */ #endif } -- 1.7.10.4