eggdrop icon indicating copy to clipboard operation
eggdrop copied to clipboard

openssl / tcl include path problem under NetBSD

Open michaelortmann opened this issue 5 years ago • 0 comments

if under NetBSD, the official NetBSD tcl package is installed, the following situation (until now it leads to a compiler warning only) can occur:

$ ./configure
[...]
checking for Tcl library flags... -pthread -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -ltcl86 -lz -lpthread -lm
checking for Tcl header flags... -I/usr/pkg/include
[...]
checking for OPENSSL_buf2hexstr... no
checking for hex_to_string... yes
checking for OPENSSL_hexstr2buf... no
checking for string_to_hex... yes
[...]
SSL/TLS Support: yes (OpenSSL 1.0.2k  26 Jan 2017)
[...]
$ make
[...]
gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/pkg/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -c tls.c
In file included from tls.c:33:0:
tls.c: In function 'ssl_fpconv':
/usr/pkg/include/openssl/x509v3.h:635:24: warning: implicit declaration of function 'OPENSSL_hexstr2buf' [-Wimplicit-function-declaration]
 # define string_to_hex OPENSSL_hexstr2buf
                        ^
../config.h:347:28: note: in expansion of macro 'string_to_hex'
 #define OPENSSL_hexstr2buf string_to_hex
                            ^
tls.c:283:15: note: in expansion of macro 'OPENSSL_hexstr2buf'
   if ((sha1 = OPENSSL_hexstr2buf(in, &len))) {
               ^
tls.c:283:13: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   if ((sha1 = OPENSSL_hexstr2buf(in, &len))) {
             ^
In file included from tls.c:33:0:
/usr/pkg/include/openssl/x509v3.h:634:24: warning: implicit declaration of function 'OPENSSL_buf2hexstr' [-Wimplicit-function-declaration]
 # define hex_to_string OPENSSL_buf2hexstr
                        ^
../config.h:344:28: note: in expansion of macro 'hex_to_string'
 #define OPENSSL_buf2hexstr hex_to_string
                            ^
tls.c:284:10: note: in expansion of macro 'OPENSSL_buf2hexstr'
     fp = OPENSSL_buf2hexstr(sha1, len);
          ^
tls.c:284:8: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     fp = OPENSSL_buf2hexstr(sha1, len);
        ^
tls.c: In function 'ssl_getfp':
tls.c:332:11: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   if (!(p = OPENSSL_buf2hexstr(md, i)))
           ^
tls.c: In function 'ssl_getuid':
tls.c:363:3: warning: 'ASN1_STRING_data' is deprecated [-Wdeprecated-declarations]
   return (const char *) egg_ASN1_string_data(name);
   ^
In file included from /usr/pkg/include/openssl/e_os2.h:13:0,
                 from /usr/pkg/include/openssl/ssl.h:15,
                 from eggdrop.h:265,
                 from main.h:90,
                 from tls.c:27:
/usr/pkg/include/openssl/asn1.h:554:35: note: declared here
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
                                   ^
/usr/pkg/include/openssl/opensslconf.h:109:37: note: in definition of macro 'DECLARE_DEPRECATED'
 #   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));
                                     ^
/usr/pkg/include/openssl/asn1.h:554:1: note: in expansion of macro 'DEPRECATEDIN_1_1_0'
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
 ^
tls.c: In function 'ssl_verifycn':
tls.c:437:9: warning: 'ASN1_STRING_data' is deprecated [-Wdeprecated-declarations]
         cn = (const char *) egg_ASN1_string_data(gn->d.ia5);
         ^
In file included from /usr/pkg/include/openssl/e_os2.h:13:0,
                 from /usr/pkg/include/openssl/ssl.h:15,
                 from eggdrop.h:265,
                 from main.h:90,
                 from tls.c:27:
/usr/pkg/include/openssl/asn1.h:554:35: note: declared here
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
                                   ^
/usr/pkg/include/openssl/opensslconf.h:109:37: note: in definition of macro 'DECLARE_DEPRECATED'
 #   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));
                                     ^
/usr/pkg/include/openssl/asn1.h:554:1: note: in expansion of macro 'DEPRECATEDIN_1_1_0'
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
 ^
tls.c:474:9: warning: 'ASN1_STRING_data' is deprecated [-Wdeprecated-declarations]
         cn = (const char *) egg_ASN1_string_data(name);
         ^
In file included from /usr/pkg/include/openssl/e_os2.h:13:0,
                 from /usr/pkg/include/openssl/ssl.h:15,
                 from eggdrop.h:265,
                 from main.h:90,
                 from tls.c:27:
/usr/pkg/include/openssl/asn1.h:554:35: note: declared here
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
                                   ^
/usr/pkg/include/openssl/opensslconf.h:109:37: note: in definition of macro 'DECLARE_DEPRECATED'
 #   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));
                                     ^
/usr/pkg/include/openssl/asn1.h:554:1: note: in expansion of macro 'DEPRECATEDIN_1_1_0'
 DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
 ^
tls.c: In function 'ssl_showcert':
tls.c:605:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     buf = OPENSSL_buf2hexstr(md, len);
         ^
tls.c:610:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     buf = OPENSSL_buf2hexstr(md, len);
         ^
[...]

There are 2 openssl versions installed:

$ /usr/bin/openssl version
OpenSSL 1.0.2k  26 Jan 2017
$ /usr/pkg/bin/openssl version
OpenSSL 1.1.1e  17 Mar 2020

./configure picks up the one under /usr, so far so good

then .configure picks up tcl under /usr/pkg, so far so good

but then configure will add tcls include path, that was found during configure:

checking for Tcl header flags... -I/usr/pkg/include

and that overrides /usr/include, so make picks up the wrong openssl header files, the ones it didnt configure with.

I guess the solution is, that eggdrop should use the tcl include path and lib path for configuring openssl, because later during make (and probably in the final executable) it will use those paths.

$ ./configure
checking for Tcl library flags... -pthread -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -ltcl86 -lz -lpthread -lm
checking for Tcl header flags... -I/usr/pkg/include
$ make
[...]
---------- Yeah! That's the compiling, now the linking! ----------

Linking eggdrop (debug build).

gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/pkg/include -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS  -o ../eggdrop bg.o botcmd.o botmsg.o botnet.o chanprog.o cmds.o dcc.o  dccutil.o dns.o flags.o language.o match.o main.o mem.o misc.o misc_file.o  modules.o net.o rfc1459.o tcl.o tcldcc.o tclhash.o tclmisc.o tcluser.o  tls.o userent.o userrec.o users.o  -pthread -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -ltcl86 -lz -lpthread -lm -lssl -lcrypto md5/md5c.o compat/*.o `cat mod/mod.xlibs`
[...]
$ ldd eggdrop
eggdrop:
        -ltcl86 => /usr/pkg/lib/libtcl86.so
        -lz.1 => /usr/lib/libz.so.1
        -lc.12 => /usr/lib/libc.so.12
        -lpthread.1 => /usr/lib/libpthread.so.1
        -lm.0 => /usr/lib/libm.so.0
        -lssl.1.1 => /usr/pkg/lib/libssl.so.1.1
        -lcrypto.1.1 => /usr/pkg/lib/libcrypto.so.1.1

This problem only happens, if the 2 installed openssl versions differ significantly in their API. It could become a problem again, now that we are nearing OpenSSL 3.0.

michaelortmann avatar Oct 10 '20 23:10 michaelortmann