mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
sql_acl.cc:
BUG #5831 Revoke privileges in a loop until no more privileges are revoked, because acl_dbs and column_priv_hash can re-organize during privilege removal. sql/sql_acl.cc: BUG #5831 Revoke privileges in a loop until no more privileges are revoked, because acl_dbs and column_priv_hash can re-organize during privilege removal.
This commit is contained in:
122
sql/sql_acl.cc
122
sql/sql_acl.cc
@@ -3623,67 +3623,91 @@ int mysql_revoke_all(THD *thd, List <LEX_USER> &list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remove db access privileges */
|
/* Remove db access privileges */
|
||||||
for (counter= 0 ; counter < acl_dbs.elements ; )
|
/*
|
||||||
|
Because acl_dbs and column_priv_hash shrink and may re-order
|
||||||
|
as privileges are removed, removal occurs in a repeated loop
|
||||||
|
until no more privileges are revoked.
|
||||||
|
*/
|
||||||
|
while (1)
|
||||||
{
|
{
|
||||||
const char *user,*host;
|
int revoke= 0;
|
||||||
|
for (counter= 0 ; counter < acl_dbs.elements ; )
|
||||||
acl_db=dynamic_element(&acl_dbs,counter,ACL_DB*);
|
|
||||||
if (!(user=acl_db->user))
|
|
||||||
user= "";
|
|
||||||
if (!(host=acl_db->host.hostname))
|
|
||||||
host= "";
|
|
||||||
|
|
||||||
if (!strcmp(lex_user->user.str,user) &&
|
|
||||||
!my_strcasecmp(system_charset_info, lex_user->host.str, host))
|
|
||||||
{
|
{
|
||||||
if (replace_db_table(tables[1].table, acl_db->db, *lex_user, ~0, 1))
|
const char *user,*host;
|
||||||
result= -1;
|
|
||||||
else
|
acl_db=dynamic_element(&acl_dbs,counter,ACL_DB*);
|
||||||
continue;
|
if (!(user=acl_db->user))
|
||||||
|
user= "";
|
||||||
|
if (!(host=acl_db->host.hostname))
|
||||||
|
host= "";
|
||||||
|
|
||||||
|
if (!strcmp(lex_user->user.str,user) &&
|
||||||
|
!my_strcasecmp(system_charset_info, lex_user->host.str, host))
|
||||||
|
{
|
||||||
|
if (replace_db_table(tables[1].table, acl_db->db, *lex_user, ~0, 1))
|
||||||
|
result= -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
revoke= 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++counter;
|
||||||
}
|
}
|
||||||
++counter;
|
if (!revoke)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove column access */
|
/* Remove column access */
|
||||||
for (counter= 0 ; counter < column_priv_hash.records ; )
|
while (1)
|
||||||
{
|
{
|
||||||
const char *user,*host;
|
int revoke= 0;
|
||||||
GRANT_TABLE *grant_table= (GRANT_TABLE*) hash_element(&column_priv_hash,
|
for (counter= 0 ; counter < column_priv_hash.records ; )
|
||||||
counter);
|
|
||||||
if (!(user=grant_table->user))
|
|
||||||
user= "";
|
|
||||||
if (!(host=grant_table->host))
|
|
||||||
host= "";
|
|
||||||
|
|
||||||
if (!strcmp(lex_user->user.str,user) &&
|
|
||||||
!my_strcasecmp(system_charset_info, lex_user->host.str, host))
|
|
||||||
{
|
{
|
||||||
if (replace_table_table(thd,grant_table,tables[2].table,*lex_user,
|
const char *user,*host;
|
||||||
grant_table->db,
|
GRANT_TABLE *grant_table= (GRANT_TABLE*)hash_element(&column_priv_hash,
|
||||||
grant_table->tname,
|
counter);
|
||||||
~0, 0, 1))
|
if (!(user=grant_table->user))
|
||||||
|
user= "";
|
||||||
|
if (!(host=grant_table->host))
|
||||||
|
host= "";
|
||||||
|
|
||||||
|
if (!strcmp(lex_user->user.str,user) &&
|
||||||
|
!my_strcasecmp(system_charset_info, lex_user->host.str, host))
|
||||||
{
|
{
|
||||||
result= -1;
|
if (replace_table_table(thd,grant_table,tables[2].table,*lex_user,
|
||||||
}
|
grant_table->db,
|
||||||
else
|
grant_table->tname,
|
||||||
{
|
~0, 0, 1))
|
||||||
if (grant_table->cols)
|
result= -1;
|
||||||
{
|
|
||||||
List<LEX_COLUMN> columns;
|
|
||||||
if (replace_column_table(grant_table,tables[3].table, *lex_user,
|
|
||||||
columns,
|
|
||||||
grant_table->db,
|
|
||||||
grant_table->tname,
|
|
||||||
~0, 1))
|
|
||||||
result= -1;
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
continue;
|
{
|
||||||
|
if (grant_table->cols)
|
||||||
|
{
|
||||||
|
List<LEX_COLUMN> columns;
|
||||||
|
if (replace_column_table(grant_table,tables[3].table, *lex_user,
|
||||||
|
columns,
|
||||||
|
grant_table->db,
|
||||||
|
grant_table->tname,
|
||||||
|
~0, 1))
|
||||||
|
result= -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
revoke= 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
revoke= 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
++counter;
|
||||||
}
|
}
|
||||||
++counter;
|
if (!revoke)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user