From 65f2f289d106efbfa73002d10294ff22e7af834a Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Mon, 10 Feb 2014 09:22:24 -0500 Subject: [PATCH] MDEV#5626 : Cannot install InnoDB/XtraDB plugin (undefined symbol: wsrep_md5_update) Refactored wsrep's md5 related code so that Innodb/xtradb no longer relies on mysys_ssl for md5 implementation. --- include/my_md5.h | 6 --- mysys_ssl/my_md5.cc | 31 ----------- storage/innobase/CMakeLists.txt | 27 +++++++++- storage/innobase/handler/ha_innodb.cc | 16 ++---- storage/innobase/wsrep/md5.cc | 74 +++++++++++++++++++++++++++ storage/innobase/wsrep/wsrep_md5.h | 26 ++++++++++ storage/xtradb/CMakeLists.txt | 27 +++++++++- storage/xtradb/handler/ha_innodb.cc | 40 ++++++--------- storage/xtradb/wsrep/md5.cc | 74 +++++++++++++++++++++++++++ storage/xtradb/wsrep/wsrep_md5.h | 26 ++++++++++ 10 files changed, 272 insertions(+), 75 deletions(-) create mode 100644 storage/innobase/wsrep/md5.cc create mode 100644 storage/innobase/wsrep/wsrep_md5.h create mode 100644 storage/xtradb/wsrep/md5.cc create mode 100644 storage/xtradb/wsrep/wsrep_md5.h diff --git a/include/my_md5.h b/include/my_md5.h index 8f06586d692..77557fb9346 100644 --- a/include/my_md5.h +++ b/include/my_md5.h @@ -45,12 +45,6 @@ static inline void array_to_hex(char *to, const unsigned char *str, uint len) } } -#ifdef WITH_WSREP -void *wsrep_md5_init(); -void wsrep_md5_update(void *ctx, char* buf, int len); - void wsrep_compute_md5_hash(char *digest, void *ctx); -#endif /* WITH_WSREP */ - #ifdef __cplusplus } #endif diff --git a/mysys_ssl/my_md5.cc b/mysys_ssl/my_md5.cc index c647ac1a4b7..bc303061613 100644 --- a/mysys_ssl/my_md5.cc +++ b/mysys_ssl/my_md5.cc @@ -67,34 +67,3 @@ void compute_md5_hash(char *digest, const char *buf, int len) #endif /* HAVE_YASSL */ } -#ifdef WITH_WSREP -void *wsrep_md5_init() -{ -#if defined(HAVE_YASSL) - TaoCrypt::MD5 *hasher= new TaoCrypt::MD5; - return (void*)hasher; -#elif defined(HAVE_OPENSSL) - MD5_CTX *ctx = new MD5_CTX(); - MD5_Init (ctx); - return (void *)ctx; -#endif /* HAVE_YASSL */ -} -void wsrep_md5_update(void *ctx, char* buf, int len) -{ -#if defined(HAVE_YASSL) - ((TaoCrypt::MD5 *)ctx)->Update((TaoCrypt::byte *) buf, len); -#elif defined(HAVE_OPENSSL) - MD5_Update((MD5_CTX*)(ctx), buf, len); -#endif /* HAVE_YASSL */ -} -void wsrep_compute_md5_hash(char *digest, void *ctx) -{ -#if defined(HAVE_YASSL) - ((TaoCrypt::MD5*)ctx)->Final((TaoCrypt::byte *) digest); - delete (TaoCrypt::MD5*)ctx; -#elif defined(HAVE_OPENSSL) - MD5_Final ((unsigned char*)digest, (MD5_CTX*)ctx); - delete (MD5_CTX*)ctx; -#endif /* HAVE_YASSL */ -} -#endif /* WITH_WSREP */ diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index ee8758a08d2..67c7cf9f7db 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -234,7 +234,28 @@ ENDIF() # Include directories under innobase INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include - ${CMAKE_SOURCE_DIR}/storage/innobase/handler) + ${CMAKE_SOURCE_DIR}/storage/innobase/handler) + +IF(WITH_WSREP) + # ssl include directory + INCLUDE_DIRECTORIES(${SSL_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/storage/innobase/wsrep) + + IF(SSL_DEFINES) + ADD_DEFINITIONS(${SSL_DEFINES}) + ENDIF() + + LINK_LIBRARIES(${SSL_LIBRARIES}) + + # We do RESTRICT_SYMBOL_EXPORTS(yassl) elsewhere. + # In order to get correct symbol visibility, these files + # must be compiled with "-fvisibility=hidden" + IF(WITH_SSL STREQUAL "bundled" AND HAVE_VISIBILITY_HIDDEN) + SET_SOURCE_FILES_PROPERTIES( + {CMAKE_CURRENT_SOURCE_DIR}/wsrep/md5.cc + PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") + ENDIF() +ENDIF() # Sun Studio bug with -xO2 IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro" @@ -380,6 +401,10 @@ SET(INNOBASE_SOURCES ut/ut0vec.cc ut/ut0wqueue.cc) +IF(WITH_WSREP) + SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} wsrep/md5.cc) +ENDIF() + IF(WITH_INNODB) # Legacy option SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7b25018bbb8..748a2134ce9 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -85,9 +85,6 @@ this program; if not, write to the Free Software Foundation, Inc., #include "ha_prototypes.h" #include "ut0mem.h" #include "ibuf0ibuf.h" -#ifdef WITH_WSREP -#include "../storage/innobase/include/ut0byte.h" -#endif /* WITH_WSREP */ #include "dict0dict.h" #include "srv0mon.h" #include "api0api.h" @@ -118,17 +115,10 @@ this program; if not, write to the Free Software Foundation, Inc., # endif /* MYSQL_PLUGIN_IMPORT */ #ifdef WITH_WSREP -#include -#include -#if defined(HAVE_YASSL) -#include "my_config.h" -#include "md5.hpp" -#elif defined(HAVE_OPENSSL) -#include -#endif - - #include "dict0priv.h" +#include "../storage/innobase/include/ut0byte.h" +#include +#include extern my_bool wsrep_certify_nonPK; class binlog_trx_data; diff --git a/storage/innobase/wsrep/md5.cc b/storage/innobase/wsrep/md5.cc new file mode 100644 index 00000000000..30be6ab7dd3 --- /dev/null +++ b/storage/innobase/wsrep/md5.cc @@ -0,0 +1,74 @@ +/* + Copyright (c) 2014 SkySQL AB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef WITH_WSREP + +#if defined(HAVE_YASSL) +#include "my_config.h" +#include "md5.hpp" +#elif defined(HAVE_OPENSSL) +#include +#endif /* HAVE_YASSL */ + +/* Initialize md5 object. */ +void *wsrep_md5_init() +{ +#if defined(HAVE_YASSL) + TaoCrypt::MD5 *hasher= new TaoCrypt::MD5; + return (void*)hasher; +#elif defined(HAVE_OPENSSL) + MD5_CTX *ctx = new MD5_CTX(); + MD5_Init (ctx); + return (void *)ctx; +#endif /* HAVE_YASSL */ +} + +/** + Supply message to be hashed. + + @param ctx [IN] Pointer to MD5 context + @param buf [IN] Message to be computed. + @param len [IN] Length of the message. +*/ +void wsrep_md5_update(void *ctx, char* buf, int len) +{ +#if defined(HAVE_YASSL) + ((TaoCrypt::MD5 *)ctx)->Update((TaoCrypt::byte *) buf, len); +#elif defined(HAVE_OPENSSL) + MD5_Update((MD5_CTX*)(ctx), buf, len); +#endif /* HAVE_YASSL */ +} + +/** + Place computed MD5 digest into the given buffer. + + @param digest [OUT] Computed MD5 digest + @param ctx [IN] Pointer to MD5 context +*/ +void wsrep_compute_md5_hash(char *digest, void *ctx) +{ +#if defined(HAVE_YASSL) + ((TaoCrypt::MD5*)ctx)->Final((TaoCrypt::byte *) digest); + delete (TaoCrypt::MD5*)ctx; +#elif defined(HAVE_OPENSSL) + MD5_Final ((unsigned char*)digest, (MD5_CTX*)ctx); + delete (MD5_CTX*)ctx; +#endif /* HAVE_YASSL */ +} + +#endif /* WITH_WSREP */ + diff --git a/storage/innobase/wsrep/wsrep_md5.h b/storage/innobase/wsrep/wsrep_md5.h new file mode 100644 index 00000000000..1339f7f4b86 --- /dev/null +++ b/storage/innobase/wsrep/wsrep_md5.h @@ -0,0 +1,26 @@ +#ifndef WSREP_MD5_INCLUDED +#define WSREP_MD5_INCLUDED + +/* Copyright (c) 2014 SkySQL AB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +*/ + +#ifdef WITH_WSREP +void *wsrep_md5_init(); +void wsrep_md5_update(void *ctx, char* buf, int len); +void wsrep_compute_md5_hash(char *digest, void *ctx); +#endif /* WITH_WSREP */ + +#endif /* WSREP_MD5_INCLUDED */ diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index 282db2ddf31..1a1bb63f227 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -250,7 +250,28 @@ ENDIF() # Include directories under xtradb INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/xtradb/include - ${CMAKE_SOURCE_DIR}/storage/xtradb/handler) + ${CMAKE_SOURCE_DIR}/storage/xtradb/handler) + +IF(WITH_WSREP) + # ssl include directory + INCLUDE_DIRECTORIES(${SSL_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/storage/xtradb/wsrep) + + IF(SSL_DEFINES) + ADD_DEFINITIONS(${SSL_DEFINES}) + ENDIF() + + LINK_LIBRARIES(${SSL_LIBRARIES}) + + # We do RESTRICT_SYMBOL_EXPORTS(yassl) elsewhere. + # In order to get correct symbol visibility, these files + # must be compiled with "-fvisibility=hidden" + IF(WITH_SSL STREQUAL "bundled" AND HAVE_VISIBILITY_HIDDEN) + SET_SOURCE_FILES_PROPERTIES( + {CMAKE_CURRENT_SOURCE_DIR}/wsrep/md5.cc + PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") + ENDIF() +ENDIF() # Sun Studio bug with -xO2 IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro" @@ -389,6 +410,10 @@ SET(INNOBASE_SOURCES ut/ut0vec.cc ut/ut0wqueue.cc) +IF(WITH_WSREP) + SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} wsrep/md5.cc) +ENDIF() + IF(WITH_INNODB) # Legacy option SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 62a033e82e0..e3a3f71f559 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -101,17 +101,27 @@ this program; if not, write to the Free Software Foundation, Inc., #endif /* UNIV_DEBUG */ #include "fts0priv.h" #include "page0zip.h" + +#define thd_get_trx_isolation(X) ((enum_tx_isolation)thd_tx_isolation(X)) + +#ifdef MYSQL_DYNAMIC_PLUGIN +#define tc_size 400 +#define tdc_size 400 +#endif + +#include "ha_innodb.h" +#include "i_s.h" +#include "xtradb_i_s.h" + +# ifndef MYSQL_PLUGIN_IMPORT +# define MYSQL_PLUGIN_IMPORT /* nothing */ +# endif /* MYSQL_PLUGIN_IMPORT */ + #ifdef WITH_WSREP #include "dict0priv.h" #include "../storage/innobase/include/ut0byte.h" #include -#include -#if defined(HAVE_YASSL) -#include "my_config.h" -#include "md5.hpp" -#elif defined(HAVE_OPENSSL) -#include -#endif +#include extern my_bool wsrep_certify_nonPK; class binlog_trx_data; @@ -158,22 +168,6 @@ wsrep_dict_foreign_find_index( ulint check_null); #endif /* WITH_WSREP */ - -#define thd_get_trx_isolation(X) ((enum_tx_isolation)thd_tx_isolation(X)) - -#ifdef MYSQL_DYNAMIC_PLUGIN -#define tc_size 400 -#define tdc_size 400 -#endif - -#include "ha_innodb.h" -#include "i_s.h" -#include "xtradb_i_s.h" - -# ifndef MYSQL_PLUGIN_IMPORT -# define MYSQL_PLUGIN_IMPORT /* nothing */ -# endif /* MYSQL_PLUGIN_IMPORT */ - /** to protect innobase_open_files */ static mysql_mutex_t innobase_share_mutex; /** to force correct commit order in binlog */ diff --git a/storage/xtradb/wsrep/md5.cc b/storage/xtradb/wsrep/md5.cc new file mode 100644 index 00000000000..30be6ab7dd3 --- /dev/null +++ b/storage/xtradb/wsrep/md5.cc @@ -0,0 +1,74 @@ +/* + Copyright (c) 2014 SkySQL AB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef WITH_WSREP + +#if defined(HAVE_YASSL) +#include "my_config.h" +#include "md5.hpp" +#elif defined(HAVE_OPENSSL) +#include +#endif /* HAVE_YASSL */ + +/* Initialize md5 object. */ +void *wsrep_md5_init() +{ +#if defined(HAVE_YASSL) + TaoCrypt::MD5 *hasher= new TaoCrypt::MD5; + return (void*)hasher; +#elif defined(HAVE_OPENSSL) + MD5_CTX *ctx = new MD5_CTX(); + MD5_Init (ctx); + return (void *)ctx; +#endif /* HAVE_YASSL */ +} + +/** + Supply message to be hashed. + + @param ctx [IN] Pointer to MD5 context + @param buf [IN] Message to be computed. + @param len [IN] Length of the message. +*/ +void wsrep_md5_update(void *ctx, char* buf, int len) +{ +#if defined(HAVE_YASSL) + ((TaoCrypt::MD5 *)ctx)->Update((TaoCrypt::byte *) buf, len); +#elif defined(HAVE_OPENSSL) + MD5_Update((MD5_CTX*)(ctx), buf, len); +#endif /* HAVE_YASSL */ +} + +/** + Place computed MD5 digest into the given buffer. + + @param digest [OUT] Computed MD5 digest + @param ctx [IN] Pointer to MD5 context +*/ +void wsrep_compute_md5_hash(char *digest, void *ctx) +{ +#if defined(HAVE_YASSL) + ((TaoCrypt::MD5*)ctx)->Final((TaoCrypt::byte *) digest); + delete (TaoCrypt::MD5*)ctx; +#elif defined(HAVE_OPENSSL) + MD5_Final ((unsigned char*)digest, (MD5_CTX*)ctx); + delete (MD5_CTX*)ctx; +#endif /* HAVE_YASSL */ +} + +#endif /* WITH_WSREP */ + diff --git a/storage/xtradb/wsrep/wsrep_md5.h b/storage/xtradb/wsrep/wsrep_md5.h new file mode 100644 index 00000000000..1339f7f4b86 --- /dev/null +++ b/storage/xtradb/wsrep/wsrep_md5.h @@ -0,0 +1,26 @@ +#ifndef WSREP_MD5_INCLUDED +#define WSREP_MD5_INCLUDED + +/* Copyright (c) 2014 SkySQL AB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +*/ + +#ifdef WITH_WSREP +void *wsrep_md5_init(); +void wsrep_md5_update(void *ctx, char* buf, int len); +void wsrep_compute_md5_hash(char *digest, void *ctx); +#endif /* WITH_WSREP */ + +#endif /* WSREP_MD5_INCLUDED */