diff --git a/CHANGES b/CHANGES index 1941793..7303704 100644 --- a/CHANGES +++ b/CHANGES @@ -2,7 +2,13 @@ Corrections: Socat 1.7.4.2 did not compile on OmniOS (and probably other OpenSolaris distributions) - Thanks to Andy Fiddaman for sending a patch + Thanks to Andy Fiddaman for sending a patch. + + Socat since 1.7.4.0 did not compile on Solaris and its derivatives + because the getprotobynumber_r() function prototype differ from the + Linux versino. + configure now checks for the variant. + Thanks to Robert Zybeck for reporting this issue. ####################### V 1.7.4.2: diff --git a/configure.ac b/configure.ac index 09dbb7a..afbc534 100644 --- a/configure.ac +++ b/configure.ac @@ -134,6 +134,23 @@ if test $sc_cv_have_prototype_hstrerror = yes; then fi AC_MSG_RESULT($sc_cv_have_prototype_hstrerror) +# getprotobynumber_r() is not standardized +AC_MSG_CHECKING(for getprotobynumber_r() variant) +AC_CACHE_VAL(sc_cv_getprotobynumber_r, +[AC_TRY_COMPILE([#include +#include ],[getprotobynumber_r(1,NULL,NULL,1024,NULL);], +[sc_cv_getprotobynumber_r=1; tmp_bynum_variant=Linux], + [AC_TRY_COMPILE([#include + #include ],[getprotobynumber_r(1,NULL,NULL,1024);], + [sc_cv_getprotobynumber_r=2; tmp_bynum_variant=Solaris], + # there is a 3 arg variant in AIX, but its doc is limited + [sc_cv_getprotobynumber_r=] +)])]) +if test "$sc_cv_getprotobynumber_r"; then + AC_DEFINE_UNQUOTED(HAVE_GETPROTOBYNUMBER_R, $sc_cv_getprotobynumber_r) +fi +AC_MSG_RESULT($sc_cv_getprotobynumber_r /* $tmp_bynum_variant */) + AC_MSG_CHECKING(whether to include help) AC_ARG_ENABLE(help, [ --disable-help disable help], @@ -811,7 +828,7 @@ AC_TYPE_SIGNAL AC_FUNC_STRFTIME AC_CHECK_FUNCS(putenv select pselect poll socket strtod strtol) AC_CHECK_FUNCS(strtoul uname getpgid getsid gethostbyname getaddrinfo) -AC_CHECK_FUNCS(getprotobynumber getprotobynumber_r) +AC_CHECK_FUNCS(getprotobynumber) AC_CHECK_FUNCS(setgroups inet_aton) AC_CHECK_FUNCS(grantpt unlockpt) diff --git a/fdname.c b/fdname.c index 3f2c449..ee1d5ce 100644 --- a/fdname.c +++ b/fdname.c @@ -253,14 +253,14 @@ int sockname(int fd, FILE *outfile, char style) { #endif #if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE) -#if HAVE_GETPROTOBYNUMBER_R +#if HAVE_GETPROTOBYNUMBER_R==1 /* Linux */ rc = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname), &protoentp); if (protoentp == NULL) { Warn2("sockname(): getprotobynumber_r(proto=%d, ...): %s", proto, strerror(rc)); } strncpy(protoname, protoentp->p_name, sizeof(protoname)); -#elif HAVE_GETPROTOBYNUMBER +#elif HAVE_GETPROTOBYNUMBER_R==2 /* Solaris */ protoentp = getprotobynumber(proto); strncpy(protoname, protoentp->p_name, sizeof(protoname)); #else