aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac5
-rw-r--r--src/assuan-socket-server.c9
2 files changed, 14 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 8ed17a4..5dc2dc3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -468,6 +468,11 @@ AC_CHECK_FUNCS([getpeerucred])
# FreeBSD
AC_CHECK_FUNCS([getpeereid])
+AC_CHECK_MEMBER(struct xucred.cr_pid,
+ [AC_DEFINE(HAVE_XUCRED_CR_PID, 1,
+ Define if struct xucred contains the cr_pid member.)],
+ [], [#include <sys/ucred.h>
+#include <sys/ucred.h> ])
#
diff --git a/src/assuan-socket-server.c b/src/assuan-socket-server.c
index a260221..c270e8d 100644
--- a/src/assuan-socket-server.c
+++ b/src/assuan-socket-server.c
@@ -135,6 +135,15 @@ accept_connection_bottom (assuan_context_t ctx)
{
ctx->peercred_valid = 1;
ctx->peercred.pid = ASSUAN_INVALID_PID;
+#if defined (HAVE_XUCRED_CR_PID)
+ {
+ struct xucred cr;
+ socklen_t len = sizeof (struct xucred);
+
+ if (!getsockopt (fd, SOL_LOCAL, LOCAL_PEERCRED, &cr, &len))
+ ctx->peercred.pid = cr.cr_pid;
+ }
+#endif
}
}
#endif