Commit 91223c4d authored by Davi Arnaut's avatar Davi Arnaut

Bug#51770: UNINSTALL PLUGIN requires no privileges

The problem was that UNINSTALL PLUGIN wasn't performing privilege
checks before removing a plugin. Any user (including users without 
any kind of privileges) could uninstall any plugin.

The solution is to verify if the user has the DELETE privilege for
the mysql.plugin table before uninstalling a plugin.
parent 64de2343
#
# Bug#51770: UNINSTALL PLUGIN requires no privileges
#
GRANT INSERT ON mysql.plugin TO bug51770@localhost;
INSTALL PLUGIN example SONAME 'ha_example.so';
UNINSTALL PLUGIN example;
ERROR 42000: DELETE command denied to user 'bug51770'@'localhost' for table 'plugin'
GRANT DELETE ON mysql.plugin TO bug51770@localhost;
FLUSH PRIVILEGES;
UNINSTALL PLUGIN example;
DROP USER bug51770@localhost;
--source include/not_embedded.inc
--source include/have_example_plugin.inc
--echo #
--echo # Bug#51770: UNINSTALL PLUGIN requires no privileges
--echo #
GRANT INSERT ON mysql.plugin TO bug51770@localhost;
connect(con1,localhost,bug51770,,);
eval INSTALL PLUGIN example SONAME $HA_EXAMPLE_SO;
--error ER_TABLEACCESS_DENIED_ERROR
UNINSTALL PLUGIN example;
connection default;
GRANT DELETE ON mysql.plugin TO bug51770@localhost;
FLUSH PRIVILEGES;
connection con1;
UNINSTALL PLUGIN example;
disconnect con1;
connection default;
DROP USER bug51770@localhost;
...@@ -1736,6 +1736,8 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) ...@@ -1736,6 +1736,8 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
bzero(&tables, sizeof(tables)); bzero(&tables, sizeof(tables));
tables.db= (char *)"mysql"; tables.db= (char *)"mysql";
tables.table_name= tables.alias= (char *)"plugin"; tables.table_name= tables.alias= (char *)"plugin";
if (check_table_access(thd, DELETE_ACL, &tables, 1, FALSE))
DBUG_RETURN(TRUE);
/* need to open before acquiring LOCK_plugin or it will deadlock */ /* need to open before acquiring LOCK_plugin or it will deadlock */
if (! (table= open_ltable(thd, &tables, TL_WRITE, 0))) if (! (table= open_ltable(thd, &tables, TL_WRITE, 0)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment