1*4882a593SmuzhiyunFrom bd59be8e4e339870a1400f6866a7b73ca11f6460 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Giulio Benetti <giulio.benetti@micronovasrl.com> 3*4882a593SmuzhiyunDate: Wed, 12 Sep 2018 20:16:39 +0200 4*4882a593SmuzhiyunSubject: [PATCH] configure, static linking: Fix SSL checks 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunDuring checking of DTLS_method, the stub program is linked only with -ssl 7*4882a593Smuzhiyunlibssl.a lacks some function from -lcrypto: 8*4882a593SmuzhiyunRAND_*() 9*4882a593SmuzhiyunERR_*() 10*4882a593SmuzhiyunBUF_MEM_*() 11*4882a593Smuzhiyunetc. 12*4882a593Smuzhiyunand -lz: 13*4882a593Smuzhiyun- inflate() 14*4882a593Smuzhiyun- deflate() 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunAppend -lcrypto and -lz to LIBS variable when checking DTLS_method. 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunSee also https://sourceforge.net/p/net-snmp/patches/1374/. 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunSigned-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> 21*4882a593Smuzhiyun[bvanassche: Edited subject / rewrote this patch] 22*4882a593Smuzhiyun[yann.morin.1998@free.fr: 23*4882a593Smuzhiyun - use an actual backport of bd59be8e4e339870a1400f6866a7b73ca11f6460 24*4882a593Smuzhiyun] 25*4882a593SmuzhiyunSigned-off-by: Yann E. MORIN <yann.morin.1998@free.fr> 26*4882a593Smuzhiyun--- 27*4882a593Smuzhiyun configure | 52 ++++++++++++++++++++++++++++++++++--- 28*4882a593Smuzhiyun configure.d/config_os_libs2 | 14 +++++++--- 29*4882a593Smuzhiyun 2 files changed, 58 insertions(+), 8 deletions(-) 30*4882a593Smuzhiyun 31*4882a593Smuzhiyundiff --git a/configure b/configure 32*4882a593Smuzhiyunindex 6504a8e58a..1116cecaad 100755 33*4882a593Smuzhiyun--- a/configure 34*4882a593Smuzhiyun+++ b/configure 35*4882a593Smuzhiyun@@ -23228,16 +23228,60 @@ fi 36*4882a593Smuzhiyun { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_md5" >&5 37*4882a593Smuzhiyun $as_echo "$ac_cv_lib_crypto_EVP_md5" >&6; } 38*4882a593Smuzhiyun if test "x$ac_cv_lib_crypto_EVP_md5" = xyes; then : 39*4882a593Smuzhiyun- CRYPTO="crypto" 40*4882a593Smuzhiyun+ CRYPTO="crypto"; LIBCRYPTO="-lcrypto" 41*4882a593Smuzhiyun+else 42*4882a593Smuzhiyun+ 43*4882a593Smuzhiyun+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_md5 in -lcrypto" >&5 44*4882a593Smuzhiyun+$as_echo_n "checking for EVP_md5 in -lcrypto... " >&6; } 45*4882a593Smuzhiyun+if ${ac_cv_lib_crypto_EVP_md5+:} false; then : 46*4882a593Smuzhiyun+ $as_echo_n "(cached) " >&6 47*4882a593Smuzhiyun+else 48*4882a593Smuzhiyun+ ac_check_lib_save_LIBS=$LIBS 49*4882a593Smuzhiyun+LIBS="-lcrypto -lz $LIBS" 50*4882a593Smuzhiyun+cat confdefs.h - <<_ACEOF >conftest.$ac_ext 51*4882a593Smuzhiyun+/* end confdefs.h. */ 52*4882a593Smuzhiyun+ 53*4882a593Smuzhiyun+/* Override any GCC internal prototype to avoid an error. 54*4882a593Smuzhiyun+ Use char because int might match the return type of a GCC 55*4882a593Smuzhiyun+ builtin and then its argument prototype would still apply. */ 56*4882a593Smuzhiyun+#ifdef __cplusplus 57*4882a593Smuzhiyun+extern "C" 58*4882a593Smuzhiyun+#endif 59*4882a593Smuzhiyun+char EVP_md5 (); 60*4882a593Smuzhiyun+int 61*4882a593Smuzhiyun+main () 62*4882a593Smuzhiyun+{ 63*4882a593Smuzhiyun+return EVP_md5 (); 64*4882a593Smuzhiyun+ ; 65*4882a593Smuzhiyun+ return 0; 66*4882a593Smuzhiyun+} 67*4882a593Smuzhiyun+_ACEOF 68*4882a593Smuzhiyun+if ac_fn_c_try_link "$LINENO"; then : 69*4882a593Smuzhiyun+ ac_cv_lib_crypto_EVP_md5=yes 70*4882a593Smuzhiyun+else 71*4882a593Smuzhiyun+ ac_cv_lib_crypto_EVP_md5=no 72*4882a593Smuzhiyun+fi 73*4882a593Smuzhiyun+rm -f core conftest.err conftest.$ac_objext \ 74*4882a593Smuzhiyun+ conftest$ac_exeext conftest.$ac_ext 75*4882a593Smuzhiyun+LIBS=$ac_check_lib_save_LIBS 76*4882a593Smuzhiyun+fi 77*4882a593Smuzhiyun+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_md5" >&5 78*4882a593Smuzhiyun+$as_echo "$ac_cv_lib_crypto_EVP_md5" >&6; } 79*4882a593Smuzhiyun+if test "x$ac_cv_lib_crypto_EVP_md5" = xyes; then : 80*4882a593Smuzhiyun+ CRYPTO="crypto"; LIBCRYPTO="-lcrypto -lz" 81*4882a593Smuzhiyun+fi 82*4882a593Smuzhiyun+ 83*4882a593Smuzhiyun+ 84*4882a593Smuzhiyun fi 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun- fi 87*4882a593Smuzhiyun+ else 88*4882a593Smuzhiyun+ LIBCRYPTO="-l${CRYPTO}" 89*4882a593Smuzhiyun+ fi 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun if test x$CRYPTO != x; then 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun $as_echo "#define HAVE_LIBCRYPTO 1" >>confdefs.h 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun- LIBCRYPTO="-l${CRYPTO}" 96*4882a593Smuzhiyun netsnmp_save_LIBS="$LIBS" 97*4882a593Smuzhiyun LIBS="$LIBCRYPTO" 98*4882a593Smuzhiyun for ac_func in AES_cfb128_encrypt EVP_sha224 EVP_sha384 EVP_MD_CTX_create EVP_MD_CTX_destroy EVP_MD_CTX_new EVP_MD_CTX_free DH_set0_pqg DH_get0_pqg DH_get0_key ASN1_STRING_get0_data X509_NAME_ENTRY_get_object X509_NAME_ENTRY_get_data X509_get_signature_nid 99*4882a593Smuzhiyun@@ -23291,7 +23335,7 @@ _ACEOF 100*4882a593Smuzhiyun LIBS="$netsnmp_save_LIBS" 101*4882a593Smuzhiyun fi 102*4882a593Smuzhiyun netsnmp_save_LIBS="$LIBS" 103*4882a593Smuzhiyun- LIBS="-lssl" 104*4882a593Smuzhiyun+ LIBS="-lssl $LIBCRYPTO" 105*4882a593Smuzhiyun for ac_func in TLS_method TLSv1_method DTLS_method DTLSv1_method SSL_library_init SSL_load_error_strings ERR_get_error_all 106*4882a593Smuzhiyun do : 107*4882a593Smuzhiyun as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` 108*4882a593Smuzhiyundiff --git a/configure.d/config_os_libs2 b/configure.d/config_os_libs2 109*4882a593Smuzhiyunindex 4a1ad1551f..75214cfff3 100644 110*4882a593Smuzhiyun--- a/configure.d/config_os_libs2 111*4882a593Smuzhiyun+++ b/configure.d/config_os_libs2 112*4882a593Smuzhiyun@@ -306,13 +306,19 @@ if test "x$tryopenssl" != "xno" -a "x$tryopenssl" != "xinternal"; then 113*4882a593Smuzhiyun LIBS="$netsnmp_save_LIBS" 114*4882a593Smuzhiyun 115*4882a593Smuzhiyun if test x$CRYPTO = x; then 116*4882a593Smuzhiyun- AC_CHECK_LIB([crypto], [EVP_md5], [CRYPTO="crypto"]) 117*4882a593Smuzhiyun- fi 118*4882a593Smuzhiyun+ AC_CHECK_LIB([crypto], [EVP_md5], 119*4882a593Smuzhiyun+ [CRYPTO="crypto"; LIBCRYPTO="-lcrypto"], [ 120*4882a593Smuzhiyun+ AC_CHECK_LIB([crypto], [EVP_md5], 121*4882a593Smuzhiyun+ [CRYPTO="crypto"; LIBCRYPTO="-lcrypto -lz"], [], 122*4882a593Smuzhiyun+ [-lz]) 123*4882a593Smuzhiyun+ ]) 124*4882a593Smuzhiyun+ else 125*4882a593Smuzhiyun+ LIBCRYPTO="-l${CRYPTO}" 126*4882a593Smuzhiyun+ fi 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun if test x$CRYPTO != x; then 129*4882a593Smuzhiyun AC_DEFINE(HAVE_LIBCRYPTO, 1, 130*4882a593Smuzhiyun [Define to 1 if you have the OpenSSL library (-lcrypto or -leay32).]) 131*4882a593Smuzhiyun- LIBCRYPTO="-l${CRYPTO}" 132*4882a593Smuzhiyun netsnmp_save_LIBS="$LIBS" 133*4882a593Smuzhiyun LIBS="$LIBCRYPTO" 134*4882a593Smuzhiyun AC_CHECK_FUNCS([AES_cfb128_encrypt]dnl 135*4882a593Smuzhiyun@@ -342,7 +348,7 @@ if test "x$tryopenssl" != "xno" -a "x$tryopenssl" != "xinternal"; then 136*4882a593Smuzhiyun LIBS="$netsnmp_save_LIBS" 137*4882a593Smuzhiyun fi 138*4882a593Smuzhiyun netsnmp_save_LIBS="$LIBS" 139*4882a593Smuzhiyun- LIBS="-lssl" 140*4882a593Smuzhiyun+ LIBS="-lssl $LIBCRYPTO" 141*4882a593Smuzhiyun AC_CHECK_FUNCS([TLS_method TLSv1_method DTLS_method DTLSv1_method]dnl 142*4882a593Smuzhiyun [SSL_library_init SSL_load_error_strings]) 143*4882a593Smuzhiyun LIBS="$netsnmp_save_LIBS" 144*4882a593Smuzhiyun-- 145*4882a593Smuzhiyun2.25.1 146*4882a593Smuzhiyun 147