aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Kibbey <[email protected]>2024-09-16 05:54:37 +0000
committerBen Kibbey <[email protected]>2024-09-16 05:54:37 +0000
commitdfa5e6532d7eecc25841666010004d278e9e4542 (patch)
tree4946eec3410013b05431d65d259b719bc3ba621d
parentUse socklen_t for the length of socket address. (diff)
downloadlibassuan-dfa5e6532d7eecc25841666010004d278e9e4542.tar.gz
libassuan-dfa5e6532d7eecc25841666010004d278e9e4542.zip
Fix FreeBSD to set the pid of assuan_peercred_t.
* configure.ac: Check for struct xucred.cr_pid. * src/assuan-socket-server.c (accept_connection_bottom): Obtain the pid via LOCAL_PEERCRED. Signed-off-by: Ben Kibbey <[email protected]>
-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