For testing patches aimed at Darwin. GLib provides the core application building blocks for libraries and applications written in C. It provides the core object system used in GNOME, the main loop implementation, and a large set of utility functions for strings and common data structures. This package contains GLib version 2.
102 lines
3.7 KiB
Text
102 lines
3.7 KiB
Text
$NetBSD: patch-ap,v 1.1 2013/02/08 03:20:55 outpaddling Exp $
|
|
|
|
--- gio/gcredentials.c.orig 2012-11-10 03:18:53.000000000 +0000
|
|
+++ gio/gcredentials.c
|
|
@@ -32,6 +32,9 @@
|
|
#include <sys/socket.h>
|
|
#include <string.h>
|
|
#endif
|
|
+#ifdef __NetBSD__
|
|
+#include <string.h>
|
|
+#endif
|
|
#include <stdlib.h>
|
|
|
|
#include <gobject/gvaluecollector.h>
|
|
@@ -90,8 +93,14 @@ struct _GCredentials
|
|
struct ucred native;
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
struct cmsgcred native;
|
|
-#elif defined(__OpenBSD__)
|
|
+#elif defined(__OpenBSD__) && !defined(__MirBSD__)
|
|
struct sockpeercred native;
|
|
+#elif defined(__NetBSD__) || defined(__MirBSD__)
|
|
+ struct {
|
|
+ pid_t pid;
|
|
+ uid_t uid;
|
|
+ gid_t gid;
|
|
+ } native;
|
|
#else
|
|
#ifdef __GNUC__
|
|
#warning Please add GCredentials support for your OS
|
|
@@ -136,7 +145,7 @@ g_credentials_class_init (GCredentialsCl
|
|
static void
|
|
g_credentials_init (GCredentials *credentials)
|
|
{
|
|
-#ifdef __linux__
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
|
credentials->native.pid = getpid ();
|
|
credentials->native.uid = geteuid ();
|
|
credentials->native.gid = getegid ();
|
|
@@ -192,7 +201,7 @@ g_credentials_to_string (GCredentials *c
|
|
g_return_val_if_fail (G_IS_CREDENTIALS (credentials), NULL);
|
|
|
|
ret = g_string_new ("GCredentials:");
|
|
-#ifdef __linux__
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
|
g_string_append (ret, "linux-ucred:");
|
|
if (credentials->native.pid != -1)
|
|
g_string_append_printf (ret, "pid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.pid);
|
|
@@ -257,7 +266,7 @@ g_credentials_is_same_user (GCredentials
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
ret = FALSE;
|
|
-#ifdef __linux__
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
|
if (credentials->native.uid == other_credentials->native.uid)
|
|
ret = TRUE;
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
@@ -305,7 +314,7 @@ g_credentials_get_native (GCredentials
|
|
|
|
ret = NULL;
|
|
|
|
-#ifdef __linux__
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
|
if (native_type != G_CREDENTIALS_TYPE_LINUX_UCRED)
|
|
{
|
|
g_warning ("g_credentials_get_native: Trying to get credentials of type %d but only "
|
|
@@ -366,7 +375,7 @@ g_credentials_set_native (GCredentials
|
|
GCredentialsType native_type,
|
|
gpointer native)
|
|
{
|
|
-#ifdef __linux__
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
|
if (native_type != G_CREDENTIALS_TYPE_LINUX_UCRED)
|
|
{
|
|
g_warning ("g_credentials_set_native: Trying to set credentials of type %d "
|
|
@@ -375,7 +384,7 @@ g_credentials_set_native (GCredentials
|
|
}
|
|
else
|
|
{
|
|
- memcpy (&credentials->native, native, sizeof (struct ucred));
|
|
+ memcpy (&credentials->native, native, sizeof (credentials->native));
|
|
}
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
if (native_type != G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED)
|
|
@@ -433,7 +442,7 @@ g_credentials_get_unix_user (GCredential
|
|
g_return_val_if_fail (G_IS_CREDENTIALS (credentials), -1);
|
|
g_return_val_if_fail (error == NULL || *error == NULL, -1);
|
|
|
|
-#ifdef __linux__
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
|
ret = credentials->native.uid;
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
ret = credentials->native.cmcred_euid;
|
|
@@ -479,7 +488,7 @@ g_credentials_set_unix_user (GCredential
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
ret = FALSE;
|
|
-#ifdef __linux__
|
|
+#if defined(__linux__) || defined(__NetBSD__) || defined(__MirBSD__)
|
|
credentials->native.uid = uid;
|
|
ret = TRUE;
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|