diff --git a/include/mysql/auth_dialog_client.h b/include/mysql/auth_dialog_client.h new file mode 100644 index 00000000000..2c58aac9444 --- /dev/null +++ b/include/mysql/auth_dialog_client.h @@ -0,0 +1,56 @@ +#ifndef MYSQL_AUTH_DIALOG_CLIENT_INCLUDED +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/** + @file + + Definitions needed to use Dialog client authentication plugin +*/ + +struct st_mysql; + +#define MYSQL_AUTH_DIALOG_CLIENT_INCLUDED + +/** + type of the mysql_authentication_dialog_ask function + + @param mysql mysql + @param type type of the input + 1 - ordinary string input + 2 - password string + @param prompt prompt + @param buf a buffer to store the use input + @param buf_len the length of the buffer + + @retval a pointer to the user input string. + It may be equal to 'buf' or to 'mysql->password'. + In all other cases it is assumed to be an allocated + string, and the "dialog" plugin will free() it. +*/ +typedef char *(*mysql_authentication_dialog_ask_t)(struct st_mysql *mysql, + int type, const char *prompt, char *buf, int buf_len); + +/** + first byte of the question string is the question "type". + It can be an "ordinary" or a "password" question. + The last bit set marks a last question in the authentication exchange. +*/ +#define ORDINARY_QUESTION "\2" +#define LAST_QUESTION "\3" +#define PASSWORD_QUESTION "\4" +#define LAST_PASSWORD "\5" + +#endif diff --git a/include/mysql/client_plugin.h b/include/mysql/client_plugin.h index 6af0d226ea2..eb1c74d7c0b 100644 --- a/include/mysql/client_plugin.h +++ b/include/mysql/client_plugin.h @@ -23,6 +23,30 @@ */ #define MYSQL_CLIENT_PLUGIN_INCLUDED +/* + On Windows, exports from DLL need to be declared + Also, plugin needs to be declared as extern "C" because MSVC + unlike other compilers, uses C++ mangling for variables not only + for functions. +*/ +#if defined(_MSC_VER) +#if defined(MYSQL_DYNAMIC_PLUGIN) + #ifdef __cplusplus + #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport) + #else + #define MYSQL_PLUGIN_EXPORT __declspec(dllexport) + #endif +#else /* MYSQL_DYNAMIC_PLUGIN */ + #ifdef __cplusplus + #define MYSQL_PLUGIN_EXPORT extern "C" + #else + #define MYSQL_PLUGIN_EXPORT + #endif +#endif /*MYSQL_DYNAMIC_PLUGIN */ +#else /*_MSC_VER */ +#define MYSQL_PLUGIN_EXPORT +#endif + #ifndef MYSQL_ABI_CHECK #include #include @@ -74,24 +98,8 @@ struct st_mysql_client_plugin_AUTHENTICATION int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql); }; -/** - type of the mysql_authentication_dialog_ask function +#include - @param mysql mysql - @param type type of the input - 1 - ordinary string input - 2 - password string - @param prompt prompt - @param buf a buffer to store the use input - @param buf_len the length of the buffer - - @retval a pointer to the user input string. - It may be equal to 'buf' or to 'mysql->password'. - In all other cases it is assumed to be an allocated - string, and the "dialog" plugin will free() it. -*/ -typedef char *(*mysql_authentication_dialog_ask_t)(struct st_mysql *mysql, - int type, const char *prompt, char *buf, int buf_len); /******** using plugins ************/ /** diff --git a/include/mysql/client_plugin.h.pp b/include/mysql/client_plugin.h.pp index 06ed6f2e6d8..f3a0b5769df 100644 --- a/include/mysql/client_plugin.h.pp +++ b/include/mysql/client_plugin.h.pp @@ -24,6 +24,8 @@ struct st_mysql_client_plugin_AUTHENTICATION int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(); int (*options)(const char *option, const void *); int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql); }; +#include +struct st_mysql; typedef char *(*mysql_authentication_dialog_ask_t)(struct st_mysql *mysql, int type, const char *prompt, char *buf, int buf_len); struct st_mysql_client_plugin * diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 816977d9b8e..8bacc312087 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -134,12 +134,6 @@ CACHE INTERNAL "Functions exported by client API" ) -IF(WIN32) - ADD_SUBDIRECTORY(authentication_win) - SET(WITH_AUTHENTICATION_WIN 1) - ADD_DEFINITIONS(-DAUTHENTICATION_WIN) -ENDIF(WIN32) - SET(CLIENT_SOURCES get_password.c libmysql.c diff --git a/plugin/auth_dialog/CMakeLists.txt b/plugin/auth_dialog/CMakeLists.txt new file mode 100644 index 00000000000..3e1f3579848 --- /dev/null +++ b/plugin/auth_dialog/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2 of the +# License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +MYSQL_ADD_PLUGIN(dialog dialog.c MODULE_ONLY) diff --git a/plugin/auth/dialog.c b/plugin/auth_dialog/dialog.c similarity index 66% rename from plugin/auth/dialog.c rename to plugin/auth_dialog/dialog.c index f2901811428..48e9c4a3882 100644 --- a/plugin/auth/dialog.c +++ b/plugin/auth_dialog/dialog.c @@ -43,138 +43,13 @@ # define _GNU_SOURCE /* for RTLD_DEFAULT */ #endif -#include #include #include #include #include +#include +#include -/** - first byte of the question string is the question "type". - It can be an "ordinary" or a "password" question. - The last bit set marks a last question in the authentication exchange. -*/ -#define ORDINARY_QUESTION "\2" -#define LAST_QUESTION "\3" -#define PASSWORD_QUESTION "\4" -#define LAST_PASSWORD "\5" - -/********************* SERVER SIDE ****************************************/ - -/** - dialog demo with two questions, one password and one, the last, ordinary. -*/ -static int two_questions(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) -{ - unsigned char *pkt; - int pkt_len; - - /* send a password question */ - if (vio->write_packet(vio, - (const unsigned char *) PASSWORD_QUESTION "Password, please:", - 18)) - return CR_ERROR; - - /* read the answer */ - if ((pkt_len= vio->read_packet(vio, &pkt)) < 0) - return CR_ERROR; - - info->password_used= PASSWORD_USED_YES; - - /* fail if the password is wrong */ - if (strcmp((const char *) pkt, info->auth_string)) - return CR_ERROR; - - /* send the last, ordinary, question */ - if (vio->write_packet(vio, - (const unsigned char *) LAST_QUESTION "Are you sure ?", - 15)) - return CR_ERROR; - - /* read the answer */ - if ((pkt_len= vio->read_packet(vio, &pkt)) < 0) - return CR_ERROR; - - /* check the reply */ - return strcmp((const char *) pkt, "yes, of course") ? CR_ERROR : CR_OK; -} - -static struct st_mysql_auth two_handler= -{ - MYSQL_AUTHENTICATION_INTERFACE_VERSION, - "dialog", /* requires dialog client plugin */ - two_questions -}; - -/* dialog demo where the number of questions is not known in advance */ -static int three_attempts(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) -{ - unsigned char *pkt; - int pkt_len, i; - - for (i= 0; i < 3; i++) - { - /* send the prompt */ - if (vio->write_packet(vio, - (const unsigned char *) PASSWORD_QUESTION "Password, please:", 18)) - return CR_ERROR; - - /* read the password */ - if ((pkt_len= vio->read_packet(vio, &pkt)) < 0) - return CR_ERROR; - - info->password_used= PASSWORD_USED_YES; - - /* - finish, if the password is correct. - note, that we did not mark the prompt packet as "last" - */ - if (strcmp((const char *) pkt, info->auth_string) == 0) - return CR_OK; - } - - return CR_ERROR; -} - -static struct st_mysql_auth three_handler= -{ - MYSQL_AUTHENTICATION_INTERFACE_VERSION, - "dialog", /* requires dialog client plugin */ - three_attempts -}; - -mysql_declare_plugin(dialog) -{ - MYSQL_AUTHENTICATION_PLUGIN, - &two_handler, - "two_questions", - "Sergei Golubchik", - "Dialog plugin demo 1", - PLUGIN_LICENSE_GPL, - NULL, - NULL, - 0x0100, - NULL, - NULL, - NULL -}, -{ - MYSQL_AUTHENTICATION_PLUGIN, - &three_handler, - "three_attempts", - "Sergei Golubchik", - "Dialog plugin demo 2", - PLUGIN_LICENSE_GPL, - NULL, - NULL, - 0x0100, - NULL, - NULL, - NULL -} -mysql_declare_plugin_end; - -/********************* CLIENT SIDE ***************************************/ /* This plugin performs a dialog with the user, asking questions and reading answers. Depending on the client it may be desirable to do it @@ -186,9 +61,6 @@ mysql_declare_plugin_end; dialog plugin will use it for communication with the user. Otherwise a default fgets() based implementation will be used. */ -#include -#include - static mysql_authentication_dialog_ask_t ask; static char *builtin_ask(MYSQL *mysql __attribute__((unused)), diff --git a/plugin/auth/CMakeLists.txt b/plugin/auth_examples/CMakeLists.txt similarity index 77% rename from plugin/auth/CMakeLists.txt rename to plugin/auth_examples/CMakeLists.txt index 6a9c31f82ce..0c9fb32b77a 100644 --- a/plugin/auth/CMakeLists.txt +++ b/plugin/auth_examples/CMakeLists.txt @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -MYSQL_ADD_PLUGIN(auth dialog.c +MYSQL_ADD_PLUGIN(dialog_examples dialog_examples.c MODULE_ONLY) MYSQL_ADD_PLUGIN(auth_test_plugin test_plugin.c MODULE_ONLY) @@ -27,15 +27,5 @@ MYSQL_ADD_PLUGIN(qa_auth_server qa_auth_server.c MYSQL_ADD_PLUGIN(qa_auth_client qa_auth_client.c MODULE_ONLY) -CHECK_CXX_SOURCE_COMPILES( -"#define _GNU_SOURCE -#include -int main() { - struct ucred cred; - getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0); -}" HAVE_PEERCRED) - -IF(HAVE_PEERCRED) - MYSQL_ADD_PLUGIN(auth_socket auth_socket.c - MODULE_ONLY) -ENDIF() +MYSQL_ADD_PLUGIN(mysql_clear_password clear_password_client.c + MODULE_ONLY) diff --git a/plugin/auth_examples/clear_password_client.c b/plugin/auth_examples/clear_password_client.c new file mode 100644 index 00000000000..31be263b869 --- /dev/null +++ b/plugin/auth_examples/clear_password_client.c @@ -0,0 +1,47 @@ +/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include +#include + +/** + The main function of the mysql_clear_password authentication plugin. +*/ + +static int clear_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) +{ + int res; + + /* send password in clear text */ + res= vio->write_packet(vio, (const unsigned char *) mysql->passwd, + strlen(mysql->passwd) + 1); + + return res ? CR_ERROR : CR_OK; +} + +mysql_declare_client_plugin(AUTHENTICATION) + "mysql_clear_password", + "Georgi Kodinov", + "Clear password authentication plugin", + {0,1,0}, + "GPL", + NULL, + NULL, + NULL, + NULL, + clear_password_auth_client +mysql_end_client_plugin; + diff --git a/plugin/auth_examples/dialog_examples.c b/plugin/auth_examples/dialog_examples.c new file mode 100644 index 00000000000..0d8897042c9 --- /dev/null +++ b/plugin/auth_examples/dialog_examples.c @@ -0,0 +1,154 @@ +/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab + Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; version 2 of the + License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file + + examples for dialog client authentication plugin + + Two examples are provided: two_questions server plugin, that asks + the password and an "Are you sure?" question with a reply "yes, of course". + It demonstrates the usage of "password" (input is hidden) and "ordinary" + (input can be echoed) questions, and how to mark the last question, + to avoid an extra roundtrip. + + And three_attempts plugin that gives the user three attempts to enter + a correct password. It shows the situation when a number of questions + is not known in advance. +*/ + +#include +#include +#include +#include +#include + +/********************* SERVER SIDE ****************************************/ + +/** + dialog demo with two questions, one password and one, the last, ordinary. +*/ +static int two_questions(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) +{ + unsigned char *pkt; + int pkt_len; + + /* send a password question */ + if (vio->write_packet(vio, + (const unsigned char *) PASSWORD_QUESTION "Password, please:", + 18)) + return CR_ERROR; + + /* read the answer */ + if ((pkt_len= vio->read_packet(vio, &pkt)) < 0) + return CR_ERROR; + + info->password_used= PASSWORD_USED_YES; + + /* fail if the password is wrong */ + if (strcmp((const char *) pkt, info->auth_string)) + return CR_ERROR; + + /* send the last, ordinary, question */ + if (vio->write_packet(vio, + (const unsigned char *) LAST_QUESTION "Are you sure ?", + 15)) + return CR_ERROR; + + /* read the answer */ + if ((pkt_len= vio->read_packet(vio, &pkt)) < 0) + return CR_ERROR; + + /* check the reply */ + return strcmp((const char *) pkt, "yes, of course") ? CR_ERROR : CR_OK; +} + +static struct st_mysql_auth two_handler= +{ + MYSQL_AUTHENTICATION_INTERFACE_VERSION, + "dialog", /* requires dialog client plugin */ + two_questions +}; + +/* dialog demo where the number of questions is not known in advance */ +static int three_attempts(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) +{ + unsigned char *pkt; + int pkt_len, i; + + for (i= 0; i < 3; i++) + { + /* send the prompt */ + if (vio->write_packet(vio, + (const unsigned char *) PASSWORD_QUESTION "Password, please:", 18)) + return CR_ERROR; + + /* read the password */ + if ((pkt_len= vio->read_packet(vio, &pkt)) < 0) + return CR_ERROR; + + info->password_used= PASSWORD_USED_YES; + + /* + finish, if the password is correct. + note, that we did not mark the prompt packet as "last" + */ + if (strcmp((const char *) pkt, info->auth_string) == 0) + return CR_OK; + } + + return CR_ERROR; +} + +static struct st_mysql_auth three_handler= +{ + MYSQL_AUTHENTICATION_INTERFACE_VERSION, + "dialog", /* requires dialog client plugin */ + three_attempts +}; + +mysql_declare_plugin(dialog) +{ + MYSQL_AUTHENTICATION_PLUGIN, + &two_handler, + "two_questions", + "Sergei Golubchik", + "Dialog plugin demo 1", + PLUGIN_LICENSE_GPL, + NULL, + NULL, + 0x0100, + NULL, + NULL, + NULL +}, +{ + MYSQL_AUTHENTICATION_PLUGIN, + &three_handler, + "three_attempts", + "Sergei Golubchik", + "Dialog plugin demo 2", + PLUGIN_LICENSE_GPL, + NULL, + NULL, + 0x0100, + NULL, + NULL, + NULL +} +mysql_declare_plugin_end; + diff --git a/plugin/auth/qa_auth_client.c b/plugin/auth_examples/qa_auth_client.c similarity index 91% rename from plugin/auth/qa_auth_client.c rename to plugin/auth_examples/qa_auth_client.c index da7bfc14a73..a7ee2f83a39 100644 --- a/plugin/auth/qa_auth_client.c +++ b/plugin/auth_examples/qa_auth_client.c @@ -21,16 +21,6 @@ #include #include -/** - first byte of the question string is the question "type". - It can be a "ordinary" or a "password" question. - The last bit set marks a last question in the authentication exchange. -*/ -#define ORDINARY_QUESTION "\2" -#define LAST_QUESTION "\3" -#define LAST_PASSWORD "\4" -#define PASSWORD_QUESTION "\5" - /********************* CLIENT SIDE ***************************************/ /* client plugin used for testing the plugin API diff --git a/plugin/auth/qa_auth_interface.c b/plugin/auth_examples/qa_auth_interface.c similarity index 95% rename from plugin/auth/qa_auth_interface.c rename to plugin/auth_examples/qa_auth_interface.c index 0aa6c9ce20c..a768995fbfd 100644 --- a/plugin/auth/qa_auth_interface.c +++ b/plugin/auth_examples/qa_auth_interface.c @@ -21,16 +21,6 @@ #include #include -/** - first byte of the question string is the question "type". - It can be a "ordinary" or a "password" question. - The last bit set marks a last question in the authentication exchange. -*/ -#define ORDINARY_QUESTION "\2" -#define LAST_QUESTION "\3" -#define LAST_PASSWORD "\4" -#define PASSWORD_QUESTION "\5" - /********************* SERVER SIDE ****************************************/ static int qa_auth_interface (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) diff --git a/plugin/auth/qa_auth_server.c b/plugin/auth_examples/qa_auth_server.c similarity index 86% rename from plugin/auth/qa_auth_server.c rename to plugin/auth_examples/qa_auth_server.c index 17171610200..31cc4f08616 100644 --- a/plugin/auth/qa_auth_server.c +++ b/plugin/auth_examples/qa_auth_server.c @@ -21,16 +21,6 @@ #include #include -/** - first byte of the question string is the question "type". - It can be a "ordinary" or a "password" question. - The last bit set marks a last question in the authentication exchange. -*/ -#define ORDINARY_QUESTION "\2" -#define LAST_QUESTION "\3" -#define LAST_PASSWORD "\4" -#define PASSWORD_QUESTION "\5" - /********************* SERVER SIDE ****************************************/ static int qa_auth_interface (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) diff --git a/plugin/auth/test_plugin.c b/plugin/auth_examples/test_plugin.c similarity index 94% rename from plugin/auth/test_plugin.c rename to plugin/auth_examples/test_plugin.c index d38b2782285..da9ab51bb58 100644 --- a/plugin/auth/test_plugin.c +++ b/plugin/auth_examples/test_plugin.c @@ -32,16 +32,6 @@ #include #include -/** - first byte of the question string is the question "type". - It can be a "ordinary" or a "password" question. - The last bit set marks a last question in the authentication exchange. -*/ -#define ORDINARY_QUESTION "\2" -#define LAST_QUESTION "\3" -#define LAST_PASSWORD "\4" -#define PASSWORD_QUESTION "\5" - /********************* SERVER SIDE ****************************************/ /** diff --git a/plugin/auth_socket/CMakeLists.txt b/plugin/auth_socket/CMakeLists.txt new file mode 100644 index 00000000000..731f7d01f9a --- /dev/null +++ b/plugin/auth_socket/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2 of the +# License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +CHECK_CXX_SOURCE_COMPILES( +"#define _GNU_SOURCE +#include +int main() { + struct ucred cred; + getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, 0); +}" HAVE_PEERCRED) + +IF(HAVE_PEERCRED) + MYSQL_ADD_PLUGIN(auth_socket auth_socket.c MODULE_ONLY) +ENDIF() diff --git a/plugin/auth/auth_socket.c b/plugin/auth_socket/auth_socket.c similarity index 100% rename from plugin/auth/auth_socket.c rename to plugin/auth_socket/auth_socket.c diff --git a/libmysql/authentication_win/CMakeLists.txt b/plugin/win_auth_client/CMakeLists.txt similarity index 51% rename from libmysql/authentication_win/CMakeLists.txt rename to plugin/win_auth_client/CMakeLists.txt index 80cd14780e6..4541e23e94c 100644 --- a/libmysql/authentication_win/CMakeLists.txt +++ b/plugin/win_auth_client/CMakeLists.txt @@ -13,21 +13,22 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# Configuration for building Windows Authentication Plugin (client-side) -# +IF(WIN32) + # + # Configuration for building Windows Authentication Plugin (client-side) + # -ADD_DEFINITIONS(-DSECURITY_WIN32) -ADD_DEFINITIONS(-DDEBUG_ERRROR_LOG) # no error logging in production builds -ADD_DEFINITIONS(-DWINAUTH_USE_DBUG_LIB) # it is OK to use dbug library in statically - # linked plugin + ADD_DEFINITIONS(-DSECURITY_WIN32) + ADD_DEFINITIONS(-DDEBUG_ERRROR_LOG) # no error logging in production builds + #ADD_DEFINITIONS(-DWINAUTH_USE_DBUG_LIB) # it is OK to use dbug library in statically + # # linked plugin -SET(HEADERS common.h handshake.h) -SET(PLUGIN_SOURCES plugin_client.cc handshake_client.cc log_client.cc common.cc handshake.cc) + SET(HEADERS common.h handshake.h) + SET(PLUGIN_SOURCES plugin_client.cc handshake_client.cc + log_client.cc common.cc handshake.cc) -ADD_CONVENIENCE_LIBRARY(auth_win_client ${PLUGIN_SOURCES} ${HEADERS}) -TARGET_LINK_LIBRARIES(auth_win_client Secur32) + MYSQL_ADD_PLUGIN(authentication_windows_client ${PLUGIN_SOURCES} ${HEADERS} + LINK_LIBRARUES Secur32 + MODULE_ONLY) -# In IDE, group headers in a separate folder. - -SOURCE_GROUP(Headers REGULAR_EXPRESSION ".*h$") +ENDIF(WIN32) diff --git a/libmysql/authentication_win/common.cc b/plugin/win_auth_client/common.cc similarity index 100% rename from libmysql/authentication_win/common.cc rename to plugin/win_auth_client/common.cc diff --git a/libmysql/authentication_win/common.h b/plugin/win_auth_client/common.h similarity index 100% rename from libmysql/authentication_win/common.h rename to plugin/win_auth_client/common.h diff --git a/libmysql/authentication_win/handshake.cc b/plugin/win_auth_client/handshake.cc similarity index 100% rename from libmysql/authentication_win/handshake.cc rename to plugin/win_auth_client/handshake.cc diff --git a/libmysql/authentication_win/handshake.h b/plugin/win_auth_client/handshake.h similarity index 100% rename from libmysql/authentication_win/handshake.h rename to plugin/win_auth_client/handshake.h diff --git a/libmysql/authentication_win/handshake_client.cc b/plugin/win_auth_client/handshake_client.cc similarity index 100% rename from libmysql/authentication_win/handshake_client.cc rename to plugin/win_auth_client/handshake_client.cc diff --git a/libmysql/authentication_win/log_client.cc b/plugin/win_auth_client/log_client.cc similarity index 100% rename from libmysql/authentication_win/log_client.cc rename to plugin/win_auth_client/log_client.cc diff --git a/libmysql/authentication_win/plugin_client.cc b/plugin/win_auth_client/plugin_client.cc similarity index 100% rename from libmysql/authentication_win/plugin_client.cc rename to plugin/win_auth_client/plugin_client.cc diff --git a/sql-common/client.c b/sql-common/client.c index bbe6b33b759..57653203149 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2272,7 +2272,6 @@ typedef struct st_mysql_client_plugin_AUTHENTICATION auth_plugin_t; static int client_mpvio_write_packet(struct st_plugin_vio*, const uchar*, int); static int native_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql); static int old_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql); -static int clear_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql); static auth_plugin_t native_password_client_plugin= { @@ -2306,39 +2305,13 @@ static auth_plugin_t old_password_client_plugin= old_password_auth_client }; -static auth_plugin_t clear_password_client_plugin= -{ - MYSQL_CLIENT_AUTHENTICATION_PLUGIN, - MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION, - "mysql_clear_password", - "Georgi Kodinov", - "Clear password authentication plugin", - {0,1,0}, - "GPL", - NULL, - NULL, - NULL, - NULL, - clear_password_auth_client -}; - -#ifdef AUTHENTICATION_WIN -extern auth_plugin_t win_auth_client_plugin; -#endif - struct st_mysql_client_plugin *mysql_client_builtins[]= { (struct st_mysql_client_plugin *)&native_password_client_plugin, (struct st_mysql_client_plugin *)&old_password_client_plugin, - (struct st_mysql_client_plugin *)&clear_password_client_plugin, -#ifdef AUTHENTICATION_WIN - (struct st_mysql_client_plugin *)&win_auth_client_plugin, -#endif 0 }; - - /* this is a "superset" of MYSQL_PLUGIN_VIO, in C++ I use inheritance */ typedef struct { int (*read_packet)(struct st_plugin_vio *vio, uchar **buf); @@ -4342,18 +4315,3 @@ static int old_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) DBUG_RETURN(CR_OK); } -/** - The main function of the mysql_clear_password authentication plugin. -*/ - -static int clear_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) -{ - int res; - - /* send password in clear text */ - res= vio->write_packet(vio, (const unsigned char *) mysql->passwd, - strlen(mysql->passwd) + 1); - - return res ? CR_ERROR : CR_OK; -} -