Menu

#1336 net-snmp fails to build with OpenSSL 1.1.0

backport-needed
accepted
openssl (1)
5
2017-05-11
2016-12-06
No

Detected on: 'master' of git://git.code.sf.net/p/net-snmp/code
The build fails when compiled with OpenSSL 1.1.0
With this patch, net-snmp builds with both OpenSSL 1.0.x and 1.1.x

1 Attachments

Related

Patches: #1336

Discussion

  • Niels Baggesen

    Niels Baggesen - 2016-12-15

    ... and DTLSUDP for that matter

     
  • Niels Baggesen

    Niels Baggesen - 2017-03-22

    Thanks for the patch. It has been applied, slightly modified to accomodate LibreSSL, for the 5.7 patches branch and for trunk.

     
  • Anonymous

    Anonymous - 2017-04-01

    building both trunk & 5.7-patches branches on linux64, with openssl 1.1 API libs,

    build currently fails @

    make V=1
        ...
        libtool: link: /usr/bin/gcc-6 -O3 -Wall -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -DNETSNMP_REMOVE_U64 -O3 -Wall -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native -Ulinux -Dlinux=linux -D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/CORE -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-type-limits -Wno-unused-result -Wno-sign-compare -o .libs/snmpusm .libs/snmpusm.o -Wl,-rpath -Wl,/usr/local/lib64 -Wl,-rpath -Wl,/usr/local/openssl11/lib64  -L/usr/local/lib64 -L/usr/local/openssl11/lib64 ../snmplib/.libs/libnetsnmp.so -lssh2 -lssl -lcrypto -lnl-3 -lm -Wl,-rpath -Wl,/usr/local/net-snmp/lib64
        .libs/snmpusm.o: In function `get_USM_DH_key':
        snmpusm.c:(.text+0xaac): undefined reference to `BN_num_bytes'
        snmpusm.c:(.text+0xc00): undefined reference to `BN_num_bytes'
        collect2: error: ld returned 1 exit status
        Makefile:319: recipe for target 'snmpusm' failed
        make[1]: *** [snmpusm] Error 1
        make[1]: Leaving directory '/usr/local/src/net-snmp-git/apps'
        Makefile:657: recipe for target 'subdirs' failed
        make: *** [subdirs] Error 1
    

    in openssl, the symbol's defined in,

    grep -rlin BN_num_bytes /usr/local/openssl11 | grep h$
      /usr/local/openssl11/include/openssl/bn.h
    

    in net-snmp sources the symbol appears only in

    grep -rlni BN_num_bytes .
      ./agent/mibgroup/snmp-usm-dh-objects-mib/usmDHUserKeyTable/usmDHUserKeyTable_data_get.c
      ./apps/snmpusm.c
    

    which both

    #include <openssl/dh.h>
    

    but in /usr/local/openssl11/include/openssl/dh.h

    ...
    # if OPENSSL_API_COMPAT < 0x10100000L
    #  include <openssl/bn.h>
    # endif
    ...
    

    i.e., include ONLY for pre-v1.1.0 openssl

    # if OPENSSL_API_COMPAT < 0x10100000L
    #  include <openssl/bn.h>
    # endif
    
     
    • Bill Fenner

      Bill Fenner - 2017-04-03

      Can you try adding

      #include <openssl/bn.h>
      

      below the existing #includes of dh.h? E.g., https://www.openssl.org/docs/man1.1.0/crypto/BN_num_bytes.html suggests that explicitly including is required, and maybe it was just accidental namespace pollution that made it work before.

       
      • Anonymous

        Anonymous - 2017-04-03

        for,

          Net-SNMP Version:           5.8.dev
        

        I added

        ./apps/snmpusm.c
            ...
        58  #if defined(HAVE_OPENSSL_DH_H) && defined(HAVE_LIBCRYPTO)
            #include <openssl/dh.h>
            #endif /* HAVE_OPENSSL_DH_H && HAVE_LIBCRYPTO */
        +   #include <openssl/bn.h>
            ...
        

        note, that's AFTER the HAVE_OPENSSL_DH_H if clause -- not sure if that's (still) the appropriate check.

        that^ seems to get past the problem; I see no more related error.

        but, atm, I'm failing at

        /usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: warning: libssl.so.1.0.0, needed by /usr/local/mariadb/lib64/libmariadb.so, may conflict with libssl.so.1.1
        /usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: warning: libcrypto.so.1.0.0, needed by /usr/local/mariadb/lib64/libmariadb.so, may conflict with libcrypto.so.1.1
        ./.libs/libnetsnmptrapd.so: undefined reference to `load_defaults'
        ./.libs/libnetsnmptrapd.so: undefined reference to `my_init'
        collect2: error: ld returned 1 exit status
        Makefile:302: recipe for target 'snmptrapd' failed
        make[1]: *** [snmptrapd] Error 1
        make[1]: Leaving directory '/usr/local/src/net-snmp-git/apps'
        Makefile:657: recipe for target 'subdirs' failed
        make: *** [subdirs] Error 1
        

        due to not yet having updated my mariadb libs (working on it). So not certain that the reported problem is gone, though likely, or just not hitting it (yet) ...

        Can check back in once I've cleaned up the mariadb libs ...

         
  • Anonymous

    Anonymous - 2017-04-03

    Can check back in once I've cleaned up the mariadb libs ...

    Well, that's gonna take awhile to resolve, so for my net-snmp

        ./configure \
        --with-openssl=/usr/local/openssl11 \
    -   --with-mysql \
    +   --without-mysql \
    +   --disable-manuals
    ...
    
    NOTE, the --disable-manuals is unrelated, but temporarily avoids a 'new' error:
    
            ...
            make[1]: Entering directory '/usr/local/src/net-snmp-git/man'
            mkdir /usr/local/net-snmp/share/man
            mkdir /usr/local/net-snmp/share/man/man1
            mkdir /usr/local/net-snmp/share/man/man3
            mkdir /usr/local/net-snmp/share/man/man5
            mkdir /usr/local/net-snmp/share/man/man8
            make[1]: *** No rule to make target '../sedscript', needed by 'agentxtrap.1'.  Stop.
            make[1]: Leaving directory '/usr/local/src/net-snmp-git/man'
            Makefile:953: recipe for target 'installsubdirs' failed
            make: *** [installsubdirs] Error 1
    

    now builds/installs successfully, no errors, and is seemingly correctly linked,

        sbin/snmpd --version
    
            NET-SNMP version:  5.8.dev
            Web:               http://www.net-snmp.org/
            Email:             net-snmp-coders@lists.sourceforge.net
    
        ldd sbin/snmpd | egrep -i "libssh|libssl|libcrypto"
            libssh2.so.1 => /usr/local/lib64/libssh2.so.1 (0x00007f1037ec6000)
            libssl.so.1.1 => /usr/local/openssl11/lib64/libssl.so.1.1 (0x00007f1037c58000)
            libcrypto.so.1.1 => /usr/local/openssl11/lib64/libcrypto.so.1.1 (0x00007f10377af000)
    
     
  • Anonymous

    Anonymous - 2017-05-11

    Revisiting this now that mariadb 10.2-dev's got openssl11 support working.

    1st, the

    ./.libs/libnetsnmptrapd.so: undefined reference to `load_defaults'
    ./.libs/libnetsnmptrapd.so: undefined reference to `my_init'
    

    issue, above, I've opened as

    build fails @ "undefined reference to `load_defaults'" when linking mariadb
    https://sourceforge.net/p/net-snmp/bugs/2782/

     
  • Anonymous

    Anonymous - 2017-05-11

    so with the (partial?) workaround for the 'load_defaults' issue, AND having added the

    #include <openssl/bn.h>
    

    as above, build again/still fails at

    libtool: link: /usr/bin/gcc-7 -O3 -Wall -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -DNETSNMP_REMOVE_U64 -O3 -Wall -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fmessage-length=0 -grecord-gcc-switches -march=native -mtune=native -Ulinux -Dlinux=linux -D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/CORE -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-type-limits -Wno-unused-result -Wno-sign-compare -o .libs/snmpd .libs/snmpd.o -Wl,-E -Wl,-rpath -Wl,/usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/CORE  ./.libs/libnetsnmpagent.so -L/usr/lib -L/usr/local/lib64 -L/usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/CORE ./.libs/libnetsnmpmibs.so /usr/local/src/net-snmp-git/agent/.libs/libnetsnmpagent.so -lwrap /usr/local/src/net-snmp-git/snmplib/.libs/libnetsnmp.so -lsensors -lpci -lrpm -lrpmio /usr/local/lib64/libpcre.so -lperl -ldl -lcrypt -lpthread ../snmplib/.libs/libnetsnmp.so -lcrypto -lnl-3 -lm -pthread -Wl,-rpath -Wl,/usr/local/net-snmp/lib64
    /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libdl.so when searching for -ldl
    /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libcrypt.so when searching for -lcrypt
    /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
    /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libm.so when searching for -lm
    /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for -lpthread
    /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
    /usr/local/src/net-snmp-git/snmplib/.libs/libnetsnmp.so: undefined reference to `EVP_MD_CTX_free'
    /usr/local/src/net-snmp-git/snmplib/.libs/libnetsnmp.so: undefined reference to `EVP_MD_CTX_new'
    collect2: error: ld returned 1 exit status
    Makefile:1068: recipe for target 'snmpd' failed
    make[1]: *** [snmpd] Error 1
    make[1]: Leaving directory '/usr/local/src/net-snmp-git/agent'
    Makefile:657: recipe for target 'subdirs' failed
    make: *** [subdirs] Error 1
    

    with openssl build's 1.1-only API def'd

    -DOPENSSL_API_COMPAT=0x10100000L
    

    those syms, EVP_MD_CTX_free & EVP_MD_CTX_new, as well as others, are deprecated.

    cref:

    https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes .

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.