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:
Marc-André Lureau
2022-01-19 20:35:45 +04:00
parent 568f00d65f
commit 95c3e28af5
5 changed files with 67 additions and 0 deletions

View File

@@ -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[])