- tweak this patch and add a comment

This commit is contained in:
jasper 2010-09-23 15:04:01 +00:00
parent 8b50b07564
commit 81f142cfdf

View File

@ -1,6 +1,10 @@
$OpenBSD: patch-lib_gibber_gibber-unix-transport_c,v 1.3 2010/09/23 13:47:35 jasper Exp $
--- lib/gibber/gibber-unix-transport.c.orig Tue Sep 21 20:16:36 2010
+++ lib/gibber/gibber-unix-transport.c Tue Sep 21 20:18:38 2010
$OpenBSD: patch-lib_gibber_gibber-unix-transport_c,v 1.4 2010/09/23 15:04:01 jasper Exp $
- OpenBSD lacks two defines (should they move to sys/socket.h ?)
- OpenBSD's struct ucred doesn't have a pid member.
--- lib/gibber/gibber-unix-transport.c.orig Wed Aug 18 09:52:58 2010
+++ lib/gibber/gibber-unix-transport.c Thu Sep 23 17:01:03 2010
@@ -22,6 +22,13 @@
/* needed for struct ucred */
#define _GNU_SOURCE
@ -25,38 +29,49 @@ $OpenBSD: patch-lib_gibber_gibber-unix-transport_c,v 1.3 2010/09/23 13:47:35 jas
#include "gibber-unix-transport.h"
#include "gibber-util.h"
@@ -44,6 +48,9 @@
@@ -44,6 +48,14 @@
#define DEBUG_FLAG DEBUG_NET
#include "gibber-debug.h"
+#define SCM_CREDENTIALS 0x9001
+#define SO_PASSCRED 0x9002
+#ifndef SCM_CREDENTIALS
+# define SCM_CREDENTIALS 0x9001
+#endif
+
+#ifndef SO_PASSCRED
+# define SO_PASSCRED 0x9002
+#endif
+
G_DEFINE_TYPE(GibberUnixTransport, gibber_unix_transport, \
GIBBER_TYPE_FD_TRANSPORT)
@@ -245,9 +252,8 @@ gibber_unix_transport_send_credentials (GibberUnixTran
@@ -245,9 +257,14 @@ gibber_unix_transport_send_credentials (GibberUnixTran
ch->cmsg_type = SCM_CREDENTIALS;
cred = (struct ucred *) CMSG_DATA (ch);
- cred->pid = getpid ();
- cred->uid = getuid ();
- cred->gid = getgid ();
+#ifndef __OpenBSD__
cred->pid = getpid ();
cred->uid = getuid ();
cred->gid = getgid ();
+#else
+ cred->cr_uid = getuid ();
+ cred->cr_gid = getgid ();
+#endif
ret = sendmsg (fd, &msg, 0);
if (ret == -1)
@@ -344,9 +350,9 @@ gibber_unix_transport_read (GibberFdTransport *transpo
@@ -344,9 +361,15 @@ gibber_unix_transport_read (GibberFdTransport *transpo
GibberCredentials credentials;
cred = (struct ucred *) CMSG_DATA (ch);
- credentials.pid = cred->pid;
- credentials.uid = cred->uid;
- credentials.gid = cred->gid;
+#ifndef __OpenBSD__
credentials.pid = cred->pid;
credentials.uid = cred->uid;
credentials.gid = cred->gid;
+#else
+ credentials.pid = getpid();
+ credentials.uid = cred->cr_uid;
+ credentials.gid = cred->cr_gid;
+#endif
priv->recv_creds_cb (self, &buf, &credentials, NULL,
priv->recv_creds_data);