From 309f464a5952c7d7504b875bf4853914b1242346 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 3 Feb 2017 17:13:08 +0100 Subject: agent: Tell the Pinentry the client's pid. * configure.ac: Check for SO_PEERCRED et al. * agent/agent.h (server_control_s): Add field 'client_pid'. * agent/command.c (start_command_handler): Set CLIENT_PID. * agent/command-ssh.c (get_client_pid): New. (start_command_handler_ssh): Set CLIENT_PID. * agent/call-pinentry.c (start_pinentry): Tell Pinentry the client-pid. Signed-off-by: Werner Koch --- configure.ac | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 75bed06c4..ce02d037a 100644 --- a/configure.ac +++ b/configure.ac @@ -1375,6 +1375,53 @@ if test $ac_cv_func_mmap != yes -a $mmap_needed = yes; then AC_MSG_ERROR([[Sorry, the current implemenation requires mmap.]]) fi + +# +# Check for the getsockopt SO_PEERCRED +# (This has been copied from libassuan) +# +AC_MSG_CHECKING(for SO_PEERCRED) +AC_CACHE_VAL(gnupg_cv_sys_so_peercred, + [AC_TRY_COMPILE([#include ], + [struct ucred cr; + int cl = sizeof cr; + getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);], + gnupg_cv_sys_so_peercred=yes, + gnupg_cv_sys_so_peercred=no) + ]) +AC_MSG_RESULT($gnupg_cv_sys_so_peercred) + +if test $gnupg_cv_sys_so_peercred = yes; then + AC_DEFINE(HAVE_SO_PEERCRED, 1, + [Defined if SO_PEERCRED is supported (Linux specific)]) +else + # Check for the getsockopt LOCAL_PEEREID (NetBSD) + AC_MSG_CHECKING(for LOCAL_PEEREID) + AC_CACHE_VAL(gnupg_cv_sys_so_local_peereid, + [AC_TRY_COMPILE([#include + #include ], + [struct unpcbid unp; + int unpl = sizeof unp; + getsockopt (1, SOL_SOCKET, LOCAL_PEEREID, &unp, &unpl);], + gnupg_cv_sys_so_local_peereid=yes, + gnupg_cv_sys_so_local_peereid=no) + ]) + AC_MSG_RESULT($gnupg_cv_sys_so_local_peereid) + + if test $gnupg_cv_sys_so_local_peereid = yes; then + AC_DEFINE(HAVE_LOCAL_PEEREID, 1, + [Defined if LOCAL_PEEREID is supported (NetBSD specific)]) + else + # (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 + + # # W32 specific test # -- cgit v1.2.3