From: Bart Hartgers Date: Thu, 25 Feb 1999 13:07:27 +0000 (+0000) Subject: Patch to support to determine the number of args of the X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~543 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e26de67770db049a6ec053b2b63ae12c8a65a473;p=openldap Patch to support to determine the number of args of the gethostby{name,addr}_r functions. Contributed by Juan Carlos Gomes IT#68 (apparently). Also includes support for detecting ssleay in configure.in. --- diff --git a/acconfig.h b/acconfig.h index 3904300286..2b9417817e 100644 --- a/acconfig.h +++ b/acconfig.h @@ -45,6 +45,12 @@ /* define this to the number of arguments ctime_r() expects */ #undef CTIME_R_NARGS +/* define this to the number of arguments gethostbyaddr_r expects */ +#undef GETHOSTBYADDR_R_NARGS + +/* define this to the number of arguments gethostbyname_r expects */ +#undef GETHOSTBYNAME_R_NARGS + /* define this if sys_errlist is not defined in stdio.h or errno.h */ #undef DECL_SYS_ERRLIST diff --git a/build/openldap.m4 b/build/openldap.m4 index 85e77c7266..21171f9abc 100644 --- a/build/openldap.m4 +++ b/build/openldap.m4 @@ -443,4 +443,75 @@ AC_DEFUN(OL_FUNC_CTIME_R_NARGS, AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs) fi ])dnl +dnl ==================================================================== +dnl check no of arguments for gethostbyname_r +AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS, + [AC_CACHE_CHECK(number of arguments of gethostbyname_r, ol_cv_func_gethostbyname_r_nargs, + [AC_TRY_COMPILE([#include + #include + #include + #include + #define BUFSIZE (sizeof(struct hostent)+10)], + [struct hostent hent; char buffer[BUFSIZE]; + int bufsize=BUFSIZE;int h_errno; + (void)gethostbyname_r( "segovia.cs.purdue.edu", &hent, buffer, bufsize, &h_errno); + return 0;], + ol_cv_func_gethostbyname_r_nargs=5, ol_cv_func_gethostbyname_r_nargs=0) + if test $ol_cv_func_gethostbyname_r_nargs = 0 ; then + AC_TRY_COMPILE([#include + #include + #include + #include + #define BUFSIZE (sizeof(struct hostent)+10)], + [struct hostent hent;struct hostent *rhent; + char buffer[BUFSIZE]; + int bufsize=BUFSIZE;int h_errno; + (void)gethostbyname_r( "segovia.cs.purdue.edu", &hent, buffer, bufsize, &rhent, &h_errno); + return 0;], + ol_cv_func_gethostbyname_r_nargs=6, ol_cv_func_gethostbyname_r_nargs=0) + fi + ]) + if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then + AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS, $ol_cv_func_gethostbyname_r_nargs) + fi +])dnl +dnl check no of arguments for gethostbyaddr_r +AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS, + [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r, ol_cv_func_gethostbyaddr_r_nargs, + [AC_TRY_COMPILE([#include + #include + #include + #include + #define BUFSIZE (sizeof(struct hostent)+10)], + [struct hostent hent; char buffer[BUFSIZE]; + struct in_addr add={0x70707070}; + size_t alen=sizeof(struct in_addr); + int bufsize=BUFSIZE;int h_errno; + (void)gethostbyaddr_r( (void *)&(add.s_addr), + alen, AF_INET, &hent, buffer, bufsize, &h_errno); + return 0;], + ol_cv_func_gethostbyaddr_r_nargs=7, + ol_cv_func_gethostbyaddr_r_nargs=0) + if test $ol_cv_func_gethostbyaddr_r_nargs = 0 ; then + AC_TRY_COMPILE([#include + #include + #include + #include + #define BUFSIZE (sizeof(struct hostent)+10)], + [struct hostent hent; struct hostent *rhent; char buffer[BUFSIZE]; + struct in_addr add={0x70707070}; + size_t alen=sizeof(struct in_addr); + int bufsize=BUFSIZE;int h_errno; + (void)gethostbyaddr_r( (void *)&(add.s_addr), + alen, AF_INET, &hent, buffer, bufsize, + &rhent, &h_errno); + return 0;], + ol_cv_func_gethostbyaddr_r_nargs=8, + ol_cv_func_gethostbyaddr_r_nargs=0) + fi + ]) + if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then + AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS, $ol_cv_func_gethostbyaddr_r_nargs) + fi +])dnl diff --git a/configure.in b/configure.in index 44904c3f40..0e1bc7649f 100644 --- a/configure.in +++ b/configure.in @@ -49,7 +49,6 @@ OL_ARG_ENABLE(cldap,[ --enable-cldap enable connectionless ldap], no)dnl OL_ARG_ENABLE(x_compile,[ --enable-x-compile enable cross compiling], no, [yes no])dnl - dnl General "with" options OL_ARG_ENABLE(dmalloc,[ --enable-dmalloc enable debug malloc support], no)dnl @@ -59,6 +58,8 @@ OL_ARG_WITH(threads,[ --with-threads use threads], auto, [auto posix mach lwp yes no manual] ) OL_ARG_WITH(yielding_select,[ --with-yielding-select with implicitly yielding select], auto, [auto yes no manual] ) +OL_ARG_WITH(tls,[ --with-tls use tls/ssl], + auto, [auto ssleay openssl yes no] ) dnl Server options @@ -261,6 +262,7 @@ SLAPD_PERL_CPPFLAGS= KRB_LIBS= TERMCAP_LIBS= +TLS_LIBS= dnl ---------------------------------------------------------------- dnl Checks for programs @@ -452,6 +454,35 @@ if test $ol_link_kerberos = yes ; then AC_DEFINE(HAVE_KERBEROS, 1, [define if you have Kerberos]) fi +dnl +dnl Check for SSL/TLS +dnl +ol_link_tls=no +if test $ol_with_tls = auto -o $ol_with_tls = ssleay \ + -o $ol_with_tls = openssl ; then + + AC_CHECK_HEADERS(ssl.h) + + if test $ac_cv_header_ssl_h = yes ; then + AC_CHECK_LIB( ssl, SSLeay_add_ssl_algorithms, + [have_ssleay=yes], [have_ssleay=no], [-lcrypto]) + + if test $have_ssleay = yes ; then + ol_with_tls=found + ol_link_tls=yes + + AC_DEFINE( HAVE_SSLEAY, 1, + [define if you have SSLeay] ) + + TLS_LIBS="-lssl -lcrypto" + fi + fi +fi + +if test $ol_link_tls = yes ; then + AC_DEFINE( HAVE_TLS, 1, [define if you have TLS] ) +fi + ol_link_threads=no if test $ol_with_threads = auto -o $ol_with_threads = yes \ -o $ol_with_threads = posix ; then @@ -1516,8 +1547,22 @@ else ol_cv_func_ctime_r=0 fi +if test "$ac_cv_func_gethostbyname_r" = yes ; then + OL_FUNC_GETHOSTBYNAME_R_NARGS +else + ol_cv_func_gethostbyname_r=0 +fi + +if test "$ac_cv_func_gethostbyaddr_r" = yes ; then + OL_FUNC_GETHOSTBYADDR_R_NARGS +else + ol_cv_func_gethostbyaddr_r=0 +fi + if test "$ac_cv_func_ctime_r" = yes \ -a "$ol_cv_func_ctime_r_nargs" -ge 2 -a "$ol_cv_func_ctime_r_nargs" -le 3 \ + -a "$ol_cv_func_gethostbyname_r_nargs" -ge 5 -a "$ol_cv_func_gethostbyname_r_nargs" -le 6 \ + -a "$ol_cv_func_gethostbyaddr_r_nargs" -ge 5 -a "$ol_cv_func_gethostbyaddr_r_nargs" -le 6 \ -a "$ac_cv_func_gethostbyaddr_r" = yes \ -a "$ac_cv_func_gethostbyname_r" = yes \ ; then @@ -1650,6 +1695,7 @@ AC_SUBST(SLAPD_PERL_LDFLAGS) AC_SUBST(KRB_LIBS) AC_SUBST(TERMCAP_LIBS) +AC_SUBST(TLS_LIBS) dnl ---------------------------------------------------------------- dnl final output diff --git a/libraries/libldap/util-int.c b/libraries/libldap/util-int.c index f40082c64d..2316716da6 100644 --- a/libraries/libldap/util-int.c +++ b/libraries/libldap/util-int.c @@ -4,8 +4,8 @@ */ /* * util-int.c Various functions to replace missing threadsafe ones. - * Without the real *_r funcs, things will work, but won't be - * threadsafe. + * Without the real *_r funcs, things will + * work, but might not be threadsafe. * * Written by Bart Hartgers. * @@ -19,6 +19,7 @@ * in file LICENSE in the top-level directory of the distribution. */ + #include "portable.h" #include @@ -90,6 +91,11 @@ int ldap_pvt_gethostbyname_a( int *herrno_ptr ) { #if defined( HAVE_GETHOSTBYNAME_R ) + +# if (GETHOSTBYNAME_R_NARGS > 6) || (GETHOSTBYNAME_R_NARGS < 5) + Ouch! gethostbyname_r() must have either 5 or 6 args +#endif + # define NEED_SAFE_REALLOC 1 int r=-1; int buflen=BUFSTART; @@ -97,8 +103,19 @@ int ldap_pvt_gethostbyname_a( for(;buflen 8) || (GETHOSTBYADDR_R_NARGS < 7) + Ouch! gethostbyaddr_r() must have either 7 or 8 args +#endif + # undef NEED_SAFE_REALLOC # define NEED_SAFE_REALLOC int r=-1; @@ -165,9 +187,17 @@ int ldap_pvt_gethostbyaddr_a( for(;buflenh_aliases; (*p) ; p++ ) { total_alias_len += strlen( *p ) + 1; - n_alias++; + n_alias++; } for( n_addr=0, p=src->h_addr_list; (*p) ; p++ ) {