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 /client | |
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 'client')
-rw-r--r-- | client/mysql.cc | 7 | ||||
-rw-r--r-- | client/mysqltest.cc | 44 |
2 files changed, 48 insertions, 3 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 82ffaa22032..0ce28fa90c6 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -4319,9 +4319,10 @@ char *get_arg(char *line, my_bool get_next_arg) string, and the "dialog" plugin will free() it. */ -extern "C" char *mysql_authentication_dialog_ask(MYSQL *mysql, int type, - const char *prompt, - char *buf, int buf_len) +MYSQL_PLUGIN_EXPORT +char *mysql_authentication_dialog_ask(MYSQL *mysql, int type, + const char *prompt, + char *buf, int buf_len) { char *s=buf; diff --git a/client/mysqltest.cc b/client/mysqltest.cc index cf1b81d6169..45de35ab84b 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -117,6 +117,7 @@ static my_bool disable_connect_log= 1; static my_bool disable_warnings= 0; static my_bool prepare_warnings_enabled= 0; static my_bool disable_info= 1; +static char *opt_plugin_dir= 0, *opt_default_auth; static my_bool abort_on_error= 1; static my_bool server_initialized= 0; static my_bool is_windows= 0; @@ -6235,6 +6236,13 @@ static struct my_option my_long_options[] = {"view-protocol", OPT_VIEW_PROTOCOL, "Use views for select.", &view_protocol, &view_protocol, 0, GET_BOOL, 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} }; @@ -8218,6 +8226,12 @@ int main(int argc, char **argv) if (opt_protocol) mysql_options(con->mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol); + if (opt_plugin_dir && *opt_plugin_dir) + mysql_options(con->mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir); + + if (opt_default_auth && *opt_default_auth) + mysql_options(con->mysql, MYSQL_DEFAULT_AUTH, opt_default_auth); + #ifdef HAVE_OPENSSL if (opt_use_ssl) @@ -10176,3 +10190,33 @@ static int setenv(const char *name, const char *value, int overwrite) return 0; } #endif + +/* + for the purpose of testing (see dialog.test) + we replace default mysql_authentication_dialog_ask function with the one, + that always reads from stdin with explicit echo. + +*/ +MYSQL_PLUGIN_EXPORT +char *mysql_authentication_dialog_ask(MYSQL *mysql, int type, + const char *prompt, + char *buf, int buf_len) +{ + char *s=buf; + + fputs(prompt, stdout); + fputs(" ", stdout); + + if (!fgets(buf, buf_len-1, stdin)) + buf[0]= 0; + else if (buf[0] && (s= strend(buf))[-1] == '\n') + s[-1]= 0; + + for (s= buf; *s; s++) + fputc(type == 2 ? '*' : *s, stdout); + + fputc('\n', stdout); + + return buf; +} + |