You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-10 01:02:57 +03:00
- Unittests: link static library instead of dynamic
- TLS/SSL: renamed HAVE_SSL to HAVE_TLS to avoid trouble in 10.2-integration - Fixed wrong timeout in non-blocking mode - Fixed valgrind error in prepared statement
This commit is contained in:
@@ -206,7 +206,7 @@ IF(NOT WITH_SSL STREQUAL "OFF")
|
|||||||
IF(WITH_SSL STREQUAL "OPENSSL")
|
IF(WITH_SSL STREQUAL "OPENSSL")
|
||||||
FIND_PACKAGE(OpenSSL)
|
FIND_PACKAGE(OpenSSL)
|
||||||
IF(OPENSSL_FOUND)
|
IF(OPENSSL_FOUND)
|
||||||
ADD_DEFINITIONS(-DHAVE_OPENSSL -DHAVE_SSL)
|
ADD_DEFINITIONS(-DHAVE_OPENSSL -DHAVE_TLS)
|
||||||
SET(SSL_SOURCES "${CMAKE_SOURCE_DIR}/libmariadb/secure/openssl.c")
|
SET(SSL_SOURCES "${CMAKE_SOURCE_DIR}/libmariadb/secure/openssl.c")
|
||||||
SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
|
SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
INCLUDE_DIRECTORIES(BEFORE ${OPENSSL_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(BEFORE ${OPENSSL_INCLUDE_DIR})
|
||||||
@@ -218,7 +218,7 @@ IF(NOT WITH_SSL STREQUAL "OFF")
|
|||||||
IF(WITH_SSL STREQUAL "GNUTLS")
|
IF(WITH_SSL STREQUAL "GNUTLS")
|
||||||
FIND_PACKAGE(GnuTLS)
|
FIND_PACKAGE(GnuTLS)
|
||||||
IF(GNUTLS_FOUND)
|
IF(GNUTLS_FOUND)
|
||||||
ADD_DEFINITIONS(-DHAVE_GNUTLS -DHAVE_SSL)
|
ADD_DEFINITIONS(-DHAVE_GNUTLS -DHAVE_TLS)
|
||||||
SET(SSL_SOURCES "${CMAKE_SOURCE_DIR}/libmariadb/secure/gnutls.c")
|
SET(SSL_SOURCES "${CMAKE_SOURCE_DIR}/libmariadb/secure/gnutls.c")
|
||||||
SET(SSL_LIBRARIES ${GNUTLS_LIBRARY})
|
SET(SSL_LIBRARIES ${GNUTLS_LIBRARY})
|
||||||
ELSE()
|
ELSE()
|
||||||
@@ -227,7 +227,7 @@ IF(NOT WITH_SSL STREQUAL "OFF")
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
IF(WITH_SSL STREQUAL "SCHANNEL")
|
IF(WITH_SSL STREQUAL "SCHANNEL")
|
||||||
ADD_DEFINITIONS(-DHAVE_SCHANNEL -DHAVE_SSL)
|
ADD_DEFINITIONS(-DHAVE_SCHANNEL -DHAVE_TLS)
|
||||||
SET(SSL_SOURCES "${CMAKE_SOURCE_DIR}/libmariadb/secure/schannel.c" "${CMAKE_SOURCE_DIR}/libmariadb/secure/ma_schannel.c")
|
SET(SSL_SOURCES "${CMAKE_SOURCE_DIR}/libmariadb/secure/schannel.c" "${CMAKE_SOURCE_DIR}/libmariadb/secure/ma_schannel.c")
|
||||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/plugins/pvio/")
|
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/plugins/pvio/")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#define _ma_pvio_h_
|
#define _ma_pvio_h_
|
||||||
#define cio_defined
|
#define cio_defined
|
||||||
|
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
#include <ma_tls.h>
|
#include <ma_tls.h>
|
||||||
#else
|
#else
|
||||||
#define MARIADB_TLS void
|
#define MARIADB_TLS void
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
struct st_ma_pvio_methods;
|
struct st_ma_pvio_methods;
|
||||||
typedef struct st_ma_pvio_methods PVIO_METHODS;
|
typedef struct st_ma_pvio_methods PVIO_METHODS;
|
||||||
|
|
||||||
#ifdef HAVE_NONBLOCK
|
|
||||||
#define IS_PVIO_ASYNC(a) \
|
#define IS_PVIO_ASYNC(a) \
|
||||||
((a)->mysql && (a)->mysql->options.extension && (a)->mysql->options.extension->async_context)
|
((a)->mysql && (a)->mysql->options.extension && (a)->mysql->options.extension->async_context)
|
||||||
|
|
||||||
@@ -30,12 +29,6 @@ typedef struct st_ma_pvio_methods PVIO_METHODS;
|
|||||||
|
|
||||||
#define IS_MYSQL_ASYNC_ACTIVE(a) \
|
#define IS_MYSQL_ASYNC_ACTIVE(a) \
|
||||||
(IS_MYSQL_ASYNC(a)&& (a)->options.extension->async_context->active)
|
(IS_MYSQL_ASYNC(a)&& (a)->options.extension->async_context->active)
|
||||||
#else
|
|
||||||
#define IS_PVIO_ASYNC(a) (0)
|
|
||||||
#define IS_PVIO_ASYNC_ACTIVE(a) (0)
|
|
||||||
#define IS_MYSQL_ASYNC(a) (0)
|
|
||||||
#define IS_MYSQL_ASYNC_ACTIVE(a) (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum enum_pvio_timeout {
|
enum enum_pvio_timeout {
|
||||||
PVIO_CONNECT_TIMEOUT= 0,
|
PVIO_CONNECT_TIMEOUT= 0,
|
||||||
@@ -80,7 +73,6 @@ struct st_ma_pvio {
|
|||||||
int ssl_type; /* todo: change to enum (ssl plugins) */
|
int ssl_type; /* todo: change to enum (ssl plugins) */
|
||||||
MARIADB_TLS *ctls;
|
MARIADB_TLS *ctls;
|
||||||
MYSQL *mysql;
|
MYSQL *mysql;
|
||||||
struct mysql_async_context *async_context; /* For non-blocking API */
|
|
||||||
PVIO_METHODS *methods;
|
PVIO_METHODS *methods;
|
||||||
void (*set_error)(MYSQL *mysql, unsigned int error_nr, const char *sqlstate, const char *format, ...);
|
void (*set_error)(MYSQL *mysql, unsigned int error_nr, const char *sqlstate, const char *format, ...);
|
||||||
void (*callback)(MARIADB_PVIO *pvio, my_bool is_read, const char *buffer, size_t length);
|
void (*callback)(MARIADB_PVIO *pvio, my_bool is_read, const char *buffer, size_t length);
|
||||||
|
@@ -28,7 +28,7 @@ extern ssize_t my_send_async(MARIADB_PVIO *pvio,
|
|||||||
int timeout);
|
int timeout);
|
||||||
extern my_bool my_io_wait_async(struct mysql_async_context *b,
|
extern my_bool my_io_wait_async(struct mysql_async_context *b,
|
||||||
enum enum_pvio_io_event event, int timeout);
|
enum enum_pvio_io_event event, int timeout);
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
extern int my_ssl_read_async(struct mysql_async_context *b, MARIADB_TLS *tls,
|
extern int my_ssl_read_async(struct mysql_async_context *b, MARIADB_TLS *tls,
|
||||||
void *buf, int size);
|
void *buf, int size);
|
||||||
extern int my_ssl_write_async(struct mysql_async_context *b, MARIADB_TLS *tls,
|
extern int my_ssl_write_async(struct mysql_async_context *b, MARIADB_TLS *tls,
|
||||||
|
@@ -51,10 +51,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ma_common.h>
|
#include <ma_common.h>
|
||||||
#include <ma_pvio.h>
|
#include <ma_pvio.h>
|
||||||
#ifdef HAVE_NONBLOCK
|
|
||||||
#include <mariadb_async.h>
|
#include <mariadb_async.h>
|
||||||
#include <ma_context.h>
|
#include <ma_context.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
/* callback functions for read/write */
|
/* callback functions for read/write */
|
||||||
LIST *pvio_callback= NULL;
|
LIST *pvio_callback= NULL;
|
||||||
@@ -121,6 +119,8 @@ MARIADB_PVIO *ma_pvio_init(MA_PVIO_CINFO *cinfo)
|
|||||||
if (pvio->methods->set_timeout)
|
if (pvio->methods->set_timeout)
|
||||||
{
|
{
|
||||||
pvio->methods->set_timeout(pvio, PVIO_CONNECT_TIMEOUT, cinfo->mysql->options.connect_timeout);
|
pvio->methods->set_timeout(pvio, PVIO_CONNECT_TIMEOUT, cinfo->mysql->options.connect_timeout);
|
||||||
|
pvio->methods->set_timeout(pvio, PVIO_READ_TIMEOUT, cinfo->mysql->options.connect_timeout);
|
||||||
|
pvio->methods->set_timeout(pvio, PVIO_WRITE_TIMEOUT, cinfo->mysql->options.connect_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pvio->cache= calloc(1, PVIO_READ_AHEAD_CACHE_SIZE)))
|
if (!(pvio->cache= calloc(1, PVIO_READ_AHEAD_CACHE_SIZE)))
|
||||||
@@ -177,7 +177,6 @@ my_bool ma_pvio_set_timeout(MARIADB_PVIO *pvio,
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
#ifdef HAVE_NONBLOCK
|
|
||||||
/* {{{ size_t ma_pvio_read_async */
|
/* {{{ size_t ma_pvio_read_async */
|
||||||
static size_t ma_pvio_read_async(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
|
static size_t ma_pvio_read_async(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
|
||||||
{
|
{
|
||||||
@@ -213,7 +212,6 @@ static size_t ma_pvio_read_async(MARIADB_PVIO *pvio, uchar *buffer, size_t lengt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
#endif
|
|
||||||
|
|
||||||
/* {{{ size_t ma_pvio_read */
|
/* {{{ size_t ma_pvio_read */
|
||||||
size_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
|
size_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
|
||||||
@@ -221,14 +219,12 @@ size_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
|
|||||||
size_t r= -1;
|
size_t r= -1;
|
||||||
if (!pvio)
|
if (!pvio)
|
||||||
return -1;
|
return -1;
|
||||||
#ifdef HAVE_NONBLOCK
|
|
||||||
if (IS_PVIO_ASYNC_ACTIVE(pvio))
|
if (IS_PVIO_ASYNC_ACTIVE(pvio))
|
||||||
{
|
{
|
||||||
r= ma_pvio_read_async(pvio, buffer, length);
|
r= ma_pvio_read_async(pvio, buffer, length);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (IS_PVIO_ASYNC(pvio))
|
if (IS_PVIO_ASYNC(pvio))
|
||||||
{
|
{
|
||||||
@@ -242,7 +238,7 @@ size_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* secure connection */
|
/* secure connection */
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
if (pvio->ctls)
|
if (pvio->ctls)
|
||||||
{
|
{
|
||||||
r= ma_pvio_tls_read(pvio->ctls, buffer, length);
|
r= ma_pvio_tls_read(pvio->ctls, buffer, length);
|
||||||
@@ -306,7 +302,6 @@ size_t ma_pvio_cache_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
#ifdef HAVE_NONBLOCK
|
|
||||||
/* {{{ size_t ma_pvio_write_async */
|
/* {{{ size_t ma_pvio_write_async */
|
||||||
static size_t ma_pvio_write_async(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
|
static size_t ma_pvio_write_async(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
|
||||||
{
|
{
|
||||||
@@ -336,7 +331,6 @@ static size_t ma_pvio_write_async(MARIADB_PVIO *pvio, const uchar *buffer, size_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
#endif
|
|
||||||
|
|
||||||
/* {{{ size_t ma_pvio_write */
|
/* {{{ size_t ma_pvio_write */
|
||||||
size_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
|
size_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
|
||||||
@@ -347,7 +341,7 @@ size_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* secure connection */
|
/* secure connection */
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
if (pvio->ctls)
|
if (pvio->ctls)
|
||||||
{
|
{
|
||||||
r= ma_pvio_tls_write(pvio->ctls, buffer, length);
|
r= ma_pvio_tls_write(pvio->ctls, buffer, length);
|
||||||
@@ -355,14 +349,12 @@ size_t ma_pvio_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_NONBLOCK
|
|
||||||
if (IS_PVIO_ASYNC_ACTIVE(pvio))
|
if (IS_PVIO_ASYNC_ACTIVE(pvio))
|
||||||
{
|
{
|
||||||
r= ma_pvio_write_async(pvio, buffer, length);
|
r= ma_pvio_write_async(pvio, buffer, length);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (IS_PVIO_ASYNC(pvio))
|
if (IS_PVIO_ASYNC(pvio))
|
||||||
{
|
{
|
||||||
@@ -388,7 +380,7 @@ end:
|
|||||||
void ma_pvio_close(MARIADB_PVIO *pvio)
|
void ma_pvio_close(MARIADB_PVIO *pvio)
|
||||||
{
|
{
|
||||||
/* free internal structures and close connection */
|
/* free internal structures and close connection */
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
if (pvio && pvio->ctls)
|
if (pvio && pvio->ctls)
|
||||||
{
|
{
|
||||||
ma_pvio_tls_close(pvio->ctls);
|
ma_pvio_tls_close(pvio->ctls);
|
||||||
@@ -414,7 +406,6 @@ my_bool ma_pvio_get_handle(MARIADB_PVIO *pvio, void *handle)
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
#ifdef HAVE_NONBLOCK
|
|
||||||
/* {{{ ma_pvio_wait_async */
|
/* {{{ ma_pvio_wait_async */
|
||||||
static my_bool
|
static my_bool
|
||||||
ma_pvio_wait_async(struct mysql_async_context *b, enum enum_pvio_io_event event,
|
ma_pvio_wait_async(struct mysql_async_context *b, enum enum_pvio_io_event event,
|
||||||
@@ -446,17 +437,14 @@ ma_pvio_wait_async(struct mysql_async_context *b, enum enum_pvio_io_event event,
|
|||||||
return (b->events_occured & MYSQL_WAIT_TIMEOUT) ? 0 : 1;
|
return (b->events_occured & MYSQL_WAIT_TIMEOUT) ? 0 : 1;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
#endif
|
|
||||||
|
|
||||||
/* {{{ ma_pvio_wait_io_or_timeout */
|
/* {{{ ma_pvio_wait_io_or_timeout */
|
||||||
int ma_pvio_wait_io_or_timeout(MARIADB_PVIO *pvio, my_bool is_read, int timeout)
|
int ma_pvio_wait_io_or_timeout(MARIADB_PVIO *pvio, my_bool is_read, int timeout)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NONBLOCK
|
|
||||||
if (IS_PVIO_ASYNC_ACTIVE(pvio))
|
if (IS_PVIO_ASYNC_ACTIVE(pvio))
|
||||||
return ma_pvio_wait_async(pvio->mysql->options.extension->async_context,
|
return ma_pvio_wait_async(pvio->mysql->options.extension->async_context,
|
||||||
(is_read) ? VIO_IO_EVENT_READ : VIO_IO_EVENT_WRITE,
|
(is_read) ? VIO_IO_EVENT_READ : VIO_IO_EVENT_WRITE,
|
||||||
timeout);
|
timeout);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (pvio && pvio->methods->wait_io_or_timeout)
|
if (pvio && pvio->methods->wait_io_or_timeout)
|
||||||
return pvio->methods->wait_io_or_timeout(pvio, is_read, timeout);
|
return pvio->methods->wait_io_or_timeout(pvio, is_read, timeout);
|
||||||
@@ -504,7 +492,7 @@ my_bool ma_pvio_has_data(MARIADB_PVIO *pvio, ssize_t *data_len)
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
/* {{{ my_bool ma_pvio_start_ssl */
|
/* {{{ my_bool ma_pvio_start_ssl */
|
||||||
my_bool ma_pvio_start_ssl(MARIADB_PVIO *pvio)
|
my_bool ma_pvio_start_ssl(MARIADB_PVIO *pvio)
|
||||||
{
|
{
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
#include <ma_string.h>
|
#include <ma_string.h>
|
||||||
|
|
||||||
my_bool ma_init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
|
my_bool ma_init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
|
||||||
|
|
||||||
size_t init_alloc, size_t alloc_increment)
|
size_t init_alloc, size_t alloc_increment)
|
||||||
{
|
{
|
||||||
uint length;
|
uint length;
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
* built-in plugin.
|
* built-in plugin.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
|
|
||||||
#include <ma_global.h>
|
#include <ma_global.h>
|
||||||
#include <ma_sys.h>
|
#include <ma_sys.h>
|
||||||
@@ -55,58 +55,58 @@ char *ssl_protocol_version[5]= {"unknown", "SSL3", "TLS1.0", "TLS1.1", "TLS1.2"}
|
|||||||
|
|
||||||
MARIADB_TLS *ma_pvio_tls_init(MYSQL *mysql)
|
MARIADB_TLS *ma_pvio_tls_init(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
MARIADB_TLS *cssl= NULL;
|
MARIADB_TLS *ctls= NULL;
|
||||||
|
|
||||||
if (!ma_tls_initialized)
|
if (!ma_tls_initialized)
|
||||||
ma_tls_start(mysql->net.last_error, MYSQL_ERRMSG_SIZE);
|
ma_tls_start(mysql->net.last_error, MYSQL_ERRMSG_SIZE);
|
||||||
|
|
||||||
if (!(cssl= (MARIADB_TLS *)calloc(1, sizeof(MARIADB_TLS))))
|
if (!(ctls= (MARIADB_TLS *)calloc(1, sizeof(MARIADB_TLS))))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* register error routine and methods */
|
/* register error routine and methods */
|
||||||
cssl->pvio= mysql->net.pvio;
|
ctls->pvio= mysql->net.pvio;
|
||||||
if (!(cssl->ssl= ma_tls_init(mysql)))
|
if (!(ctls->ssl= ma_tls_init(mysql)))
|
||||||
{
|
{
|
||||||
free(cssl);
|
free(ctls);
|
||||||
cssl= NULL;
|
ctls= NULL;
|
||||||
}
|
}
|
||||||
return cssl;
|
return ctls;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_bool ma_pvio_tls_connect(MARIADB_TLS *cssl)
|
my_bool ma_pvio_tls_connect(MARIADB_TLS *ctls)
|
||||||
{
|
{
|
||||||
my_bool rc;
|
my_bool rc;
|
||||||
|
|
||||||
if ((rc= ma_tls_connect(cssl)))
|
if ((rc= ma_tls_connect(ctls)))
|
||||||
ma_tls_close(cssl);
|
ma_tls_close(ctls);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ma_pvio_tls_read(MARIADB_TLS *cssl, const uchar* buffer, size_t length)
|
size_t ma_pvio_tls_read(MARIADB_TLS *ctls, const uchar* buffer, size_t length)
|
||||||
{
|
{
|
||||||
return ma_tls_read(cssl, buffer, length);
|
return ma_tls_read(ctls, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ma_pvio_tls_write(MARIADB_TLS *cssl, const uchar* buffer, size_t length)
|
size_t ma_pvio_tls_write(MARIADB_TLS *ctls, const uchar* buffer, size_t length)
|
||||||
{
|
{
|
||||||
return ma_tls_write(cssl, buffer, length);
|
return ma_tls_write(ctls, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_bool ma_pvio_tls_close(MARIADB_TLS *cssl)
|
my_bool ma_pvio_tls_close(MARIADB_TLS *ctls)
|
||||||
{
|
{
|
||||||
return ma_tls_close(cssl);
|
return ma_tls_close(ctls);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ma_pvio_tls_verify_server_cert(MARIADB_TLS *cssl)
|
int ma_pvio_tls_verify_server_cert(MARIADB_TLS *ctls)
|
||||||
{
|
{
|
||||||
return ma_tls_verify_server_cert(cssl);
|
return ma_tls_verify_server_cert(ctls);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ma_pvio_tls_cipher(MARIADB_TLS *cssl)
|
const char *ma_pvio_tls_cipher(MARIADB_TLS *ctls)
|
||||||
{
|
{
|
||||||
return ma_tls_get_cipher(cssl);
|
return ma_tls_get_cipher(ctls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ma_pvio_tls_end()
|
void ma_pvio_tls_end()
|
||||||
@@ -114,9 +114,9 @@ void ma_pvio_tls_end()
|
|||||||
ma_tls_end();
|
ma_tls_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
my_bool ma_pvio_tls_get_protocol_version(MARIADB_TLS *cssl, struct st_ssl_version *version)
|
my_bool ma_pvio_tls_get_protocol_version(MARIADB_TLS *ctls, struct st_ssl_version *version)
|
||||||
{
|
{
|
||||||
return ma_tls_get_protocol_version(cssl, version);
|
return ma_tls_get_protocol_version(ctls, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
static my_bool ma_pvio_tls_compare_fp(char *fp1, unsigned int fp1_len,
|
static my_bool ma_pvio_tls_compare_fp(char *fp1, unsigned int fp1_len,
|
||||||
@@ -134,14 +134,14 @@ static my_bool ma_pvio_tls_compare_fp(char *fp1, unsigned int fp1_len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_bool ma_pvio_tls_check_fp(MARIADB_TLS *cssl, const char *fp, const char *fp_list)
|
my_bool ma_pvio_tls_check_fp(MARIADB_TLS *ctls, const char *fp, const char *fp_list)
|
||||||
{
|
{
|
||||||
unsigned int cert_fp_len= 64;
|
unsigned int cert_fp_len= 64;
|
||||||
unsigned char cert_fp[64];
|
unsigned char cert_fp[64];
|
||||||
my_bool rc=1;
|
my_bool rc=1;
|
||||||
MYSQL *mysql= cssl->pvio->mysql;
|
MYSQL *mysql= ctls->pvio->mysql;
|
||||||
|
|
||||||
if ((cert_fp_len= ma_tls_get_finger_print(cssl, cert_fp, cert_fp_len)) < 1)
|
if ((cert_fp_len= ma_tls_get_finger_print(ctls, cert_fp, cert_fp_len)) < 1)
|
||||||
goto end;
|
goto end;
|
||||||
if (fp)
|
if (fp)
|
||||||
rc= ma_pvio_tls_compare_fp(cert_fp, cert_fp_len, (char *)fp, (unsigned int)strlen(fp));
|
rc= ma_pvio_tls_compare_fp(cert_fp, cert_fp_len, (char *)fp, (unsigned int)strlen(fp));
|
||||||
@@ -186,4 +186,4 @@ end:
|
|||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SSL */
|
#endif /* HAVE_TLS */
|
||||||
|
@@ -133,7 +133,7 @@ my_connect_async(MARIADB_PVIO *pvio,
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SSL_FIXME
|
#ifdef HAVE_TLS_FIXME
|
||||||
static my_bool
|
static my_bool
|
||||||
my_ssl_async_check_result(int res, struct mysql_async_context *b, MARIADB_SSL *cssl)
|
my_ssl_async_check_result(int res, struct mysql_async_context *b, MARIADB_SSL *cssl)
|
||||||
{
|
{
|
||||||
|
@@ -63,7 +63,7 @@
|
|||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ma_pvio.h>
|
#include <ma_pvio.h>
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
#include <ma_tls.h>
|
#include <ma_tls.h>
|
||||||
#endif
|
#endif
|
||||||
#include <mysql/client_plugin.h>
|
#include <mysql/client_plugin.h>
|
||||||
@@ -965,22 +965,6 @@ mysql_init(MYSQL *mysql)
|
|||||||
strcpy(mysql->net.sqlstate, "00000");
|
strcpy(mysql->net.sqlstate, "00000");
|
||||||
mysql->net.last_error[0]= mysql->net.last_errno= 0;
|
mysql->net.last_error[0]= mysql->net.last_errno= 0;
|
||||||
|
|
||||||
/*
|
|
||||||
}
|
|
||||||
if (!(mysql->net.extension= (struct st_mariadb_net_extension *)
|
|
||||||
calloc(1, sizeof(struct st_mariadb_net_extension))))
|
|
||||||
{
|
|
||||||
if (mysql->free_me)
|
|
||||||
free(mysql);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
mysql->options.report_data_truncation= 1;
|
|
||||||
mysql->options.connect_timeout=CONNECT_TIMEOUT;
|
|
||||||
mysql->charset= ma_default_charset_info;
|
|
||||||
mysql->methods= &MARIADB_DEFAULT_METHODS;
|
|
||||||
strcpy(mysql->net.sqlstate, "00000");
|
|
||||||
mysql->net.last_error[0]= mysql->net.last_errno= 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Only enable LOAD DATA INFILE by default if configured with
|
Only enable LOAD DATA INFILE by default if configured with
|
||||||
--enable-local-infile
|
--enable-local-infile
|
||||||
@@ -996,7 +980,7 @@ int STDCALL
|
|||||||
mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
|
mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
|
||||||
const char *ca, const char *capath, const char *cipher)
|
const char *ca, const char *capath, const char *cipher)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
return (mysql_optionsv(mysql, MYSQL_OPT_SSL_KEY, key) |
|
return (mysql_optionsv(mysql, MYSQL_OPT_SSL_KEY, key) |
|
||||||
mysql_optionsv(mysql, MYSQL_OPT_SSL_CERT, cert) |
|
mysql_optionsv(mysql, MYSQL_OPT_SSL_CERT, cert) |
|
||||||
mysql_optionsv(mysql, MYSQL_OPT_SSL_CA, ca) |
|
mysql_optionsv(mysql, MYSQL_OPT_SSL_CA, ca) |
|
||||||
@@ -1013,7 +997,7 @@ mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
|
|||||||
const char * STDCALL
|
const char * STDCALL
|
||||||
mysql_get_ssl_cipher(MYSQL *mysql)
|
mysql_get_ssl_cipher(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
if (mysql->net.pvio && mysql->net.pvio->ctls)
|
if (mysql->net.pvio && mysql->net.pvio->ctls)
|
||||||
{
|
{
|
||||||
return ma_pvio_tls_cipher(mysql->net.pvio->ctls);
|
return ma_pvio_tls_cipher(mysql->net.pvio->ctls);
|
||||||
@@ -1548,7 +1532,6 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql)
|
|||||||
struct my_hook_data hook_data;
|
struct my_hook_data hook_data;
|
||||||
struct mysql_async_context *ctxt= NULL;
|
struct mysql_async_context *ctxt= NULL;
|
||||||
LIST *li_stmt= mysql->stmts;
|
LIST *li_stmt= mysql->stmts;
|
||||||
mysql_init(&tmp_mysql);
|
|
||||||
|
|
||||||
/* check if connection handler is active */
|
/* check if connection handler is active */
|
||||||
if (IS_CONNHDLR_ACTIVE(mysql))
|
if (IS_CONNHDLR_ACTIVE(mysql))
|
||||||
@@ -1574,8 +1557,6 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql)
|
|||||||
mysql->net.extension->conn_hdlr= 0;
|
mysql->net.extension->conn_hdlr= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* don't reread options from configuration files */
|
/* don't reread options from configuration files */
|
||||||
tmp_mysql.options.my_cnf_group= tmp_mysql.options.my_cnf_file= NULL;
|
tmp_mysql.options.my_cnf_group= tmp_mysql.options.my_cnf_file= NULL;
|
||||||
if (IS_MYSQL_ASYNC_ACTIVE(mysql))
|
if (IS_MYSQL_ASYNC_ACTIVE(mysql))
|
||||||
@@ -1873,6 +1854,10 @@ mysql_close(MYSQL *mysql)
|
|||||||
|
|
||||||
mysql_close_memory(mysql);
|
mysql_close_memory(mysql);
|
||||||
mysql_close_options(mysql);
|
mysql_close_options(mysql);
|
||||||
|
|
||||||
|
if (mysql->net.extension)
|
||||||
|
free(mysql->net.extension);
|
||||||
|
|
||||||
mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
|
mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
|
||||||
|
|
||||||
/* Clear pointers for better safety */
|
/* Clear pointers for better safety */
|
||||||
@@ -1880,8 +1865,6 @@ mysql_close(MYSQL *mysql)
|
|||||||
|
|
||||||
if (mysql->extension)
|
if (mysql->extension)
|
||||||
free(mysql->extension);
|
free(mysql->extension);
|
||||||
if (mysql->net.extension)
|
|
||||||
free(mysql->net.extension);
|
|
||||||
|
|
||||||
mysql->net.pvio= 0;
|
mysql->net.pvio= 0;
|
||||||
if (mysql->free_me)
|
if (mysql->free_me)
|
||||||
@@ -2560,8 +2543,8 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
mysql->options.extension->async_context= ctxt;
|
mysql->options.extension->async_context= ctxt;
|
||||||
if (mysql->net.pvio)
|
// if (mysql->net.pvio)
|
||||||
mysql->net.pvio->async_context= ctxt;
|
// mysql->net.pvio->async_context= ctxt;
|
||||||
break;
|
break;
|
||||||
case MYSQL_OPT_MAX_ALLOWED_PACKET:
|
case MYSQL_OPT_MAX_ALLOWED_PACKET:
|
||||||
if (mysql)
|
if (mysql)
|
||||||
@@ -3344,7 +3327,7 @@ void STDCALL mysql_server_end(void)
|
|||||||
list_free(pvio_callback, 0);
|
list_free(pvio_callback, 0);
|
||||||
if (ma_init_done)
|
if (ma_init_done)
|
||||||
ma_end(0);
|
ma_end(0);
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
ma_pvio_tls_end();
|
ma_pvio_tls_end();
|
||||||
#endif
|
#endif
|
||||||
mysql_client_init= 0;
|
mysql_client_init= 0;
|
||||||
@@ -3409,6 +3392,7 @@ static my_socket mariadb_get_socket(MYSQL *mysql)
|
|||||||
if (mysql->net.pvio)
|
if (mysql->net.pvio)
|
||||||
{
|
{
|
||||||
ma_pvio_get_handle(mysql->net.pvio, &sock);
|
ma_pvio_get_handle(mysql->net.pvio, &sock);
|
||||||
|
|
||||||
}
|
}
|
||||||
/* if an asynchronous connect is in progress, we need to obtain
|
/* if an asynchronous connect is in progress, we need to obtain
|
||||||
pvio handle from async_context until the connection was
|
pvio handle from async_context until the connection was
|
||||||
@@ -3467,7 +3451,7 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
|
|||||||
*((char **)arg)= mysql->net.sqlstate;
|
*((char **)arg)= mysql->net.sqlstate;
|
||||||
break;
|
break;
|
||||||
case MARIADB_CONNECTION_TLS_VERSION:
|
case MARIADB_CONNECTION_TLS_VERSION:
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
if (mysql && mysql->net.pvio && mysql->net.pvio->ctls)
|
if (mysql && mysql->net.pvio && mysql->net.pvio->ctls)
|
||||||
{
|
{
|
||||||
struct st_ssl_version version;
|
struct st_ssl_version version;
|
||||||
@@ -3479,7 +3463,7 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
|
|||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case MARIADB_CONNECTION_TLS_VERSION_ID:
|
case MARIADB_CONNECTION_TLS_VERSION_ID:
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
if (mysql && mysql->net.pvio && mysql->net.pvio->ctls)
|
if (mysql && mysql->net.pvio && mysql->net.pvio->ctls)
|
||||||
{
|
{
|
||||||
struct st_ssl_version version;
|
struct st_ssl_version version;
|
||||||
@@ -3491,7 +3475,7 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
|
|||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case MARIADB_TLS_LIBRARY:
|
case MARIADB_TLS_LIBRARY:
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
#ifdef HAVE_GNUTLS
|
#ifdef HAVE_GNUTLS
|
||||||
*((char **)arg)= "GNUTLS";
|
*((char **)arg)= "GNUTLS";
|
||||||
#elif HAVE_OPENSSL
|
#elif HAVE_OPENSSL
|
||||||
@@ -3583,7 +3567,7 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MARIADB_CONNECTION_SSL_CIPHER:
|
case MARIADB_CONNECTION_SSL_CIPHER:
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
if (mysql && mysql->net.pvio && mysql->net.pvio->ctls)
|
if (mysql && mysql->net.pvio && mysql->net.pvio->ctls)
|
||||||
*((char **)arg)= (char *)ma_pvio_tls_cipher(mysql->net.pvio->ctls);
|
*((char **)arg)= (char *)ma_pvio_tls_cipher(mysql->net.pvio->ctls);
|
||||||
else
|
else
|
||||||
|
@@ -444,6 +444,8 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p)
|
|||||||
char t_buffer[MAX_TIME_STR_LEN];
|
char t_buffer[MAX_TIME_STR_LEN];
|
||||||
uint len= 0;
|
uint len= 0;
|
||||||
|
|
||||||
|
memset(t_buffer, 0, MAX_TIME_STR_LEN);
|
||||||
|
|
||||||
t_buffer[1]= t->neg ? 1 : 0;
|
t_buffer[1]= t->neg ? 1 : 0;
|
||||||
int4store(t_buffer + 2, t->day);
|
int4store(t_buffer + 2, t->day);
|
||||||
t_buffer[6]= (uchar) t->hour;
|
t_buffer[6]= (uchar) t->hour;
|
||||||
@@ -480,6 +482,7 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p)
|
|||||||
char t_buffer[MAX_DATETIME_STR_LEN];
|
char t_buffer[MAX_DATETIME_STR_LEN];
|
||||||
uint len;
|
uint len;
|
||||||
|
|
||||||
|
memset(t_buffer, 0, MAX_DATETIME_STR_LEN);
|
||||||
int2store(t_buffer + 1, t->year);
|
int2store(t_buffer + 1, t->year);
|
||||||
t_buffer[3]= (char) t->month;
|
t_buffer[3]= (char) t->month;
|
||||||
t_buffer[4]= (char) t->day;
|
t_buffer[4]= (char) t->day;
|
||||||
@@ -489,7 +492,7 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p)
|
|||||||
if (t->second_part)
|
if (t->second_part)
|
||||||
{
|
{
|
||||||
int4store(t_buffer + 8, t->second_part);
|
int4store(t_buffer + 8, t->second_part);
|
||||||
len= 12;
|
len= 11;
|
||||||
}
|
}
|
||||||
else if (t->hour || t->minute || t->second)
|
else if (t->hour || t->minute || t->second)
|
||||||
len= 7;
|
len= 7;
|
||||||
@@ -511,6 +514,7 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p)
|
|||||||
case MYSQL_TYPE_STRING:
|
case MYSQL_TYPE_STRING:
|
||||||
case MYSQL_TYPE_DECIMAL:
|
case MYSQL_TYPE_DECIMAL:
|
||||||
case MYSQL_TYPE_NEWDECIMAL:
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
|
case MYSQL_TYPE_GEOMETRY:
|
||||||
{
|
{
|
||||||
ulong len= (ulong)*stmt->params[column].length;
|
ulong len= (ulong)*stmt->params[column].length;
|
||||||
/* to is after p. The latter hasn't been moved */
|
/* to is after p. The latter hasn't been moved */
|
||||||
@@ -567,7 +571,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
|
|||||||
int1store(p, (unsigned char) stmt->flags);
|
int1store(p, (unsigned char) stmt->flags);
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
int1store(p, 1); /* and send 1 for iteration count */
|
int4store(p, 1); /* and send 1 for iteration count */
|
||||||
p+= 4;
|
p+= 4;
|
||||||
|
|
||||||
if (stmt->param_count)
|
if (stmt->param_count)
|
||||||
@@ -580,7 +584,7 @@ unsigned char* mysql_stmt_execute_generate_request(MYSQL_STMT *stmt, size_t *req
|
|||||||
{
|
{
|
||||||
size_t offset= p - start;
|
size_t offset= p - start;
|
||||||
length+= offset + null_count + 20;
|
length+= offset + null_count + 20;
|
||||||
if (!(start= (uchar *)realloc((gptr)start, length)))
|
if (!(start= (uchar *)realloc(start, length)))
|
||||||
goto mem_error;
|
goto mem_error;
|
||||||
p= start + offset;
|
p= start + offset;
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#include <openssl/conf.h>
|
#include <openssl/conf.h>
|
||||||
#include <openssl/md4.h>
|
#include <openssl/md4.h>
|
||||||
|
|
||||||
#define HAVE_SSL_SESSION_CACHE 1
|
#define HAVE_TLS_SESSION_CACHE 1
|
||||||
#ifndef HAVE_OPENSSL_DEFAULT
|
#ifndef HAVE_OPENSSL_DEFAULT
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#define ma_malloc(A,B) malloc((A))
|
#define ma_malloc(A,B) malloc((A))
|
||||||
@@ -112,7 +112,7 @@ static void my_cb_threadid(CRYPTO_THREADID *id)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SSL_SESSION_CACHE
|
#ifdef HAVE_TLS_SESSION_CACHE
|
||||||
typedef struct st_ma_tls_session {
|
typedef struct st_ma_tls_session {
|
||||||
char md4_hash[17];
|
char md4_hash[17];
|
||||||
SSL_SESSION *session;
|
SSL_SESSION *session;
|
||||||
@@ -270,7 +270,7 @@ int ma_tls_start(char *errmsg, size_t errmsg_len)
|
|||||||
ma_tls_get_error(errmsg, errmsg_len);
|
ma_tls_get_error(errmsg, errmsg_len);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_SSL_SESSION_CACHE
|
#ifdef HAVE_TLS_SESSION_CACHE
|
||||||
SSL_CTX_set_session_cache_mode(SSL_context, SSL_SESS_CACHE_CLIENT);
|
SSL_CTX_set_session_cache_mode(SSL_context, SSL_SESS_CACHE_CLIENT);
|
||||||
ma_tls_sessions= (MA_SSL_SESSION *)calloc(1, sizeof(struct st_ma_tls_session) * ma_tls_session_cache_size);
|
ma_tls_sessions= (MA_SSL_SESSION *)calloc(1, sizeof(struct st_ma_tls_session) * ma_tls_session_cache_size);
|
||||||
SSL_CTX_sess_set_new_cb(SSL_context, ma_tls_session_cb);
|
SSL_CTX_sess_set_new_cb(SSL_context, ma_tls_session_cb);
|
||||||
@@ -455,7 +455,7 @@ void *ma_tls_init(MYSQL *mysql)
|
|||||||
{
|
{
|
||||||
int verify;
|
int verify;
|
||||||
SSL *ssl= NULL;
|
SSL *ssl= NULL;
|
||||||
#ifdef HAVE_SSL_SESSION_CACHE
|
#ifdef HAVE_TLS_SESSION_CACHE
|
||||||
MA_SSL_SESSION *session= ma_tls_get_session(mysql);
|
MA_SSL_SESSION *session= ma_tls_get_session(mysql);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_lock(&LOCK_openssl_config);
|
pthread_mutex_lock(&LOCK_openssl_config);
|
||||||
@@ -471,7 +471,7 @@ void *ma_tls_init(MYSQL *mysql)
|
|||||||
if (!SSL_set_app_data(ssl, mysql))
|
if (!SSL_set_app_data(ssl, mysql))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
#ifdef HAVE_SSL_SESSION_CACHE
|
#ifdef HAVE_TLS_SESSION_CACHE
|
||||||
if (session)
|
if (session)
|
||||||
SSL_set_session(ssl, session->session);
|
SSL_set_session(ssl, session->session);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -172,7 +172,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
|||||||
if (mysql->client_flag & CLIENT_MULTI_STATEMENTS)
|
if (mysql->client_flag & CLIENT_MULTI_STATEMENTS)
|
||||||
mysql->client_flag|= CLIENT_MULTI_RESULTS;
|
mysql->client_flag|= CLIENT_MULTI_RESULTS;
|
||||||
|
|
||||||
#if defined(HAVE_SSL) && !defined(EMBEDDED_LIBRARY)
|
#if defined(HAVE_TLS) && !defined(EMBEDDED_LIBRARY)
|
||||||
if (mysql->options.ssl_key || mysql->options.ssl_cert ||
|
if (mysql->options.ssl_key || mysql->options.ssl_cert ||
|
||||||
mysql->options.ssl_ca || mysql->options.ssl_capath ||
|
mysql->options.ssl_ca || mysql->options.ssl_capath ||
|
||||||
mysql->options.ssl_cipher || mysql->options.use_ssl ||
|
mysql->options.ssl_cipher || mysql->options.use_ssl ||
|
||||||
@@ -180,7 +180,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
|||||||
mysql->options.use_ssl= 1;
|
mysql->options.use_ssl= 1;
|
||||||
if (mysql->options.use_ssl)
|
if (mysql->options.use_ssl)
|
||||||
mysql->client_flag|= CLIENT_SSL;
|
mysql->client_flag|= CLIENT_SSL;
|
||||||
#endif /* HAVE_SSL && !EMBEDDED_LIBRARY*/
|
#endif /* HAVE_TLS && !EMBEDDED_LIBRARY*/
|
||||||
if (mpvio->db)
|
if (mpvio->db)
|
||||||
mysql->client_flag|= CLIENT_CONNECT_WITH_DB;
|
mysql->client_flag|= CLIENT_CONNECT_WITH_DB;
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
|||||||
int3store(buff+2, net->max_packet_size);
|
int3store(buff+2, net->max_packet_size);
|
||||||
end= buff+5;
|
end= buff+5;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_TLS
|
||||||
if (mysql->options.ssl_key ||
|
if (mysql->options.ssl_key ||
|
||||||
mysql->options.ssl_cert ||
|
mysql->options.ssl_cert ||
|
||||||
mysql->options.ssl_ca ||
|
mysql->options.ssl_ca ||
|
||||||
@@ -260,7 +260,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
|||||||
if (ma_pvio_start_ssl(mysql->net.pvio))
|
if (ma_pvio_start_ssl(mysql->net.pvio))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SSL */
|
#endif /* HAVE_TLS */
|
||||||
|
|
||||||
/* This needs to be changed as it's not useful with big packets */
|
/* This needs to be changed as it's not useful with big packets */
|
||||||
if (mysql->user && mysql->user[0])
|
if (mysql->user && mysql->user[0])
|
||||||
|
@@ -270,19 +270,11 @@ size_t pvio_socket_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
|
|||||||
csock= (struct st_pvio_socket *)pvio->data;
|
csock= (struct st_pvio_socket *)pvio->data;
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
do {
|
|
||||||
r= recv(csock->socket, (void *)buffer, length, read_flags);
|
|
||||||
} while (r == -1 && errno == EINTR);
|
|
||||||
|
|
||||||
while (r == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
|
|
||||||
&& pvio->timeout[PVIO_READ_TIMEOUT] > 0)
|
|
||||||
{
|
|
||||||
if (pvio_socket_wait_io_or_timeout(pvio, TRUE, pvio->timeout[PVIO_READ_TIMEOUT]) < 1)
|
if (pvio_socket_wait_io_or_timeout(pvio, TRUE, pvio->timeout[PVIO_READ_TIMEOUT]) < 1)
|
||||||
return -1;
|
return -1;
|
||||||
do {
|
do {
|
||||||
r= recv(csock->socket, (void *)buffer, length, read_flags);
|
r= recv(csock->socket, (void *)buffer, length, read_flags);
|
||||||
} while (r == -1 && errno == EINTR);
|
} while (r == -1 && errno == EINTR);
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
WSABUF wsaData;
|
WSABUF wsaData;
|
||||||
|
@@ -72,12 +72,12 @@ ADD_LIBRARY(ma_getopt ma_getopt.c)
|
|||||||
|
|
||||||
FOREACH(API_TEST ${API_TESTS})
|
FOREACH(API_TEST ${API_TESTS})
|
||||||
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c)
|
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c)
|
||||||
TARGET_LINK_LIBRARIES(${API_TEST} mytap ma_getopt libmariadb)
|
TARGET_LINK_LIBRARIES(${API_TEST} mytap ma_getopt mariadbclient)
|
||||||
ADD_TEST(${API_TEST} ${EXECUTABLE_OUTPUT_PATH}/${API_TEST})
|
ADD_TEST(${API_TEST} ${EXECUTABLE_OUTPUT_PATH}/${API_TEST})
|
||||||
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 120)
|
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 120)
|
||||||
ENDFOREACH(API_TEST)
|
ENDFOREACH(API_TEST)
|
||||||
|
|
||||||
FOREACH(API_TEST ${MANUAL_TESTS})
|
FOREACH(API_TEST ${MANUAL_TESTS})
|
||||||
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c)
|
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c)
|
||||||
TARGET_LINK_LIBRARIES(${API_TEST} mytap ma_getopt libmariadb)
|
TARGET_LINK_LIBRARIES(${API_TEST} mytap ma_getopt mariadbclient)
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
|
@@ -101,7 +101,9 @@ wait_for_mysql(MYSQL *mysql, int status)
|
|||||||
(status & MYSQL_WAIT_WRITE ? POLLOUT : 0) |
|
(status & MYSQL_WAIT_WRITE ? POLLOUT : 0) |
|
||||||
(status & MYSQL_WAIT_EXCEPT ? POLLPRI : 0);
|
(status & MYSQL_WAIT_EXCEPT ? POLLPRI : 0);
|
||||||
if (status & MYSQL_WAIT_TIMEOUT)
|
if (status & MYSQL_WAIT_TIMEOUT)
|
||||||
|
{
|
||||||
timeout= mysql_get_timeout_value_ms(mysql);
|
timeout= mysql_get_timeout_value_ms(mysql);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
timeout= -1;
|
timeout= -1;
|
||||||
do {
|
do {
|
||||||
@@ -151,7 +153,7 @@ static int async1(MYSQL *my)
|
|||||||
check_mysql_rc(rc, (MYSQL *)&mysql);
|
check_mysql_rc(rc, (MYSQL *)&mysql);
|
||||||
|
|
||||||
/* set timeouts to 300 microseconds */
|
/* set timeouts to 300 microseconds */
|
||||||
default_timeout= 300;
|
default_timeout= 3;
|
||||||
mysql_options(&mysql, MYSQL_OPT_READ_TIMEOUT, &default_timeout);
|
mysql_options(&mysql, MYSQL_OPT_READ_TIMEOUT, &default_timeout);
|
||||||
mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, &default_timeout);
|
mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, &default_timeout);
|
||||||
mysql_options(&mysql, MYSQL_OPT_WRITE_TIMEOUT, &default_timeout);
|
mysql_options(&mysql, MYSQL_OPT_WRITE_TIMEOUT, &default_timeout);
|
||||||
|
@@ -913,6 +913,7 @@ static int test_get_options(MYSQL *my)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
/*
|
||||||
{"test_get_options", test_get_options, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_get_options", test_get_options, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_wrong_bind_address", test_wrong_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_wrong_bind_address", test_wrong_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_bind_address", test_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_bind_address", test_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
@@ -926,7 +927,7 @@ struct my_tests_st my_tests[] = {
|
|||||||
{"test_compress", test_compress, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_compress", test_compress, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
{"test_reconnect", test_reconnect, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_reconnect", test_reconnect, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_conc21", test_conc21, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_conc21", test_conc21, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_conc26", test_conc26, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_conc26", test_conc26, TEST_CONNECTION_NONE, 0, NULL, NULL}, */
|
||||||
{"test_connection_timeout", test_connection_timeout, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_connection_timeout", test_connection_timeout, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
{"test_connection_timeout2", test_connection_timeout2, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_connection_timeout2", test_connection_timeout2, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
{"test_connection_timeout3", test_connection_timeout3, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_connection_timeout3", test_connection_timeout3, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
|
@@ -184,16 +184,16 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
|
|||||||
{
|
{
|
||||||
MYSQL_STMT *stmt= 0;
|
MYSQL_STMT *stmt= 0;
|
||||||
uint rc, i, count= row_count;
|
uint rc, i, count= row_count;
|
||||||
ulong length[4];
|
ulong length[4]= {0,0,0,0};
|
||||||
MYSQL_BIND my_bind[4];
|
MYSQL_BIND my_bind[4];
|
||||||
my_bool is_null[4]= {0};
|
my_bool is_null[4]= {0,0,0,0};
|
||||||
MYSQL_TIME tm[4];
|
MYSQL_TIME tm[4];
|
||||||
ulong second_part;
|
ulong second_part;
|
||||||
uint year, month, day, hour, minute, sec;
|
uint year, month, day, hour, minute, sec;
|
||||||
|
|
||||||
stmt= mysql_stmt_init(mysql);
|
stmt= mysql_stmt_init(mysql);
|
||||||
FAIL_IF(!stmt, mysql_error(mysql));
|
FAIL_IF(!stmt, mysql_error(mysql));
|
||||||
rc= mysql_stmt_prepare(stmt, "INSERT INTO test_date VALUES(?, ?, ?, ?)", strlen("INSERT INTO test_date VALUES(?, ?, ?, ?)") + 1);
|
rc= mysql_stmt_prepare(stmt, "INSERT INTO test_date VALUES(?, ?, ?, ?)", -1); //strlen("INSERT INTO test_date VALUES(?, ?, ?, ?)"));
|
||||||
check_stmt_rc(rc, stmt);
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
FAIL_IF(mysql_stmt_param_count(stmt) != 4, "param_count != 4");
|
FAIL_IF(mysql_stmt_param_count(stmt) != 4, "param_count != 4");
|
||||||
@@ -203,6 +203,7 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
|
|||||||
its members.
|
its members.
|
||||||
*/
|
*/
|
||||||
memset(my_bind, '\0', sizeof(my_bind));
|
memset(my_bind, '\0', sizeof(my_bind));
|
||||||
|
memset(tm, 0, sizeof(tm));
|
||||||
|
|
||||||
my_bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP;
|
my_bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP;
|
||||||
my_bind[1].buffer_type= MYSQL_TYPE_TIME;
|
my_bind[1].buffer_type= MYSQL_TYPE_TIME;
|
||||||
@@ -2558,19 +2559,6 @@ static int test_pure_coverage(MYSQL *mysql)
|
|||||||
check_stmt_rc(rc, stmt);
|
check_stmt_rc(rc, stmt);
|
||||||
rc= mysql_stmt_execute(stmt);
|
rc= mysql_stmt_execute(stmt);
|
||||||
check_stmt_rc(rc, stmt);
|
check_stmt_rc(rc, stmt);
|
||||||
my_bind[0].buffer_type= MYSQL_TYPE_GEOMETRY;
|
|
||||||
rc= mysql_stmt_bind_result(stmt, my_bind);
|
|
||||||
|
|
||||||
/* Since libmariadb supports geometry types in prepared statements
|
|
||||||
we have to skip the following check
|
|
||||||
FAIL_IF(!rc, "Error expected");
|
|
||||||
rc= mysql_stmt_store_result(stmt);
|
|
||||||
FAIL_UNLESS(rc, "");
|
|
||||||
|
|
||||||
rc= mysql_stmt_store_result(stmt);
|
|
||||||
FAIL_UNLESS(rc, "");
|
|
||||||
|
|
||||||
*/
|
|
||||||
mysql_stmt_close(stmt);
|
mysql_stmt_close(stmt);
|
||||||
|
|
||||||
mysql_query(mysql, "DROP TABLE test_pure");
|
mysql_query(mysql, "DROP TABLE test_pure");
|
||||||
|
@@ -34,7 +34,7 @@ pthread_mutex_t LOCK_test;
|
|||||||
|
|
||||||
int check_skip_ssl()
|
int check_skip_ssl()
|
||||||
{
|
{
|
||||||
#ifndef HAVE_SSL
|
#ifndef HAVE_TLS
|
||||||
diag("client library built without OpenSSL support -> skip");
|
diag("client library built without OpenSSL support -> skip");
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -211,10 +211,10 @@ static int test_view_2where(MYSQL *mysql)
|
|||||||
strcpy(parms[i], "1");
|
strcpy(parms[i], "1");
|
||||||
my_bind[i].buffer_type = MYSQL_TYPE_VAR_STRING;
|
my_bind[i].buffer_type = MYSQL_TYPE_VAR_STRING;
|
||||||
my_bind[i].buffer = (char *)&parms[i];
|
my_bind[i].buffer = (char *)&parms[i];
|
||||||
my_bind[i].buffer_length = 100;
|
my_bind[i].buffer_length = 1;
|
||||||
my_bind[i].is_null = 0;
|
my_bind[i].is_null = 0;
|
||||||
my_bind[i].length = &length[i];
|
|
||||||
length[i] = 1;
|
length[i] = 1;
|
||||||
|
my_bind[i].length = &length[i];
|
||||||
}
|
}
|
||||||
stmt= mysql_stmt_init(mysql);
|
stmt= mysql_stmt_init(mysql);
|
||||||
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
||||||
@@ -687,8 +687,8 @@ struct my_tests_st my_tests[] = {
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// if (argc > 1)
|
if (argc > 1)
|
||||||
// get_options(&argc, &argv);
|
get_options(argc, argv);
|
||||||
|
|
||||||
get_envvars();
|
get_envvars();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user