Skip to content

MDEV-36397 Record change_user command in MTR output #4012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4662,6 +4662,24 @@ void do_change_user(struct st_command *command)
dynstr_set(&ds_db, mysql->db);
}

/* Connection logging if enabled */
if (!disable_query_log)
{
DYNAMIC_STRING *ds= &ds_res;

dynstr_append_mem(ds, STRING_WITH_LEN("change_user "));
replace_dynstr_append(ds, ds_user.str);
dynstr_append_mem(ds, STRING_WITH_LEN(","));

if (ds_passwd.length)
replace_dynstr_append(ds, ds_passwd.str);
dynstr_append_mem(ds, STRING_WITH_LEN(","));

if (ds_db.length)
replace_dynstr_append(ds, ds_db.str);
dynstr_append_mem(ds, STRING_WITH_LEN(";\n"));
}

DBUG_PRINT("info",("connection: '%s' user: '%s' password: '%s' database: '%s'",
cur_con->name, ds_user.str, ds_passwd.str, ds_db.str));

Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/backup_priv.result
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ BACKUP STAGE FLUSH;
SELECT lock_mode FROM information_schema.metadata_lock_info WHERE lock_type='Backup lock';
lock_mode
MDL_BACKUP_FLUSH
change_user user2,,;
SELECT lock_mode FROM information_schema.metadata_lock_info WHERE lock_type='Backup lock';
lock_mode
disconnect con1;
Expand Down
19 changes: 14 additions & 5 deletions mysql-test/main/change_user.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,35 @@ grant select on test.* to test_newpw;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<root@localhost> <root@localhost> test
change_user test_nopw,,;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<test_nopw@localhost> <test_nopw@%> NULL
change_user test_oldpw,oldpw,;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<test_oldpw@localhost> <test_oldpw@%> NULL
change_user test_newpw,newpw,;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<test_newpw@localhost> <test_newpw@%> NULL
change_user root,,;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<root@localhost> <root@localhost> NULL
change_user test_nopw,,test;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<test_nopw@localhost> <test_nopw@%> test
change_user test_oldpw,oldpw,test;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<test_oldpw@localhost> <test_oldpw@%> test
change_user test_newpw,newpw,test;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<test_newpw@localhost> <test_newpw@%> test
change_user root,,test;
select concat('<', user(), '>'), concat('<', current_user(), '>'), database();
concat('<', user(), '>') concat('<', current_user(), '>') database()
<root@localhost> <root@localhost> test
Expand All @@ -45,7 +53,7 @@ SELECT @@session.sql_big_selects;
SELECT @@global.max_join_size;
@@global.max_join_size
HA_POS_ERROR
change_user
change_user root,,test;
SELECT @@session.sql_big_selects;
@@session.sql_big_selects
1
Expand All @@ -54,13 +62,13 @@ SELECT @@global.max_join_size;
HA_POS_ERROR
SET @@global.max_join_size = 10000;
SET @@session.max_join_size = default;
change_user
change_user root,,test;
SELECT @@session.sql_big_selects;
@@session.sql_big_selects
0
SET @@global.max_join_size = 18446744073709551615;
SET @@session.max_join_size = default;
change_user
change_user root,,test;
SELECT @@session.sql_big_selects;
@@session.sql_big_selects
1
Expand All @@ -83,14 +91,15 @@ GET_LOCK('bug31418', 1)
SELECT IS_USED_LOCK('bug31418') = CONNECTION_ID();
IS_USED_LOCK('bug31418') = CONNECTION_ID()
1
change_user
change_user root,,test;
SELECT IS_FREE_LOCK('bug31418');
IS_FREE_LOCK('bug31418')
1
SELECT IS_USED_LOCK('bug31418');
IS_USED_LOCK('bug31418')
NULL
FLUSH STATUS;
change_user root,,test;
Value of com_select did not change
set global secure_auth=default;
Warnings:
Expand All @@ -102,7 +111,7 @@ now()
select year(now()) > 2011;
year(now()) > 2011
0
change_user
change_user root,,test;
select year(now()) > 2011;
year(now()) > 2011
1
5 changes: 0 additions & 5 deletions mysql-test/main/change_user.test
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,20 @@ SELECT @@session.sql_big_selects;
# The exact value depends on the server build flags
--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR
SELECT @@global.max_join_size;
--echo change_user
--change_user
SELECT @@session.sql_big_selects;
# The exact value depends on the server build flags
--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR
SELECT @@global.max_join_size;
SET @@global.max_join_size = 10000;
SET @@session.max_join_size = default;
--echo change_user
--change_user
SELECT @@session.sql_big_selects;
# On some machines the following will result into a warning
--disable_warnings
SET @@global.max_join_size = 18446744073709551615;
--enable_warnings
SET @@session.max_join_size = default;
--echo change_user
--change_user
SELECT @@session.sql_big_selects;
--replace_result 4294967295 18446744073709551615
Expand All @@ -107,7 +104,6 @@ SELECT IS_FREE_LOCK('bug31418');
SELECT IS_USED_LOCK('bug31418');
SELECT GET_LOCK('bug31418', 1);
SELECT IS_USED_LOCK('bug31418') = CONNECTION_ID();
--echo change_user
--change_user
SELECT IS_FREE_LOCK('bug31418');
SELECT IS_USED_LOCK('bug31418');
Expand Down Expand Up @@ -151,7 +147,6 @@ set global secure_auth=default;
set timestamp=unix_timestamp('2010-10-10 10:10:10');
select now();
select year(now()) > 2011;
--echo change_user
--change_user
select year(now()) > 2011;
--enable_service_connection
6 changes: 6 additions & 0 deletions mysql-test/main/change_user_notembedded.result
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
connect test,localhost,root,,;
connection test;
change_user foo,bar,;
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES)
change_user foo,,;
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: NO)
change_user root,,test;
change_user foo,bar,;
ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES)
change_user foo,bar,;
ERROR 08S01: Unknown command
change_user root,,test;
ERROR 08S01: Unknown command
disconnect test;
connection default;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/cte_nonrecursive.result
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,7 @@ use test;
# THD::create_tmp_table_def_key
#
connect con1,localhost,root,,;
change_user root,,;
CREATE TEMPORARY TABLE test.t (a INT);
WITH cte AS (SELECT 1) SELECT * FROM cte;
1
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/main/failed_auth_3909.result
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ ERROR HY000: Server is running in --secure-auth mode, but 'uu2'@'localhost' has
connect(localhost,uu2,password,test,MASTER_PORT,MASTER_SOCKET);
connect fail,localhost,uu2,password;
ERROR HY000: Server is running in --secure-auth mode, but 'uu2'@'localhost' has a password in the old format; please change the password to the new format
change_user u1,,;
ERROR 28000: Access denied for user 'u1'@'localhost' (using password: NO)
change_user uu2,,;
ERROR HY000: Server is running in --secure-auth mode, but 'uu2'@'localhost' has a password in the old format; please change the password to the new format
change_user uu2,password,;
ERROR HY000: Server is running in --secure-auth mode, but 'uu2'@'localhost' has a password in the old format; please change the password to the new format
delete from mysql.user where plugin = 'mysql_old_password';
flush privileges;
1 change: 1 addition & 0 deletions mysql-test/main/failed_auth_unixsocket.result
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ delete from mysql.global_priv where user != 'root';
flush privileges;
connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'USER'@'localhost'
change_user buildbot,,;
ERROR 28000: Access denied for user 'USER'@'localhost'
replace mysql.global_priv select * from global_priv_backup;
flush privileges;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/lock_user.result
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ connection default;
# account is locked
#
alter user user1@localhost account lock;
change_user user1,,;
ERROR HY000: Access denied, this account is locked
#
# MDEV-24098 SHOW CREATE USER invalid for both PASSWORD EXPIRE and
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/main/max_password_errors.result
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ connect(localhost,u,bad_pass,test,MASTER_PORT,MASTER_SOCKET);
connect con1, localhost, u, bad_pass;
ERROR 28000: Access denied for user 'u'@'localhost' (using password: YES)
connect con1, localhost, u, good_pass;
change_user u,bad_pass,;
ERROR 28000: Access denied for user 'u'@'localhost' (using password: YES)
change_user u,bad_pass,;
ERROR 28000: Access denied for user 'u'@'localhost' (using password: YES)
change_user u,good_pass,;
ERROR HY000: User is blocked because of too many credential errors; unblock with 'ALTER USER / FLUSH PRIVILEGES'
disconnect con1;
connection default;
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/main/mysql_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -1159,11 +1159,13 @@ connection default;
GRANT SELECT ON mysql.* TO very_long_user_name_number_1;
GRANT SELECT ON mysql.* TO very_long_user_name_number_2;
GRANT ALL ON *.* TO even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length@localhost WITH GRANT OPTION;
change_user even_longer_user_name_number_3_to_test_the_grantor_and_definer_field_length,,;
GRANT INSERT ON mysql.user TO very_long_user_name_number_1;
GRANT INSERT ON mysql.user TO very_long_user_name_number_2;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_1;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_2;
CREATE PROCEDURE test.pr() BEGIN END;
change_user root,,;
Phase 1/8: Checking and upgrading mysql database
Processing databases
mysql
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/main/mysqltest.result
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,10 @@ drop table t1;
mysqltest: At line 1: query 'change_user root,,inexistent' failed: ER_BAD_DB_ERROR (1049): Unknown database 'inexistent'
mysqltest: At line 1: query 'change_user inexistent,,test' failed: ER_ACCESS_DENIED_ERROR (1045): Access denied for user 'inexistent'@'localhost' (using password: NO)
mysqltest: At line 1: query 'change_user root,inexistent,test' failed: ER_ACCESS_DENIED_ERROR (1045): Access denied for user 'root'@'localhost' (using password: YES)
change_user root,,test;
change_user root,,;
change_user root,,;
change_user root,,test;
REPLACED_FILE1.txt
file1.txt
file2.txt
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/main/opt_trace_security.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ BEGIN
insert into t2 select * from t1;
return a+1;
END|
change_user foo,,;
set optimizer_trace="enabled=on";
select * from db1.t1;
ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table `db1`.`t1`
select * from information_schema.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
0 1
set optimizer_trace="enabled=off";
change_user root,,;
grant select(a) on db1.t1 to 'foo'@'%';
change_user foo,,;
set optimizer_trace="enabled=on";
select * from db1.t1;
a
Expand All @@ -32,10 +35,12 @@ select * from information_schema.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
0 1
set optimizer_trace="enabled=off";
change_user root,,;
select * from information_schema.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
grant select on db1.t1 to 'foo'@'%';
grant select on db1.t2 to 'foo'@'%';
change_user foo,,;
set optimizer_trace="enabled=on";
#
# SELECT privilege on the table db1.t1
Expand Down Expand Up @@ -158,10 +163,12 @@ select * from db1.t1 {
]
} 0 0
set optimizer_trace="enabled=off";
change_user root,,;
grant select on db1.v1 to 'foo'@'%';
grant show view on db1.v1 to 'foo'@'%';
grant select on db1.v1 to 'bar'@'%';
grant show view on db1.v1 to 'bar'@'%';
change_user foo,,;
select current_user();
current_user()
foo@%
Expand Down Expand Up @@ -300,6 +307,7 @@ select * from db1.v1 {
]
} 0 0
set optimizer_trace="enabled=off";
change_user bar,,;
select current_user();
current_user()
bar@%
Expand All @@ -319,10 +327,12 @@ select * from information_schema.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
0 1
set optimizer_trace="enabled=off";
change_user root,,;
grant execute on function db1.f1 to 'foo'@'%';
grant execute on function db1.f1 to 'bar'@'%';
grant select on db1.t1 to 'bar'@'%';
grant insert on db1.t2 to 'foo'@'%';
change_user foo,,;
select current_user();
current_user()
foo@%
Expand All @@ -336,6 +346,7 @@ select INSUFFICIENT_PRIVILEGES from information_schema.OPTIMIZER_TRACE;
INSUFFICIENT_PRIVILEGES
0
set optimizer_trace="enabled=off";
change_user bar,,;
select current_user();
current_user()
bar@%
Expand All @@ -354,10 +365,12 @@ select * from information_schema.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
0 1
set optimizer_trace="enabled=off";
change_user root,,;
select current_user();
current_user()
root@localhost
REVOKE ALL PRIVILEGES, GRANT OPTION FROM foo;
change_user root,,;
drop user if exists foo;
drop user if exists bar;
drop table db1.t1, db1.t2;
Expand Down
Loading