From d5e7008bddb6a7192c46c0c8f9100e5b099e71b0 Mon Sep 17 00:00:00 2001 From: Nirbhay Choubey Date: Tue, 7 Dec 2010 17:37:07 +0530 Subject: [PATCH] Bug#58139 : default-auth option not recognized in MySQL standard command line clients. Command line tools like mysqladmin and mysqldump did not recognize default-auth and plugin-dir options. Support for these options was found missing in these command line tools. Fixed by adding support for the same. --- client/mysqladmin.cc | 14 ++++++++++++++ client/mysqldump.c | 15 +++++++++++++++ mysql-test/r/plugin_auth.result | 10 ++++++++++ mysql-test/t/plugin_auth.test | 14 ++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 342a67fbc29..4c4747c25de 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -44,6 +44,7 @@ static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations; static uint opt_count_iterations= 0, my_end_arg; static ulong opt_connect_timeout, opt_shutdown_timeout; static char * unix_port=0; +static char *opt_plugin_dir= 0, *opt_default_auth; #ifdef HAVE_SMEM static char *shared_memory_base_name=0; @@ -206,6 +207,13 @@ static struct my_option my_long_options[] = {"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", &opt_shutdown_timeout, &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG, SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0}, + {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"default_auth", OPT_PLUGIN_DIR, + "Default authentication client-side plugin to use.", + (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -342,6 +350,12 @@ int main(int argc,char *argv[]) mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); error_flags= (myf)(opt_nobeep ? 0 : ME_BELL); + if (opt_plugin_dir && *opt_plugin_dir) + mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir); + + if (opt_default_auth && *opt_default_auth) + mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth); + if (sql_connect(&mysql, option_wait)) { /* diff --git a/client/mysqldump.c b/client/mysqldump.c index b47d88290a5..2d38e94f0fb 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -137,6 +137,7 @@ FILE *stderror_file=0; static char *shared_memory_base_name=0; #endif static uint opt_protocol= 0; +static char *opt_plugin_dir= 0, *opt_default_auth; /* Dynamic_string wrapper functions. In this file use these @@ -499,6 +500,13 @@ static struct my_option my_long_options[] = &where, &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.", + (uchar**) &opt_plugin_dir, (uchar**) &opt_plugin_dir, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"default_auth", OPT_PLUGIN_DIR, + "Default authentication client-side plugin to use.", + (uchar**) &opt_default_auth, (uchar**) &opt_default_auth, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -1452,6 +1460,13 @@ static int connect_to_db(char *host, char *user,char *passwd) mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name); #endif mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset); + + if (opt_plugin_dir && *opt_plugin_dir) + mysql_options(&mysql_connection, MYSQL_PLUGIN_DIR, opt_plugin_dir); + + if (opt_default_auth && *opt_default_auth) + mysql_options(&mysql_connection, MYSQL_DEFAULT_AUTH, opt_default_auth); + if (!(mysql= mysql_real_connect(&mysql_connection,host,user,passwd, NULL,opt_mysql_port,opt_mysql_unix_port, 0))) diff --git a/mysql-test/r/plugin_auth.result b/mysql-test/r/plugin_auth.result index 8a649f63598..b155b296ac1 100644 --- a/mysql-test/r/plugin_auth.result +++ b/mysql-test/r/plugin_auth.result @@ -318,4 +318,14 @@ Proxied_host Proxied_user With_grant 1 FLUSH PRIVILEGES; +# +# Bug#58139 : default-auth option not recognized in MySQL standardi +# command line clients +# +# Executing 'mysql' +1 +1 +# Executing 'mysqladmin' +mysqld is alive +# Executing 'mysqldump' End of 5.5 tests diff --git a/mysql-test/t/plugin_auth.test b/mysql-test/t/plugin_auth.test index 3b1dd93c4d1..351f61c57d1 100644 --- a/mysql-test/t/plugin_auth.test +++ b/mysql-test/t/plugin_auth.test @@ -394,4 +394,18 @@ FLUSH PRIVILEGES; FLUSH PRIVILEGES; +--echo # +--echo # Bug#58139 : default-auth option not recognized in MySQL standardi +--echo # command line clients +--echo # + +--echo # Executing 'mysql' +--exec $MYSQL -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT -e 'SELECT 1' + +--echo # Executing 'mysqladmin' +--exec $MYSQLADMIN -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT ping + +--echo # Executing 'mysqldump' +--exec $MYSQL_DUMP -u root -S $MASTER_MYSOCK -P $MASTER_MYPORT --compact --default-auth=auth_test_plugin $PLUGIN_AUTH_OPT test + --echo End of 5.5 tests