Add test for windows sid.
authorRalf Habacker <ralf.habacker@freenet.de>
Tue, 10 Feb 2015 14:41:52 +0000 (15:41 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 11 Feb 2015 11:57:46 +0000 (11:57 +0000)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54445
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
dbus/dbus-sysdeps-win.c
dbus/dbus-sysdeps-win.h
test/dbus-daemon.c

index dbd9043d06d5e95c1259f5fba4bc34dce2a084d1..526db8e883566296b15b42a8429c68e8a96c7115 100644 (file)
@@ -984,7 +984,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;
index 02e7a83fc5585fd902ac46aa5d7ef0cfea96f773..3efdf72ee20999c5182350da37dc8ff68d667106 100644 (file)
@@ -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 */
index 6b0e9b8a98521b4580a8766420e3609eb39ce0ad..451609100488ba3f01da19205057a8756b099c4a 100644 (file)
@@ -369,6 +369,28 @@ test_creds (Fixture *f,
           seen |= SEEN_UNIX_USER;
 #else
           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))
+            {
+              g_assert_cmpstr (self_sid, ==, sid);
+              LocalFree(self_sid);
+            }
+          seen |= SEEN_WINDOWS_SID;
+#else
+          g_assert_not_reached ();
 #endif
         }
       else if (g_strcmp0 (name, "ProcessID") == 0)
@@ -402,9 +424,7 @@ test_creds (Fixture *f,
 #endif
 
 #ifdef G_OS_WIN32
-  /* FIXME: when implemented:
   g_assert (seen & SEEN_WINDOWS_SID);
-   */
 #endif
 }