[git] Assuan - branch, master, updated. libassuan-2.0.3-13-gcd96daf

by Ben Kibbey cvs at cvs.gnupg.org
Mon Nov 26 16:05:56 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPC library used by GnuPG".

The branch, master has been updated
       via  cd96daf5a4ddb4a7e9e373220a7aaead0a97c8cf (commit)
      from  76ea68c2a77cafe2424fe6bc97403c9d9a6b1e95 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cd96daf5a4ddb4a7e9e373220a7aaead0a97c8cf
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Thu Nov 22 17:17:54 2012 -0500

    Check for getpeerucred().
    
    * configure.ac: check for getpeerucred() which (Open)Solaris/SunOS
    uses.
    * src/assuan-socket-server.c (accept_connection_bottom): make use
    of getpeerucred().

diff --git a/configure.ac b/configure.ac
index 5a2a8d6..bc71578 100644
--- a/configure.ac
+++ b/configure.ac
@@ -391,10 +391,12 @@ else
     AC_DEFINE(HAVE_LOCAL_PEEREID, 1,
               [Defined if LOCAL_PEEREID is supported (NetBSD specific)])
   else
-    #
-    # FreeBSD
-    #
-    AC_CHECK_FUNCS([getpeereid])
+    # (Open)Solaris
+    AC_CHECK_FUNCS([getpeerucred], AC_CHECK_HEADERS([ucred.h]))
+    if test $ac_cv_func_getpeerucred != yes; then
+        # FreeBSD
+        AC_CHECK_FUNCS([getpeereid])
+    fi
   fi
 fi
 
diff --git a/src/assuan-socket-server.c b/src/assuan-socket-server.c
index 1e8e541..964720b 100644
--- a/src/assuan-socket-server.c
+++ b/src/assuan-socket-server.c
@@ -30,6 +30,9 @@
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
+#ifdef HAVE_UCRED_H
+#include <ucred.h>
+#endif
 #ifdef HAVE_W32_SYSTEM
 # ifdef HAVE_WINSOCK2_H
 #  include <winsock2.h>
@@ -58,7 +61,7 @@ accept_connection_bottom (assuan_context_t ctx)
   ctx->peercred_valid = 0;
 #ifdef HAVE_SO_PEERCRED
   {
-    struct ucred cr; 
+    struct ucred cr;
     socklen_t cl = sizeof cr;
 
     if ( !getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl))
@@ -70,16 +73,29 @@ accept_connection_bottom (assuan_context_t ctx)
 
          /* This overrides any already set PID if the function returns
             a valid one. */
-         if (cr.pid != ASSUAN_INVALID_PID && cr.pid) 
+         if (cr.pid != ASSUAN_INVALID_PID && cr.pid)
            ctx->pid = cr.pid;
       }
   }
-#elif defined(HAVE_LOCAL_PEEREID)
+#elif defined (HAVE_GETPEERUCRED)
+  {
+    ucred_t *ucred = NULL;
+
+    if (getpeerucred (fd, &ucred) != -1)
+      {
+        ctx->peercred.uid = ucred_geteuid (ucred);
+        ctx->peercred.gid = ucred_getegid (ucred);
+	ctx->peercred.pid = ucred_getpid (ucred);
+	ctx->peercred_valid = 1;
+	ucred_free (ucred);
+      }
+  }
+#elif defined (HAVE_LOCAL_PEEREID)
   {
     struct unpcbid unp;
     socklen_t unpl = sizeof unp;
 
-    if (getsockopt(fd, 0, LOCAL_PEEREID, &unp, &unpl) != -1)
+    if (getsockopt (fd, 0, LOCAL_PEEREID, &unp, &unpl) != -1)
       {
 	ctx->peercred.pid = unp.unp_pid;
 	ctx->peercred.uid = unp.unp_euid;
@@ -89,7 +105,7 @@ accept_connection_bottom (assuan_context_t ctx)
   }
 #elif defined(HAVE_GETPEEREID)
   {
-    if (getpeereid(fd, &ctx->peercred.uid, &ctx->peercred.gid) != -1)
+    if (getpeereid (fd, &ctx->peercred.uid, &ctx->peercred.gid) != -1)
       {
 	ctx->peercred.pid = ASSUAN_INVALID_PID;
 	ctx->peercred_valid = 1;

-----------------------------------------------------------------------

Summary of changes:
 configure.ac               |   10 ++++++----
 src/assuan-socket-server.c |   26 +++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
IPC library used by GnuPG
http://git.gnupg.org




More information about the Gnupg-commits mailing list