Index: glib2.0-2.36.3/gio/gcredentials.c
===================================================================
--- glib2.0-2.36.3.orig/gio/gcredentials.c	2013-06-03 03:20:49.000000000 +0400
+++ glib2.0-2.36.3/gio/gcredentials.c	2013-07-28 23:41:57.054667994 +0400
@@ -33,6 +33,16 @@
 
 #include "glibintl.h"
 
+#if !defined(USE_SOLARIS_UCRED)
+# if defined(__sun__) || defined(__illumos__) || defined (__OpenSolaris_kernel__)
+#  define USE_SOLARIS_UCRED
+# endif
+#endif
+
+#if defined(USE_SOLARIS_UCRED)
+# include <ucred.h>
+#endif
+
 /**
  * SECTION:gcredentials
  * @short_description: An object containing credentials
@@ -83,6 +93,8 @@
   struct cmsgcred native;
 #elif defined(__OpenBSD__)
   struct sockpeercred native;
+#elif defined(USE_SOLARIS_UCRED)
+  ucred_t *native;
 #else
 #ifdef __GNUC__
 #warning Please add GCredentials support for your OS
@@ -108,7 +120,12 @@
 static void
 g_credentials_finalize (GObject *object)
 {
+#ifdef USE_SOLARIS_UCRED
+  GCredentials *credentials = G_CREDENTIALS (object);
+  ucred_free(credentials->native);
+#else
   G_GNUC_UNUSED GCredentials *credentials = G_CREDENTIALS (object);
+#endif
 
   if (G_OBJECT_CLASS (g_credentials_parent_class)->finalize != NULL)
     G_OBJECT_CLASS (g_credentials_parent_class)->finalize (object);
@@ -140,6 +157,8 @@
   credentials->native.pid = getpid ();
   credentials->native.uid = geteuid ();
   credentials->native.gid = getegid ();
+#elif defined(USE_SOLARIS_UCRED)
+  credentials->native = ucred_get (P_MYID);
 #endif
 }
 
@@ -179,6 +198,8 @@
 g_credentials_to_string (GCredentials *credentials)
 {
   GString *ret;
+#if defined(USE_SOLARIS_UCRED)
+#endif
 
   g_return_val_if_fail (G_IS_CREDENTIALS (credentials), NULL);
 
@@ -211,6 +232,19 @@
     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(USE_SOLARIS_UCRED)
+  g_string_append (ret, "solaris-ucred:");
+  {
+    id_t id;
+    if ((id = ucred_getpid(credentials->native)) != -1)
+      g_string_append_printf (ret, "pid=%" G_GINT64_FORMAT ",", (gint64) id);
+    if ((id = ucred_geteuid(credentials->native)) != -1)
+      g_string_append_printf (ret, "uid=%" G_GINT64_FORMAT ",", (gint64) id);
+    if ((id = ucred_getegid(credentials->native)) != -1)
+      g_string_append_printf (ret, "gid=%" G_GINT64_FORMAT ",", (gint64) id);
+    if (ret->str[ret->len - 1] == ',')
+      ret->str[ret->len - 1] = '\0';
+  }
 #else
   g_string_append (ret, "unknown");
 #endif
@@ -257,6 +291,9 @@
 #elif defined(__OpenBSD__)
   if (credentials->native.uid == other_credentials->native.uid)
     ret = TRUE;
+#elif defined(USE_SOLARIS_UCRED)
+  if (ucred_geteuid(credentials->native) == ucred_geteuid(other_credentials->native))
+    ret = TRUE;
 #else
   g_set_error_literal (error,
                        G_IO_ERROR,
@@ -329,6 +366,17 @@
     {
       ret = &credentials->native;
     }
+#elif defined(USE_SOLARIS_UCRED)
+  if (native_type != G_CREDENTIALS_TYPE_SOLARIS_UCRED)
+    {
+      g_warning ("g_credentials_get_native: Trying to get credentials of type %d but only "
+                 "G_CREDENTIALS_TYPE_SOLARIS_UCRED is supported.",
+                 native_type);
+    }
+  else
+    {
+      ret = credentials->native; /* native is a pointer! */
+    }
 #else
   g_warning ("g_credentials_get_native: Trying to get credentials but GLib has no support "
              "for the native credentials type. Please add support.");
@@ -390,6 +438,19 @@
     {
       memcpy (&credentials->native, native, sizeof (struct sockpeercred));
     }
+#elif defined(USE_SOLARIS_UCRED)
+  if (native_type != G_CREDENTIALS_TYPE_SOLARIS_UCRED)
+    {
+      g_warning ("g_credentials_set_native: Trying to set credentials of type %d "
+                 "but only G_CREDENTIALS_TYPE_SOLARIS_UCRED is supported.",
+                 native_type);
+    }
+  else
+    {
+      /* native is allocated in g_credentials_class_init(),
+         ucred_size() is constant until reboot.  */
+      memcpy (credentials->native, native, ucred_size());
+    }
 #else
   g_warning ("g_credentials_set_native: Trying to set credentials but GLib has no support "
              "for the native credentials type. Please add support.");
@@ -430,6 +491,8 @@
   ret = credentials->native.cmcred_euid;
 #elif defined(__OpenBSD__)
   ret = credentials->native.uid;
+#elif defined(USE_SOLARIS_UCRED)
+  ret = ucred_geteuid(credentials->native);
 #else
   ret = -1;
   g_set_error_literal (error,
@@ -472,6 +535,8 @@
   ret = credentials->native.cmcred_pid;
 #elif defined(__OpenBSD__)
   ret = credentials->native.pid;
+#elif defined(USE_SOLARIS_UCRED)
+  ret = ucred_getpid(credentials->native);
 #else
   ret = -1;
   g_set_error_literal (error,
@@ -521,6 +586,9 @@
 #elif defined(__OpenBSD__)
   credentials->native.uid = uid;
   ret = TRUE;
+#elif defined(USE_SOLARIS_UCRED)
+  /* WHY? */
+  ret = FALSE;
 #else
   g_set_error_literal (error,
                        G_IO_ERROR,
Index: glib2.0-2.36.3/gio/gioenums.h
===================================================================
--- glib2.0-2.36.3.orig/gio/gioenums.h	2013-06-10 02:03:17.000000000 +0400
+++ glib2.0-2.36.3/gio/gioenums.h	2013-07-28 19:37:00.095103870 +0400
@@ -1317,7 +1317,8 @@
   G_CREDENTIALS_TYPE_INVALID,
   G_CREDENTIALS_TYPE_LINUX_UCRED,
   G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED,
-  G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED
+  G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED,
+  G_CREDENTIALS_TYPE_SOLARIS_UCRED
 } GCredentialsType;
 
 /**
Index: glib2.0-2.36.3/gio/gioenumtypes.c
===================================================================
--- glib2.0-2.36.3.orig/gio/gioenumtypes.c	2013-06-10 03:19:38.000000000 +0400
+++ glib2.0-2.36.3/gio/gioenumtypes.c	2013-07-28 19:28:25.715946499 +0400
@@ -1249,6 +1249,7 @@
         { G_CREDENTIALS_TYPE_LINUX_UCRED, "G_CREDENTIALS_TYPE_LINUX_UCRED", "linux-ucred" },
         { G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED, "G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED", "freebsd-cmsgcred" },
         { G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED, "G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED", "openbsd-sockpeercred" },
+        { G_CREDENTIALS_TYPE_SOLARIS_UCRED, "G_CREDENTIALS_TYPE_SOLARIS_UCRED", "solaris-ucred" },
         { 0, NULL, NULL }
       };
       GType g_define_type_id =
Index: glib2.0-2.36.3/gio/gsocket.c
===================================================================
--- glib2.0-2.36.3.orig/gio/gsocket.c	2013-06-03 03:20:49.000000000 +0400
+++ glib2.0-2.36.3/gio/gsocket.c	2013-07-28 23:40:27.788985750 +0400
@@ -65,6 +65,16 @@
 #include "gcredentials.h"
 #include "glibintl.h"
 
+#if !defined(USE_SOLARIS_UCRED)
+# if defined(__sun__) || defined(__illumos__) || defined (__OpenSolaris_kernel__)
+#  define USE_SOLARIS_UCRED
+# endif
+#endif
+
+#if defined(USE_SOLARIS_UCRED)
+# include <ucred.h>
+#endif
+
 /**
  * SECTION:gsocket
  * @short_description: Low-level socket object
@@ -4384,6 +4394,21 @@
                                   &native_creds);
       }
   }
+#elif defined(USE_SOLARIS_UCRED)
+  {
+    ucred_t *ucred = NULL;
+    if (!getpeerucred(g_socket_get_fd(socket), &ucred)) {
+        ret = g_credentials_new ();
+        g_credentials_set_native (ret, G_CREDENTIALS_TYPE_SOLARIS_UCRED, ucred);
+        ucred_free(ucred);
+    } else {
+        g_set_error (error,
+                     G_IO_ERROR,
+                     errno,
+                     _("Unable to get pending error: %s"),
+                     strerror (errno));
+    }
+  }
 #else
   g_set_error_literal (error,
                        G_IO_ERROR,
Index: glib2.0-2.36.3/gio/gunixcredentialsmessage.c
===================================================================
--- glib2.0-2.36.3.orig/gio/gunixcredentialsmessage.c	2013-06-03 03:20:49.000000000 +0400
+++ glib2.0-2.36.3/gio/gunixcredentialsmessage.c	2013-07-29 00:35:01.588795072 +0400
@@ -36,10 +36,22 @@
 #include "config.h"
 
 /* ---------------------------------------------------------------------------------------------------- */
+
+#if !defined(USE_SOLARIS_UCRED)
+# if defined(__sun__) || defined(__illumos__) || defined (__OpenSolaris_kernel__)
+#  define USE_SOLARIS_UCRED
+# endif
+#endif
+
+#if defined(USE_SOLARIS_UCRED)
+# include <ucred.h>
+#endif
 #ifdef __linux__
 #define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1
+#elif defined(USE_SOLARIS_UCRED)
+#define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1
 #else
 /* TODO: please add support for your UNIX flavor */
 #define G_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 0
@@ -78,6 +90,8 @@
   return sizeof (struct ucred);
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
   return sizeof (struct cmsgcred);
+#elif defined(USE_SOLARIS_UCRED)
+  return ucred_size();
 #else
   return 0;
 #endif
@@ -90,6 +104,8 @@
   return SOL_SOCKET;
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
   return SOL_SOCKET;
+#elif defined(USE_SOLARIS_UCRED)
+  return SOL_SOCKET;
 #else
   return 0;
 #endif
@@ -102,6 +118,8 @@
   return SCM_CREDENTIALS;
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
   return SCM_CREDS;
+#elif defined(USE_SOLARIS_UCRED)
+  return SCM_UCRED;
 #else
   return 0;
 #endif
@@ -177,6 +195,33 @@
  out:
     ;
   }
+#elif defined(USE_SOLARIS_UCRED)
+  {
+    GCredentials *credentials;
+    ucred_t *ucred;;
+
+    if (level != SOL_SOCKET || type != SCM_UCRED)
+      {
+        goto out;
+      }
+    if (size < ucred_size())
+      {
+        g_warning ("Expected ucred_t (%" G_GSIZE_FORMAT " bytes) but "
+                   "got %" G_GSIZE_FORMAT " bytes of data",
+                   CMSG_LEN (ucred_size()),
+                   size);
+        goto out;
+      }
+
+    ucred = 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;
@@ -197,6 +242,11 @@
           g_credentials_get_native (message->priv->credentials,
                                     G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED),
           sizeof (struct cmsgcred));
+#elif defined(USE_SOLARIS_UCRED)
+  memcpy (data,
+          g_credentials_get_native (message->priv->credentials,
+                                    G_CREDENTIALS_TYPE_SOLARIS_UCRED),
+          ucred_size());
 
 #endif
 }
