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

Collin Funk via Gnupg-devel <[email protected]>
Newsgroups gmane.comp.encryption.gpg.devel
Message-ID <[email protected]>
* 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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.