diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-12-02 16:26:43 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-12-02 16:26:43 +0100 |
commit | d5fd757a4279f4fa8f032c6dd63d1d121d8e1fea (patch) | |
tree | ad5b63e8b1d154ab7b1753f9e156e7741b01899d /plugin | |
parent | 791286ee1c3c705cb8853e242cdf718a7b5ce5b7 (diff) | |
download | mariadb-git-d5fd757a4279f4fa8f032c6dd63d1d121d8e1fea.tar.gz |
1. add --plugin-dir and --default-auth to mysqltest.
2. dialog plugin now always returns mysql->password if non-empty and the first question is of password type
3. split get_tty_password into get_tty_password_buff and strdup.
4. dialog plugin now uses get_tty_password by default
5. dialog.test
6. moved small tests of individual plugins into a dedicated suite
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/auth/CMakeLists.txt | 2 | ||||
-rw-r--r-- | plugin/auth/Makefile.am | 2 | ||||
-rw-r--r-- | plugin/auth/dialog.c | 64 | ||||
-rw-r--r-- | plugin/feedback/feedback.h | 5 |
4 files changed, 26 insertions, 47 deletions
diff --git a/plugin/auth/CMakeLists.txt b/plugin/auth/CMakeLists.txt index 931a47fec5e..2174826b2cd 100644 --- a/plugin/auth/CMakeLists.txt +++ b/plugin/auth/CMakeLists.txt @@ -1,3 +1,3 @@ INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake") -SET(AUTH_SOURCES dialog.c) +SET(AUTH_SOURCES dialog.c ${CMAKE_SOURCE_DIR}/libmysql/get_password.c) MYSQL_PLUGIN(AUTH) diff --git a/plugin/auth/Makefile.am b/plugin/auth/Makefile.am index acca98e26f8..2995d35adf4 100644 --- a/plugin/auth/Makefile.am +++ b/plugin/auth/Makefile.am @@ -4,7 +4,7 @@ AM_LDFLAGS=-module -rpath $(pkgplugindir) AM_CPPFLAGS=-DMYSQL_DYNAMIC_PLUGIN -I$(top_srcdir)/include pkgplugin_LTLIBRARIES= dialog.la -dialog_la_SOURCES= dialog.c +dialog_la_SOURCES= dialog.c $(top_srcdir)/libmysql/get_password.c if HAVE_PEERCRED pkgplugin_LTLIBRARIES+= auth_socket.la diff --git a/plugin/auth/dialog.c b/plugin/auth/dialog.c index 76b2ddae528..24765c17d1c 100644 --- a/plugin/auth/dialog.c +++ b/plugin/auth/dialog.c @@ -142,36 +142,6 @@ static struct st_mysql_auth three_handler= 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; maria_declare_plugin(dialog) { MYSQL_AUTHENTICATION_PLUGIN, @@ -186,7 +156,7 @@ maria_declare_plugin(dialog) NULL, NULL, "1.0", - MariaDB_PLUGIN_MATURITY_BETA + MariaDB_PLUGIN_MATURITY_EXPERIMENTAL }, { MYSQL_AUTHENTICATION_PLUGIN, @@ -201,7 +171,7 @@ maria_declare_plugin(dialog) NULL, NULL, "1.0", - MariaDB_PLUGIN_MATURITY_BETA + MariaDB_PLUGIN_MATURITY_EXPERIMENTAL } maria_declare_plugin_end; @@ -224,16 +194,25 @@ static char *builtin_ask(MYSQL *mysql __attribute__((unused)), const char *prompt, char *buf, int buf_len) { - int len; - fputs(prompt, stdout); fputc(' ', stdout); - if (fgets(buf, buf_len, stdin) == 0) - return 0; - len= strlen(buf); - if (len && buf[len-1]=='\n') - buf[len-1]=0; + if (type == 2) /* password */ + { + get_tty_password_buff("", buf, buf_len); + buf[buf_len-1]= 0; + } + else + { + if (!fgets(buf, buf_len-1, stdin)) + buf[0]= 0; + else + { + int len= strlen(buf); + if (len && buf[len-1] == '\n') + buf[len-1]= 0; + } + } return buf; } @@ -261,6 +240,7 @@ static int perform_dialog(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) unsigned char *pkt, cmd= 0; int pkt_len, res; char reply_buf[1024], *reply; + int first = 1; do { @@ -269,7 +249,7 @@ static int perform_dialog(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) if (pkt_len < 0) return CR_ERROR; - if (pkt == 0) + if (pkt == 0 && first) { /* in mysql_change_user() the client sends the first packet, so @@ -291,10 +271,10 @@ static int perform_dialog(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) return CR_OK_HANDSHAKE_COMPLETE; /* yes. we're done */ /* - asking for a password with an empty prompt means mysql->password + asking for a password in the first packet mean mysql->password, if it's set otherwise we ask the user and read the reply */ - if ((cmd >> 1) == 2 && *pkt == 0) + if ((cmd >> 1) == 2 && first && mysql->passwd[0]) reply= mysql->passwd; else reply= ask(mysql, cmd >> 1, (char*) pkt, reply_buf, sizeof(reply_buf)); diff --git a/plugin/feedback/feedback.h b/plugin/feedback/feedback.h index df9020fc37e..f9e2cd34231 100644 --- a/plugin/feedback/feedback.h +++ b/plugin/feedback/feedback.h @@ -12,9 +12,8 @@ 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 */ -#ifndef MYSQL_SERVER -#define MYSQL_SERVER -#endif + +#define MYSQL_SERVER 1 #include <mysql_priv.h> namespace feedback { |