diff options
author | NIIBE Yutaka <[email protected]> | 2017-03-07 05:01:17 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2017-03-07 05:06:35 +0000 |
commit | f7f806afa5083617f4aba02fc3b285b06a7d73d4 (patch) | |
tree | b06550000e9af382e6fbdecfdd2455ae4fe6fc73 /configure.ac | |
parent | common: Fix warning for portability. (diff) | |
download | gnupg-f7f806afa5083617f4aba02fc3b285b06a7d73d4.tar.gz gnupg-f7f806afa5083617f4aba02fc3b285b06a7d73d4.zip |
agent: Fix get_client_pid for portability.
* configure.ac: Simply check getpeerucred and ucred.h, and structure
members.
* agent/command-ssh.c: Include ucred.h.
(get_client_pid) [HAVE_STRUCT_SOCKPEERCRED_PID]: Use sockpeercred
structure for OpenBSD.
[LOCAL_PEERPID]: Use LOCAL_PEERPID for macOS.
[LOCAL_PEEREID]: Use LOCAL_PEEREID for NetBSD.
[HAVE_GETPEERUCRED]: Use getpeerucred for OpenSolaris.
--
This change also addresses following bug.
GnuPG-bug-id: 2981.
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/configure.ac b/configure.ac index 5fc2b8518..6d35450b0 100644 --- a/configure.ac +++ b/configure.ac @@ -1274,7 +1274,8 @@ AC_MSG_NOTICE([checking for header files]) AC_HEADER_STDC AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h \ pty.h utmp.h pwd.h inttypes.h signal.h sys/select.h \ - stdint.h signal.h util.h libutil.h termios.h]) + stdint.h signal.h util.h libutil.h termios.h \ + ucred.h]) AC_HEADER_TIME @@ -1394,49 +1395,13 @@ fi # -# Check for the getsockopt SO_PEERCRED -# (This has been copied from libassuan) +# Check for the getsockopt SO_PEERCRED, etc. # -AC_MSG_CHECKING(for SO_PEERCRED) -AC_CACHE_VAL(gnupg_cv_sys_so_peercred, - [AC_TRY_COMPILE([#include <sys/socket.h>], - [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) +AC_CHECK_MEMBERS([struct ucred.pid, struct ucred.cr_pid, struct sockpeercred.pid], [], [], [#include <sys/types.h> +#include <sys/socket.h> ]) -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 <sys/socket.> - #include <sys/un.h>], - [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 +# (Open)Solaris +AC_CHECK_FUNCS([getpeerucred]) # |