Bug #53675 Missing a table level privilege after upgrade
Submitted: 15 May 2010 19:54 Modified: 17 May 2010 22:06
Reporter: Victor Kirkebo Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S3 (Non-critical)
Version:5.1.46, 5.1.47 OS:Any
Assigned to: CPU Architecture:Any

[15 May 2010 19:54] Victor Kirkebo
Description:
When running mysql_upgrade the mysql.tables_priv.table_priv column may be altered to contain too few privileges.

How to repeat:
1)
mysql> create database tstdb;
mysql> use tstdb;
mysql> create table tst(i int);
mysql> create user 'trig_user'@'localhost';
mysql> grant trigger on tstdb.tst to 'trig_user'@'localhost';
mysql> select * from mysql.tables_priv;
+-----------+-------+-----------+------------+----------------+---------------------+------------+-------------+
| Host      | Db    | User      | Table_name | Grantor        | Timestamp           | Table_priv | Column_priv |
+-----------+-------+-----------+------------+----------------+---------------------+------------+-------------+
| localhost | tstdb | trig_user | tst        | root@localhost | 2010-05-15 21:38:39 | Trigger    |             |
+-----------+-------+-----------+------------+----------------+---------------------+------------+-------------+
1 row in set (0.00 sec)

2)
Now run mysql_upgrade on the server.

3)
mysql> select * from mysql.tables_priv;
+-----------+-------+-----------+------------+----------------+---------------------+------------+-------------+
| Host      | Db    | User      | Table_name | Grantor        | Timestamp           | Table_priv | Column_priv |
+-----------+-------+-----------+------------+----------------+---------------------+------------+-------------+
| localhost | tstdb | trig_user | tst        | root@localhost | 2010-05-15 21:38:39 |            |             |
+-----------+-------+-----------+------------+----------------+---------------------+------------+-------------+
1 row in set (0.00 sec)

Notice that that the table level privilege "Trigger" is no longer present.
[16 May 2010 14:38] Valeriy Kravchuk
Thank you for the bug report. Verified just as described:

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -uroot -proot -P3310 test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.1.46-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database tstdb;
Query OK, 1 row affected (0.03 sec)

mysql> use tstdb;
Database changed
mysql> create table tst(i int);
Query OK, 0 rows affected (0.36 sec)

mysql> create user trig_user@localhost;
Query OK, 0 rows affected (0.56 sec)

mysql> grant trigger on tstdb.tst to trig_user@localhost;
Query OK, 0 rows affected (0.01 sec)

mysql> select * from mysql.tables_priv;
+-----------+-------+-----------+------------+----------------+-----------------
----+------------+-------------+
| Host      | Db    | User      | Table_name | Grantor        | Timestamp
    | Table_priv | Column_priv |
+-----------+-------+-----------+------------+----------------+-----------------
----+------------+-------------+
| localhost | tstdb | trig_user | tst        | root@localhost | 2010-05-16 17:31
:00 | Trigger    |             |
+-----------+-------+-----------+------------+----------------+-----------------
----+------------+-------------+
1 row in set (0.03 sec)

mysql> exit
Bye

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql_upgrade.exe -P3310 -uroot -pro
ot
Looking for 'mysql.exe' as: C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql.ex
e
Looking for 'mysqlcheck.exe' as: C:\Program Files\MySQL\MySQL Server 5.1\bin\mys
qlcheck.exe
Running 'mysqlcheck' with connection arguments: "--port=3310" "--port=3310"
Running 'mysqlcheck' with connection arguments: "--port=3310" "--port=3310"
dump.t1                                            OK
dump.t2                                            OK
inow6.tmp_tbl_1                                    OK
inow6.tmp_tbl_2                                    OK
...
tstdb.tst                                          OK

Repairing tables
mysql.time_zone_name                               OK
Running 'mysql_fix_privilege_tables'...
OK

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -uroot -proot -P3310 test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.1.46-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select * from mysql.tables_priv;
+-----------+-------+-----------+------------+----------------+-----------------
----+------------+-------------+
| Host      | Db    | User      | Table_name | Grantor        | Timestamp
    | Table_priv | Column_priv |
+-----------+-------+-----------+------------+----------------+-----------------
----+------------+-------------+
| localhost | tstdb | trig_user | tst        | root@localhost | 2010-05-16 17:31
:00 |            |             |
+-----------+-------+-----------+------------+----------------+-----------------
----+------------+-------------+
1 row in set (0.00 sec)
[17 May 2010 22:06] Omer Barnir
Duplicate of bug#53613