[git] Assuan - branch, master, updated. libassuan-2.0.3-12-g76ea68c

by Ben Kibbey cvs at cvs.gnupg.org
Wed Nov 21 14:41:50 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  76ea68c2a77cafe2424fe6bc97403c9d9a6b1e95 (commit)
      from  76ceeb3582bba138227bf76167b451ee017d38fc (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 76ea68c2a77cafe2424fe6bc97403c9d9a6b1e95
Author: Ben Kibbey <bjk at luxsci.net>
Date:   Tue Nov 20 21:53:31 2012 -0500

    Support LOCAL_PEEREID (NetBSD) and getpeereid() (FreeBSD)
    
    * configure.ac: check for LOCAL_PEEREID and getpeereid().
    * src/assuan-socket-server.c (accept_connection_bottom): make use of
    LOCAL_PEEREID and getpeereid().
    --
    
    For use with assuan_get_peercred(). Note that getpeereid() does not
    set the PID member. LOCAL_PEEREID is checked before getpeereid()
    since NetBSD has both of these. SO_PEERCRED is still checked first.
    
    [Second revision]
    This revision adds support for LOCAL_PEEREID which NetBSD uses. Its
    tested against NetBSD 6.0 and may work without problems with earlier
    versions. FreeBSD uses getpeereid() which does not have PID support.
    Recent OpenBSD versions do support SO_PEERCRED and old versions have
    getpeereid() but also may have LOCAL_PEEREID (not sure).

diff --git a/configure.ac b/configure.ac
index b420f48..5a2a8d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -367,9 +367,35 @@ AC_CACHE_VAL(assuan_cv_sys_so_peercred,
           assuan_cv_sys_so_peercred=no)
        ])
 AC_MSG_RESULT($assuan_cv_sys_so_peercred)
+
 if test $assuan_cv_sys_so_peercred = yes; then
   AC_DEFINE(HAVE_SO_PEERCRED, 1,
             [Defined if SO_PEERCRED is supported (Linux specific)])
+else
+  #
+  # Check for the getsockopt LOCAL_PEEREID (NetBSD)
+  #
+  AC_MSG_CHECKING(for LOCAL_PEEREID)
+  AC_CACHE_VAL(assuan_cv_sys_so_local_peereid,
+      [AC_TRY_COMPILE([#include <sys/socket.>
+         #include <sys/un.h>],
+         [struct unpcbid unp;
+          int unpl = sizeof unp;
+          getsockopt (1, SOL_SOCKET, LOCAL_PEEREID, &unp, &unpl);],
+          assuan_cv_sys_so_local_peereid=yes,
+          assuan_cv_sys_so_local_peereid=no)
+       ])
+  AC_MSG_RESULT($assuan_cv_sys_so_local_peereid)
+
+  if test $assuan_cv_sys_so_local_peereid = yes; then
+    AC_DEFINE(HAVE_LOCAL_PEEREID, 1,
+              [Defined if LOCAL_PEEREID is supported (NetBSD specific)])
+  else
+    #
+    # FreeBSD
+    #
+    AC_CHECK_FUNCS([getpeereid])
+  fi
 fi
 
 
diff --git a/src/assuan-socket-server.c b/src/assuan-socket-server.c
index 27994a2..1e8e541 100644
--- a/src/assuan-socket-server.c
+++ b/src/assuan-socket-server.c
@@ -74,6 +74,27 @@ accept_connection_bottom (assuan_context_t ctx)
            ctx->pid = cr.pid;
       }
   }
+#elif defined(HAVE_LOCAL_PEEREID)
+  {
+    struct unpcbid unp;
+    socklen_t unpl = sizeof unp;
+
+    if (getsockopt(fd, 0, LOCAL_PEEREID, &unp, &unpl) != -1)
+      {
+	ctx->peercred.pid = unp.unp_pid;
+	ctx->peercred.uid = unp.unp_euid;
+	ctx->peercred.gid = unp.unp_egid;
+	ctx->peercred_valid = 1;
+      }
+  }
+#elif defined(HAVE_GETPEEREID)
+  {
+    if (getpeereid(fd, &ctx->peercred.uid, &ctx->peercred.gid) != -1)
+      {
+	ctx->peercred.pid = ASSUAN_INVALID_PID;
+	ctx->peercred_valid = 1;
+      }
+  }
 #endif
 
   ctx->inbound.fd = fd;

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

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


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




More information about the Gnupg-commits mailing list