diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-11-17 15:06:33 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-11-17 15:06:33 -0800 |
commit | 61bc50ffdbbf9cdb2444b97fbbcc0700e724414e (patch) | |
tree | c9375ba7b25d18b013203ed7fd6ae86627c1772f | |
parent | c909e8a31ffcbb7f1a41bb801392e14f5d20e1fc (diff) |
Use the XPG 4.2 versions of the networking APIs in Solaris.
Those, unlike the default versions, comply with the Single UNIX
Specification, meaning they are able to detect truncation of datagrams
when received with recvmsg().
-rw-r--r-- | aclocal.m4 | 8 | ||||
-rwxr-xr-x | configure | 10 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | ftmacros.h | 7 |
4 files changed, 23 insertions, 4 deletions
@@ -1055,9 +1055,13 @@ dnl AC_DEFUN(AC_LBL_LIBRARY_NET, [ # Most operating systems have gethostbyname() in the default searched # libraries (i.e. libc): - # Some OSes (eg. Solaris) place it in libnsl + # Some OSes (eg. Solaris) place it in libnsl, but in at least some + # versions of Solaris, there are alternate versions of these APIs + # in libxnet, and those versions conform to the Single UNIX + # Specification, meaning you can actually check for truncation + # of incoming datagrams in recvmsg(), so we prefer that. # Some strange OSes (SINIX) have it in libsocket: - AC_SEARCH_LIBS(gethostbyname, nsl socket resolv) + AC_SEARCH_LIBS(gethostbyname, xnet nsl socket resolv) # Unfortunately libsocket sometimes depends on libnsl and # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. if test "$ac_cv_search_gethostbyname" = "no" @@ -4789,7 +4789,11 @@ fi # Most operating systems have gethostbyname() in the default searched # libraries (i.e. libc): - # Some OSes (eg. Solaris) place it in libnsl + # Some OSes (eg. Solaris) place it in libnsl, but in at least some + # versions of Solaris, there are alternate versions of these APIs + # in libxnet, and those versions conform to the Single UNIX + # Specification, meaning you can actually check for truncation + # of incoming datagrams in recvmsg(), so we prefer that. # Some strange OSes (SINIX) have it in libsocket: { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } @@ -4815,7 +4819,7 @@ return gethostbyname (); return 0; } _ACEOF -for ac_lib in '' nsl socket resolv; do +for ac_lib in '' xnet nsl socket resolv; do if test -z "$ac_lib"; then ac_res="none required" else @@ -7235,6 +7239,7 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +# include "ftmacros.h" # include <sys/socket.h> int main () @@ -7267,6 +7272,7 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +# include "ftmacros.h" # include <sys/socket.h> int main () diff --git a/configure.ac b/configure.ac index 7f16399c..65daad89 100644 --- a/configure.ac +++ b/configure.ac @@ -1303,6 +1303,7 @@ yes) AC_MSG_RESULT(yes) AC_MSG_CHECKING(if struct msghdr has a msg_control member) AC_CACHE_VAL(ac_cv_lbl_struct_msghdr_has_msg_control, AC_TRY_COMPILE([ +# include "ftmacros.h" # include <sys/socket.h>], [u_int i = sizeof(((struct msghdr *)0)->msg_control)], ac_cv_lbl_struct_msghdr_has_msg_control=yes, @@ -1314,6 +1315,7 @@ yes) AC_MSG_RESULT(yes) AC_MSG_CHECKING(if struct msghdr has a msg_flags member) AC_CACHE_VAL(ac_cv_lbl_struct_msghdr_has_msg_flags, AC_TRY_COMPILE([ +# include "ftmacros.h" # include <sys/socket.h>], [u_int i = sizeof(((struct msghdr *)0)->msg_flags)], ac_cv_lbl_struct_msghdr_has_msg_flags=yes, @@ -49,6 +49,13 @@ */ #if defined(sun) || defined(__sun) #define __EXTENSIONS__ + + /* + * We also need to define _XPG4_2 in order to get + * the Single UNIX Specification version of + * recvmsg(). + */ + #define _XPG4_2 #elif defined(_hpux) || defined(hpux) || defined(__hpux) #define _REENTRANT #elif defined(__linux__) || defined(linux) || defined(__linux) |