[Pkg-gnupg-commit] [libassuan] 385/437: Check for getpeerucred().
Eric Dorland
eric at moszumanska.debian.org
Fri May 22 05:34:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository libassuan.
commit cd96daf5a4ddb4a7e9e373220a7aaead0a97c8cf
Author: Ben Kibbey <bjk at luxsci.net>
Date: Thu Nov 22 17:17:54 2012 -0500
Check for getpeerucred().
* configure.ac: check for getpeerucred() which (Open)Solaris/SunOS
uses.
* src/assuan-socket-server.c (accept_connection_bottom): make use
of getpeerucred().
---
configure.ac | 10 ++++++----
src/assuan-socket-server.c | 26 +++++++++++++++++++++-----
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5a2a8d6..bc71578 100644
--- a/configure.ac
+++ b/configure.ac
@@ -391,10 +391,12 @@ else
AC_DEFINE(HAVE_LOCAL_PEEREID, 1,
[Defined if LOCAL_PEEREID is supported (NetBSD specific)])
else
- #
- # FreeBSD
- #
- AC_CHECK_FUNCS([getpeereid])
+ # (Open)Solaris
+ AC_CHECK_FUNCS([getpeerucred], AC_CHECK_HEADERS([ucred.h]))
+ if test $ac_cv_func_getpeerucred != yes; then
+ # FreeBSD
+ AC_CHECK_FUNCS([getpeereid])
+ fi
fi
fi
diff --git a/src/assuan-socket-server.c b/src/assuan-socket-server.c
index 1e8e541..964720b 100644
--- a/src/assuan-socket-server.c
+++ b/src/assuan-socket-server.c
@@ -30,6 +30,9 @@
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
+#ifdef HAVE_UCRED_H
+#include <ucred.h>
+#endif
#ifdef HAVE_W32_SYSTEM
# ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -58,7 +61,7 @@ accept_connection_bottom (assuan_context_t ctx)
ctx->peercred_valid = 0;
#ifdef HAVE_SO_PEERCRED
{
- struct ucred cr;
+ struct ucred cr;
socklen_t cl = sizeof cr;
if ( !getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl))
@@ -70,16 +73,29 @@ accept_connection_bottom (assuan_context_t ctx)
/* This overrides any already set PID if the function returns
a valid one. */
- if (cr.pid != ASSUAN_INVALID_PID && cr.pid)
+ if (cr.pid != ASSUAN_INVALID_PID && cr.pid)
ctx->pid = cr.pid;
}
}
-#elif defined(HAVE_LOCAL_PEEREID)
+#elif defined (HAVE_GETPEERUCRED)
+ {
+ ucred_t *ucred = NULL;
+
+ if (getpeerucred (fd, &ucred) != -1)
+ {
+ ctx->peercred.uid = ucred_geteuid (ucred);
+ ctx->peercred.gid = ucred_getegid (ucred);
+ ctx->peercred.pid = ucred_getpid (ucred);
+ ctx->peercred_valid = 1;
+ ucred_free (ucred);
+ }
+ }
+#elif defined (HAVE_LOCAL_PEEREID)
{
struct unpcbid unp;
socklen_t unpl = sizeof unp;
- if (getsockopt(fd, 0, LOCAL_PEEREID, &unp, &unpl) != -1)
+ if (getsockopt (fd, 0, LOCAL_PEEREID, &unp, &unpl) != -1)
{
ctx->peercred.pid = unp.unp_pid;
ctx->peercred.uid = unp.unp_euid;
@@ -89,7 +105,7 @@ accept_connection_bottom (assuan_context_t ctx)
}
#elif defined(HAVE_GETPEEREID)
{
- if (getpeereid(fd, &ctx->peercred.uid, &ctx->peercred.gid) != -1)
+ if (getpeereid (fd, &ctx->peercred.uid, &ctx->peercred.gid) != -1)
{
ctx->peercred.pid = ASSUAN_INVALID_PID;
ctx->peercred_valid = 1;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git
More information about the Pkg-gnupg-commit
mailing list