2013-04-20 00:21:41 +02:00
|
|
|
$NetBSD: patch-ap,v 1.5 2013/04/19 22:21:41 prlw1 Exp $
|
2011-03-09 12:22:04 +01:00
|
|
|
|
2013-04-20 00:21:41 +02:00
|
|
|
--- gio/gcredentials.c.orig 2013-03-13 13:39:09.000000000 +0000
|
2011-03-09 12:22:04 +01:00
|
|
|
+++ gio/gcredentials.c
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -81,8 +81,14 @@ struct _GCredentials
|
2012-04-10 21:48:17 +02:00
|
|
|
struct ucred native;
|
2012-11-13 22:23:07 +01:00
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
2011-03-09 12:22:04 +01:00
|
|
|
struct cmsgcred native;
|
2012-04-10 21:48:17 +02:00
|
|
|
-#elif defined(__OpenBSD__)
|
|
|
|
+#elif defined(__OpenBSD__) && !defined(__MirBSD__)
|
2012-01-29 11:46:52 +01:00
|
|
|
struct sockpeercred native;
|
2012-04-10 21:48:17 +02:00
|
|
|
+#elif defined(__NetBSD__) || defined(__MirBSD__)
|
2011-03-09 12:22:04 +01:00
|
|
|
+ struct {
|
|
|
|
+ pid_t pid;
|
|
|
|
+ uid_t uid;
|
|
|
|
+ gid_t gid;
|
|
|
|
+ } native;
|
|
|
|
#else
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning Please add GCredentials support for your OS
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -127,7 +133,7 @@ g_credentials_class_init (GCredentialsCl
|
2011-03-09 12:22:04 +01:00
|
|
|
static void
|
|
|
|
g_credentials_init (GCredentials *credentials)
|
|
|
|
{
|
|
|
|
-#ifdef __linux__
|
2012-04-10 21:48:17 +02:00
|
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
2011-03-09 12:22:04 +01:00
|
|
|
credentials->native.pid = getpid ();
|
|
|
|
credentials->native.uid = geteuid ();
|
|
|
|
credentials->native.gid = getegid ();
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -183,7 +189,7 @@ g_credentials_to_string (GCredentials *c
|
2011-03-09 12:22:04 +01:00
|
|
|
g_return_val_if_fail (G_IS_CREDENTIALS (credentials), NULL);
|
|
|
|
|
|
|
|
ret = g_string_new ("GCredentials:");
|
|
|
|
-#ifdef __linux__
|
2012-04-10 21:48:17 +02:00
|
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
2011-03-09 12:22:04 +01:00
|
|
|
g_string_append (ret, "linux-ucred:");
|
|
|
|
if (credentials->native.pid != -1)
|
|
|
|
g_string_append_printf (ret, "pid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.pid);
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -248,7 +254,7 @@ g_credentials_is_same_user (GCredentials
|
2011-03-09 12:22:04 +01:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
|
|
ret = FALSE;
|
|
|
|
-#ifdef __linux__
|
2012-04-10 21:48:17 +02:00
|
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
2011-03-09 12:22:04 +01:00
|
|
|
if (credentials->native.uid == other_credentials->native.uid)
|
|
|
|
ret = TRUE;
|
2012-11-13 22:23:07 +01:00
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -296,7 +302,7 @@ g_credentials_get_native (GCredentials
|
2011-03-09 12:22:04 +01:00
|
|
|
|
|
|
|
ret = NULL;
|
|
|
|
|
|
|
|
-#ifdef __linux__
|
2012-04-10 21:48:17 +02:00
|
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
2011-03-09 12:22:04 +01:00
|
|
|
if (native_type != G_CREDENTIALS_TYPE_LINUX_UCRED)
|
|
|
|
{
|
|
|
|
g_warning ("g_credentials_get_native: Trying to get credentials of type %d but only "
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -357,7 +363,7 @@ g_credentials_set_native (GCredentials
|
2011-03-09 12:22:04 +01:00
|
|
|
GCredentialsType native_type,
|
|
|
|
gpointer native)
|
|
|
|
{
|
|
|
|
-#ifdef __linux__
|
2012-04-10 21:48:17 +02:00
|
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
2011-03-09 12:22:04 +01:00
|
|
|
if (native_type != G_CREDENTIALS_TYPE_LINUX_UCRED)
|
|
|
|
{
|
|
|
|
g_warning ("g_credentials_set_native: Trying to set credentials of type %d "
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -366,7 +372,7 @@ g_credentials_set_native (GCredentials
|
2011-03-09 12:22:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
- memcpy (&credentials->native, native, sizeof (struct ucred));
|
|
|
|
+ memcpy (&credentials->native, native, sizeof (credentials->native));
|
|
|
|
}
|
2012-11-13 22:23:07 +01:00
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
2011-03-09 12:22:04 +01:00
|
|
|
if (native_type != G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED)
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -424,7 +430,7 @@ g_credentials_get_unix_user (GCredential
|
2011-03-09 12:22:04 +01:00
|
|
|
g_return_val_if_fail (G_IS_CREDENTIALS (credentials), -1);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, -1);
|
|
|
|
|
|
|
|
-#ifdef __linux__
|
2012-04-10 21:48:17 +02:00
|
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
2011-03-09 12:22:04 +01:00
|
|
|
ret = credentials->native.uid;
|
2012-11-13 22:23:07 +01:00
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
2011-03-09 12:22:04 +01:00
|
|
|
ret = credentials->native.cmcred_euid;
|
2013-04-20 00:21:41 +02:00
|
|
|
@@ -470,7 +476,7 @@ g_credentials_get_unix_pid (GCredentials
|
|
|
|
ret = credentials->native.pid;
|
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
|
|
ret = credentials->native.cmcred_pid;
|
|
|
|
-#elif defined(__OpenBSD__)
|
|
|
|
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
|
|
|
ret = credentials->native.pid;
|
|
|
|
#else
|
|
|
|
ret = -1;
|
|
|
|
@@ -512,7 +518,7 @@ g_credentials_set_unix_user (GCredential
|
2011-03-09 12:22:04 +01:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
|
|
ret = FALSE;
|
|
|
|
-#ifdef __linux__
|
2012-04-10 21:48:17 +02:00
|
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
2011-03-09 12:22:04 +01:00
|
|
|
credentials->native.uid = uid;
|
|
|
|
ret = TRUE;
|
2012-11-13 22:23:07 +01:00
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|