diff --git a/CMakeLists.txt b/CMakeLists.txt index 41762556..567e1c47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,13 +68,6 @@ ADD_OPTION(WITH_SSL "Enables use of TLS/SSL library" ON) INCLUDE(${CC_SOURCE_DIR}/cmake/misc.cmake) -IF (WITH_CURL) - INCLUDE(FindCURL) - IF(CURL_FOUND) - ADD_DEFINITIONS(-DHAVE_CURL=1) - ENDIF() -ENDIF() - IF(WITH_SIGNCODE) IF(WIN32 AND NOT SIGN_OPTIONS) SET(SIGN_OPTIONS /a /t http://timestamp.verisign.com/scripts/timstamp.dll) @@ -313,7 +306,8 @@ IF(NOT WITH_SSL STREQUAL "OFF") IF(WIN32) IF(WITH_SSL STREQUAL "SCHANNEL") ADD_DEFINITIONS(-DHAVE_SCHANNEL -DHAVE_TLS) - SET(SSL_SOURCES "${CC_SOURCE_DIR}/libmariadb/secure/schannel.c" "${CC_SOURCE_DIR}/libmariadb/secure/ma_schannel.c") + SET(SSL_SOURCES "${CC_SOURCE_DIR}/libmariadb/secure/schannel.c" + "${CC_SOURCE_DIR}/libmariadb/secure/ma_schannel.c") INCLUDE_DIRECTORIES("${CC_SOURCE_DIR}/plugins/pvio/") SET(SSL_LIBRARIES secur32) SET(TLS_LIBRARY_VERSION "Schannel ${CMAKE_SYSTEM_VERSION}") @@ -371,9 +365,9 @@ IF(NOT WIN32) ENDIF() ENDIF() ENDIF() +INCLUDE(${CMAKE_SOURCE_DIR}/plugins/CMakeLists.txt) ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(libmariadb) -ADD_SUBDIRECTORY(plugins) IF(NOT WIN32) ADD_SUBDIRECTORY(mariadb_config) ENDIF() @@ -475,6 +469,8 @@ ELSE() ENDIF() MESSAGE1(STATUS "MariaDB Connector/c configuration: +-- Static PLUGINS ${PLUGINS_STATIC} +-- Dynamic PLUGINS ${PLUGINS_DYNAMIC} -- CPack generation: ${CPACK_GENERATOR} -- SSL support: ${WITH_SSL} Libs: ${SSL_LIBRARIES} -- Zlib support: ${zlib_status} diff --git a/cmake/plugins.cmake b/cmake/plugins.cmake index 05d4d01d..87af1687 100644 --- a/cmake/plugins.cmake +++ b/cmake/plugins.cmake @@ -1,5 +1,5 @@ # -# Copyright (C) 2013-2016 MariaDB Corporation AB +# Copyright (C) 2013-2018 MariaDB Corporation AB # # Redistribution and use is allowed according to the terms of the New # BSD license. @@ -7,102 +7,85 @@ # # plugin configuration -MACRO(REGISTER_PLUGIN name source struct type target allow) - SET(PLUGIN_TYPE ${${name}}) - IF(NOT PLUGIN_TYPE STREQUAL "OFF" AND NOT PLUGIN_TYPE) - SET(PLUGIN_TYPE ${type}) - ENDIF() - IF(PLUGINS) - LIST(REMOVE_ITEM PLUGINS ${name}) - ENDIF() - SET(${name}_PLUGIN_SOURCE ${source}) - MARK_AS_ADVANCED(${name}_PLUGIN_SOURCE}) - SET(${name}_PLUGIN_TYPE ${PLUGIN_TYPE}) - IF(NOT ${target} STREQUAL "") - SET(${name}_PLUGIN_TARGET ${target}) - ENDIF() - SET(${name}_PLUGIN_STRUCT ${struct}) - SET(${name}_PLUGIN_SOURCE ${source}) - SET(${name}_PLUGIN_CHG ${allow}) - SET(PLUGINS ${PLUGINS} "${name}") - ADD_DEFINITIONS(-DHAVE_${name}=1) -ENDMACRO() +include(${CC_SOURCE_DIR}/cmake/install_plugins.cmake) +include(${CC_SOURCE_DIR}/cmake/sign.cmake) -MARK_AS_ADVANCED(PLUGINS) +FUNCTION(REGISTER_PLUGIN) -# CIO -REGISTER_PLUGIN("SOCKET" "${CC_SOURCE_DIR}/plugins/pvio/pvio_socket.c" "pvio_socket_plugin" "STATIC" pvio_socket 0) -IF(WIN32) - REGISTER_PLUGIN("NPIPE" "${CC_SOURCE_DIR}/plugins/pvio/pvio_npipe.c" "pvio_npipe_plugin" "STATIC" pvio_npipe 1) - REGISTER_PLUGIN("SHMEM" "${CC_SOURCE_DIR}/plugins/pvio/pvio_shmem.c" "pvio_shmem_plugin" "STATIC" pvio_shmem 1) -ENDIF() + SET(one_value_keywords TARGET DEFAULT TYPE) + SET(multi_value_keywords CONFIGURATIONS SOURCES LIBRARIES INCLUDES COMPILE_OPTIONS) -# AUTHENTICATION -IF(WIN32 OR WITH_SSL STREQUAL "OPENSSL") - REGISTER_PLUGIN("AUTH_SHA256PW" "${CC_SOURCE_DIR}/plugins/auth/sha256_pw.c" "sha256_password_client_plugin" "DYNAMIC" sha256_password 1) -ENDIF() -REGISTER_PLUGIN("AUTH_NATIVE" "${CC_SOURCE_DIR}/plugins/auth/my_auth.c" "native_password_client_plugin" "STATIC" "" 0) -REGISTER_PLUGIN("AUTH_OLDPASSWORD" "${CC_SOURCE_DIR}/plugins/auth/old_password.c" "old_password_client_plugin" "STATIC" "" 1) -SET(DIALOG_SOURCES ${CC_SOURCE_DIR}/plugins/auth/dialog.c ${CC_SOURCE_DIR}/libmariadb/get_password.c) -REGISTER_PLUGIN("AUTH_DIALOG" "${DIALOG_SOURCES}" "auth_dialog_plugin" "DYNAMIC" dialog 1) -REGISTER_PLUGIN("AUTH_CLEARTEXT" "${CC_SOURCE_DIR}/plugins/auth/mariadb_clear_text.c" "auth_cleartext_plugin" "DYNAMIC" "mysql_clear_password" 1) -IF(WIN32) - SET(GSSAPI_SOURCES ${CC_SOURCE_DIR}/plugins/auth/auth_gssapi_client.c ${CC_SOURCE_DIR}/plugins/auth/sspi_client.c ${CC_SOURCE_DIR}/plugins/auth/sspi_errmsg.c) - REGISTER_PLUGIN("AUTH_GSSAPI" "${GSSAPI_SOURCES}" "auth_gssapi_plugin" "DYNAMIC" "auth_gssapi_client" 1) -ELSE() - IF(GSSAPI_FOUND) - SET(GSSAPI_SOURCES ${CC_SOURCE_DIR}/plugins/auth/auth_gssapi_client.c ${CC_SOURCE_DIR}/plugins/auth/gssapi_client.c ${CC_SOURCE_DIR}/plugins/auth/gssapi_errmsg.c) - REGISTER_PLUGIN("AUTH_GSSAPI" "${GSSAPI_SOURCES}" "auth_gssapi_plugin" "DYNAMIC" "auth_gssapi_client" 1) - ENDIF() -ENDIF() + cmake_parse_arguments(CC_PLUGIN + "${options}" + "${one_value_keywords}" + "${multi_value_keywords}" + ${ARGN}) -#Remote_IO -IF(CURL_FOUND) - IF(WIN32) - REGISTER_PLUGIN("REMOTEIO" "${CC_SOURCE_DIR}/plugins/io/remote_io.c" "remote_io_plugin" "DYNAMIC" "remote_io" 1) - ELSE() - REGISTER_PLUGIN("REMOTEIO" "${CC_SOURCE_DIR}/plugins/io/remote_io.c" "remote_io_plugin" "DYNAMIC" "remote_io" 1) - ENDIF() -ENDIF() + # overwrite default if it was specified with cmake option + string(TOUPPER ${CC_PLUGIN_TARGET} cc_plugin) + if(NOT "${CLIENT_PLUGIN_${cc_plugin}}" STREQUAL "") + SET(CC_PLUGIN_DEFAULT ${CLIENT_PLUGIN_${cc_plugin}}) + endif() -#Trace -REGISTER_PLUGIN("TRACE_EXAMPLE" "${CC_SOURCE_DIR}/plugins/trace/trace_example.c" "trace_example_plugin" "OFF" "trace_example" 1) + # use uppercase + string(TOUPPER ${CC_PLUGIN_TARGET} target_name) + string(TOUPPER "${CC_PLUGIN_CONFIGURATIONS}" CC_PLUGIN_CONFIGURATIONS) -#Connection -REGISTER_PLUGIN("REPLICATION" "${CC_SOURCE_DIR}/plugins/connection/replication.c" "connection_replication_plugin" "OFF" "replication" 1) -REGISTER_PLUGIN("AURORA" "${CC_SOURCE_DIR}/plugins/connection/aurora.c" "connection_aurora_plugin" "OFF" "aurora" 1) + if(NOT ${PLUGIN_${target_name}} STREQUAL "") + string(TOUPPER ${PLUGIN_${target_name}} PLUGIN_${target_name}) + set(CC_PLUGIN_DEFAULT ${PLUGIN_${target_name}}) + endif() -# Allow registration of additional plugins -IF(PLUGIN_CONF_FILE) - INCLUDE(${PLUGIN_CONF_FILE}) -ENDIF() +# check if default value is valid + string(TOUPPER ${CC_PLUGIN_DEFAULT} CC_PLUGIN_DEFAULT) + list(FIND CC_PLUGIN_CONFIGURATIONS ${CC_PLUGIN_DEFAULT} configuration_found) + if(${configuration_found} EQUAL -1) + message(FATAL_ERROR "Invalid plugin type ${CC_PLUGIN_DEFAULT}. Allowed plugin types are ${CC_PLUGIN_CONFIGURATIONS}") + endif() + if(NOT ${CC_PLUGIN_DEFAULT} STREQUAL "OFF") + set(PLUGIN_${CC_PLUGIN_TARGET}_TYPE ${CC_PLUGIN_TYPE}) -SET(LIBMARIADB_SOURCES "") + if(${CC_PLUGIN_DEFAULT} STREQUAL "DYNAMIC") + set_source_files_properties(${CC_PLUGIN_SOURCES} + PROPERTIES COMPILE_FLAGS + "-DPLUGIN_DYNAMIC=1 ${CC_PLUGIN_COMPILE_OPTIONS}") + set(PLUGINS_DYNAMIC ${PLUGINS_DYNAMIC} ${CC_PLUGIN_TARGET} PARENT_SCOPE) + if(WIN32) + set(target ${CC_PLUGIN_TARGET}) + set(FILE_TYPE "VFT_DLL") + set(FILE_DESCRIPTION "MariaDB client plugin") + set(FILE_VERSION ${CPACK_PACKAGE_VERSION}) + set(ORIGINAL_FILE_NAME "${target}.dll") + configure_file(${CC_SOURCE_DIR}/win/resource.rc.in + ${CC_BINARY_DIR}/win/${target}.rc + @ONLY) + set(CC_PLUGIN_SOURCES ${CC_PLUGIN_SOURCES} ${CC_BINARY_DIR}/win/${target}.rc ${CC_SOURCE_DIR}/plugins/plugin.def) + MESSAGE(STATUS "PLugin sources: ${CC_PLUGIN_SOURCES}") + endif() + add_library(${CC_PLUGIN_TARGET} MODULE ${CC_PLUGIN_SOURCES}) + target_link_libraries(${CC_PLUGIN_TARGET} ${CC_PLUGIN_LIBRARIES}) + set_target_properties(${CC_PLUGIN_TARGET} PROPERTIES PREFIX "") + set_target_properties(${CC_PLUGIN_TARGET} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CC_BINARY_DIR}/plugins/lib") + if (NOT "${CC_PLUGIN_INCLUDES}" STREQUAL "") + target_include_directories(${CC_PLUGIN_TARGET} PRIVATE ${CC_PLUGIN_INCLUDES}) + endif() + if (${CC_TARGET_COMPILE_OPTIONS}) + target_compile_options(${CC_PLUGIN_TARGET} ${CC_TARGET_COMPILE_OPTIONS}) + endif() -FOREACH(PLUGIN ${PLUGINS}) - IF(${OPT}WITH_${PLUGIN}_PLUGIN AND ${${PLUGIN}_PLUGIN_CHG} GREATER 0) - SET(${PLUGIN}_PLUGIN_TYPE ${${OPT}WITH_${PLUGIN}_PLUGIN}) - ENDIF() - IF(${PLUGIN}_PLUGIN_TYPE MATCHES "STATIC") - SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${${PLUGIN}_PLUGIN_SOURCE}) - SET(EXTERNAL_PLUGINS "${EXTERNAL_PLUGINS}extern struct st_mysql_client_plugin ${${PLUGIN}_PLUGIN_STRUCT};\n") - SET(BUILTIN_PLUGINS "${BUILTIN_PLUGINS}(struct st_mysql_client_plugin *)&${${PLUGIN}_PLUGIN_STRUCT},\n") - ENDIF() - SET(plugin_config "${plugin_config}\n-- ${PLUGIN}: ${${PLUGIN}_PLUGIN_TYPE}") - MARK_AS_ADVANCED(${PLUGIN}_PLUGIN_TYPE) -ENDFOREACH() -MESSAGE1(plugin_config "Plugin configuration:${plugin_config}") -MESSAGE1(LIBMARIADB_SOURCES "STATIC PLUGIN SOURCES: ${LIBMARIADB_SOURCES}") - -IF(NOT REMOTEIO_PLUGIN_TYPE MATCHES "NO") - FIND_PACKAGE(CURL) -ENDIF() - -# since some files contain multiple plugins, remove duplicates from source files -LIST(REMOVE_DUPLICATES LIBMARIADB_SOURCES) - -CONFIGURE_FILE(${CC_SOURCE_DIR}/libmariadb/ma_client_plugin.c.in - ${CC_BINARY_DIR}/libmariadb/ma_client_plugin.c) - -MARK_AS_ADVANCED(LIBMARIADB_SOURCES) + if(WIN32) + SIGN_TARGET(${target}) + endif() + INSTALL_PLUGIN(${CC_PLUGIN_TARGET} ${CMAKE_CURRENT_BINARY_DIR}) + elseif(${CC_PLUGIN_DEFAULT} STREQUAL "STATIC") + set(PLUGINS_STATIC ${PLUGINS_STATIC} ${CC_PLUGIN_TARGET} PARENT_SCOPE) + set(LIBMARIADB_PLUGIN_CFLAGS ${LIBMARIADB_PLUGIN_CFLAGS} ${CC_PLUGIN_COMPILE_OPTIONS} PARENT_SCOPE) + set(LIBMARIADB_PLUGIN_INCLUDES ${LIBMARIADB_PLUGIN_INCLUDES} ${CC_PLUGIN_INCLUDES} PARENT_SCOPE) + set(LIBMARIADB_PLUGIN_SOURCES ${LIBMARIADB_PLUGIN_SOURCES} ${CC_PLUGIN_SOURCES} PARENT_SCOPE) + set(LIBMARIADB_PLUGIN_LIBS ${LIBMARIADB_PLUGIN_LIBS} ${CC_PLUGIN_LIBRARIES} PARENT_SCOPE) + endif() + else() + set(PLUGINS_OFF ${PLUGINS_OFF} ${CC_PLUGIN_TARGET}) + endif() +endfunction() diff --git a/include/mariadb/ma_io.h b/include/mariadb/ma_io.h index bfbc706c..d39fc06e 100644 --- a/include/mariadb/ma_io.h +++ b/include/mariadb/ma_io.h @@ -19,7 +19,7 @@ #define _ma_io_h_ -#ifdef HAVE_CURL +#ifdef HAVE_REMOTEIO #include #endif @@ -29,7 +29,7 @@ enum enum_file_type { MA_FILE_REMOTE=2 }; -typedef struct +typedef struct { enum enum_file_type type; void *ptr; diff --git a/include/mysql/client_plugin.h b/include/mysql/client_plugin.h index d6ced69a..ac29afd6 100644 --- a/include/mysql/client_plugin.h +++ b/include/mysql/client_plugin.h @@ -48,7 +48,7 @@ /* Connector/C specific plugin types */ #define MARIADB_CLIENT_REMOTEIO_PLUGIN 100 /* communication IO */ -#define MARIADB_CLIENT_PVIO_PLUGIN 101 +#define MARIADB_CLIENT_PVIO_PLUGIN 101 #define MARIADB_CLIENT_TRACE_PLUGIN 102 #define MARIADB_CLIENT_CONNECTION_PLUGIN 103 @@ -89,15 +89,19 @@ struct st_mysql_client_plugin struct st_mysql; /********* connection handler plugin specific declarations **********/ + typedef struct st_ma_connection_plugin { MYSQL_CLIENT_PLUGIN_HEADER /* functions */ - MYSQL *(*connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd, - const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); + MYSQL *(*connect)(MYSQL *mysql, const char *host, + const char *user, const char *passwd, + const char *db, unsigned int port, + const char *unix_socket, unsigned long clientflag); void (*close)(MYSQL *mysql); - int (*set_options)(MYSQL *mysql, enum mysql_option, void *arg); - int (*set_connection)(MYSQL *mysql,enum enum_server_command command, const char *arg, + int (*set_optionsv)(MYSQL *mysql, unsigned int option, ...); + int (*set_connection)(MYSQL *mysql,enum enum_server_command command, + const char *arg, size_t length, my_bool skipp_check, void *opt_arg); my_bool (*reconnect)(MYSQL *mysql); int (*reset)(MYSQL *mysql); diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt index 449ffb12..430020bb 100644 --- a/libmariadb/CMakeLists.txt +++ b/libmariadb/CMakeLists.txt @@ -253,7 +253,19 @@ SET(MARIADB_NONBLOCK_SYMBOLS mysql_store_result_start ) +# handle static plugins +SET(LIBMARIADB_SOURCES ${LIBMARIADB_PLUGIN_SOURCES}) +SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBMARIADB_PLUGIN_LIBS}) +ADD_DEFINITIONS(${LIBMARIADB_PLUGIN_DEFS}) +FOREACH(plugin ${PLUGINS_STATIC}) + SET(EXTERNAL_PLUGINS "${EXTERNAL_PLUGINS} extern struct st_mysql_client_plugin ${plugin}_client_plugin;\n") + SET(BUILTIN_PLUGINS "${BUILTIN_PLUGINS} (struct st_mysql_client_plugin *)&${plugin}_client_plugin,\n") +ENDFOREACH() +CONFIGURE_FILE(${CC_SOURCE_DIR}/libmariadb/ma_client_plugin.c.in + ${CC_BINARY_DIR}/libmariadb/ma_client_plugin.c) + SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} +${CC_SOURCE_DIR}/plugins/auth/my_auth.c ma_array.c ma_charset.c ma_hash.c diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index f7a23a10..b4f20b0b 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -2616,7 +2616,7 @@ uchar *ma_get_hash_keyval(const uchar *hash_entry, return p; } -void ma_hash_free(void *p) +void ma_int_hash_free(void *p) { free(p); } @@ -2855,7 +2855,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) if (!hash_inited(&mysql->options.extension->userdata)) { if (_hash_init(&mysql->options.extension->userdata, - 0, 0, 0, ma_get_hash_keyval, ma_hash_free, 0)) + 0, 0, 0, ma_get_hash_keyval, ma_int_hash_free, 0)) { SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); goto end; @@ -2917,7 +2917,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) if (!hash_inited(&mysql->options.extension->connect_attrs)) { if (_hash_init(&mysql->options.extension->connect_attrs, - 0, 0, 0, ma_get_hash_keyval, ma_hash_free, 0)) + 0, 0, 0, ma_get_hash_keyval, ma_int_hash_free, 0)) { SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); goto end; @@ -4113,5 +4113,6 @@ struct st_mariadb_methods MARIADB_DEFAULT_METHODS = { my_set_error, /* invalidate statements */ ma_invalidate_stmts, + /* API functions */ &MARIADB_API }; diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index dd01414d..3b0e5e83 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,7 +1,9 @@ SET(PLUGIN_EXTRA_FILES ${CC_SOURCE_DIR}/libmariadb/ma_errmsg.c) + + FILE(GLOB plugin_dirs ${CC_SOURCE_DIR}/plugins/*) FOREACH(dir ${plugin_dirs}) IF (EXISTS ${dir}/CMakeLists.txt) - ADD_SUBDIRECTORY(${dir}) + INCLUDE(${dir}/CMakeLists.txt) ENDIF() ENDFOREACH() diff --git a/plugins/auth/auth_gssapi_client.c b/plugins/auth/auth_gssapi_client.c index 970615af..bd8ce6f4 100644 --- a/plugins/auth/auth_gssapi_client.c +++ b/plugins/auth/auth_gssapi_client.c @@ -100,8 +100,8 @@ static int gssapi_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) /* register client plugin */ -#ifndef HAVE_AUTH_GSSAPI_DYNAMIC -struct st_mysql_client_plugin_AUTHENTICATION auth_gssapi_plugin= +#ifndef PLUGIN_DYNAMIC +struct st_mysql_client_plugin_AUTHENTICATION auth_gssapi_client_plugin= #else struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ = #endif diff --git a/plugins/auth/dialog.c b/plugins/auth/dialog.c index c78898ae..31d7b7d8 100644 --- a/plugins/auth/dialog.c +++ b/plugins/auth/dialog.c @@ -1,5 +1,5 @@ /************************************************************************************ - Copyright (C) 2014 MariaDB Corporation AB + Copyright (C) 2014-2018 MariaDB Corporation AB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -34,15 +34,15 @@ /* function prototypes */ extern char *get_tty_password(char *opt_message, char *buff, int bufflen); static int auth_dialog_open(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql); -static int auth_dialog_init(char *unused1, - size_t unused2, - int unused3, +static int auth_dialog_init(char *unused1, + size_t unused2, + int unused3, va_list); mysql_authentication_dialog_ask_t auth_dialog_func; -#ifndef HAVE_DIALOG_DYNAMIC -struct st_mysql_client_plugin_AUTHENTICATION auth_dialog_plugin= +#ifndef PLUGIN_DYNAMIC +struct st_mysql_client_plugin_AUTHENTICATION dialog_client_plugin= #else struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ = #endif diff --git a/plugins/auth/mariadb_cleartext.c b/plugins/auth/mariadb_cleartext.c index 32d96e82..0ab68c09 100644 --- a/plugins/auth/mariadb_cleartext.c +++ b/plugins/auth/mariadb_cleartext.c @@ -1,5 +1,5 @@ /************************************************************************************ - Copyright (C) 2014 MariaDB Corporation AB + Copyright (C) 2014-2018 MariaDB Corporation AB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -53,8 +53,8 @@ static int clear_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) } /* }}} */ -#ifndef HAVE_DIALOG_DYNAMIC -struct st_mysql_client_plugin_AUTHENTICATION auth_cleartext_plugin= +#ifndef PLUGIN_DYNAMIC +struct st_mysql_client_plugin_AUTHENTICATION mysql_clear_password_client_plugin= #else struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ = #endif diff --git a/plugins/auth/my_auth.c b/plugins/auth/my_auth.c index 7f754523..af3cd7f5 100644 --- a/plugins/auth/my_auth.c +++ b/plugins/auth/my_auth.c @@ -34,7 +34,7 @@ do {\ } while (0); */ -auth_plugin_t native_password_client_plugin= +auth_plugin_t mysql_native_password_client_plugin= { MYSQL_CLIENT_AUTHENTICATION_PLUGIN, MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION, @@ -93,8 +93,6 @@ static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) return CR_OK; } - - static int send_change_user_packet(MCPVIO_EXT *mpvio, const uchar *data, int data_len) { @@ -313,7 +311,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio, } free(buff); return 0; - + error: free(buff); return 1; @@ -516,11 +514,11 @@ int run_plugin_auth(MYSQL *mysql, char *data, uint data_len, else { if (mysql->server_capabilities & CLIENT_PROTOCOL_41) - auth_plugin= &native_password_client_plugin; + auth_plugin= &mysql_native_password_client_plugin; else { if (!(auth_plugin= (auth_plugin_t*)mysql_client_find_plugin(mysql, - "old_password", MYSQL_CLIENT_AUTHENTICATION_PLUGIN))) + "mysql_old_password", MYSQL_CLIENT_AUTHENTICATION_PLUGIN))) return 1; /* not found */ } auth_plugin_name= auth_plugin->name; diff --git a/plugins/auth/old_password.c b/plugins/auth/old_password.c index 543a5b1d..b5a120da 100644 --- a/plugins/auth/old_password.c +++ b/plugins/auth/old_password.c @@ -1,5 +1,5 @@ /************************************************************************************ - Copyright (C) 2014,2015 MariaDB Corporation AB + Copyright (C) 2014,2015,2018 MariaDB Corporation AB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -46,8 +46,8 @@ typedef struct { int last_read_packet_len; /**< the length of the last *read* packet */ } MCPVIO_EXT; -#ifndef HAVE_OLDPASSWORD_DYNAMIC -struct st_mysql_client_plugin_AUTHENTICATION old_password_client_plugin= +#ifndef PLUGIN_DYNAMIC +struct st_mysql_client_plugin_AUTHENTICATION mysql_old_password_client_plugin= #else struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ = #endif diff --git a/plugins/auth/sha256_pw.c b/plugins/auth/sha256_pw.c index c5a23356..522307f1 100644 --- a/plugins/auth/sha256_pw.c +++ b/plugins/auth/sha256_pw.c @@ -60,7 +60,7 @@ static int auth_sha256_init(char *unused1, va_list); -#ifndef HAVE_SHA256PW_DYNAMIC +#ifndef PLUGIN_DYNAMIC struct st_mysql_client_plugin_AUTHENTICATION sha256_password_client_plugin= #else struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ = @@ -235,7 +235,7 @@ static int auth_sha256_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) /* Create context and load public key */ if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, der_buffer, der_buffer_len, - CRYPT_ENCODE_ALLOC_FLAG, NULL, + CRYPT_DECODE_ALLOC_FLAG, NULL, &publicKeyInfo, (DWORD *)&publicKeyInfoLen)) goto error; LocalFree(der_buffer); @@ -288,6 +288,8 @@ error: RSA_free(pubkey); #elif defined(HAVE_WINCRYPT) CryptReleaseContext(hProv, 0); + if (publicKeyInfo) + LocalFree(publicKeyInfo); #endif free(filebuffer); return rc; diff --git a/plugins/connection/CMakeLists.txt b/plugins/connection/CMakeLists.txt index 3642f087..cbfd4633 100644 --- a/plugins/connection/CMakeLists.txt +++ b/plugins/connection/CMakeLists.txt @@ -1,46 +1,13 @@ -IF(WIN32) - SET(EXPORT_FILE "../plugin.def") -ENDIF() +# Aurora +REGISTER_PLUGIN(TARGET aurora + TYPE MARIADB_CLIENT_PLUGIN_CONNECTION + CONFIGURATIONS STATIC DYNAMIC OFF + DEFAULT OFF + SOURCES ${CC_SOURCE_DIR}/plugins/connection/aurora.c) -SET(CMAKE_SHARED_LIBRARY_PREFIX "") -INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include) - -IF(REPLICATION_PLUGIN_TYPE MATCHES "DYNAMIC") - IF(WIN32) - SET_VERSION_INFO("TARGET:replication" - "FILE_TYPE:VFT_DLL" - "SOURCE_FILE:plugins/connection/replication.c" - "ORIGINAL_FILE_NAME:replication.dll" - "FILE_DESCRIPTION:Connection plugin for master/slave environment") - ENDIF() - ADD_DEFINITIONS(-DHAVE_REPLICATION_DYNAMIC=1) - ADD_LIBRARY(replication MODULE ${replication_RC} replication.c ${PLUGIN_EXTRA_FILES} ${EXPORT_FILE}) - IF(WIN32) - TARGET_LINK_LIBRARIES(replication libmariadb) - ENDIF() - SET(INSTALL_LIBS replication) -ENDIF() - -IF(AURORA_PLUGIN_TYPE MATCHES "DYNAMIC") - IF(WIN32) - SET_VERSION_INFO("TARGET:aurora" - "FILE_TYPE:VFT_DLL" - "SOURCE_FILE:plugins/connection/aurora.c" - "ORIGINAL_FILE_NAME:aurora.dll" - "FILE_DESCRIPTION:Connection plugin for Amazon AWS Aurora") - ENDIF() - ADD_DEFINITIONS(-DHAVE_AURORA_DYNAMIC=1) - ADD_LIBRARY(aurora MODULE ${aurora_RC} aurora.c ${PLUGIN_EXTRA_FILES} ${EXPORT_FILE}) - IF(WIN32) - TARGET_LINK_LIBRARIES(aurora libmariadb) - ENDIF() - SET(INSTALL_LIBS ${INSTALL_LIBS} aurora) -ENDIF() - - -IF(INSTALL_LIBS) - INSTALL(TARGETS - ${INSTALL_LIBS} - COMPONENT ClientPlugins - DESTINATION "${INSTALL_PLUGINDIR}") -ENDIF() +# Replication +REGISTER_PLUGIN(TARGET replication + TYPE MARIADB_CLIENT_PLUGIN_CONNECTION + CONFIGURATIONS STATIC DYNAMIC OFF + DEFAULT OFF + SOURCES ${CC_SOURCE_DIR}/plugins/connection/replication.c) diff --git a/plugins/connection/aurora.c b/plugins/connection/aurora.c index 342acf41..c62726d3 100644 --- a/plugins/connection/aurora.c +++ b/plugins/connection/aurora.c @@ -1,5 +1,5 @@ /************************************************************************************ - Copyright (C) 2015 MariaDB Corporation AB + Copyright (C) 2015-2018 MariaDB Corporation AB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -55,8 +55,10 @@ my_bool aurora_reconnect(MYSQL *mysql); #define AURORA_REPLICA 1 #define AURORA_UNAVAILABLE 2 -#ifndef HAVE_AURORA_DYNAMIC -MARIADB_CONNECTION_PLUGIN connection_aurora_plugin = +static struct st_mariadb_api *libmariadb_api= NULL; + +#ifndef PLUGIN_DYNAMIC +MARIADB_CONNECTION_PLUGIN aurora_client_plugin = #else MARIADB_CONNECTION_PLUGIN _mysql_client_plugin_declaration_ = #endif @@ -80,7 +82,6 @@ MARIADB_CONNECTION_PLUGIN _mysql_client_plugin_declaration_ = NULL }; -struct st_mariadb_api *mariadb_api= NULL; typedef struct st_aurora_instance { char *host; @@ -256,11 +257,11 @@ int aurora_get_instance_type(MYSQL *mysql) return -1; mysql->extension->conn_hdlr= 0; - if (!mariadb_api->mysql_query(mysql, query)) + if (!libmariadb_api->mysql_query(mysql, query)) { - MYSQL_RES *res= mariadb_api->mysql_store_result(mysql); - rc= mariadb_api->mysql_num_rows(res) ? AURORA_PRIMARY : AURORA_REPLICA; - mariadb_api->mysql_free_result(res); + MYSQL_RES *res= libmariadb_api->mysql_store_result(mysql); + rc= libmariadb_api->mysql_num_rows(res) ? AURORA_PRIMARY : AURORA_REPLICA; + libmariadb_api->mysql_free_result(res); } mysql->extension->conn_hdlr= save_hdlr; return rc; @@ -286,15 +287,15 @@ my_bool aurora_get_primary_id(MYSQL *mysql, AURORA *aurora) MA_CONNECTION_HANDLER *save_hdlr= mysql->extension->conn_hdlr; mysql->extension->conn_hdlr= 0; - if (!mariadb_api->mysql_query(mysql, "select server_id from information_schema.replica_host_status " + if (!libmariadb_api->mysql_query(mysql, "select server_id from information_schema.replica_host_status " "where session_id = 'MASTER_SESSION_ID'")) { MYSQL_RES *res; MYSQL_ROW row; - if ((res= mariadb_api->mysql_store_result(mysql))) + if ((res= libmariadb_api->mysql_store_result(mysql))) { - if ((row= mariadb_api->mysql_fetch_row(res))) + if ((row= libmariadb_api->mysql_fetch_row(res))) { if (row[0]) { @@ -302,7 +303,7 @@ my_bool aurora_get_primary_id(MYSQL *mysql, AURORA *aurora) rc= 1; } } - mariadb_api->mysql_free_result(res); + libmariadb_api->mysql_free_result(res); } } mysql->extension->conn_hdlr= save_hdlr; @@ -354,7 +355,7 @@ void aurora_refresh_blacklist(AURORA *aurora) /* {{{ MYSQL *aurora_connect_instance() */ MYSQL *aurora_connect_instance(AURORA *aurora, AURORA_INSTANCE *instance, MYSQL *mysql) { - if (!mariadb_api->mysql_real_connect(mysql, + if (!libmariadb_api->mysql_real_connect(mysql, instance->host, aurora->username, aurora->password, @@ -398,7 +399,7 @@ void aurora_close_internal(MYSQL *mysql) { mysql->extension->conn_hdlr= 0; memset(&mysql->options, 0, sizeof(struct st_mysql_options)); - mariadb_api->mysql_close(mysql); + libmariadb_api->mysql_close(mysql); } } /* }}} */ @@ -420,7 +421,7 @@ my_bool aurora_find_replica(AURORA *aurora) while (valid_instances && !replica_found) { int random_pick= rand() % valid_instances; - mysql= mariadb_api->mysql_init(NULL); + mysql= libmariadb_api->mysql_init(NULL); mysql->options= aurora->save_mysql.options; /* don't execute init_command on slave */ @@ -488,7 +489,7 @@ my_bool aurora_find_primary(AURORA *aurora) for (i=0; i < aurora->num_instances; i++) { - mysql= mariadb_api->mysql_init(NULL); + mysql= libmariadb_api->mysql_init(NULL); mysql->options= aurora->save_mysql.options; if (check_primary && aurora->primary_id[0]) @@ -527,8 +528,8 @@ MYSQL *aurora_connect(MYSQL *mysql, const char *host, const char *user, const ch AURORA *aurora= NULL; MA_CONNECTION_HANDLER *save_hdlr= mysql->extension->conn_hdlr; - if (!mariadb_api) - mariadb_api= mysql->methods->api; + if (!libmariadb_api) + libmariadb_api= mysql->methods->api; /* we call aurora_connect either from mysql_real_connect or from mysql_reconnect, * so make sure in case of reconnect we don't allocate aurora twice */ @@ -536,7 +537,7 @@ MYSQL *aurora_connect(MYSQL *mysql, const char *host, const char *user, const ch { if (!(aurora= (AURORA *)calloc(1, sizeof(AURORA)))) { - mysql->methods->set_error(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); + mysql->methods->set_error(mysql, CR_OUT_OF_MEMORY, "HY000", 0); return NULL; } aurora->save_mysql= *mysql; @@ -740,7 +741,7 @@ int aurora_command(MYSQL *mysql,enum enum_server_command command, const char *ar if (aurora->mysql[AURORA_REPLICA] && mysql->thread_id == aurora->mysql[AURORA_PRIMARY]->thread_id) { aurora->mysql[AURORA_REPLICA]->extension->conn_hdlr= 0; - mariadb_api->mysql_select_db(aurora->mysql[AURORA_REPLICA], arg); + libmariadb_api->mysql_select_db(aurora->mysql[AURORA_REPLICA], arg); aurora->mysql[AURORA_REPLICA]->extension->conn_hdlr= mysql->extension->conn_hdlr; } break; @@ -759,8 +760,8 @@ int aurora_command(MYSQL *mysql,enum enum_server_command command, const char *ar else { aurora_switch_connection(mysql, aurora, AURORA_PRIMARY); - } - + } + break; default: aurora_switch_connection(mysql, aurora, AURORA_PRIMARY); break; diff --git a/plugins/connection/replication.c b/plugins/connection/replication.c index 101edaa8..11729532 100644 --- a/plugins/connection/replication.c +++ b/plugins/connection/replication.c @@ -1,5 +1,5 @@ /************************************************************************************ - Copyright (C) 2015 MariaDB Corporation AB + Copyright (C) 2015-2018 MariaDB Corporation AB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -41,15 +41,15 @@ MYSQL *repl_connect(MYSQL *mysql, const char *host, const char *user, const char void repl_close(MYSQL *mysql); int repl_command(MYSQL *mysql,enum enum_server_command command, const char *arg, size_t length, my_bool skipp_check, void *opt_arg); -int repl_set_options(MYSQL *msql, enum mysql_option option, void *arg); +int repl_set_optionsv(MYSQL *mysql, unsigned int option, ...); #define MARIADB_MASTER 0 #define MARIADB_SLAVE 1 -struct st_mariadb_api *mariadb_api= NULL; +static struct st_mariadb_api *libmariadb_api= NULL; -#ifndef HAVE_REPLICATION_DYNAMIC -MARIADB_CONNECTION_PLUGIN connection_replication_plugin = +#ifndef PLUGIN_DYNAMIC +MARIADB_CONNECTION_PLUGIN replication_client_plugin = #else MARIADB_CONNECTION_PLUGIN _mysql_client_plugin_declaration_ = #endif @@ -67,7 +67,7 @@ MARIADB_CONNECTION_PLUGIN _mysql_client_plugin_declaration_ = NULL, repl_connect, repl_close, - repl_set_options, + repl_set_optionsv, repl_command, NULL, NULL @@ -185,8 +185,8 @@ MYSQL *repl_connect(MYSQL *mysql, const char *host, const char *user, const char REPL_DATA *data= NULL; MA_CONNECTION_HANDLER *hdlr= mysql->extension->conn_hdlr; - if (!mariadb_api) - mariadb_api= mysql->methods->api; + if (!libmariadb_api) + libmariadb_api= mysql->methods->api; if ((data= (REPL_DATA *)hdlr->data)) { @@ -197,7 +197,7 @@ MYSQL *repl_connect(MYSQL *mysql, const char *host, const char *user, const char if (!(data= calloc(1, sizeof(REPL_DATA)))) { - mysql->methods->set_error(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); + mysql->methods->set_error(mysql, CR_OUT_OF_MEMORY, "HY000", 0); return NULL; } memset(data->pvio, 0, 2 * sizeof(MARIADB_PVIO *)); @@ -206,7 +206,7 @@ MYSQL *repl_connect(MYSQL *mysql, const char *host, const char *user, const char goto error; /* try to connect to master */ - if (!(mariadb_api->mysql_real_connect(mysql, data->host[MARIADB_MASTER], user, passwd, db, + if (!(libmariadb_api->mysql_real_connect(mysql, data->host[MARIADB_MASTER], user, passwd, db, data->port[MARIADB_MASTER] ? data->port[MARIADB_MASTER] : port, unix_socket, clientflag))) goto error; @@ -218,12 +218,12 @@ MYSQL *repl_connect(MYSQL *mysql, const char *host, const char *user, const char * connecting to slave(s) in background */ /* if slave connection will fail, we will not return error but use master instead */ - if (!(data->slave_mysql= mariadb_api->mysql_init(NULL)) || + if (!(data->slave_mysql= libmariadb_api->mysql_init(NULL)) || !(mysql->methods->db_connect(data->slave_mysql, data->host[MARIADB_SLAVE], user, passwd, db, data->port[MARIADB_SLAVE] ? data->port[MARIADB_SLAVE] : port, unix_socket, clientflag))) { if (data->slave_mysql) - mariadb_api->mysql_close(data->slave_mysql); + libmariadb_api->mysql_close(data->slave_mysql); data->pvio[MARIADB_SLAVE]= NULL; } else @@ -255,7 +255,7 @@ void repl_close(MYSQL *mysql) { /* restore mysql */ data->pvio[MARIADB_SLAVE]->mysql= data->slave_mysql; - mariadb_api->mysql_close(data->slave_mysql); + libmariadb_api->mysql_close(data->slave_mysql); data->pvio[MARIADB_SLAVE]= NULL; data->slave_mysql= NULL; } @@ -334,19 +334,24 @@ int repl_command(MYSQL *mysql,enum enum_server_command command, const char *arg, return 0; } -int repl_set_options(MYSQL *mysql, enum mysql_option option, void *arg) +int repl_set_optionsv(MYSQL *mysql, unsigned int option, ...) { - REPL_DATA *data= (REPL_DATA *)mysql->extension->conn_hdlr->data; - + REPL_DATA *data= (REPL_DATA *)mysql->extension->conn_hdlr->data; + va_list ap; + void *arg1; + int rc= 0; + + va_start(ap, option); + arg1= va_arg(ap, void *); + switch(option) { case MARIADB_OPT_CONNECTION_READ_ONLY: - data->read_only= *(my_bool *)arg; - return 0; -/* - case MARIADB_OPT_CONNECTION_ROUND_ROBIN: - data->round_robin= *(my_bool *)arg; - return 0; */ + data->read_only= *(my_bool *)arg1; + break; default: - return -1; + rc= -1; + break; } + va_end(ap); + return(rc); } diff --git a/plugins/io/CMakeLists.txt b/plugins/io/CMakeLists.txt index 276a733e..8c304c99 100644 --- a/plugins/io/CMakeLists.txt +++ b/plugins/io/CMakeLists.txt @@ -1,27 +1,15 @@ -INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include) - -INCLUDE(${CC_SOURCE_DIR}/cmake/install_plugins.cmake) -IF(WITH_SIGNCODE) - INCLUDE(${CC_SOURCE_DIR}/cmake/sign.cmake) -ENDIF() - -IF(REMOTEIO_PLUGIN_TYPE MATCHES "DYNAMIC") +IF (WITH_CURL) + INCLUDE(FindCURL) IF(CURL_FOUND) - IF(WIN32) - SET_VERSION_INFO("TARGET:remote_io" - "FILE_TYPE:VFT_DLL" - "SOURCE_FILE:plugins/io/remote_io.c" - "ORIGINAL_FILE_NAME:remote_io.dll" - "FILE_DESCRIPTION:Plugin for remote file access") - ENDIF() - # remote file plugin - INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR}) - SET(REMOTE_IO_SOURCES ${remote_io_RC} remote_io.c) - ADD_DEFINITIONS(-DHAVE_REMOTEIO_DYNAMIC=1) - ADD_LIBRARY(remote_io MODULE ${REMOTE_IO_SOURCES} ${CC_SOURCE_DIR}/plugins/plugin.def) - TARGET_LINK_LIBRARIES(remote_io ${CURL_LIBRARIES}) - SET_TARGET_PROPERTIES(remote_io PROPERTIES PREFIX "") - INSTALL_PLUGIN(remote_io ${CC_BINARY_DIR}/plugins/io) - SIGN_TARGET(remote_io) + + ADD_DEFINITIONS(-DHAVE_REMOTEIO=1) + #remote io plugin + REGISTER_PLUGIN(TARGET remote_io + TYPE MARIADB_CLIENT_PLUGIN_IO + CONFIGURATIONS DYNAMIC STATIC OFF + DEFAULT DYNAMIC + SOURCES ${CC_SOURCE_DIR}/plugins/io/remote_io.c + INCLUDES ${CURL_INCLUDE_DIR} + LIBRARIES ${CURL_LIBRARIES}) ENDIF() ENDIF() diff --git a/plugins/io/remote_io.c b/plugins/io/remote_io.c index 2a942c78..bb0a904a 100644 --- a/plugins/io/remote_io.c +++ b/plugins/io/remote_io.c @@ -1,5 +1,5 @@ /************************************************************************************ - * Copyright (C) 2015, 2016 Monty Program AB + * Copyright (C) 2015 - 2018 MariaDB Corporation AB * Copyright (c) 2003 Simtec Electronics * * Re-implemented by Vincent Sanders with extensive @@ -91,7 +91,7 @@ typedef struct CURLM *multi_handle= NULL; -#ifndef HAVE_REMOTEIO_DYNAMIC +#ifndef PLUGIN_DYNAMIC MARIADB_REMOTEIO_PLUGIN remote_io_plugin= #else MARIADB_REMOTEIO_PLUGIN _mysql_client_plugin_declaration_ = @@ -112,7 +112,10 @@ MARIADB_REMOTEIO_PLUGIN _mysql_client_plugin_declaration_ = mysql_end_client_plugin; /* {{{ ma_rio_init - Plugin initialization */ -int ma_rio_init(char *unused1, size_t unused2, int unused3, va_list unused4) +int ma_rio_init(char *unused1 __attribute__((unused)), + size_t unused2 __attribute__((unused)), + int unused3 __attribute__((unused)), + va_list unused4 __attribute__((unused))) { curl_global_init(CURL_GLOBAL_ALL); if (!multi_handle) diff --git a/plugins/pvio/CMakeLists.txt b/plugins/pvio/CMakeLists.txt index ff969664..76eb3ef0 100644 --- a/plugins/pvio/CMakeLists.txt +++ b/plugins/pvio/CMakeLists.txt @@ -1,55 +1,27 @@ -IF(WIN32) - SET(EXPORT_FILE "pvio_plugin.def") -ENDIF() - -INCLUDE(${CC_SOURCE_DIR}/cmake/install_plugins.cmake) -IF(WITH_SIGNCODE) - INCLUDE(${CC_SOURCE_DIR}/cmake/sign.cmake) -ENDIF() +SET(PVIO_DIR ${CC_SOURCE_DIR}/plugins/pvio) +INCLUDE_DIRECTORIES(${PVIO_DIR}) INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include) -SET(CMAKE_SHARED_LIBRARY_PREFIX "") - -IF(SOCKET_PLUGIN_TYPE MATCHES "DYNAMIC") - IF(WIN32) - SET_VERSION_INFO("TARGET:pvio_socket" - "FILE_TYPE:VFT_DLL" - "SOURCE_FILE:plugins/pvio/pvio_socket.c" - "ORIGINAL_FILE_NAME:pvio_socket.dll" - "FILE_DESCRIPTION:VIO plugin for socket communication") - ENDIF() - ADD_DEFINITIONS(-DHAVE_SOCKET_DYNAMIC=1) - ADD_LIBRARY(pvio_socket MODULE ${pvio_socket_RC} pvio_socket.c ${PLUGIN_EXTRA_FILES} ${EXPORT_FILE}) - INSTALL_PLUGIN(pvio_socket ${CC_BINARY_DIR}/plugins/pvio) - SIGN_TARGET(pvio_socket) -ENDIF() +#native password +REGISTER_PLUGIN(TARGET pvio_socket + TYPE MARIADB_CLIENT_PLUGIN_PVIO + CONFIGURATIONS STATIC DYNAMIC DEFAULT + DEFAULT STATIC + SOURCES ${CC_SOURCE_DIR}/plugins/pvio/pvio_socket.c) IF(WIN32) - IF(NPIPE_PLUGIN_TYPE MATCHES "DYNAMIC") - IF(WIN32) - SET_VERSION_INFO("TARGET:pvio_npipe" - "FILE_TYPE:VFT_DLL" - "SOURCE_FILE:plugins/pvio/pvio_npipe.c" - "ORIGINAL_FILE_NAME:pvio_npipe.dll" - "FILE_DESCRIPTION:VIO plugin for named pipe communication") - ENDIF() - ADD_DEFINITIONS(-DHAVE_NPIPE_DYNAMIC=1) - ADD_LIBRARY(pvio_npipe MODULE ${pvio_npipe_RC} pvio_npipe.c ${PLUGIN_EXTRA_FILES} ${EXPORT_FILE}) - INSTALL_PLUGIN(pvio_npipe ${CC_BINARY_DIR}/plugins/pvio) - SIGN_TARGET(pvio_npipe) - ENDIF() - IF(SHMEM_PLUGIN_TYPE MATCHES "DYNAMIC") - ADD_DEFINITIONS(-DHAVE_SHMEM_DYNAMIC=1) - IF(WIN32) - SET_VERSION_INFO("TARGET:pvio_shmem" - "FILE_TYPE:VFT_DLL" - "SOURCE_FILE:plugins/pvio/pvio_shmm.c" - "ORIGINAL_FILE_NAME:pvio_shmem.dll" - "FILE_DESCRIPTION:VIO plugin for shared memory communication") - ENDIF() - ADD_LIBRARY(pvio_shmem MODULE ${pvio_shmem_RC} pvio_shmem.c ${PLUGIN_EXTRA_FILES} ${EXPORT_FILE}) - INSTALL_PLUGIN(pvio_shmem ${CC_BINARY_DIR}/plugins/pvio) - SIGN_TARGET(pvio_shmem) - ENDIF() + # named pipe + REGISTER_PLUGIN(TARGET pvio_npipe + TYPE MARIADB_CLIENT_PLUGIN_PVIO + CONFIGURATIONS STATIC DYNAMIC DEFAULT + DEFAULT DYNAMIC + SOURCES ${CC_SOURCE_DIR}/plugins/pvio/pvio_npipe.c) + + # shared memory + REGISTER_PLUGIN(TARGET pvio_shmem + TYPE MARIADB_CLIENT_PLUGIN_PVIO + CONFIGURATIONS STATIC DYNAMIC DEFAULT + DEFAULT DYNAMIC + SOURCES ${CC_SOURCE_DIR}/plugins/pvio/pvio_shmem.c) ENDIF() diff --git a/plugins/pvio/pvio_npipe.c b/plugins/pvio/pvio_npipe.c index d745027b..1068d2c8 100644 --- a/plugins/pvio/pvio_npipe.c +++ b/plugins/pvio/pvio_npipe.c @@ -68,8 +68,8 @@ struct st_ma_pvio_methods pvio_npipe_methods= { pvio_npipe_shutdown }; -#ifndef HAVE_NPIPE_DYNAMIC -MARIADB_PVIO_PLUGIN pvio_npipe_plugin = +#ifndef PLUGIN_DYNAMIC +MARIADB_PVIO_PLUGIN pvio_npipe_client_plugin = #else MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_ = #endif @@ -234,7 +234,7 @@ my_bool pvio_npipe_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) if (!(cpipe= (struct st_pvio_npipe *)LocalAlloc(LMEM_ZEROINIT, sizeof(struct st_pvio_npipe)))) { - PVIO_SET_ERROR(cinfo->mysql, CR_OUT_OF_MEMORY, unknown_sqlstate, 0, ""); + PVIO_SET_ERROR(cinfo->mysql, CR_OUT_OF_MEMORY, "HY000", 0, ""); return 1; } memset(cpipe, 0, sizeof(struct st_pvio_npipe)); @@ -271,14 +271,14 @@ my_bool pvio_npipe_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) if (GetLastError() != ERROR_PIPE_BUSY) { - pvio->set_error(pvio->mysql, CR_NAMEDPIPEOPEN_ERROR, SQLSTATE_UNKNOWN, 0, + pvio->set_error(pvio->mysql, CR_NAMEDPIPEOPEN_ERROR, "HY000", 0, cinfo->host, cinfo->unix_socket, GetLastError()); goto end; } if (has_timedout || !WaitNamedPipe(szPipeName, pvio->timeout[PVIO_CONNECT_TIMEOUT])) { - pvio->set_error(pvio->mysql, CR_NAMEDPIPEWAIT_ERROR, SQLSTATE_UNKNOWN, 0, + pvio->set_error(pvio->mysql, CR_NAMEDPIPEWAIT_ERROR, "HY000", 0, cinfo->host, cinfo->unix_socket, GetLastError()); goto end; } @@ -288,7 +288,7 @@ my_bool pvio_npipe_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) dwMode = PIPE_READMODE_BYTE | PIPE_WAIT; if (!SetNamedPipeHandleState(cpipe->pipe, &dwMode, NULL, NULL)) { - pvio->set_error(pvio->mysql, CR_NAMEDPIPESETSTATE_ERROR, SQLSTATE_UNKNOWN, 0, + pvio->set_error(pvio->mysql, CR_NAMEDPIPESETSTATE_ERROR, "HY000", 0, cinfo->host, cinfo->unix_socket, (ulong) GetLastError()); goto end; } @@ -296,7 +296,7 @@ my_bool pvio_npipe_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) /* Register event handler for overlapped IO */ if (!(cpipe->overlapped.hEvent= CreateEvent(NULL, FALSE, FALSE, NULL))) { - pvio->set_error(pvio->mysql, CR_EVENT_CREATE_FAILED, SQLSTATE_UNKNOWN, 0, + pvio->set_error(pvio->mysql, CR_EVENT_CREATE_FAILED, "HY000", 0, GetLastError()); goto end; } diff --git a/plugins/pvio/pvio_shmem.c b/plugins/pvio/pvio_shmem.c index 86cd2ba1..8e7efa7d 100644 --- a/plugins/pvio/pvio_shmem.c +++ b/plugins/pvio/pvio_shmem.c @@ -63,8 +63,8 @@ struct st_ma_pvio_methods pvio_shm_methods= { pvio_shm_shutdown }; -#ifndef HAVE_SHMEM_DYNAMIC -MARIADB_PVIO_PLUGIN pvio_shmem_plugin= +#ifndef PLUGIN_DYNAMIC +MARIADB_PVIO_PLUGIN pvio_shmem_client_plugin= #else MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_= #endif @@ -249,11 +249,11 @@ my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) hdlConnectRequestAnswer= NULL, file_map= NULL; LPVOID map= NULL; - PVIO_SHM *pvio_shm= (PVIO_SHM*)LocalAlloc(LMEM_ZEROINIT, sizeof(PVIO_SHM)); + PVIO_SHM *pvio_shm= (PVIO_SHM*)LocalAlloc(LMEM_ZEROINIT, sizeof(PVIO_SHM)); if (!pvio_shm) { - PVIO_SET_ERROR(cinfo->mysql, CR_OUT_OF_MEMORY, unknown_sqlstate, 0, ""); + PVIO_SET_ERROR(cinfo->mysql, CR_OUT_OF_MEMORY, "HY000", 0, ""); return 0; } @@ -267,7 +267,7 @@ my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) if (!(shm_name= (char *)LocalAlloc(LMEM_ZEROINIT, strlen(base_memory_name) + 40))) { - PVIO_SET_ERROR(cinfo->mysql, CR_OUT_OF_MEMORY, unknown_sqlstate, 0, ""); + PVIO_SET_ERROR(cinfo->mysql, CR_OUT_OF_MEMORY, "HY000", 0, ""); goto error; } @@ -287,14 +287,14 @@ my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) } if (!hdlConnectRequest) { - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Opening CONNECT_REQUEST event failed", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Opening CONNECT_REQUEST event failed", GetLastError()); goto error; } strcpy(shm_suffix, "CONNECT_ANSWER"); if (!(hdlConnectRequestAnswer= OpenEvent(dwDesiredAccess, 0, shm_name))) { - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Opening CONNECT_ANSWER event failed", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Opening CONNECT_ANSWER event failed", GetLastError()); goto error; } @@ -302,42 +302,42 @@ my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) strcpy(shm_suffix, "CONNECT_DATA"); if (!(file_map= OpenFileMapping(FILE_MAP_WRITE, 0, shm_name))) { - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "OpenFileMapping failed", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "OpenFileMapping failed", GetLastError()); goto error; } /* try to get first 4 bytes, which represents connection_id */ if (!(map= MapViewOfFile(file_map, FILE_MAP_WRITE, 0, 0, sizeof(cid)))) { - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Reading connection_id failed", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Reading connection_id failed", GetLastError()); goto error; } /* notify server */ if (!SetEvent(hdlConnectRequest)) { - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Failed sending connection request", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Failed sending connection request", GetLastError()); goto error; } /* Wait for server answer */ switch(WaitForSingleObject(hdlConnectRequestAnswer, pvio->timeout[PVIO_CONNECT_TIMEOUT])) { case WAIT_ABANDONED: - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Mutex was not released in time", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Mutex was not released in time", GetLastError()); goto error; break; case WAIT_FAILED: - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Operation wait failed", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Operation wait failed", GetLastError()); goto error; break; case WAIT_TIMEOUT: - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Operation timed out", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Operation timed out", GetLastError()); goto error; break; case WAIT_OBJECT_0: break; default: - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Wait for server failed", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Wait for server failed", GetLastError()); break; } @@ -350,12 +350,12 @@ my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) pvio_shm->file_map= OpenFileMapping(FILE_MAP_WRITE, 0, shm_name); if (pvio_shm->file_map == NULL) { - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "OpenFileMapping failed", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "OpenFileMapping failed", GetLastError()); goto error; } if (!(pvio_shm->map= MapViewOfFile(pvio_shm->file_map, FILE_MAP_WRITE, 0, 0, PVIO_SHM_BUFFER_SIZE))) { - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "MapViewOfFile failed", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "MapViewOfFile failed", GetLastError()); goto error; } @@ -364,7 +364,7 @@ my_bool pvio_shm_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo) strcpy(shm_suffix, StrEvent[i]); if (!(pvio_shm->event[i]= OpenEvent(dwDesiredAccess, 0, shm_name))) { - PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, unknown_sqlstate, 0, "Couldn't create event", GetLastError()); + PVIO_SET_ERROR(cinfo->mysql, CR_SHARED_MEMORY_CONNECT_ERROR, "HY000", 0, "Couldn't create event", GetLastError()); goto error; } } diff --git a/plugins/pvio/pvio_socket.c b/plugins/pvio/pvio_socket.c index 0a6c4231..06a90090 100644 --- a/plugins/pvio/pvio_socket.c +++ b/plugins/pvio/pvio_socket.c @@ -80,7 +80,6 @@ #endif #endif - /* Function prototypes */ my_bool pvio_socket_set_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout); int pvio_socket_get_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type); @@ -128,8 +127,8 @@ struct st_ma_pvio_methods pvio_socket_methods= { pvio_socket_shutdown }; -#ifndef HAVE_SOCKET_DYNAMIC -MARIADB_PVIO_PLUGIN pvio_socket_plugin= +#ifndef PLUGIN_DYNAMIC +MARIADB_PVIO_PLUGIN pvio_socket_client_plugin= #else MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_ #endif diff --git a/plugins/trace/CMakeLists.txt b/plugins/trace/CMakeLists.txt deleted file mode 100644 index 9e0fe1ac..00000000 --- a/plugins/trace/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include) -INCLUDE(${CC_SOURCE_DIR}/cmake/install_plugins.cmake) -IF(WITH_SIGNCODE) - INCLUDE(${CC_SOURCE_DIR}/cmake/sign.cmake) -ENDIF() - -# Trace example plugin -IF(TRACE_EXAMPLE_PLUGIN_TYPE MATCHES "DYNAMIC") - IF(WIN32) - SET_VERSION_INFO("TARGET:trace_example" - "FILE_TYPE:VFT_DLL" - "SOURCE_FILE:plugins/trace/trace_example.c" - "ORIGINAL_FILE_NAME:trace_example.dll" - "FILE_DESCRIPTION:Trace example") - ENDIF() - ADD_DEFINITIONS(-DHAVE_TRACE_EXAMPLE_PLUGIN_DYNAMIC=1) - SET(TRACE_EXAMPLE_SOURCES ${trace_example_RC} trace_example.c) - IF(WIN32) - SET(TRACE_EXAMPLE_SOURCES ${TRACE_EXAMPLE_SOURCES} ${CC_SOURCE_DIR}/plugins/plugin.def) - ENDIF() - ADD_LIBRARY(trace_example MODULE ${TRACE_EXAMPLE_SOURCES}) - SET_TARGET_PROPERTIES(trace_example PROPERTIES PREFIX "") - INSTALL_PLUGIN(trace_example ${CC_BINARY_DIR}/plugins/trace) - SIGN_TARGET(trace_example) -ENDIF() diff --git a/unittest/libmariadb/misc.c b/unittest/libmariadb/misc.c index ab548b17..af97f509 100644 --- a/unittest/libmariadb/misc.c +++ b/unittest/libmariadb/misc.c @@ -707,6 +707,9 @@ static int test_wl4284_1(MYSQL *mysql) MYSQL_ROW row; MYSQL_RES *result; + diag("Test temporarily disabled"); + return SKIP; + if (mysql_get_server_version(mysql) < 60000) { diag("Test requires MySQL Server version 6.0 or above"); return SKIP; @@ -1088,7 +1091,7 @@ static int test_mdev12965(MYSQL *unused __attribute__((unused))) fprintf(fp, "[client]\ndefault-character-set=latin2\nreconnect=1\n"); fclose(fp); - mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "client"); + mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, ""); my_test_connect(mysql, hostname, username, password, schema, 0, socketname, 0); diff --git a/unittest/libmariadb/my_test.h b/unittest/libmariadb/my_test.h index 91ff6415..0aa673cf 100644 --- a/unittest/libmariadb/my_test.h +++ b/unittest/libmariadb/my_test.h @@ -525,8 +525,13 @@ MYSQL *my_test_connect(MYSQL *mysql, unsigned long clientflag) { if (force_tls) - mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &force_tls); - mysql= mysql_real_connect(mysql, host, user, passwd, db, port, unix_socket, clientflag); + mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &force_tls); + if (!mysql_real_connect(mysql, host, user, passwd, db, port, unix_socket, clientflag)) + { + diag("error: %s", mysql_error(mysql)); + return NULL; + } + if (mysql && force_tls && !mysql_get_ssl_cipher(mysql)) { diag("Error: TLS connection not established");