From: acspike Date: Sun, 7 Jan 2007 17:51:26 +0000 (+0000) Subject: use relaytool to weak link libssl X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f4f76ab18b014c84d2b6abdd24fe5ac94dda22e5;p=inkscape.git use relaytool to weak link libssl --- diff --git a/Makefile.am b/Makefile.am index 650f1d3f8..c06d15db3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,6 +24,7 @@ man_MANS = inkscape.1 \ inkview.1 EXTRA_DIST = \ + acinclude.m4 \ fix-roff-punct \ intltool-extract.in \ intltool-merge.in \ diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 000000000..5cd65aea0 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,30 @@ +dnl Usage: RELAYTOOL(LIBRARY_NAME, LIBS, CFLAGS, ACTION-IF-WEAK-LINK-IS-POSSIBLE) + +dnl Example: +dnl RELAYTOOL("gtkspell", GTKSPELL_LIBS, GTKSPELL_CFLAGS, gtkspell_weak=yes) +dnl Will modify GTKSPELL_LIBS to include a call to relaytool if available +dnl or if not, will modify GTKSPELL_CFLAGS to include -D switches to define +dnl libgtkspell_is_present=1 and libgtkspell_symbol_is_present=1 + +AC_DEFUN([RELAYTOOL], [ + if test -z "$RELAYTOOL_PROG"; then + AC_PATH_PROG(RELAYTOOL_PROG, relaytool, no) + fi + + AC_MSG_CHECKING(whether we can weak link $1) + + _RELAYTOOL_PROCESSED_NAME=`echo "$1" | sed 's/-/_/g;s/\./_/g;'` + _RELAYTOOL_UPPER_NAME=`echo $_RELAYTOOL_PROCESSED_NAME | tr '[[:lower:]]' '[[:upper:]]'` + + if test "$RELAYTOOL_PROG" = "no"; then + AC_MSG_RESULT(no) + $3="-DRELAYTOOL_${_RELAYTOOL_UPPER_NAME}='static const int lib${_RELAYTOOL_PROCESSED_NAME}_is_present = 1; static int __attribute__((unused)) lib${_RELAYTOOL_PROCESSED_NAME}_symbol_is_present(char *m) { return 1; }' $$3" + else + AC_MSG_RESULT(yes) + $2=`echo $$2|sed 's/\`/\\\\\`/g;'` + $2="-Wl,--gc-sections \`relaytool --relay $1 $$2\`" + $3="-DRELAYTOOL_${_RELAYTOOL_UPPER_NAME}='extern int lib${_RELAYTOOL_PROCESSED_NAME}_is_present; extern int lib${_RELAYTOOL_PROCESSED_NAME}_symbol_is_present(char *s);' $$3" + $4 + fi +]) + diff --git a/build.xml b/build.xml index 77f89ae6a..43368b645 100644 --- a/build.xml +++ b/build.xml @@ -164,6 +164,7 @@ -DHAVE_CONFIG_H -DXP_WIN -D_INTL_REDIRECT_INLINE + -DRELAYTOOL_SSL='static const int libssl_is_present=1; static int __attribute__((unused)) libssl_symbol_is_present(char *s){ return 1; }' -DWITH_INKBOARD -DHAVE_SSL diff --git a/build28.xml b/build28.xml index 5acbf67d7..d4c0262cf 100644 --- a/build28.xml +++ b/build28.xml @@ -93,6 +93,7 @@ -DHAVE_CONFIG_H -DXP_WIN -D_INTL_REDIRECT_INLINE + -DRELAYTOOL_SSL='static const int libssl_is_present=1; static int __attribute__((unused)) libssl_symbol_is_present(char *s){ return 1; }' -DWITH_INKBOARD -DHAVE_SSL diff --git a/configure.ac b/configure.ac index 0eb5d66e1..639e4746a 100644 --- a/configure.ac +++ b/configure.ac @@ -494,6 +494,8 @@ if test "x$with_inkboard" = "xyes"; then if test "x$with_inkboard_ssl" = "xyes"; then dnl OpenSSL found; enable SSL support in Pedro INKBOARD_CFLAGS="$INKBOARD_CFLAGS -DHAVE_SSL" + RELAYTOOL([ssl], INKBOARD_LIBS, INKBOARD_CFLAGS, [inkboard_weak=yes]) + RELAYTOOL([crypto], INKBOARD_LIBS, INKBOARD_CFLAGS, [inkboard_weak=yes]) AC_DEFINE(WITH_INKBOARD_SSL,1,[Build in SSL support for Inkboard]) fi else diff --git a/m4/Makefile.am b/m4/Makefile.am index 26e2af705..3343be6c5 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -1,3 +1,3 @@ EXTRA_DIST=codeset.m4 glibc21.m4 isc-posix.m4 progtest.m4 gettext.m4 \ - iconv.m4 lcmessage.m4 + iconv.m4 lcmessage.m4 relaytool.m4 diff --git a/m4/relaytool.m4 b/m4/relaytool.m4 new file mode 100644 index 000000000..5cd65aea0 --- /dev/null +++ b/m4/relaytool.m4 @@ -0,0 +1,30 @@ +dnl Usage: RELAYTOOL(LIBRARY_NAME, LIBS, CFLAGS, ACTION-IF-WEAK-LINK-IS-POSSIBLE) + +dnl Example: +dnl RELAYTOOL("gtkspell", GTKSPELL_LIBS, GTKSPELL_CFLAGS, gtkspell_weak=yes) +dnl Will modify GTKSPELL_LIBS to include a call to relaytool if available +dnl or if not, will modify GTKSPELL_CFLAGS to include -D switches to define +dnl libgtkspell_is_present=1 and libgtkspell_symbol_is_present=1 + +AC_DEFUN([RELAYTOOL], [ + if test -z "$RELAYTOOL_PROG"; then + AC_PATH_PROG(RELAYTOOL_PROG, relaytool, no) + fi + + AC_MSG_CHECKING(whether we can weak link $1) + + _RELAYTOOL_PROCESSED_NAME=`echo "$1" | sed 's/-/_/g;s/\./_/g;'` + _RELAYTOOL_UPPER_NAME=`echo $_RELAYTOOL_PROCESSED_NAME | tr '[[:lower:]]' '[[:upper:]]'` + + if test "$RELAYTOOL_PROG" = "no"; then + AC_MSG_RESULT(no) + $3="-DRELAYTOOL_${_RELAYTOOL_UPPER_NAME}='static const int lib${_RELAYTOOL_PROCESSED_NAME}_is_present = 1; static int __attribute__((unused)) lib${_RELAYTOOL_PROCESSED_NAME}_symbol_is_present(char *m) { return 1; }' $$3" + else + AC_MSG_RESULT(yes) + $2=`echo $$2|sed 's/\`/\\\\\`/g;'` + $2="-Wl,--gc-sections \`relaytool --relay $1 $$2\`" + $3="-DRELAYTOOL_${_RELAYTOOL_UPPER_NAME}='extern int lib${_RELAYTOOL_PROCESSED_NAME}_is_present; extern int lib${_RELAYTOOL_PROCESSED_NAME}_symbol_is_present(char *s);' $$3" + $4 + fi +]) + diff --git a/packaging/autopackage/default.apspec.in b/packaging/autopackage/default.apspec.in index 9c332646b..aec1dafdd 100644 --- a/packaging/autopackage/default.apspec.in +++ b/packaging/autopackage/default.apspec.in @@ -16,7 +16,7 @@ PackageDesktop: share/applications/inkscape.desktop if [ ! -x configure ]; then ./autogen.sh fi -export APBUILD_STATIC="popt gc gccpp gtkmm-2.4 gdkmm-2.4 atkmm-1.6 pangomm-1.4 glibmm-2.4 sigc-2.0 Xrender lcms cairo Xfixes Xext ssl crypto" +export APBUILD_STATIC="popt gc gccpp gtkmm-2.4 gdkmm-2.4 atkmm-1.6 pangomm-1.4 glibmm-2.4 sigc-2.0 Xrender lcms cairo Xfixes Xext" export APBUILD_PROJECTNAME=inkscape PATH=/usr/local/src/inkscape/extra/static/bin:$PATH diff --git a/src/dom/io/socket.cpp b/src/dom/io/socket.cpp index 31eeb56ba..22b03b8b3 100644 --- a/src/dom/io/socket.cpp +++ b/src/dom/io/socket.cpp @@ -53,6 +53,8 @@ #ifdef HAVE_SSL #include #include + +RELAYTOOL_SSL #endif @@ -205,12 +207,15 @@ void TcpSocket::init() WSAStartup( wVersionRequested, &wsaData ); #endif #ifdef HAVE_SSL - sslStream = NULL; - sslContext = NULL; + if (libssl_is_present) + { + sslStream = NULL; + sslContext = NULL; CRYPTO_set_locking_callback(cryptoLockCallback); - CRYPTO_set_id_callback(cryptoIdCallback); - SSL_library_init(); - SSL_load_error_strings(); + CRYPTO_set_id_callback(cryptoIdCallback); + SSL_library_init(); + SSL_load_error_strings(); + } #endif tcp_socket_inited = true; } @@ -285,6 +290,8 @@ static void infoCallback(const SSL *ssl, int where, int ret) bool TcpSocket::startTls() { #ifdef HAVE_SSL + if (libssl_is_present) + { sslStream = NULL; sslContext = NULL; @@ -335,6 +342,7 @@ bool TcpSocket::startTls() } sslEnabled = true; + } #endif /*HAVE_SSL*/ return true; } @@ -397,6 +405,8 @@ bool TcpSocket::disconnect() bool ret = true; connected = false; #ifdef HAVE_SSL + if (libssl_is_present) + { if (sslEnabled) { if (sslStream) @@ -419,6 +429,7 @@ bool TcpSocket::disconnect() } sslStream = NULL; sslContext = NULL; + } #endif /*HAVE_SSL*/ #ifdef __WIN32__ @@ -460,7 +471,10 @@ long TcpSocket::available() if (count<=0 && sslEnabled) { #ifdef HAVE_SSL - return SSL_pending(sslStream); + if (libssl_is_present) + { + return SSL_pending(sslStream); + } #endif } return count; @@ -480,6 +494,8 @@ bool TcpSocket::write(int ch) if (sslEnabled) { #ifdef HAVE_SSL + if (libssl_is_present) + { int r = SSL_write(sslStream, &c, 1); if (r<=0) { @@ -490,6 +506,7 @@ bool TcpSocket::write(int ch) return -1; } } + } #endif } else @@ -518,6 +535,8 @@ bool TcpSocket::write(const DOMString &strArg) if (sslEnabled) { #ifdef HAVE_SSL + if (libssl_is_present) + { int r = SSL_write(sslStream, (unsigned char *)str.c_str(), len); if (r<=0) { @@ -528,6 +547,7 @@ bool TcpSocket::write(const DOMString &strArg) return -1; } } + } #endif } else @@ -572,6 +592,8 @@ int TcpSocket::read() if (sslEnabled) { #ifdef HAVE_SSL + if (libssl_is_present) + { if (!sslStream) return -1; int r = SSL_read(sslStream, &ch, 1); @@ -591,6 +613,7 @@ int TcpSocket::read() ERR_error_string(ERR_get_error(), NULL)); return -1; } + } #endif } else diff --git a/src/pedro/pedroutil.cpp b/src/pedro/pedroutil.cpp index e08bed0a6..13577bf8f 100644 --- a/src/pedro/pedroutil.cpp +++ b/src/pedro/pedroutil.cpp @@ -48,6 +48,9 @@ #endif /* UNIX */ +#ifdef HAVE_SSL +RELAYTOOL_SSL +#endif namespace Pedro @@ -995,12 +998,15 @@ void TcpSocket::init() WSAStartup( wVersionRequested, &wsaData ); #endif #ifdef HAVE_SSL + if (libssl_is_present) + { sslStream = NULL; sslContext = NULL; CRYPTO_set_locking_callback(cryptoLockCallback); CRYPTO_set_id_callback(cryptoIdCallback); SSL_library_init(); SSL_load_error_strings(); + } #endif tcp_socket_inited = true; } @@ -1027,7 +1033,12 @@ bool TcpSocket::isConnected() bool TcpSocket::getHaveSSL() { #ifdef HAVE_SSL - return true; + if (libssl_is_present) + { + return true; + } else { + return false; + } #else return false; #endif @@ -1094,7 +1105,13 @@ bool TcpSocket::startTls() "SSL starttls() error: client not compiled with SSL enabled\n"); return false; #else /*HAVE_SSL*/ - + if (!libssl_is_present) + { + fprintf(stderr, + "SSL starttls() error: the correct version of libssl was not found \n"); + return false; + } else { + sslStream = NULL; sslContext = NULL; @@ -1157,6 +1174,7 @@ bool TcpSocket::startTls() sslEnabled = true; return true; + } #endif /* HAVE_SSL */ } @@ -1218,6 +1236,8 @@ bool TcpSocket::disconnect() bool ret = true; connected = false; #ifdef HAVE_SSL + if (libssl_is_present) + { if (sslEnabled) { if (sslStream) @@ -1240,6 +1260,7 @@ bool TcpSocket::disconnect() } sslStream = NULL; sslContext = NULL; + } #endif /*HAVE_SSL*/ #ifdef __WIN32__ @@ -1281,7 +1302,10 @@ long TcpSocket::available() if (count<=0 && sslEnabled) { #ifdef HAVE_SSL - return SSL_pending(sslStream); + if (libssl_is_present) + { + return SSL_pending(sslStream); + } #endif } return count; @@ -1301,6 +1325,8 @@ bool TcpSocket::write(int ch) if (sslEnabled) { #ifdef HAVE_SSL + if (libssl_is_present) + { int r = SSL_write(sslStream, &c, 1); if (r<=0) { @@ -1311,6 +1337,7 @@ bool TcpSocket::write(int ch) return -1; } } + } #endif } else @@ -1337,6 +1364,8 @@ bool TcpSocket::write(char *str) if (sslEnabled) { #ifdef HAVE_SSL + if (libssl_is_present) + { int r = SSL_write(sslStream, (unsigned char *)str, len); if (r<=0) { @@ -1347,6 +1376,7 @@ bool TcpSocket::write(char *str) return -1; } } + } #endif } else @@ -1396,6 +1426,8 @@ int TcpSocket::read() if (sslEnabled) { #ifdef HAVE_SSL + if (libssl_is_present) + { if (!sslStream) return -1; int r = SSL_read(sslStream, &ch, 1); @@ -1415,6 +1447,7 @@ int TcpSocket::read() ERR_error_string(ERR_get_error(), NULL)); return -1; } + } #endif } else