You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When u2 tries to run SET PASSWORD FOR u1, it should return an error saying that u2 does not have enough privilege. But the current error will say u1 does not have enough privilege, which doesn't seem correct.
Tested with MySQL 8.3.0 and verified that the behavior is different:
➜ ~ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.3.0 Homebrew
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create user u1;
Query OK, 0 rows affected (0.01 sec)
mysql> grant super on *.* to u1;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> create user u2;
Query OK, 0 rows affected (0.01 sec)
mysql> grant create user on *.* to u2;
Query OK, 0 rows affected (0.01 sec)
➜ ~ mysql -u u2;
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.3.0 Homebrew
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password for 'u1'='pwd';
ERROR 1044 (42000): Access denied for user 'u2'@'%' to database 'mysql'
1. Minimal reproduce step (Required)
Add a unit test:
funcTestSetPwd(t*testing.T) {
store:=testkit.CreateMockStore(t)
tk:=testkit.NewTestKit(t, store)
// Create user u1 with super privilege.tk.MustExec("create user 'u1'")
tk.MustExec("grant super on *.* to u1")
// Create user u2 with create user privilege.tk.MustExec("create user 'u2'")
tk.MustExec("grant create user on *.* to u2")
tk2:=testkit.NewTestKit(t, store)
require.NoError(t, tk2.Session().Auth(&auth.UserIdentity{Username: "u2", Hostname: "localhost"}, nil, nil, nil))
tk2.MustExec("set password for 'u1'='randompassword'")
}
2. What did you expect to see? (Required)
Should see this error: [executor:1044]Access denied for user 'u2'@'%' to database 'mysql' since u2 lacks the privileges.
3. What did you see instead (Required)
Error: [executor:1044]Access denied for user 'u1'@'%' to database 'mysql'
we are checking if the current user in the session has enough privilege for executing the SET PASSWORD statement, but the error message is populated with the user in the statement.
Bug Report
Imagine having two users:
u1
withSUPER
privilegeu2
withoutSUPER
privilegeWhen
u2
tries to runSET PASSWORD FOR u1
, it should return an error saying thatu2
does not have enough privilege. But the current error will sayu1
does not have enough privilege, which doesn't seem correct.Tested with MySQL 8.3.0 and verified that the behavior is different:
1. Minimal reproduce step (Required)
Add a unit test:
2. What did you expect to see? (Required)
Should see this error:
[executor:1044]Access denied for user 'u2'@'%' to database 'mysql'
sinceu2
lacks the privileges.3. What did you see instead (Required)
Error:
[executor:1044]Access denied for user 'u1'@'%' to database 'mysql'
Full trace:
4. What is your TiDB version? (Required)
Latest commit or v8.1.0.
The text was updated successfully, but these errors were encountered: