Commit b19eb67f authored by unknown's avatar unknown

Bug#6123 - GRANT USAGE creates useless mysql.db row

  Prevent creation of a row which grants no rights
  Test included


mysql-test/r/grant.result:
  Test for Bug#6123
mysql-test/t/grant.test:
  Test for Bug#6123
sql/sql_acl.cc:
  Bug#6123
    Prevent creation of useless row
parent 98b31cd6
...@@ -150,3 +150,9 @@ GRANT SELECT ON `ab%`.* TO 'test11'@'localhost' ...@@ -150,3 +150,9 @@ GRANT SELECT ON `ab%`.* TO 'test11'@'localhost'
GRANT SELECT ON `a%`.* TO 'test11'@'localhost' GRANT SELECT ON `a%`.* TO 'test11'@'localhost'
delete from mysql.user where user='test11'; delete from mysql.user where user='test11';
delete from mysql.db where user='test11'; delete from mysql.db where user='test11';
create database db6123;
grant usage on db6123.* to test6123 identified by 'magic123';
select host,db,user,select_priv,insert_priv from mysql.db where db="db6123";
host db user select_priv insert_priv
delete from mysql.user where user='test6123';
drop database db6123;
...@@ -105,3 +105,12 @@ flush privileges; ...@@ -105,3 +105,12 @@ flush privileges;
show grants for test11@localhost; show grants for test11@localhost;
delete from mysql.user where user='test11'; delete from mysql.user where user='test11';
delete from mysql.db where user='test11'; delete from mysql.db where user='test11';
#
# Bug#6123: GRANT USAGE inserts useless Db row
#
create database db6123;
grant usage on db6123.* to test6123 identified by 'magic123';
select host,db,user,select_priv,insert_priv from mysql.db where db="db6123";
delete from mysql.user where user='test6123';
drop database db6123;
...@@ -1587,7 +1587,7 @@ static int replace_db_table(TABLE *table, const char *db, ...@@ -1587,7 +1587,7 @@ static int replace_db_table(TABLE *table, const char *db,
goto table_error; /* purecov: deadcode */ goto table_error; /* purecov: deadcode */
} }
} }
else if ((error=table->file->write_row(table->record[0]))) else if (rights && (error=table->file->write_row(table->record[0])))
{ {
if (error && error != HA_ERR_FOUND_DUPP_KEY) /* purecov: inspected */ if (error && error != HA_ERR_FOUND_DUPP_KEY) /* purecov: inspected */
goto table_error; /* purecov: deadcode */ goto table_error; /* purecov: deadcode */
...@@ -1597,6 +1597,7 @@ static int replace_db_table(TABLE *table, const char *db, ...@@ -1597,6 +1597,7 @@ static int replace_db_table(TABLE *table, const char *db,
if (old_row_exists) if (old_row_exists)
acl_update_db(combo.user.str,combo.host.str,db,rights); acl_update_db(combo.user.str,combo.host.str,db,rights);
else else
if (rights)
acl_insert_db(combo.user.str,combo.host.str,db,rights); acl_insert_db(combo.user.str,combo.host.str,db,rights);
table->file->index_end(); table->file->index_end();
DBUG_RETURN(0); DBUG_RETURN(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