Skip to content

Commit

Permalink
MDEV-21928 ALTER USER doesn't remove excess authentication plugins fr…
Browse files Browse the repository at this point in the history
…om mysql.global_priv

only use auth1 update (no "auth_or":[]) array, if there was no
"auth_or" array in the json yet.
  • Loading branch information
vuvova committed Apr 27, 2020
1 parent 2144dc1 commit a58b2b3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
13 changes: 13 additions & 0 deletions mysql-test/suite/plugins/r/multiauth.result
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,16 @@ user() current_user() database()
mysqltest1@localhost mysqltest1@% test
drop user mysqltest1;
uninstall soname 'auth_ed25519';
create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket;
show create user mysqltest1;
CREATE USER for mysqltest1@%
CREATE USER `mysqltest1`@`%` IDENTIFIED VIA mysql_native_password USING '*8409037B3E362D6DAE24C8E667F4D3B66716144E' OR unix_socket
alter user mysqltest1 identified via mysql_native_password as password("better");
show create user mysqltest1;
CREATE USER for mysqltest1@%
CREATE USER `mysqltest1`@`%` IDENTIFIED BY PASSWORD '*6E6CABC9967AB586F009616BA69DAC2953849C88'
flush privileges;
show create user mysqltest1;
CREATE USER for mysqltest1@%
CREATE USER `mysqltest1`@`%` IDENTIFIED BY PASSWORD '*6E6CABC9967AB586F009616BA69DAC2953849C88'
drop user mysqltest1;
11 changes: 11 additions & 0 deletions mysql-test/suite/plugins/t/multiauth.test
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,14 @@ drop user mysqltest1;

uninstall soname 'auth_ed25519';
--remove_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt

#
# MDEV-21928 ALTER USER doesn't remove excess authentication plugins from mysql.global_priv
#
create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket;
show create user mysqltest1;
alter user mysqltest1 identified via mysql_native_password as password("better");
show create user mysqltest1;
flush privileges;
show create user mysqltest1;
drop user mysqltest1;
7 changes: 5 additions & 2 deletions sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1425,9 +1425,12 @@ class User_table_json: public User_table

bool set_auth(const ACL_USER &u) const
{
StringBuffer<JSON_SIZE> json(m_table->field[2]->charset());
if (u.nauth == 1)
size_t array_len;
const char *array;
if (u.nauth == 1 && get_value("auth_or", JSV_ARRAY, &array, &array_len))
return set_auth1(u, 0);

StringBuffer<JSON_SIZE> json(m_table->field[2]->charset());
bool top_done = false;
json.append('[');
for (uint i=0; i < u.nauth; i++)
Expand Down

0 comments on commit a58b2b3

Please sign in to comment.