diff --git a/gb.db.mysql/configure.ac b/gb.db.mysql/configure.ac index f2eec5d82..56b203c30 100644 --- a/gb.db.mysql/configure.ac +++ b/gb.db.mysql/configure.ac @@ -13,7 +13,29 @@ GB_COMPONENT( [GB_FIND(mysql.h, $prefix /opt/local /opt /usr/local/lib /usr/local /usr/lib /usr, include mysql*/include)], [GB_FIND(libmysqlclient.$SHLIBEXT, $prefix /opt/local /opt /usr/local /usr, lib mysql*/lib)], [$C_LIB -lmysqlclient -lz]) - + +gb_save_cppflags=$CPPFLAGS +CPPFLAGS=$MYSQL_INC + +AC_CACHE_CHECK(for SSL mode option, + gb_cv_db_mysql_ssl_mode, + [AC_TRY_COMPILE( + [ + #include + ], + [ + int flag = SSL_MODE_DISABLED; + ], + gb_cv_db_mysql_ssl_mode=yes, gb_cv_db_mysql_ssl_mode=no + )]) + + if test $gb_cv_db_mysql_ssl_mode = yes; then + AC_DEFINE(HAVE_MYSQL_SSL_MODE_DISABLED, 1, [Define if you have SSL_MODE_DISABLED constant.]) + fi + +CPPFLAGS=$gb_save_cppflags + + AC_OUTPUT( \ Makefile \ src/Makefile \ diff --git a/gb.db.mysql/src/main.c b/gb.db.mysql/src/main.c index 6c6edd247..a208239df 100644 --- a/gb.db.mysql/src/main.c +++ b/gb.db.mysql/src/main.c @@ -739,9 +739,11 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db) char *host; char *socket; my_bool reconnect = TRUE; - unsigned int mode; unsigned int timeout; + #if HAVE_MYSQL_SSL_MODE_DISABLED char *env; + unsigned int mode; + #endif conn = mysql_init(NULL); @@ -766,7 +768,7 @@ static int open_database(DB_DESC *desc, DB_DATABASE *db) timeout = db->timeout; mysql_options(conn, MYSQL_OPT_CONNECT_TIMEOUT, &timeout); - #if MYSQL_VERSION_ID >= 80000 + #if HAVE_MYSQL_SSL_MODE_DISABLED env = getenv("GB_DB_MYSQL_NOSSL"); if (env && strcmp(env, "0")) {