[PATCH libassuan] Work around missing getpeereid declaration on AIX.

Collin Funk collin.funk1 at gmail.com
Thu May 1 06:35:30 CEST 2025


* configure.ac: Check for a declaration of getpeereid.
* src/assuan-socket-server.c (getpeereid)
[HAVE_GETPEEREID && !HAVE_DECL_GETPEEREID]: Declare function.
(accept_connection_bottom): Adjust a comment.

--
GnuPG-bug-id: 7631
Signed-off-by: Collin Funk <collin.funk1 at gmail.com>
---
 configure.ac               | 8 +++++++-
 src/assuan-socket-server.c | 7 ++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 979a7e4..bc4ff39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -471,8 +471,14 @@ AC_CHECK_MEMBER(struct sockpeercred.pid,
 # (Open)Solaris
 AC_CHECK_FUNCS([getpeerucred])
 
-# FreeBSD
+# FreeBSD and AIX
 AC_CHECK_FUNCS([getpeereid])
+# AIX is missing the declaration.
+AC_CHECK_DECLS([getpeereid],,, [[
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/socket.h>
+]])
 AC_CHECK_MEMBER(struct xucred.cr_pid,
 		[AC_DEFINE(HAVE_XUCRED_CR_PID, 1,
 		 Define if struct xucred contains the cr_pid member.)],
diff --git a/src/assuan-socket-server.c b/src/assuan-socket-server.c
index c270e8d..8c44755 100644
--- a/src/assuan-socket-server.c
+++ b/src/assuan-socket-server.c
@@ -55,6 +55,11 @@
 #include "debug.h"
 #include "assuan-defs.h"
 
+/* Missing declaration on AIX.  */
+#if HAVE_GETPEEREID && !HAVE_DECL_GETPEEREID
+int getpeereid (int fd, uid_t *euid, gid_t *egid);
+#endif
+
 static gpg_error_t
 accept_connection_bottom (assuan_context_t ctx)
 {
@@ -130,7 +135,7 @@ accept_connection_bottom (assuan_context_t ctx)
       }
   }
 #elif defined(HAVE_GETPEEREID)
-  {                             /* FreeBSD */
+  {                             /* FreeBSD and AIX */
     if (getpeereid (fd, &ctx->peercred.uid, &ctx->peercred.gid) != -1)
       {
         ctx->peercred_valid = 1;
-- 
2.49.0




More information about the Gnupg-devel mailing list