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 19:00:46.981962391 +0400
@@ -33,6 +33,22 @@
 
 #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>
+/* ucred_t is a transparent structure, so we use our own, something like a cache.  */
+struct _g_solaris_ucred {
+    uid_t uid;
+    pid_t pid;
+    gid_t gid;
+};
+#endif
+
 /**
  * SECTION:gcredentials
  * @short_description: An object containing credentials
@@ -83,6 +99,8 @@
   struct cmsgcred native;
 #elif defined(__OpenBSD__)
   struct sockpeercred native;
+#elif defined(USE_SOLARIS_UCRED)
+  struct _g_solaris_ucred native;
 #else
 #ifdef __GNUC__
 #warning Please add GCredentials support for your OS
@@ -140,6 +158,15 @@
   credentials->native.pid = getpid ();
   credentials->native.uid = geteuid ();
   credentials->native.gid = getegid ();
+#elif defined(USE_SOLARIS_UCRED)
+  ucred_t *ucred = ucred_get(P_MYID);
+  memset (&credentials->native, 0, sizeof (struct _g_solaris_ucred));
+  if (ucred) {
+      credentials->native.pid = ucred_getpid (ucred);
+      credentials->native.uid = ucred_geteuid (ucred);
+      credentials->native.gid = ucred_getegid (ucred);
+      free(ucred);
+  }
 #endif
 }
 
@@ -211,6 +238,16 @@
     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:");
+  if (credentials->native.pid != -1)
+    g_string_append_printf (ret, "pid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.pid);
+  if (credentials->native.uid != -1)
+    g_string_append_printf (ret, "uid=%" G_GINT64_FORMAT ",", (gint64) credentials->native.uid);
+  if (credentials->native.gid != -1)
+    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';
 #else
   g_string_append (ret, "unknown");
 #endif
@@ -257,6 +294,9 @@
 #elif defined(__OpenBSD__)
   if (credentials->native.uid == other_credentials->native.uid)
     ret = TRUE;
+#elif defined(USE_SOLARIS_UCRED)
+  if (credentials->native.uid == other_credentials->native.uid)
+    ret = TRUE;
 #else
   g_set_error_literal (error,
                        G_IO_ERROR,
@@ -329,6 +369,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;
+    }
 #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 +441,17 @@
     {
       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
+    {
+      memcpy (&credentials->native, native, sizeof (struct _g_solaris_ucred));
+    }
 #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 +492,8 @@
   ret = credentials->native.cmcred_euid;
 #elif defined(__OpenBSD__)
   ret = credentials->native.uid;
+#elif defined(USE_SOLARIS_UCRED)
+  ret = credentials->native.uid;
 #else
   ret = -1;
   g_set_error_literal (error,
@@ -472,6 +536,8 @@
   ret = credentials->native.cmcred_pid;
 #elif defined(__OpenBSD__)
   ret = credentials->native.pid;
+#elif defined(USE_SOLARIS_UCRED)
+  ret = credentials->native.pid;
 #else
   ret = -1;
   g_set_error_literal (error,
@@ -521,6 +587,9 @@
 #elif defined(__OpenBSD__)
   credentials->native.uid = uid;
   ret = TRUE;
+#elif defined(USE_SOLARIS_UCRED)
+  credentials->native.uid = uid;
+  ret = TRUE;
 #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 18:57:55.967681664 +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;
 
 /**
