diff --git a/configure b/configure index 26d120dec..d64ad9470 100755 --- a/configure +++ b/configure @@ -3874,6 +3874,48 @@ if test "x$ac_cv_lib_nsl_inet_ntoa" = xyes; then : INETLIB="-lnsl" fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAND_egd in -lcrypto" >&5 +$as_echo_n "checking for RAND_egd in -lcrypto... " >&6; } +if ${ac_cv_lib_crypto_RAND_egd+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcrypto $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char RAND_egd (); +int +main () +{ +return RAND_egd (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_crypto_RAND_egd=yes +else + ac_cv_lib_crypto_RAND_egd=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_RAND_egd" >&5 +$as_echo "$ac_cv_lib_crypto_RAND_egd" >&6; } +if test "x$ac_cv_lib_crypto_RAND_egd" = xyes; then : + +$as_echo "#define HAVE_RAND_EGD 1" >>confdefs.h + +fi + diff --git a/configure.ac b/configure.ac index 9b476f48e..70c1a8098 100644 --- a/configure.ac +++ b/configure.ac @@ -93,6 +93,8 @@ AC_CHECK_LIB(socket, socket, AC_CHECK_LIB(nsl, inet_ntoa, [IRCDLIBS="$IRCDLIBS-lnsl " INETLIB="-lnsl"]) +AC_CHECK_LIB(crypto, RAND_egd, + AC_DEFINE(HAVE_RAND_EGD, 1, [Define if the libcrypto has RAND_egd])) AC_SUBST(IRCDLIBS) AC_SUBST(MKPASSWDLIBS) diff --git a/include/dynconf.h b/include/dynconf.h index e41482612..193a81b8b 100644 --- a/include/dynconf.h +++ b/include/dynconf.h @@ -204,7 +204,11 @@ extern MODVAR aConfiguration iConf; #define SHOWCONNECTINFO iConf.show_connect_info #define OPER_ONLY_STATS iConf.oper_only_stats #define ANTI_SPAM_QUIT_MSG_TIME iConf.anti_spam_quit_message_time +#ifdef HAVE_RAND_EGD #define USE_EGD iConf.use_egd +#else +#define USE_EGD 0 +#endif #define EGD_PATH iConf.egd_path #define ircnetwork iConf.network.x_ircnetwork diff --git a/include/setup.h.in b/include/setup.h.in index e89be6524..7864a455b 100644 --- a/include/setup.h.in +++ b/include/setup.h.in @@ -109,6 +109,9 @@ /* Define if you have pstat */ #undef HAVE_PSTAT +/* Define if the libcrypto has RAND_egd */ +#undef HAVE_RAND_EGD + /* Define if you have setproctitle */ #undef HAVE_SETPROCTITLE diff --git a/src/random.c b/src/random.c index 132fa7568..36832aa8d 100644 --- a/src/random.c +++ b/src/random.c @@ -187,7 +187,7 @@ MEMORYSTATUS mstat; /* Grab non-OS specific "random" data */ #ifdef USE_SSL - #if OPENSSL_VERSION_NUMBER >= 0x000907000 + #if OPENSSL_VERSION_NUMBER >= 0x000907000 && defined(HAVE_RAND_EGD) if (EGD_PATH) { n = RAND_query_egd_bytes(EGD_PATH, rdat.egd, sizeof(rdat.egd)); }