mirror of
https://github.com/MariaDB/server.git
synced 2026-05-16 11:57:38 +02:00
Fix for BUG#27337: Privileges are not properly restored.
The problem was that THD::db_access variable was not restored after
database switch in stored-routine-execution code.
The fix is to restore THD::db_access in this case.
Unfortunately, this fix requires additional changes,
because in prepare_schema_table(), called on the parsing stage, we checked
privileges. That was wrong according to our design, but this flaw haven't
struck so far, because it was masked. All privilege checkings must be
done on the execution stage in order to be compatible with prepared statements
and stored routines. So, this patch also contains patch for
prepare_schema_table(), which moves the checkings to the execution phase.
mysql-test/r/grant.result:
Updated result file.
mysql-test/t/grant.test:
Added test case for BUG#27337.
sql/mysql_priv.h:
Added function declaration.
sql/sql_db.cc:
Fix for BUG#27337 -- set THD::db_access even if we're called
from stored-routine-execution code.
sql/sql_parse.cc:
Split prepare_schema_table() into two functions:
- prepare_schema_table(), which is called from the parser (parsing stage);
- check_show_access(), which is called on the execution stage.
sql/sql_show.cc:
Ignore schema_select_lex member if its table is NULL.
This commit is contained in:
parent
a9f4be7054
commit
7e08016a91
6 changed files with 362 additions and 71 deletions
|
|
@ -1019,4 +1019,79 @@ DROP DATABASE mysqltest2;
|
|||
DROP DATABASE mysqltest3;
|
||||
DROP DATABASE mysqltest4;
|
||||
DROP USER mysqltest_1@localhost;
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
|
||||
GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
|
||||
CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
|
||||
SELECT 1;
|
||||
|
||||
---> connection: bug27337_con1
|
||||
CREATE TABLE t1(c INT);
|
||||
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
|
||||
CALL mysqltest1.p1();
|
||||
1
|
||||
1
|
||||
CREATE TABLE t1(c INT);
|
||||
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
|
||||
|
||||
---> connection: bug27337_con2
|
||||
CREATE TABLE t1(c INT);
|
||||
ERROR 42000: CREATE command denied to user 'mysqltest_1'@'localhost' for table 't1'
|
||||
SHOW TABLES;
|
||||
Tables_in_mysqltest2
|
||||
|
||||
---> connection: default
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP USER mysqltest_1@localhost;
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
CREATE DATABASE mysqltest1;
|
||||
CREATE DATABASE mysqltest2;
|
||||
CREATE TABLE mysqltest1.t1(c INT);
|
||||
CREATE TABLE mysqltest2.t2(c INT);
|
||||
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
|
||||
GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
|
||||
|
||||
---> connection: bug27337_con1
|
||||
SHOW TABLES FROM mysqltest1;
|
||||
Tables_in_mysqltest1
|
||||
t1
|
||||
PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
|
||||
EXECUTE stmt1;
|
||||
Tables_in_mysqltest1
|
||||
t1
|
||||
|
||||
---> connection: bug27337_con2
|
||||
SHOW COLUMNS FROM mysqltest2.t2;
|
||||
Field Type Null Key Default Extra
|
||||
c int(11) YES NULL
|
||||
PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
|
||||
EXECUTE stmt2;
|
||||
Field Type Null Key Default Extra
|
||||
c int(11) YES NULL
|
||||
|
||||
---> connection: default
|
||||
REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
|
||||
REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
|
||||
|
||||
---> connection: bug27337_con1
|
||||
SHOW TABLES FROM mysqltest1;
|
||||
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
|
||||
EXECUTE stmt1;
|
||||
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest1'
|
||||
|
||||
---> connection: bug27337_con2
|
||||
SHOW COLUMNS FROM mysqltest2.t2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
|
||||
EXECUTE stmt2;
|
||||
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'
|
||||
|
||||
---> connection: default
|
||||
DROP DATABASE mysqltest1;
|
||||
DROP DATABASE mysqltest2;
|
||||
DROP USER mysqltest_1@localhost;
|
||||
End of 5.0 tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue