From fadcd8d3ac6e29efd927632e3236143dde3a3dba Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Oct 2004 15:43:22 +0300 Subject: [PATCH] fixed db/user privileges getting (BUG#5976) mysql-test/r/view.result: user with global DB privileges test mysql-test/t/view.test: user with global DB privileges test sql/sql_acl.cc: fixed db/user privileges getting --- mysql-test/r/view.result | 7 +++++++ mysql-test/t/view.test | 18 ++++++++++++++++++ sql/sql_acl.cc | 5 +++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 9c89de4259e..caec33eb59b 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1628,3 +1628,10 @@ Field 3,'Field 4| |Field 6| | 'Field 7'| drop view v1; drop table t1; +create database mysqltest; +create table mysqltest.t1 (a int); +grant all privileges on mysqltest.* to mysqltest_1@localhost; +use mysqltest; +create view v1 as select * from t1; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +drop database mysqltest; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 8e38b5616f8..a63086acd71 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1554,3 +1554,21 @@ select concat('|',a,'|'), concat('|',b,'|') from v1; drop view v1; drop table t1; +# +# user with global DB privileges +# +connection root; +--disable_warnings +create database mysqltest; +--enable_warnings +create table mysqltest.t1 (a int); +grant all privileges on mysqltest.* to mysqltest_1@localhost; + +connection user1; +use mysqltest; +create view v1 as select * from t1; + + +connection root; +revoke all privileges on mysqltest.* from mysqltest_1@localhost; +drop database mysqltest; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index df615383ec3..34aa0984798 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3889,12 +3889,13 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant, /* global privileges */ grant->privilege= thd->master_access; + /* db privileges */ + grant->privilege|= acl_get(thd->host, thd->ip, thd->priv_user, db, 0); + /* if privileges ignored (--skip-grant-tables) above is enough */ if (!grant_option) return; - /* db privileges */ - grant->privilege|= acl_get(thd->host, thd->ip, thd->priv_user, db, 0); /* table privileges */ if (grant->version != grant_version) {