[glib] Fall back to SO_PEERCRED if credentials passing fails



commit 386f0f29fd3dc8e39f49b50ae496c6b1feb3b0a1
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Apr 12 16:50:20 2012 +0200

    Fall back to SO_PEERCRED if credentials passing fails
    
    Turns out libdbus doesn't send struct ucred credentials on linux, but
    just relies on the SO_PEERCRED support. However, gdbus does send, and
    expect to recieve a ucred credential. So, when libdbus talks to a
    gdbus server the authentication fails to send the credentials.
    
    We fix this by falling back to g_socket_get_credentials() if we don't
    get any credential messages.

 gio/gunixconnection.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/gio/gunixconnection.c b/gio/gunixconnection.c
index cce009b..70a31a4 100644
--- a/gio/gunixconnection.c
+++ b/gio/gunixconnection.c
@@ -570,7 +570,9 @@ g_unix_connection_receive_credentials (GUnixConnection      *connection,
       goto out;
     }
 
-  if (g_unix_credentials_message_is_supported ())
+  if (g_unix_credentials_message_is_supported () &&
+      /* Fall back on get_credentials if the other side didn't send the credentials */
+      nscm > 0)
     {
       if (nscm != 1)
         {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]