diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2010-08-30 05:04:30 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2010-08-30 05:04:30 +0800 |
commit | 50c28d455fb700666dd4772f8c6c83bdea7182c3 (patch) | |
tree | 007084acd5539849d9b5a38b4ce5a231796d9b38 | |
parent | c49b06a1d3816553f3da568b63ea4c89a2018a15 (diff) | |
download | marcuscom-ports-50c28d455fb700666dd4772f8c6c83bdea7182c3.tar marcuscom-ports-50c28d455fb700666dd4772f8c6c83bdea7182c3.tar.gz marcuscom-ports-50c28d455fb700666dd4772f8c6c83bdea7182c3.tar.bz2 marcuscom-ports-50c28d455fb700666dd4772f8c6c83bdea7182c3.tar.lz marcuscom-ports-50c28d455fb700666dd4772f8c6c83bdea7182c3.tar.xz marcuscom-ports-50c28d455fb700666dd4772f8c6c83bdea7182c3.tar.zst marcuscom-ports-50c28d455fb700666dd4772f8c6c83bdea7182c3.zip |
Add credentials support to GIO. This should fix gdbus.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@14479 df743ca5-7f9a-e211-a948-0013205c9059
-rw-r--r-- | devel/glib20/Makefile | 4 | ||||
-rw-r--r-- | devel/glib20/files/patch-gio_gcredentials.c | 124 | ||||
-rw-r--r-- | devel/glib20/files/patch-gio_gioenums.h | 20 | ||||
-rw-r--r-- | devel/glib20/files/patch-gio_gioenumtypes.c | 10 | ||||
-rw-r--r-- | devel/glib20/files/patch-gio_gunixcredentialsmessage.c | 90 |
5 files changed, 246 insertions, 2 deletions
diff --git a/devel/glib20/Makefile b/devel/glib20/Makefile index 0e724d155..1828f6a2e 100644 --- a/devel/glib20/Makefile +++ b/devel/glib20/Makefile @@ -3,13 +3,13 @@ # Whom: Vanilla I. Shu <vanilla@FreeBSD.org> # # $FreeBSD$ -# $MCom: ports/devel/glib20/Makefile,v 1.178 2010/08/21 16:53:43 kwm Exp $ +# $MCom: ports/devel/glib20/Makefile,v 1.179 2010/08/28 04:25:14 avl Exp $ # # !! DON'T FORGET ABOUT devel/gio-fam-backend !! PORTNAME= glib PORTVERSION= 2.25.14 -PORTREVISION?= 2 +PORTREVISION?= 3 CATEGORIES= devel MASTER_SITES= ${MASTER_SITE_GNOME:S,%SUBDIR%,sources/glib/${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/},} \ ftp://ftp.gtk.org/pub/glib/${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}/ \ diff --git a/devel/glib20/files/patch-gio_gcredentials.c b/devel/glib20/files/patch-gio_gcredentials.c new file mode 100644 index 000000000..b1b68ff85 --- /dev/null +++ b/devel/glib20/files/patch-gio_gcredentials.c @@ -0,0 +1,124 @@ +--- gio/gcredentials.c.orig 2010-08-29 12:29:02.000000000 -0400 ++++ gio/gcredentials.c 2010-08-29 13:46:08.000000000 -0400 +@@ -22,6 +22,10 @@ + + #include "config.h" + ++#ifdef __FreeBSD__ ++#include <sys/types.h> ++#include <sys/socket.h> ++#endif + #include <stdlib.h> + + #include <gobject/gvaluecollector.h> +@@ -55,6 +59,9 @@ + * <citerefentry><refentrytitle>unix</refentrytitle><manvolnum>7</manvolnum></citerefentry> + * man page for details. This corresponds to + * %G_CREDENTIALS_TYPE_LINUX_UCRED. ++ * ++ * On FreeBSD, the native credential type is a <type>struct cmsgcred</type>. ++ * This corresponds to %G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED. + */ + + /** +@@ -72,6 +79,8 @@ struct _GCredentials + + #ifdef __linux__ + struct ucred native; ++#elif defined(__FreeBSD__) ++ struct cmsgcred native; + #else + #ifdef __GNUC__ + #warning Please add GCredentials support for your OS +@@ -120,6 +129,11 @@ g_credentials_init (GCredentials *creden + credentials->native.pid = getpid (); + credentials->native.uid = geteuid (); + credentials->native.gid = getegid (); ++#elif defined(__FreeBSD__) ++ memset (&credentials->native, 0, sizeof (struct cmsgcred)); ++ credentials->native.cmcred_pid = getpid (); ++ credentials->native.cmcred_euid = geteuid (); ++ credentials->native.cmcred_gid = getegid (); + #endif + } + +@@ -173,6 +187,14 @@ g_credentials_to_string (GCredentials *c + 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__) ++ 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); ++ if (credentials->native.cmcred_euid != -1) ++ g_string_append_printf (ret, "uid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.cmcred_euid); ++ if (credentials->native.cmcred_gid != -1) ++ g_string_append_printf (ret, "gid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.cmcred_gid); + #else + g_string_append (ret, "unknown"); + #endif +@@ -213,6 +235,9 @@ g_credentials_is_same_user (GCredentials + #ifdef __linux__ + if (credentials->native.uid == other_credentials->native.uid) + ret = TRUE; ++#elif defined(__FreeBSD__) ++ if (credentials->native.cmcred_euid == other_credentials->native.cmcred_euid) ++ ret = TRUE; + #else + g_set_error_literal (error, + G_IO_ERROR, +@@ -263,6 +288,17 @@ g_credentials_get_native (GCredentials + { + ret = &credentials->native; + } ++#elif defined(__FreeBSD__) ++ if (native_type != G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED) ++ { ++ g_waring ("g_credentials_get_native: Trying to get credentials of type %d but only " ++ "G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED is supported.", ++ native_type); ++ } ++ else ++ { ++ ret = &credentials->native; ++ } + #else + g_warning ("g_credentials_get_native: Trying to get credentials but GLib has no support " + "for the native credentials type. Please add support."); +@@ -302,6 +338,17 @@ g_credentials_set_native (GCredentials + { + memcpy (&credentials->native, native, sizeof (struct ucred)); + } ++#elif defined(__FreeBSD__) ++ if (native_type != G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED) ++ { ++ g_warning ("g_credentials_set_native: Trying to set credentials of type %d " ++ "but only G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED is supported.", ++ native_type); ++ } ++ else ++ { ++ memcpy (&credentials->native, native, sizeof (struct cmsgcred)); ++ } + #else + g_warning ("g_credentials_set_native: Trying to set credentials but GLib has no support " + "for the native credentials type. Please add support."); +@@ -338,6 +385,8 @@ g_credentials_get_unix_user (GCredential + + #ifdef __linux__ + ret = credentials->native.uid; ++#elif defined(__FreeBSD__) ++ ret = credentials->native.cmcred_euid; + #else + ret = -1; + g_set_error_literal (error, +@@ -381,6 +430,9 @@ g_credentials_set_unix_user (GCredential + #ifdef __linux__ + credentials->native.uid = uid; + ret = TRUE; ++#elif defined(__FreeBSD__) ++ credentials->native.cmcred_euid = uid; ++ ret = TRUE; + #else + g_set_error_literal (error, + G_IO_ERROR, diff --git a/devel/glib20/files/patch-gio_gioenums.h b/devel/glib20/files/patch-gio_gioenums.h new file mode 100644 index 000000000..75c9b0129 --- /dev/null +++ b/devel/glib20/files/patch-gio_gioenums.h @@ -0,0 +1,20 @@ +--- gio/gioenums.h.orig 2010-08-29 12:43:20.000000000 -0400 ++++ gio/gioenums.h 2010-08-29 12:44:12.000000000 -0400 +@@ -1173,6 +1173,7 @@ typedef enum + * GCredentialsType: + * @G_CREDENTIALS_TYPE_INVALID: Indicates an invalid native credential type. + * @G_CREDENTIALS_TYPE_LINUX_UCRED: The native credentials type is a <type>struct ucred</type>. ++ * @G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED: The native credentials type is a <type>struct cmsgcred</type>. + * + * Enumeration describing different kinds of native credential types. + * +@@ -1181,7 +1182,8 @@ typedef enum + typedef enum + { + G_CREDENTIALS_TYPE_INVALID, +- G_CREDENTIALS_TYPE_LINUX_UCRED ++ G_CREDENTIALS_TYPE_LINUX_UCRED, ++ G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED + } GCredentialsType; + + /** diff --git a/devel/glib20/files/patch-gio_gioenumtypes.c b/devel/glib20/files/patch-gio_gioenumtypes.c new file mode 100644 index 000000000..929cc1567 --- /dev/null +++ b/devel/glib20/files/patch-gio_gioenumtypes.c @@ -0,0 +1,10 @@ +--- gio/gioenumtypes.c.orig 2010-08-29 12:45:26.000000000 -0400 ++++ gio/gioenumtypes.c 2010-08-29 12:45:58.000000000 -0400 +@@ -1130,6 +1130,7 @@ g_credentials_type_get_type (void) + static const GEnumValue values[] = { + { G_CREDENTIALS_TYPE_INVALID, "G_CREDENTIALS_TYPE_INVALID", "invalid" }, + { G_CREDENTIALS_TYPE_LINUX_UCRED, "G_CREDENTIALS_TYPE_LINUX_UCRED", "linux-ucred" }, ++ { G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED, "G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED", "freebsd-cmsgcred" }, + { 0, NULL, NULL } + }; + GType g_define_type_id = diff --git a/devel/glib20/files/patch-gio_gunixcredentialsmessage.c b/devel/glib20/files/patch-gio_gunixcredentialsmessage.c new file mode 100644 index 000000000..09ed30599 --- /dev/null +++ b/devel/glib20/files/patch-gio_gunixcredentialsmessage.c @@ -0,0 +1,90 @@ +--- gio/gunixcredentialsmessage.c.orig 2010-08-29 13:05:21.000000000 -0400 ++++ gio/gunixcredentialsmessage.c 2010-08-29 13:42:42.000000000 -0400 +@@ -46,6 +46,13 @@ + #include <fcntl.h> + #define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1 + ++#elif defined(__FreeBSD__) ++#include <sys/types.h> ++#include <sys/socket.h> ++#include <sys/un.h> ++#include <unistd.h> ++#include <fcntl.h> ++#define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1 + #else + /* TODO: please add support for your UNIX flavor */ + #define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 0 +@@ -79,6 +86,8 @@ g_unix_credentials_message_get_size (GSo + { + #ifdef __linux__ + return sizeof (struct ucred); ++#elif defined(__FreeBSD__) ++ return sizeof (struct cmsgcred); + #else + return 0; + #endif +@@ -89,6 +98,8 @@ g_unix_credentials_message_get_level (GS + { + #ifdef __linux__ + return SOL_SOCKET; ++#elif defined(__FreeBSD__) ++ return SOL_SOCKET; + #else + return 0; + #endif +@@ -99,6 +110,8 @@ g_unix_credentials_message_get_msg_type + { + #ifdef __linux__ + return SCM_CREDENTIALS; ++#elif defined(__FreeBSD__) ++ return SCM_CREDS; + #else + return 0; + #endif +@@ -140,6 +153,33 @@ g_unix_credentials_message_deserialize ( + out: + ; + } ++#elif defined(__FreeBSD__) ++ { ++ GCredentials *credentials; ++ struct cmsgcred *cred; ++ ++ if (level != SOL_SOCKET || type != SCM_CREDS) ++ { ++ goto out; ++ } ++ if (size < CMSG_LEN (sizeof *cred)) ++ { ++ g_warning ("Expected a struct ucred (%" G_GSIZE_FORMAT " bytes) but " ++ "got %" G_GSIZE_FORMAT " bytes of data", ++ CMSG_LEN (sizeof *cred), ++ size); ++ goto out; ++ } ++ ++ cred = data; ++ ++ credentials = g_credentials_new (); ++ g_credentials_set_native (credentials, G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED, ucred); ++ message = g_unix_credentials_message_new_with_credentials (credentials); ++ g_object_unref (credentials); ++ out: ++ ; ++ } + #endif + + return message; +@@ -155,6 +195,12 @@ g_unix_credentials_message_serialize (GS + g_credentials_get_native (message->priv->credentials, + G_CREDENTIALS_TYPE_LINUX_UCRED), + sizeof (struct ucred)); ++#elif defined(__FreeBSD__) ++ memcpy (data, ++ g_credentials_get_native (message->priv->credentials, ++ G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED), ++ sizeof (struct cmsgcred)); ++ + #endif + } + |