GCredentials: Add the concept of credentials that lack the process ID

struct xucred on macOS doesn't have the process ID, only the user ID
and groups.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2020-03-15 18:10:53 +00:00
committed by Philip Withnall
parent a9a7aa05dc
commit 05cb229082
3 changed files with 39 additions and 7 deletions

View File

@@ -54,9 +54,16 @@ test_basic (void)
g_assert_cmpuint (g_credentials_get_unix_user (creds, &error), ==,
geteuid ());
g_assert_no_error (error);
g_assert_cmpuint (g_credentials_get_unix_pid (creds, &error), ==,
#if G_CREDENTIALS_HAS_PID
g_assert_cmpint (g_credentials_get_unix_pid (creds, &error), ==,
getpid ());
g_assert_no_error (error);
#else
g_assert_cmpint (g_credentials_get_unix_pid (creds, &error), ==, -1);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
g_clear_error (&error);
#endif
set = g_credentials_set_unix_user (other, not_me, &error);
#if G_CREDENTIALS_SPOOFING_SUPPORTED