Skip to content

Commit a86191c

Browse files
author
Arun Kuruvila
committed
Bug #21235226 : THE --ENABLE-CLEARTEXT-PLUGIN IS NOT
IMPLEMENTED IN ALL CLIENT PROGRAMS Description: Option "enable-cleartext-plugin" is not available for the following client utilities:- mysqldump mysqlimport mysqlshow mysqlcheck Analysis: The unavailability of this option limits the features like PAM authentication from using the above mentioned utilities. Fix: Option "enable-cleartext-plugin" is implemented in the above mentioned client utilities.
1 parent 3846b08 commit a86191c

7 files changed

Lines changed: 157 additions & 3 deletions

File tree

client/mysqlcheck.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -42,6 +42,8 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
4242
opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0,
4343
opt_write_binlog= 1;
4444
static uint verbose = 0, opt_mysql_port=0;
45+
static uint opt_enable_cleartext_plugin= 0;
46+
static my_bool using_opt_enable_cleartext_plugin= 0;
4547
static int my_end_arg;
4648
static char * opt_mysql_unix_port = 0;
4749
static char *opt_password = 0, *current_user = 0,
@@ -110,6 +112,10 @@ static struct my_option my_long_options[] =
110112
"Default authentication client-side plugin to use.",
111113
&opt_default_auth, &opt_default_auth, 0,
112114
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
115+
{"enable_cleartext_plugin", OPT_ENABLE_CLEARTEXT_PLUGIN,
116+
"Enable/disable the clear text authentication plugin.",
117+
&opt_enable_cleartext_plugin, &opt_enable_cleartext_plugin,
118+
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
113119
{"fast",'F', "Check only tables that haven't been closed properly.",
114120
&opt_fast, &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
115121
0},
@@ -326,6 +332,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
326332
verbose++;
327333
break;
328334
case 'V': print_version(); exit(0);
335+
case OPT_ENABLE_CLEARTEXT_PLUGIN:
336+
using_opt_enable_cleartext_plugin= TRUE;
337+
break;
329338
case OPT_MYSQL_PROTOCOL:
330339
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
331340
opt->name);
@@ -880,6 +889,10 @@ static int dbConnect(char *host, char *user, char *passwd)
880889
if (opt_default_auth && *opt_default_auth)
881890
mysql_options(&mysql_connection, MYSQL_DEFAULT_AUTH, opt_default_auth);
882891

892+
if (using_opt_enable_cleartext_plugin)
893+
mysql_options(&mysql_connection, MYSQL_ENABLE_CLEARTEXT_PLUGIN,
894+
(char *) &opt_enable_cleartext_plugin);
895+
883896
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
884897
if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
885898
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))

client/mysqldump.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -129,6 +129,8 @@ static ulong opt_compatible_mode= 0;
129129
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
130130
#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1
131131
#define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL 2
132+
static uint opt_enable_cleartext_plugin= 0;
133+
static my_bool using_opt_enable_cleartext_plugin= 0;
132134
static uint opt_mysql_port= 0, opt_master_data;
133135
static uint opt_slave_data;
134136
static uint my_end_arg;
@@ -513,6 +515,10 @@ static struct my_option my_long_options[] =
513515
"Default authentication client-side plugin to use.",
514516
&opt_default_auth, &opt_default_auth, 0,
515517
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
518+
{"enable_cleartext_plugin", OPT_ENABLE_CLEARTEXT_PLUGIN,
519+
"Enable/disable the clear text authentication plugin.",
520+
&opt_enable_cleartext_plugin, &opt_enable_cleartext_plugin,
521+
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
516522
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
517523
};
518524

@@ -883,6 +889,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
883889
default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
884890
break;
885891
}
892+
case (int) OPT_ENABLE_CLEARTEXT_PLUGIN:
893+
using_opt_enable_cleartext_plugin= TRUE;
894+
break;
886895
case (int) OPT_MYSQL_PROTOCOL:
887896
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
888897
opt->name);
@@ -1485,6 +1494,10 @@ static int connect_to_db(char *host, char *user,char *passwd)
14851494
if (opt_default_auth && *opt_default_auth)
14861495
mysql_options(&mysql_connection, MYSQL_DEFAULT_AUTH, opt_default_auth);
14871496

1497+
if (using_opt_enable_cleartext_plugin)
1498+
mysql_options(&mysql_connection, MYSQL_ENABLE_CLEARTEXT_PLUGIN,
1499+
(char *) &opt_enable_cleartext_plugin);
1500+
14881501
if (!(mysql= mysql_real_connect(&mysql_connection,host,user,passwd,
14891502
NULL,opt_mysql_port,opt_mysql_unix_port,
14901503
0)))

client/mysqlimport.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ static char *opt_password=0, *current_user=0,
4949
*lines_terminated=0, *enclosed=0, *opt_enclosed=0,
5050
*escaped=0, *opt_columns=0,
5151
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
52+
static uint opt_enable_cleartext_plugin= 0;
53+
static my_bool using_opt_enable_cleartext_plugin= 0;
5254
static uint opt_mysql_port= 0, opt_protocol= 0;
5355
static char * opt_mysql_unix_port=0;
5456
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
@@ -88,6 +90,10 @@ static struct my_option my_long_options[] =
8890
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
8991
{"delete", 'd', "First delete all rows from table.", &opt_delete,
9092
&opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
93+
{"enable_cleartext_plugin", OPT_ENABLE_CLEARTEXT_PLUGIN,
94+
"Enable/disable the clear text authentication plugin.",
95+
&opt_enable_cleartext_plugin, &opt_enable_cleartext_plugin,
96+
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
9197
{"fields-terminated-by", OPT_FTB,
9298
"Fields in the input file are terminated by the given string.",
9399
&fields_terminated, &fields_terminated, 0,
@@ -234,6 +240,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
234240
opt_local_file=1;
235241
break;
236242
#endif
243+
case OPT_ENABLE_CLEARTEXT_PLUGIN:
244+
using_opt_enable_cleartext_plugin= TRUE;
245+
break;
237246
case OPT_MYSQL_PROTOCOL:
238247
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
239248
opt->name);
@@ -435,6 +444,10 @@ static MYSQL *db_connect(char *host, char *database,
435444
if (opt_default_auth && *opt_default_auth)
436445
mysql_options(mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
437446

447+
if (using_opt_enable_cleartext_plugin)
448+
mysql_options(mysql, MYSQL_ENABLE_CLEARTEXT_PLUGIN,
449+
(char*)&opt_enable_cleartext_plugin);
450+
438451
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset);
439452
if (!(mysql_real_connect(mysql,host,user,passwd,
440453
database,opt_mysql_port,opt_mysql_unix_port,

client/mysqlshow.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -37,6 +37,8 @@ static uint my_end_arg= 0;
3737
static uint opt_verbose=0;
3838
static char *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
3939
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
40+
static uint opt_enable_cleartext_plugin= 0;
41+
static my_bool using_opt_enable_cleartext_plugin= 0;
4042

4143
#ifdef HAVE_SMEM
4244
static char *shared_memory_base_name=0;
@@ -133,6 +135,10 @@ int main(int argc, char **argv)
133135
if (opt_default_auth && *opt_default_auth)
134136
mysql_options(&mysql, MYSQL_DEFAULT_AUTH, opt_default_auth);
135137

138+
if (using_opt_enable_cleartext_plugin)
139+
mysql_options(&mysql, MYSQL_ENABLE_CLEARTEXT_PLUGIN,
140+
(char*)&opt_enable_cleartext_plugin);
141+
136142
if (!(mysql_real_connect(&mysql,host,user,opt_password,
137143
(first_argument_uses_wildcards) ? "" :
138144
argv[0],opt_mysql_port,opt_mysql_unix_port,
@@ -195,6 +201,10 @@ static struct my_option my_long_options[] =
195201
"Default authentication client-side plugin to use.",
196202
&opt_default_auth, &opt_default_auth, 0,
197203
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
204+
{"enable_cleartext_plugin", OPT_ENABLE_CLEARTEXT_PLUGIN,
205+
"Enable/disable the clear text authentication plugin.",
206+
&opt_enable_cleartext_plugin, &opt_enable_cleartext_plugin,
207+
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
198208
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
199209
0, 0, 0, 0, 0, 0},
200210
{"host", 'h', "Connect to host.", &host, &host, 0, GET_STR,
@@ -309,6 +319,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
309319
opt_protocol = MYSQL_PROTOCOL_PIPE;
310320
#endif
311321
break;
322+
case (int) OPT_ENABLE_CLEARTEXT_PLUGIN:
323+
using_opt_enable_cleartext_plugin= TRUE;
324+
break;
312325
case OPT_MYSQL_PROTOCOL:
313326
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
314327
opt->name);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Bug #21235226 : THE --ENABLE-CLEARTEXT-PLUGIN IS NOT IMPLEMENTED
3+
# IN ALL CLIENT PROGRAMS
4+
#
5+
CREATE DATABASE db21235226;
6+
USE db21235226;
7+
CREATE TABLE t1(a INT);
8+
INSERT INTO t1 VALUES (1), (2);
9+
SELECT * FROM t1;
10+
a
11+
1
12+
2
13+
CREATE USER uplain@localhost IDENTIFIED WITH 'cleartext_plugin_server'
14+
AS 'cleartext_test';
15+
GRANT ALL PRIVILEGES ON *.* TO uplain@localhost;
16+
mysqldump: Got error: 2059: Authentication plugin 'mysql_clear_password' cannot be loaded: plugin not enabled when trying to connect
17+
SELECT * FROM t1;
18+
a
19+
mysqlimport: Error: 2059 Authentication plugin 'mysql_clear_password' cannot be loaded: plugin not enabled
20+
SELECT * FROM t1;
21+
a
22+
1
23+
2
24+
mysqlshow: Authentication plugin 'mysql_clear_password' cannot be loaded: plugin not enabled
25+
Database: db21235226
26+
+--------+
27+
| Tables |
28+
+--------+
29+
| t1 |
30+
+--------+
31+
mysqlcheck: Got error: 2059: Authentication plugin 'mysql_clear_password' cannot be loaded: plugin not enabled when trying to connect
32+
db21235226.t1 OK
33+
DROP TABLE t1;
34+
DROP DATABASE db21235226;
35+
DROP USER uplain@localhost;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$PLUGIN_AUTH_OPT
2+
$PLUGIN_AUTH_LOAD
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--source include/have_plugin_auth.inc
2+
--source include/not_embedded.inc
3+
4+
--echo #
5+
--echo # Bug #21235226 : THE --ENABLE-CLEARTEXT-PLUGIN IS NOT IMPLEMENTED
6+
--echo # IN ALL CLIENT PROGRAMS
7+
--echo #
8+
9+
CREATE DATABASE db21235226;
10+
USE db21235226;
11+
12+
CREATE TABLE t1(a INT);
13+
INSERT INTO t1 VALUES (1), (2);
14+
SELECT * FROM t1;
15+
16+
CREATE USER uplain@localhost IDENTIFIED WITH 'cleartext_plugin_server'
17+
AS 'cleartext_test';
18+
19+
GRANT ALL PRIVILEGES ON *.* TO uplain@localhost;
20+
21+
#Reset the LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN variable.
22+
let LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=N;
23+
24+
#Scenario 1 : MYSQL_DUMP without --enable_cleartext_plugin
25+
# Should get CR_AUTH_PLUGIN_CANNOT_LOAD error
26+
--error 2
27+
--exec $MYSQL_DUMP --user=uplain --password=cleartext_test --tab=$MYSQLTEST_VARDIR/tmp/ db21235226 2>&1
28+
29+
#Scenario 2 : MYSQL_DUMP with --enable_cleartext_plugin
30+
--exec $MYSQL_DUMP --enable_cleartext_plugin --user=uplain --password=cleartext_test --tab=$MYSQLTEST_VARDIR/tmp/ db21235226
31+
--exec $MYSQL --enable_cleartext_plugin --user=uplain --password=cleartext_test db21235226 < $MYSQLTEST_VARDIR/tmp/t1.sql
32+
SELECT * FROM t1;
33+
34+
#Scenario 3 : MYSQL_IMPORT without --enable_cleartext_plugin
35+
# Should get CR_AUTH_PLUGIN_CANNOT_LOAD error
36+
--replace_regex /.*mysqlimport(\.exe)*/mysqlimport/
37+
--error 1
38+
--exec $MYSQL_IMPORT --user=uplain --password=cleartext_test --silent db21235226 $MYSQLTEST_VARDIR/tmp/t1.txt 2>&1
39+
40+
#Scenario 4 : MYSQL_IMPORT with --enable_cleartext_plugin
41+
--exec $MYSQL_IMPORT --enable_cleartext_plugin --user=uplain --password=cleartext_test --silent db21235226 $MYSQLTEST_VARDIR/tmp/t1.txt
42+
SELECT * FROM t1;
43+
44+
#Scenario 5 : MYSQL_SHOW without --enable_cleartext_plugin
45+
# Should get CR_AUTH_PLUGIN_CANNOT_LOAD error
46+
--replace_regex /.*mysqlshow(\.exe)*/mysqlshow/
47+
--error 1
48+
--exec $MYSQL_SHOW --user=uplain --password=cleartext_test db21235226 2>&1
49+
50+
#Scenario 6 : MYSQL_SHOW with --enable_cleartext_plugin
51+
--exec $MYSQL_SHOW --enable_cleartext_plugin --user=uplain --password=cleartext_test db21235226
52+
53+
#Scenario 7 : MYSQL_CHECK without --enable_cleartext_plugin
54+
# Should get CR_AUTH_PLUGIN_CANNOT_LOAD error
55+
--replace_regex /.*mysqlcheck(\.exe)*/mysqlcheck/
56+
--error 2
57+
--exec $MYSQL_CHECK --user=uplain --password=cleartext_test db21235226 t1 2>&1
58+
59+
#Scenario 8 : MYSQL_CHECK with --enable_cleartext_plugin
60+
--exec $MYSQL_CHECK --enable_cleartext_plugin --user=uplain --password=cleartext_test db21235226 t1
61+
62+
#Cleanup
63+
DROP TABLE t1;
64+
DROP DATABASE db21235226;
65+
DROP USER uplain@localhost;

0 commit comments

Comments
 (0)