Skip to content

Commit 3f91821

Browse files
committed
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
1 parent 5d74e43 commit 3f91821

12 files changed

+59
-39
lines changed

client/mysqltest.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6030,7 +6030,7 @@ void do_connect(struct st_command *command)
60306030
int read_timeout= 0;
60316031
int write_timeout= 0;
60326032
int connect_timeout= 0;
6033-
char *csname=0;
6033+
char *csname=0, *rauth __attribute__((unused))= 0;
60346034
struct st_connection* con_slot;
60356035
my_bool default_db;
60366036

@@ -6157,6 +6157,10 @@ void do_connect(struct st_command *command)
61576157
{
61586158
csname= strdup(con_options + sizeof("CHARSET=") - 1);
61596159
}
6160+
else if (strncasecmp(con_options, STRING_WITH_LEN("auth=")) == 0)
6161+
{
6162+
rauth= strdup(con_options + sizeof("auth=") - 1);
6163+
}
61606164
else
61616165
die("Illegal option to connect: %.*b",
61626166
(int) (end - con_options), con_options);
@@ -6195,8 +6199,10 @@ void do_connect(struct st_command *command)
61956199
if (opt_charsets_dir)
61966200
mysql_options(con_slot->mysql, MYSQL_SET_CHARSET_DIR,
61976201
opt_charsets_dir);
6202+
#ifndef EMBEDDED_LIBRARY
6203+
if (rauth)
6204+
mysql_options(con_slot->mysql, MARIADB_OPT_RESTRICTED_AUTH, rauth);
61986205

6199-
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
62006206
set_ssl_opts(con_slot->mysql, con_ssl == USE_SSL_FORBIDDEN ? 0 :
62016207
con_ssl == USE_SSL_REQUIRED ? 1 : opt_use_ssl,
62026208
ssl_cipher ? ssl_cipher : opt_ssl_cipher);
@@ -6273,6 +6279,7 @@ void do_connect(struct st_command *command)
62736279
dynstr_free(&ds_options);
62746280
dynstr_free(&ds_default_auth);
62756281
free(csname);
6282+
free(rauth);
62766283
DBUG_VOID_RETURN;
62776284
}
62786285

mysql-test/main/change_user.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
connect old,localhost,root,,,,,auth=mysql_old_password:mysql_native_password;
12
set global secure_auth=0;
23
Warnings:
34
Warning 1287 '@@secure_auth' is deprecated and will be removed in a future release

mysql-test/main/change_user.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# This test is checking that old password authentication works
22
--disable_service_connection
3+
4+
# connect with mysql_old_password enabled
5+
connect old,localhost,root,,,,,auth=mysql_old_password:mysql_native_password;
6+
37
set global secure_auth=0;
48
#
59
# functional change user tests

mysql-test/main/connect.result

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ flush privileges;
112112
show grants for test@localhost;
113113
Grants for test@localhost
114114
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'
115-
connect con10,localhost,test,gambling2,;
116-
connect con5,localhost,test,gambling2,mysql;
115+
connect con10,localhost,test,gambling2,,,,auth=mysql_old_password:mysql_native_password;
116+
connect con5,localhost,test,gambling2,mysql,,,auth=mysql_old_password:mysql_native_password;
117117
set password="";
118118
set password='gambling3';
119119
ERROR HY000: Password hash should be a 41-digit hexadecimal number
@@ -152,24 +152,24 @@ time_zone_transition_type
152152
transaction_registry
153153
user
154154
user_bak
155-
connect con6,localhost,test,gambling3,test;
155+
connect con6,localhost,test,gambling3,test,,,auth=mysql_old_password:mysql_native_password;
156156
show tables;
157157
Tables_in_test
158158
connection default;
159159
disconnect con10;
160160
disconnect con5;
161161
disconnect con6;
162162
connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
163-
connect fail_con,localhost,test,,test2;
163+
connect fail_con,localhost,test,,test2,,,auth=mysql_old_password:mysql_native_password;
164164
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
165165
connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
166-
connect fail_con,localhost,test,,;
166+
connect fail_con,localhost,test,,,,,auth=mysql_old_password:mysql_native_password;
167167
ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
168168
connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
169-
connect fail_con,localhost,test,zorro,test2;
169+
connect fail_con,localhost,test,zorro,test2,,,auth=mysql_old_password:mysql_native_password;
170170
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
171171
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
172-
connect fail_con,localhost,test,zorro,;
172+
connect fail_con,localhost,test,zorro,,,,auth=mysql_old_password:mysql_native_password;
173173
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
174174
# switching back from mysql.user to mysql.global_priv
175175
delete from mysql.user where user=_binary"test";
@@ -353,9 +353,9 @@ user() current_user()
353353
mysqltest_up1@localhost mysqltest_up1@%
354354
disconnect pcon2;
355355
connect(localhost,mysqltest_up2,newpw,test,MASTER_PORT,MASTER_SOCKET);
356-
connect pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,;
356+
connect pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password;
357357
ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password: YES)
358-
connect pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,;
358+
connect pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password;
359359
select user(), current_user();
360360
user() current_user()
361361
mysqltest_up2@localhost mysqltest_up2@%
@@ -381,7 +381,7 @@ select user(), current_user();
381381
user() current_user()
382382
mysqltest_up1@localhost mysqltest_up1@%
383383
disconnect pcon6;
384-
connect pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,;
384+
connect pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password;
385385
select user(), current_user();
386386
user() current_user()
387387
mysqltest_up2@localhost mysqltest_up2@%

mysql-test/main/connect.test

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ update mysql.user set plugin='mysql_old_password' where user='test';
7070
flush privileges;
7171
show grants for test@localhost;
7272

73-
connect (con10,localhost,test,gambling2,);
74-
connect (con5,localhost,test,gambling2,mysql);
73+
connect con10,localhost,test,gambling2,,,,auth=mysql_old_password:mysql_native_password;
74+
connect con5,localhost,test,gambling2,mysql,,,auth=mysql_old_password:mysql_native_password;
7575
set password="";
7676
--error ER_PASSWD_LENGTH
7777
set password='gambling3';
7878
set password=old_password('gambling3');
7979
show tables;
80-
connect (con6,localhost,test,gambling3,test);
80+
connect (con6,localhost,test,gambling3,test,,,auth=mysql_old_password:mysql_native_password);
8181
show tables;
8282

8383
connection default;
@@ -87,16 +87,16 @@ disconnect con6;
8787

8888
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
8989
--error ER_ACCESS_DENIED_ERROR
90-
connect (fail_con,localhost,test,,test2);
90+
connect (fail_con,localhost,test,,test2,,,auth=mysql_old_password:mysql_native_password);
9191
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
9292
--error ER_ACCESS_DENIED_ERROR
93-
connect (fail_con,localhost,test,,);
93+
connect (fail_con,localhost,test,,,,,auth=mysql_old_password:mysql_native_password);
9494
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
9595
--error ER_ACCESS_DENIED_ERROR
96-
connect (fail_con,localhost,test,zorro,test2);
96+
connect (fail_con,localhost,test,zorro,test2,,,auth=mysql_old_password:mysql_native_password);
9797
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
9898
--error ER_ACCESS_DENIED_ERROR
99-
connect (fail_con,localhost,test,zorro,);
99+
connect (fail_con,localhost,test,zorro,,,,auth=mysql_old_password:mysql_native_password);
100100

101101
source include/switch_to_mysql_global_priv.inc;
102102
# remove user 'test' so that other tests which may use 'test'
@@ -379,8 +379,8 @@ disconnect pcon2;
379379

380380
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
381381
--error ER_ACCESS_DENIED_ERROR
382-
connect(pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,);
383-
connect(pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,);
382+
connect(pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password);
383+
connect(pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password);
384384
select user(), current_user();
385385
disconnect pcon4;
386386

@@ -415,7 +415,7 @@ connect(pcon6,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,);
415415
select user(), current_user();
416416
disconnect pcon6;
417417

418-
connect(pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,);
418+
connect(pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,,auth=mysql_old_password:mysql_native_password);
419419
select user(), current_user();
420420
disconnect pcon7;
421421
connection default;

mysql-test/main/connect_debug.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set global debug_dbug='+d,auth_invalid_plugin';
1919
create user 'bad' identified by 'worse';
2020
--replace_regex /loaded: [^\n]*/loaded: invalid plugin name/
2121
--error 1
22-
--exec $MYSQL --default-auth=mysql_old_password --user=bad --password=worse 2>&1
22+
--exec $MYSQL --default-auth=ed25519 --user=bad --password=worse 2>&1
2323
set global debug_dbug=@old_dbug;
2424
drop user bad;
2525

mysql-test/main/set_password.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ select current_user();
4242
current_user()
4343
newpassnat@localhost
4444
disconnect con;
45-
connect con,localhost,oldauth,test,;
45+
connect con,localhost,oldauth,test,,,,auth=mysql_old_password:mysql_native_password;
4646
select current_user();
4747
current_user()
4848
oldauth@localhost
4949
disconnect con;
50-
connect con,localhost,oldpass,test,;
50+
connect con,localhost,oldpass,test,,,,auth=mysql_old_password:mysql_native_password;
5151
select current_user();
5252
current_user()
5353
oldpass@localhost
5454
disconnect con;
55-
connect con,localhost,oldpassold,test,;
55+
connect con,localhost,oldpassold,test,,,,auth=mysql_old_password:mysql_native_password;
5656
select current_user();
5757
current_user()
5858
oldpassold@localhost
@@ -74,17 +74,17 @@ select current_user();
7474
current_user()
7575
newpassnat@localhost
7676
disconnect con;
77-
connect con,localhost,oldauth,test,;
77+
connect con,localhost,oldauth,test,,,,auth=mysql_old_password:mysql_native_password;
7878
select current_user();
7979
current_user()
8080
oldauth@localhost
8181
disconnect con;
82-
connect con,localhost,oldpass,test,;
82+
connect con,localhost,oldpass,test,,,,auth=mysql_old_password:mysql_native_password;
8383
select current_user();
8484
current_user()
8585
oldpass@localhost
8686
disconnect con;
87-
connect con,localhost,oldpassold,test,;
87+
connect con,localhost,oldpassold,test,,,,auth=mysql_old_password:mysql_native_password;
8888
select current_user();
8989
current_user()
9090
oldpassold@localhost

mysql-test/main/set_password.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ select current_user();
4747
--connect(con,localhost,newpassnat,test,)
4848
select current_user();
4949
--disconnect con
50-
--connect(con,localhost,oldauth,test,)
50+
--connect(con,localhost,oldauth,test,,,,auth=mysql_old_password:mysql_native_password)
5151
select current_user();
5252
--disconnect con
53-
--connect(con,localhost,oldpass,test,)
53+
--connect(con,localhost,oldpass,test,,,,auth=mysql_old_password:mysql_native_password)
5454
select current_user();
5555
--disconnect con
56-
--connect(con,localhost,oldpassold,test,)
56+
--connect(con,localhost,oldpassold,test,,,,auth=mysql_old_password:mysql_native_password)
5757
select current_user();
5858
--disconnect con
5959

@@ -70,13 +70,13 @@ select current_user();
7070
--connect(con,localhost,newpassnat,test,)
7171
select current_user();
7272
--disconnect con
73-
--connect(con,localhost,oldauth,test,)
73+
--connect(con,localhost,oldauth,test,,,,auth=mysql_old_password:mysql_native_password)
7474
select current_user();
7575
--disconnect con
76-
--connect(con,localhost,oldpass,test,)
76+
--connect(con,localhost,oldpass,test,,,,auth=mysql_old_password:mysql_native_password)
7777
select current_user();
7878
--disconnect con
79-
--connect(con,localhost,oldpassold,test,)
79+
--connect(con,localhost,oldpassold,test,,,,auth=mysql_old_password:mysql_native_password)
8080
select current_user();
8181
--disconnect con
8282

mysql-test/suite/sys_vars/r/old_passwords_func.result

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ SELECT CURRENT_USER();
2121
CURRENT_USER()
2222
userNewPass2@localhost
2323
userNewPass2@localhost Expected
24-
connect con3,localhost,userOldPass,pass3,;
24+
connect(localhost,userOldPass,pass3,test,MASTER_MYPORT,MASTER_MYSOCK);
25+
connect con3,localhost,userOldPass,pass3;
26+
ERROR HY000: Authentication plugin 'mysql_old_password' couldn't be found in restricted_auth plugin list.
27+
connect con3,localhost,userOldPass,pass3,,,,auth=mysql_old_password:mysql_native_password;
2528
SELECT CURRENT_USER();
2629
CURRENT_USER()
2730
userOldPass@localhost

mysql-test/suite/sys_vars/r/secure_auth_func.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CREATE USER 'testUser'@'localhost' IDENTIFIED BY 'newpass';
1414
connect con_user1,localhost,testUser,newpass,;
1515
connection default;
1616
SET PASSWORD FOR 'testUser'@'localhost' = OLD_PASSWORD('newpass');
17-
connect con_user2,localhost,testUser,newpass,;
17+
connect con_user2,localhost,testUser,newpass,,,,auth=mysql_old_password:mysql_native_password;
1818
connection default;
1919
'#--------------------FN_DYNVARS_144_03-------------------------#'
2020
SET GLOBAL secure_auth = ON;

0 commit comments

Comments
 (0)