summaryrefslogtreecommitdiff
path: root/devel/glib2/patches/patch-aq
blob: c680a98da744639c907eb591b3265fb3cf70bc52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
$NetBSD: patch-aq,v 1.4 2012/05/01 18:45:52 adam Exp $

--- gio/gsocket.c.orig	2012-05-01 00:06:39.000000000 +0000
+++ gio/gsocket.c
@@ -37,6 +37,9 @@
 #include <signal.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef __NetBSD__
+#include <sys/un.h>
+#endif
 
 #ifndef G_OS_WIN32
 # include <fcntl.h>
@@ -4301,7 +4304,7 @@ g_socket_get_credentials (GSocket   *soc
 
   ret = NULL;
 
-#if defined(__linux__) || defined(__OpenBSD__)
+#if defined(__linux__) || (defined(__OpenBSD__) && !defined(__MirBSD__))
   {
     socklen_t optlen;
 #if defined(__linux__)
@@ -4336,6 +4339,35 @@ g_socket_get_credentials (GSocket   *soc
                                   &native_creds);
       }
   }
+#elif defined(__NetBSD__) && defined(LOCAL_PEEREID)
+  {
+    struct unpcbid cred;
+    socklen_t len = sizeof(cred);
+    if (getsockopt(socket->priv->fd, 0, LOCAL_PEEREID, &cred, &len) < 0)
+      {
+	int errsv = get_socket_errno ();
+	g_set_error (error,
+		     G_IO_ERROR,
+		     socket_io_error_from_errno (errsv),
+		     _("Unable to get pending error: %s"),
+		     socket_strerror (errsv));
+      }
+    else
+      {
+	struct {
+ 		pid_t pid;
+		uid_t uid;
+		gid_t gid;
+	} native_creds;
+	native_creds.uid = cred.unp_euid;
+	native_creds.gid = cred.unp_egid;
+	native_creds.pid = cred.unp_pid;
+	ret = g_credentials_new ();
+	g_credentials_set_native (ret,
+				  G_CREDENTIALS_TYPE_LINUX_UCRED,
+				  &native_creds);
+      }
+  }
 #else
   g_set_error_literal (error,
                        G_IO_ERROR,