mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-03 16:03:40 +02:00
gio: add G_CREDENTIALS_TYPE_WIN32_PID
Credentials are often used to check peer processes details. With AF_UNIX sockets on Windows, SIO_AF_UNIX_GETPEERPID can be used to retrive the peer PID. We will probably introduce more advanced mechanisms later on, though, but I am not a Windows API expert. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
@@ -25,6 +25,28 @@
|
||||
#include <gio/gio.h>
|
||||
#include <gio/gcredentialsprivate.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
static void
|
||||
test_basic (void)
|
||||
{
|
||||
GCredentials *creds = g_credentials_new ();
|
||||
gchar *stringified;
|
||||
DWORD *pid;
|
||||
|
||||
stringified = g_credentials_to_string (creds);
|
||||
g_test_message ("%s", stringified);
|
||||
g_free (stringified);
|
||||
|
||||
pid = g_credentials_get_native (creds,
|
||||
G_CREDENTIALS_TYPE_WIN32_PID);
|
||||
g_assert_cmpuint (*pid, ==, GetCurrentProcessId ());
|
||||
|
||||
g_object_unref (creds);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void
|
||||
test_basic (void)
|
||||
{
|
||||
@@ -177,6 +199,8 @@ test_basic (void)
|
||||
g_object_unref (other);
|
||||
}
|
||||
|
||||
#endif /* !G_OS_WIN32 */
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
|
Reference in New Issue
Block a user