Commit 19f7edf4 authored by Sergei Golubchik's avatar Sergei Golubchik Committed by Oleksandr Byelkin

mysqltest: support MARIADB_OPT_RESTRICTED_AUTH

C/C 3.4 disables mysql_old_password by default, so

add an option for the `connect` command to support specifying
allowed authentication plugins (MARIADB_OPT_RESTRICTED_AUTH).

use it to enable mysql_old_password when needed for testing
parent 1588e615
...@@ -6094,7 +6094,7 @@ void do_connect(struct st_command *command) ...@@ -6094,7 +6094,7 @@ void do_connect(struct st_command *command)
int read_timeout= 0; int read_timeout= 0;
int write_timeout= 0; int write_timeout= 0;
int connect_timeout= 0; int connect_timeout= 0;
char *csname=0; char *csname=0, *rauth __attribute__((unused))= 0;
struct st_connection* con_slot; struct st_connection* con_slot;
my_bool default_db; my_bool default_db;
...@@ -6221,6 +6221,10 @@ void do_connect(struct st_command *command) ...@@ -6221,6 +6221,10 @@ void do_connect(struct st_command *command)
{ {
csname= strdup(con_options + sizeof("CHARSET=") - 1); csname= strdup(con_options + sizeof("CHARSET=") - 1);
} }
else if (strncasecmp(con_options, STRING_WITH_LEN("auth=")) == 0)
{
rauth= strdup(con_options + sizeof("auth=") - 1);
}
else else
die("Illegal option to connect: %.*b", die("Illegal option to connect: %.*b",
(int) (end - con_options), con_options); (int) (end - con_options), con_options);
...@@ -6259,8 +6263,10 @@ void do_connect(struct st_command *command) ...@@ -6259,8 +6263,10 @@ void do_connect(struct st_command *command)
if (opt_charsets_dir) if (opt_charsets_dir)
mysql_options(con_slot->mysql, MYSQL_SET_CHARSET_DIR, mysql_options(con_slot->mysql, MYSQL_SET_CHARSET_DIR,
opt_charsets_dir); opt_charsets_dir);
#ifndef EMBEDDED_LIBRARY
if (rauth)
mysql_options(con_slot->mysql, MARIADB_OPT_RESTRICTED_AUTH, rauth);
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
set_ssl_opts(con_slot->mysql, con_ssl == USE_SSL_FORBIDDEN ? 0 : set_ssl_opts(con_slot->mysql, con_ssl == USE_SSL_FORBIDDEN ? 0 :
con_ssl == USE_SSL_REQUIRED ? 1 : opt_use_ssl, con_ssl == USE_SSL_REQUIRED ? 1 : opt_use_ssl,
ssl_cipher ? ssl_cipher : opt_ssl_cipher); ssl_cipher ? ssl_cipher : opt_ssl_cipher);
...@@ -6337,6 +6343,7 @@ void do_connect(struct st_command *command) ...@@ -6337,6 +6343,7 @@ void do_connect(struct st_command *command)
dynstr_free(&ds_options); dynstr_free(&ds_options);
dynstr_free(&ds_default_auth); dynstr_free(&ds_default_auth);
free(csname); free(csname);
free(rauth);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
connect old,localhost,root,,,,,auth=mysql_old_password:mysql_native_password;
set global secure_auth=0; set global secure_auth=0;
Warnings: Warnings:
Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release
......
# This test is checking that old password authentication works # This test is checking that old password authentication works
--disable_service_connection --disable_service_connection
# connect with mysql_old_password enabled
connect old,localhost,root,,,,,auth=mysql_old_password:mysql_native_password;
set global secure_auth=0; set global secure_auth=0;
# #
# functional change user tests # functional change user tests
......
...@@ -112,8 +112,8 @@ flush privileges; ...@@ -112,8 +112,8 @@ flush privileges;
show grants for test@localhost; show grants for test@localhost;
Grants for test@localhost Grants for test@localhost
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, BINLOG MONITOR, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE HISTORY, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY, SLAVE MONITOR ON *.* TO `test`@`localhost` IDENTIFIED BY PASSWORD '2f27438961437573' GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, BINLOG MONITOR, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, DELETE HISTORY, SET USER, FEDERATED ADMIN, CONNECTION ADMIN, READ_ONLY ADMIN, REPLICATION SLAVE ADMIN, REPLICATION MASTER ADMIN, BINLOG ADMIN, BINLOG REPLAY, SLAVE MONITOR ON *.* TO `test`@`localhost` IDENTIFIED BY PASSWORD '2f27438961437573'
connect con10,localhost,test,gambling2,; connect con10,localhost,test,gambling2,,,,auth=mysql_old_password:mysql_native_password;
connect con5,localhost,test,gambling2,mysql; connect con5,localhost,test,gambling2,mysql,,,auth=mysql_old_password:mysql_native_password;
set password=""; set password="";
set password='gambling3'; set password='gambling3';
ERROR HY000: Password hash should be a 41-digit hexadecimal number ERROR HY000: Password hash should be a 41-digit hexadecimal number
...@@ -152,7 +152,7 @@ time_zone_transition_type ...@@ -152,7 +152,7 @@ time_zone_transition_type
transaction_registry transaction_registry
user user
user_bak user_bak
connect con6,localhost,test,gambling3,test; connect con6,localhost,test,gambling3,test,,,auth=mysql_old_password:mysql_native_password;
show tables; show tables;
Tables_in_test Tables_in_test
connection default; connection default;
...@@ -160,16 +160,16 @@ disconnect con10; ...@@ -160,16 +160,16 @@ disconnect con10;
disconnect con5; disconnect con5;
disconnect con6; disconnect con6;
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET); connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
connect fail_con,localhost,test,,test2; connect fail_con,localhost,test,,test2,,,auth=mysql_old_password:mysql_native_password;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO) ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET); connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
connect fail_con,localhost,test,,; connect fail_con,localhost,test,,,,,auth=mysql_old_password:mysql_native_password;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO) ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET); connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
connect fail_con,localhost,test,zorro,test2; connect fail_con,localhost,test,zorro,test2,,,auth=mysql_old_password:mysql_native_password;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES) ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET); connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
connect fail_con,localhost,test,zorro,; connect fail_con,localhost,test,zorro,,,,auth=mysql_old_password:mysql_native_password;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES) ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
# switching back from mysql.user to mysql.global_priv # switching back from mysql.user to mysql.global_priv
delete from mysql.user where user=_binary"test"; delete from mysql.user where user=_binary"test";
...@@ -353,9 +353,9 @@ user() current_user() ...@@ -353,9 +353,9 @@ user() current_user()
mysqltest_up1@localhost mysqltest_up1@% mysqltest_up1@localhost mysqltest_up1@%
disconnect pcon2; disconnect pcon2;
connect(localhost,mysqltest_up2,newpw,test,MASTER_PORT,MASTER_SOCKET); connect(localhost,mysqltest_up2,newpw,test,MASTER_PORT,MASTER_SOCKET);
connect pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,; connect pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password;
ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password: YES) ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password: YES)
connect pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,; connect pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password;
select user(), current_user(); select user(), current_user();
user() current_user() user() current_user()
mysqltest_up2@localhost mysqltest_up2@% mysqltest_up2@localhost mysqltest_up2@%
...@@ -381,7 +381,7 @@ select user(), current_user(); ...@@ -381,7 +381,7 @@ select user(), current_user();
user() current_user() user() current_user()
mysqltest_up1@localhost mysqltest_up1@% mysqltest_up1@localhost mysqltest_up1@%
disconnect pcon6; disconnect pcon6;
connect pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,; connect pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password;
select user(), current_user(); select user(), current_user();
user() current_user() user() current_user()
mysqltest_up2@localhost mysqltest_up2@% mysqltest_up2@localhost mysqltest_up2@%
......
...@@ -70,14 +70,14 @@ update mysql.user set plugin='mysql_old_password' where user='test'; ...@@ -70,14 +70,14 @@ update mysql.user set plugin='mysql_old_password' where user='test';
flush privileges; flush privileges;
show grants for test@localhost; show grants for test@localhost;
connect (con10,localhost,test,gambling2,); connect con10,localhost,test,gambling2,,,,auth=mysql_old_password:mysql_native_password;
connect (con5,localhost,test,gambling2,mysql); connect con5,localhost,test,gambling2,mysql,,,auth=mysql_old_password:mysql_native_password;
set password=""; set password="";
--error ER_PASSWD_LENGTH --error ER_PASSWD_LENGTH
set password='gambling3'; set password='gambling3';
set password=old_password('gambling3'); set password=old_password('gambling3');
show tables; show tables;
connect (con6,localhost,test,gambling3,test); connect (con6,localhost,test,gambling3,test,,,auth=mysql_old_password:mysql_native_password);
show tables; show tables;
connection default; connection default;
...@@ -87,16 +87,16 @@ disconnect con6; ...@@ -87,16 +87,16 @@ disconnect con6;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR --error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,,test2); connect (fail_con,localhost,test,,test2,,,auth=mysql_old_password:mysql_native_password);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR --error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,,); connect (fail_con,localhost,test,,,,,auth=mysql_old_password:mysql_native_password);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR --error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,zorro,test2); connect (fail_con,localhost,test,zorro,test2,,,auth=mysql_old_password:mysql_native_password);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR --error ER_ACCESS_DENIED_ERROR
connect (fail_con,localhost,test,zorro,); connect (fail_con,localhost,test,zorro,,,,auth=mysql_old_password:mysql_native_password);
source include/switch_to_mysql_global_priv.inc; source include/switch_to_mysql_global_priv.inc;
# remove user 'test' so that other tests which may use 'test' # remove user 'test' so that other tests which may use 'test'
...@@ -379,8 +379,8 @@ disconnect pcon2; ...@@ -379,8 +379,8 @@ disconnect pcon2;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR --error ER_ACCESS_DENIED_ERROR
connect(pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,); connect(pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password);
connect(pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,); connect(pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password);
select user(), current_user(); select user(), current_user();
disconnect pcon4; disconnect pcon4;
...@@ -415,7 +415,7 @@ connect(pcon6,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,); ...@@ -415,7 +415,7 @@ connect(pcon6,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,);
select user(), current_user(); select user(), current_user();
disconnect pcon6; disconnect pcon6;
connect(pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,); connect(pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password);
select user(), current_user(); select user(), current_user();
disconnect pcon7; disconnect pcon7;
connection default; connection default;
......
...@@ -19,7 +19,7 @@ set global debug_dbug='+d,auth_invalid_plugin'; ...@@ -19,7 +19,7 @@ set global debug_dbug='+d,auth_invalid_plugin';
create user 'bad' identified by 'worse'; create user 'bad' identified by 'worse';
--replace_regex /loaded: [^\n]*/loaded: invalid plugin name/ --replace_regex /loaded: [^\n]*/loaded: invalid plugin name/
--error 1 --error 1
--exec $MYSQL --default-auth=mysql_old_password --user=bad --password=worse 2>&1 --exec $MYSQL --default-auth=ed25519 --user=bad --password=worse 2>&1
set global debug_dbug=@old_dbug; set global debug_dbug=@old_dbug;
drop user bad; drop user bad;
......
...@@ -42,17 +42,17 @@ select current_user(); ...@@ -42,17 +42,17 @@ select current_user();
current_user() current_user()
newpassnat@localhost newpassnat@localhost
disconnect con; disconnect con;
connect con,localhost,oldauth,test,; connect con,localhost,oldauth,test,,,,auth=mysql_old_password:mysql_native_password;
select current_user(); select current_user();
current_user() current_user()
oldauth@localhost oldauth@localhost
disconnect con; disconnect con;
connect con,localhost,oldpass,test,; connect con,localhost,oldpass,test,,,,auth=mysql_old_password:mysql_native_password;
select current_user(); select current_user();
current_user() current_user()
oldpass@localhost oldpass@localhost
disconnect con; disconnect con;
connect con,localhost,oldpassold,test,; connect con,localhost,oldpassold,test,,,,auth=mysql_old_password:mysql_native_password;
select current_user(); select current_user();
current_user() current_user()
oldpassold@localhost oldpassold@localhost
...@@ -74,17 +74,17 @@ select current_user(); ...@@ -74,17 +74,17 @@ select current_user();
current_user() current_user()
newpassnat@localhost newpassnat@localhost
disconnect con; disconnect con;
connect con,localhost,oldauth,test,; connect con,localhost,oldauth,test,,,,auth=mysql_old_password:mysql_native_password;
select current_user(); select current_user();
current_user() current_user()
oldauth@localhost oldauth@localhost
disconnect con; disconnect con;
connect con,localhost,oldpass,test,; connect con,localhost,oldpass,test,,,,auth=mysql_old_password:mysql_native_password;
select current_user(); select current_user();
current_user() current_user()
oldpass@localhost oldpass@localhost
disconnect con; disconnect con;
connect con,localhost,oldpassold,test,; connect con,localhost,oldpassold,test,,,,auth=mysql_old_password:mysql_native_password;
select current_user(); select current_user();
current_user() current_user()
oldpassold@localhost oldpassold@localhost
......
...@@ -47,13 +47,13 @@ select current_user(); ...@@ -47,13 +47,13 @@ select current_user();
--connect(con,localhost,newpassnat,test,) --connect(con,localhost,newpassnat,test,)
select current_user(); select current_user();
--disconnect con --disconnect con
--connect(con,localhost,oldauth,test,) --connect(con,localhost,oldauth,test,,,,auth=mysql_old_password:mysql_native_password)
select current_user(); select current_user();
--disconnect con --disconnect con
--connect(con,localhost,oldpass,test,) --connect(con,localhost,oldpass,test,,,,auth=mysql_old_password:mysql_native_password)
select current_user(); select current_user();
--disconnect con --disconnect con
--connect(con,localhost,oldpassold,test,) --connect(con,localhost,oldpassold,test,,,,auth=mysql_old_password:mysql_native_password)
select current_user(); select current_user();
--disconnect con --disconnect con
...@@ -70,13 +70,13 @@ select current_user(); ...@@ -70,13 +70,13 @@ select current_user();
--connect(con,localhost,newpassnat,test,) --connect(con,localhost,newpassnat,test,)
select current_user(); select current_user();
--disconnect con --disconnect con
--connect(con,localhost,oldauth,test,) --connect(con,localhost,oldauth,test,,,,auth=mysql_old_password:mysql_native_password)
select current_user(); select current_user();
--disconnect con --disconnect con
--connect(con,localhost,oldpass,test,) --connect(con,localhost,oldpass,test,,,,auth=mysql_old_password:mysql_native_password)
select current_user(); select current_user();
--disconnect con --disconnect con
--connect(con,localhost,oldpassold,test,) --connect(con,localhost,oldpassold,test,,,,auth=mysql_old_password:mysql_native_password)
select current_user(); select current_user();
--disconnect con --disconnect con
......
...@@ -21,7 +21,10 @@ SELECT CURRENT_USER(); ...@@ -21,7 +21,10 @@ SELECT CURRENT_USER();
CURRENT_USER() CURRENT_USER()
userNewPass2@localhost userNewPass2@localhost
userNewPass2@localhost Expected userNewPass2@localhost Expected
connect con3,localhost,userOldPass,pass3,; connect(localhost,userOldPass,pass3,test,MASTER_MYPORT,MASTER_MYSOCK);
connect con3,localhost,userOldPass,pass3;
ERROR HY000: Authentication plugin 'mysql_old_password' couldn't be found in restricted_auth plugin list.
connect con3,localhost,userOldPass,pass3,,,,auth=mysql_old_password:mysql_native_password;
SELECT CURRENT_USER(); SELECT CURRENT_USER();
CURRENT_USER() CURRENT_USER()
userOldPass@localhost userOldPass@localhost
......
...@@ -14,7 +14,7 @@ CREATE USER 'testUser'@'localhost' IDENTIFIED BY 'newpass'; ...@@ -14,7 +14,7 @@ CREATE USER 'testUser'@'localhost' IDENTIFIED BY 'newpass';
connect con_user1,localhost,testUser,newpass,; connect con_user1,localhost,testUser,newpass,;
connection default; connection default;
SET PASSWORD FOR 'testUser'@'localhost' = OLD_PASSWORD('newpass'); SET PASSWORD FOR 'testUser'@'localhost' = OLD_PASSWORD('newpass');
connect con_user2,localhost,testUser,newpass,; connect con_user2,localhost,testUser,newpass,,,,auth=mysql_old_password:mysql_native_password;
connection default; connection default;
'#--------------------FN_DYNVARS_144_03-------------------------#' '#--------------------FN_DYNVARS_144_03-------------------------#'
SET GLOBAL secure_auth = ON; SET GLOBAL secure_auth = ON;
......
...@@ -61,7 +61,11 @@ connect (con2,localhost,userNewPass2,pass2,); ...@@ -61,7 +61,11 @@ connect (con2,localhost,userNewPass2,pass2,);
SELECT CURRENT_USER(); SELECT CURRENT_USER();
--echo userNewPass2@localhost Expected --echo userNewPass2@localhost Expected
connect (con3,localhost,userOldPass,pass3,); --replace_result $MASTER_MYSOCK MASTER_MYSOCK $MASTER_MYPORT MASTER_MYPORT
--error 5010
connect con3,localhost,userOldPass,pass3;
connect con3,localhost,userOldPass,pass3,,,,auth=mysql_old_password:mysql_native_password;
SELECT CURRENT_USER(); SELECT CURRENT_USER();
--echo userOldPass@localhost Expected --echo userOldPass@localhost Expected
......
...@@ -65,7 +65,8 @@ connection default; ...@@ -65,7 +65,8 @@ connection default;
# #
SET PASSWORD FOR 'testUser'@'localhost' = OLD_PASSWORD('newpass'); SET PASSWORD FOR 'testUser'@'localhost' = OLD_PASSWORD('newpass');
connect (con_user2,localhost,testUser,newpass,); connect (con_user2,localhost,testUser,newpass,,,,auth=mysql_old_password:mysql_native_password);
connection default; connection default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment