Skip to content

Commit f4d4b18

Browse files
author
Vamsikrishna Bhagi
committed
WL#6982 Make plugin column in mysql.user non-null
Since the introduction of the post-4.1 authentication method, the choice of authentication method was performed on the length of the password hash alone, thus enabling easy change of the authentication methods through a password change. This has become a problem with the introduction of other authentication methods in 5.5. We needed a special value (empty) of the authentication plugin column and a set of special cases throughout the code to support the backward compatible behavior. Since in 5.6 the pre-4.1 password hash is to be deprecated this worklog aims to remove this backward compatible layer and simplify the authentication code by removing the special cases. Now the native authentication methods will be subject to the same rules as the other authentication methods.
1 parent a82c330 commit f4d4b18

28 files changed

+319
-308
lines changed

mysql-test/r/mysqld--help-notwin.result

+3-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ The following options may be given as the first argument:
136136
--datetime-format=name
137137
The DATETIME format (ignored)
138138
--default-authentication-plugin=name
139-
Defines what password- and authentication algorithm to
140-
use per default
139+
The default authentication plugin used by the server to
140+
hash the password.
141141
--default-storage-engine=name
142142
The default storage engine for new tables
143143
--default-time-zone=name
@@ -1028,6 +1028,7 @@ connect-timeout 10
10281028
console FALSE
10291029
date-format %Y-%m-%d
10301030
datetime-format %Y-%m-%d %H:%i:%s
1031+
default-authentication-plugin mysql_native_password
10311032
default-storage-engine InnoDB
10321033
default-time-zone (No default value)
10331034
default-tmp-storage-engine InnoDB

mysql-test/r/mysqld--help-win.result

+3-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ The following options may be given as the first argument:
136136
--datetime-format=name
137137
The DATETIME format (ignored)
138138
--default-authentication-plugin=name
139-
Defines what password- and authentication algorithm to
140-
use per default
139+
The default authentication plugin used by the server to
140+
hash the password.
141141
--default-storage-engine=name
142142
The default storage engine for new tables
143143
--default-time-zone=name
@@ -1036,6 +1036,7 @@ connect-timeout 10
10361036
console FALSE
10371037
date-format %Y-%m-%d
10381038
datetime-format %Y-%m-%d %H:%i:%s
1039+
default-authentication-plugin mysql_native_password
10391040
default-storage-engine InnoDB
10401041
default-time-zone (No default value)
10411042
default-tmp-storage-engine InnoDB

mysql-test/r/plugin_auth.result

+3-3
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ TABLE_SCHEMA='mysql'
437437
ORDER BY COLUMN_NAME;
438438
IS_NULLABLE COLUMN_NAME
439439
YES authentication_string
440-
YES plugin
440+
NO plugin
441441
#
442442
# Bug #11936829: diff. between mysql.user (authentication_string)
443443
# in fresh and upgraded 5.5.11
@@ -448,7 +448,7 @@ COLUMN_NAME IN ('plugin', 'authentication_string')
448448
ORDER BY COLUMN_NAME;
449449
IS_NULLABLE COLUMN_NAME
450450
YES authentication_string
451-
YES plugin
451+
NO plugin
452452
ALTER TABLE mysql.user MODIFY plugin char(64) DEFAULT '' NOT NULL;
453453
ALTER TABLE mysql.user MODIFY authentication_string TEXT NOT NULL;
454454
Run mysql_upgrade on a 5.5.10 external authentication column layout
@@ -493,7 +493,7 @@ COLUMN_NAME IN ('plugin', 'authentication_string')
493493
ORDER BY COLUMN_NAME;
494494
IS_NULLABLE COLUMN_NAME
495495
YES authentication_string
496-
YES plugin
496+
NO plugin
497497
#
498498
# Bug #12610784: SET PASSWORD INCORRECTLY KEEP AN OLD EMPTY PASSWORD
499499
#

mysql-test/r/plugin_auth_qa_2.result

+16-16
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ SELECT user,plugin,authentication_string,password FROM mysql.user;
105105
user plugin authentication_string password
106106
qa_test_6_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
107107
qa_test_6_user qa_auth_interface qa_test_6_dest
108-
root
109-
root
110-
root
111-
root
108+
root mysql_native_password
109+
root mysql_native_password
110+
root mysql_native_password
111+
root mysql_native_password
112112
exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
113113
Warning: Using a password on the command line interface can be insecure.
114114
ERROR 1045 (28000): Access denied for user 'qa_test_6_user'@'localhost' (using password: YES)
@@ -117,10 +117,10 @@ SELECT user,plugin,authentication_string,password FROM mysql.user;
117117
user plugin authentication_string password
118118
qa_test_6_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
119119
qa_test_6_user qa_auth_interface qa_test_6_dest
120-
root
121-
root
122-
root
123-
root
120+
root mysql_native_password
121+
root mysql_native_password
122+
root mysql_native_password
123+
root mysql_native_password
124124
root qa_auth_interface qa_test_6_dest
125125
exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
126126
Warning: Using a password on the command line interface can be insecure.
@@ -130,10 +130,10 @@ SELECT user,plugin,authentication_string FROM mysql.user;
130130
user plugin authentication_string
131131
qa_test_6_dest mysql_native_password
132132
qa_test_6_user qa_auth_interface qa_test_6_dest
133-
root
134-
root
135-
root
136-
root
133+
root mysql_native_password
134+
root mysql_native_password
135+
root mysql_native_password
136+
root mysql_native_password
137137
root qa_auth_interface qa_test_6_dest
138138
exec MYSQL PLUGIN_AUTH_OPT -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
139139
Warning: Using a password on the command line interface can be insecure.
@@ -143,10 +143,10 @@ DROP USER qa_test_6_dest;
143143
DELETE FROM mysql.user WHERE user='root' AND plugin='qa_auth_interface';
144144
SELECT user,plugin,authentication_string,password FROM mysql.user;
145145
user plugin authentication_string password
146-
root
147-
root
148-
root
149-
root
146+
root mysql_native_password
147+
root mysql_native_password
148+
root mysql_native_password
149+
root mysql_native_password
150150
=== Test of the --default_auth option for clients ====
151151
CREATE USER qa_test_11_user IDENTIFIED WITH qa_auth_interface AS 'qa_test_11_dest';
152152
CREATE USER qa_test_11_dest IDENTIFIED BY 'dest_passwd';

mysql-test/r/plugin_auth_sha256.result

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ SET SESSION old_passwords= 2;
44
SET PASSWORD FOR 'kristofer'=PASSWORD('secret');
55
SELECT user, plugin FROM mysql.user;
66
user plugin
7-
root
8-
root
9-
root
10-
root
7+
root mysql_native_password
8+
root mysql_native_password
9+
root mysql_native_password
10+
root mysql_native_password
1111
kristofer sha256_password
1212
SELECT USER(),CURRENT_USER();
1313
USER() CURRENT_USER()
@@ -79,10 +79,10 @@ SET SESSION old_passwords= 2;
7979
SET PASSWORD FOR 'kristofer'=PASSWORD('secret');
8080
SELECT user, plugin FROM mysql.user;
8181
user plugin
82-
root
83-
root
84-
root
85-
root
82+
root mysql_native_password
83+
root mysql_native_password
84+
root mysql_native_password
85+
root mysql_native_password
8686
kristofer sha256_password
8787
SELECT USER(),CURRENT_USER();
8888
USER() CURRENT_USER()

mysql-test/r/plugin_auth_sha256_2.result

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
CREATE USER 'kristofer' IDENTIFIED BY 'secret';
22
SELECT user, plugin FROM mysql.user;
33
user plugin
4-
root
5-
root
6-
root
7-
root
4+
root mysql_native_password
5+
root mysql_native_password
6+
root mysql_native_password
7+
root mysql_native_password
88
kristofer sha256_password
99
user() current_user()
1010
kristofer@localhost kristofer@%

mysql-test/r/plugin_auth_sha256_server_default.result

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ SET old_passwords=2;
33
SET PASSWORD FOR 'kristofer'=PASSWORD('secret');
44
SELECT user, plugin FROM mysql.user;
55
user plugin
6-
root
7-
root
8-
root
9-
root
6+
root mysql_native_password
7+
root mysql_native_password
8+
root mysql_native_password
9+
root mysql_native_password
1010
kristofer sha256_password
1111
SELECT USER(),CURRENT_USER();
1212
USER() CURRENT_USER()

mysql-test/r/plugin_auth_sha256_server_default_tls.result

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ SET old_passwords=2;
33
SET PASSWORD FOR 'kristofer'=PASSWORD('secret');
44
SELECT user, plugin FROM mysql.user;
55
user plugin
6-
root
7-
root
8-
root
9-
root
6+
root mysql_native_password
7+
root mysql_native_password
8+
root mysql_native_password
9+
root mysql_native_password
1010
kristofer sha256_password
1111
SELECT USER(),CURRENT_USER();
1212
USER() CURRENT_USER()

mysql-test/r/system_mysql_db.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ user CREATE TABLE `user` (
9999
`max_updates` int(11) unsigned NOT NULL DEFAULT '0',
100100
`max_connections` int(11) unsigned NOT NULL DEFAULT '0',
101101
`max_user_connections` int(11) unsigned NOT NULL DEFAULT '0',
102-
`plugin` char(64) COLLATE utf8_bin DEFAULT '',
102+
`plugin` char(64) COLLATE utf8_bin NOT NULL DEFAULT 'mysql_native_password',
103103
`authentication_string` text COLLATE utf8_bin,
104104
`password_expired` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
105105
PRIMARY KEY (`Host`,`User`)

mysql-test/suite/funcs_1/r/is_columns_mysql.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def mysql user max_updates 38 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) uns
251251
def mysql user max_user_connections 40 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned select,insert,update,references
252252
def mysql user Password 3 NO char 41 41 NULL NULL NULL latin1 latin1_bin char(41) select,insert,update,references
253253
def mysql user password_expired 43 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
254-
def mysql user plugin 41 YES char 64 192 NULL NULL NULL utf8 utf8_bin char(64) select,insert,update,references
254+
def mysql user plugin 41 mysql_native_password NO char 64 192 NULL NULL NULL utf8 utf8_bin char(64) select,insert,update,references
255255
def mysql user Process_priv 12 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
256256
def mysql user References_priv 15 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
257257
def mysql user Reload_priv 10 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references

mysql-test/suite/innodb/r/innodb-wl5980-linux.result

100755100644
+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# Note that lower case option is required because the
1212
# partition tables will be stored in mixed (Upper & Lower) format on Linux,
1313
# but on Windows the partition table names are stored in lower case only.
14+
# Restarting the server with skip-grant-tables and updating mysql.user
15+
# table to deal with the restriction added to plugin value for users
16+
# in WL6982.
17+
# Stop server
1418
# Check the DB & tables with DML statements.
1519
use test;
1620
SHOW CREATE TABLE emp1;

mysql-test/suite/innodb/r/innodb-wl5980-windows.result

100755100644
+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ purchase#p#p0#sp#s0.isl
1717
purchase#p#p0#sp#s1.isl
1818
purchase#p#p1#sp#s2.isl
1919
purchase#p#p1#sp#s3.isl
20+
# Restarting the server with skip-grant-tables option and updating
21+
# mysql.user table. This is to deal with the restriction imposed on
22+
# plugin field for users in WL6982.
23+
# Restart the DB server from unzip location of MySQL Data Dir
24+
# Stop server
2025
# Restart the DB server from unzip location of MySQL Data Dir
2126
# Check the DB & tables with DML statements.
2227
use test;

mysql-test/suite/innodb/t/innodb-wl5980-linux.test

+14
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ EOF
101101
--echo # partition tables will be stored in mixed (Upper & Lower) format on Linux,
102102
--echo # but on Windows the partition table names are stored in lower case only.
103103

104+
--echo # Restarting the server with skip-grant-tables and updating mysql.user
105+
--echo # table to deal with the restriction added to plugin value for users
106+
--echo # in WL6982.
107+
108+
-- exec echo "restart:--lower_case_table_names=1 --datadir=$MYSQL_TMP_DIR/mysqld.5980/data/ --skip-grant-tables" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
109+
-- enable_reconnect
110+
-- source include/wait_until_connected_again.inc
111+
112+
-- exec $MYSQL -e "UPDATE mysql.user SET plugin = 'mysql_native_password'"
113+
-- echo # Stop server
114+
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
115+
-- shutdown_server 30
116+
-- source include/wait_until_disconnected.inc
117+
104118
-- exec echo "restart:--lower_case_table_names=1 --datadir=$MYSQL_TMP_DIR/mysqld.5980/data/ " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
105119
-- enable_reconnect
106120
-- source include/wait_until_connected_again.inc

mysql-test/suite/innodb/t/innodb-wl5980-windows.test

100755100644
+16
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ closedir(DIR);
108108
exit 0;
109109
EOF
110110

111+
--echo # Restarting the server with skip-grant-tables option and updating
112+
--echo # mysql.user table. This is to deal with the restriction imposed on
113+
--echo # plugin field for users in WL6982.
114+
115+
--echo # Restart the DB server from unzip location of MySQL Data Dir
116+
-- exec echo "restart: --datadir=$MYSQL_TMP_DIR/mysqld.5980/data/ --skip-grant-tables" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
117+
-- enable_reconnect
118+
-- source include/wait_until_connected_again.inc
119+
120+
-- exec $MYSQL -e "UPDATE mysql.user SET plugin = 'mysql_native_password'"
121+
122+
-- echo # Stop server
123+
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
124+
-- shutdown_server 30
125+
-- source include/wait_until_disconnected.inc
126+
111127
--echo # Restart the DB server from unzip location of MySQL Data Dir
112128
-- exec echo "restart: --datadir=$MYSQL_TMP_DIR/mysqld.5980/data/ " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
113129
-- enable_reconnect
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
SELECT @@GLOBAL.default_authentication_plugin;
2+
@@GLOBAL.default_authentication_plugin
3+
mysql_native_password
4+
SELECT COUNT(@@GLOBAL.default_authentication_plugin);
5+
COUNT(@@GLOBAL.default_authentication_plugin)
6+
1
7+
1 Expected
8+
SET @@GLOBAL.default_authentication_plugin=1;
9+
ERROR HY000: Variable 'default_authentication_plugin' is a read only variable
10+
Expected error 'Read only variable'
11+
SELECT COUNT(@@GLOBAL.default_authentication_plugin);
12+
COUNT(@@GLOBAL.default_authentication_plugin)
13+
1
14+
1 Expected
15+
SELECT @@GLOBAL.default_authentication_plugin = VARIABLE_VALUE
16+
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
17+
WHERE VARIABLE_NAME='default_authentication_plugin';
18+
@@GLOBAL.default_authentication_plugin = VARIABLE_VALUE
19+
1
20+
1 Expected
21+
SELECT COUNT(@@GLOBAL.default_authentication_plugin);
22+
COUNT(@@GLOBAL.default_authentication_plugin)
23+
1
24+
1 Expected
25+
SELECT COUNT(VARIABLE_VALUE)
26+
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
27+
WHERE VARIABLE_NAME='default_authentication_plugin';
28+
COUNT(VARIABLE_VALUE)
29+
1
30+
1 Expected
31+
SELECT @@default_authentication_plugin = @@GLOBAL.default_authentication_plugin;
32+
@@default_authentication_plugin = @@GLOBAL.default_authentication_plugin
33+
1
34+
1 Expected
35+
SELECT COUNT(@@default_authentication_plugin);
36+
COUNT(@@default_authentication_plugin)
37+
1
38+
1 Expected
39+
SELECT COUNT(@@local.default_authentication_plugin);
40+
ERROR HY000: Variable 'default_authentication_plugin' is a GLOBAL variable
41+
Expected error 'Variable is a GLOBAL variable'
42+
SELECT COUNT(@@SESSION.default_authentication_plugin);
43+
ERROR HY000: Variable 'default_authentication_plugin' is a GLOBAL variable
44+
Expected error 'Variable is a GLOBAL variable'
45+
SELECT COUNT(@@GLOBAL.default_authentication_plugin);
46+
COUNT(@@GLOBAL.default_authentication_plugin)
47+
1
48+
1 Expected
49+
SELECT default_authentication_plugin = @@SESSION.default_authentication_plugin;
50+
ERROR 42S22: Unknown column 'default_authentication_plugin' in 'field list'
51+
Expected error 'Readonly variable'

0 commit comments

Comments
 (0)