[glib/glib-2-32] Use the FreeBSD credentials-passing code on Debian GNU/kFreeBSD
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-32] Use the FreeBSD credentials-passing code on Debian GNU/kFreeBSD
- Date: Fri, 2 Nov 2012 13:56:58 +0000 (UTC)
commit 7a3f70e7e19f900fcfa48eabce60be0e806b5647
Author: Simon McVittie <simon mcvittie collabora co uk>
Date: Sun Oct 21 23:38:31 2012 +0100
Use the FreeBSD credentials-passing code on Debian GNU/kFreeBSD
The __FreeBSD__ macro means we have both a FreeBSD kernel and FreeBSD
libc, which isn't the case on GNU/kFreeBSD (GNU libc and userland on
the FreeBSD kernel), so it predefines a different macro. The kernel
is what actually matters for credentials-passing, though.
Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
Tested-by: Steven Chamberlain <steven pyro eu org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=649302
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=581750
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631968
Reviewed-by: Dan Winship <danw gnome org>
gio/gcredentials.c | 18 +++++++++---------
gio/gunixcredentialsmessage.c | 12 ++++++------
2 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/gio/gcredentials.c b/gio/gcredentials.c
index 3a98333..2827c45 100644
--- a/gio/gcredentials.c
+++ b/gio/gcredentials.c
@@ -22,7 +22,7 @@
#include "config.h"
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
@@ -88,7 +88,7 @@ struct _GCredentials
#ifdef __linux__
struct ucred native;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
struct cmsgcred native;
#elif defined(__OpenBSD__)
struct sockpeercred native;
@@ -140,7 +140,7 @@ g_credentials_init (GCredentials *credentials)
credentials->native.pid = getpid ();
credentials->native.uid = geteuid ();
credentials->native.gid = getegid ();
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
memset (&credentials->native, 0, sizeof (struct cmsgcred));
credentials->native.cmcred_pid = getpid ();
credentials->native.cmcred_euid = geteuid ();
@@ -202,7 +202,7 @@ g_credentials_to_string (GCredentials *credentials)
g_string_append_printf (ret, "gid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.gid);
if (ret->str[ret->len - 1] == ',')
ret->str[ret->len - 1] = '\0';
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
g_string_append (ret, "freebsd-cmsgcred:");
if (credentials->native.cmcred_pid != -1)
g_string_append_printf (ret, "pid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.cmcred_pid);
@@ -260,7 +260,7 @@ g_credentials_is_same_user (GCredentials *credentials,
#ifdef __linux__
if (credentials->native.uid == other_credentials->native.uid)
ret = TRUE;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (credentials->native.cmcred_euid == other_credentials->native.cmcred_euid)
ret = TRUE;
#elif defined(__OpenBSD__)
@@ -316,7 +316,7 @@ g_credentials_get_native (GCredentials *credentials,
{
ret = &credentials->native;
}
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (native_type != G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED)
{
g_warning ("g_credentials_get_native: Trying to get credentials of type %d but only "
@@ -377,7 +377,7 @@ g_credentials_set_native (GCredentials *credentials,
{
memcpy (&credentials->native, native, sizeof (struct ucred));
}
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (native_type != G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED)
{
g_warning ("g_credentials_set_native: Trying to set credentials of type %d "
@@ -435,7 +435,7 @@ g_credentials_get_unix_user (GCredentials *credentials,
#ifdef __linux__
ret = credentials->native.uid;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
ret = credentials->native.cmcred_euid;
#elif defined(__OpenBSD__)
ret = credentials->native.uid;
@@ -482,7 +482,7 @@ g_credentials_set_unix_user (GCredentials *credentials,
#ifdef __linux__
credentials->native.uid = uid;
ret = TRUE;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
credentials->native.cmcred_euid = uid;
ret = TRUE;
#elif defined(__OpenBSD__)
diff --git a/gio/gunixcredentialsmessage.c b/gio/gunixcredentialsmessage.c
index 7cbbab9..13bf3de 100644
--- a/gio/gunixcredentialsmessage.c
+++ b/gio/gunixcredentialsmessage.c
@@ -44,7 +44,7 @@
#include <fcntl.h>
#define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -84,7 +84,7 @@ g_unix_credentials_message_get_size (GSocketControlMessage *message)
{
#ifdef __linux__
return sizeof (struct ucred);
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
return sizeof (struct cmsgcred);
#else
return 0;
@@ -96,7 +96,7 @@ g_unix_credentials_message_get_level (GSocketControlMessage *message)
{
#ifdef __linux__
return SOL_SOCKET;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
return SOL_SOCKET;
#else
return 0;
@@ -108,7 +108,7 @@ g_unix_credentials_message_get_msg_type (GSocketControlMessage *message)
{
#ifdef __linux__
return SCM_CREDENTIALS;
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
return SCM_CREDS;
#else
return 0;
@@ -158,7 +158,7 @@ g_unix_credentials_message_deserialize (gint level,
out:
;
}
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
{
GCredentials *credentials;
struct cmsgcred *cred;
@@ -200,7 +200,7 @@ g_unix_credentials_message_serialize (GSocketControlMessage *_message,
g_credentials_get_native (message->priv->credentials,
G_CREDENTIALS_TYPE_LINUX_UCRED),
sizeof (struct ucred));
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
memcpy (data,
g_credentials_get_native (message->priv->credentials,
G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]