summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnel Husakovic <anel@mariadb.org>2019-07-24 03:23:01 -0700
committerAnel Husakovic <anel@mariadb.org>2019-07-24 23:27:10 -0700
commitee555f8fc5fed02503d45cc4ad0d08b07d5a6355 (patch)
treeeb0c4682e8e3f45cdb849619c1db1d140d6e924e
parent8fb39b2c35e991f22911a88cb66ac4aef12eb5a5 (diff)
downloadmariadb-git-ee555f8fc5fed02503d45cc4ad0d08b07d5a6355.tar.gz
MDEV-19948 `SHOW GRANTS` return privileges individually update in 10.2
-rw-r--r--sql/sql_acl.cc86
1 files changed, 50 insertions, 36 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index ec6a1de6230..6d339b81ce2 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -997,6 +997,56 @@ class User_table: public Grant_table_base
return get_YN_as_bool(is_role());
}
+ ulong get_access() const
+ {
+ ulong access= Grant_table_base::get_access();
+ if ((num_fields() <= 13) && (access & CREATE_ACL))
+ access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL;
+
+ if (num_fields() <= 18)
+ {
+ access|= LOCK_TABLES_ACL | CREATE_TMP_ACL | SHOW_DB_ACL;
+ if (access & FILE_ACL)
+ access|= REPL_CLIENT_ACL | REPL_SLAVE_ACL;
+ if (access & PROCESS_ACL)
+ access|= SUPER_ACL | EXECUTE_ACL;
+ }
+ /*
+ If it is pre 5.0.1 privilege table then map CREATE privilege on
+ CREATE VIEW & SHOW VIEW privileges.
+ */
+ if (num_fields() <= 31 && (access & CREATE_ACL))
+ access|= (CREATE_VIEW_ACL | SHOW_VIEW_ACL);
+ /*
+ If it is pre 5.0.2 privilege table then map CREATE/ALTER privilege on
+ CREATE PROCEDURE & ALTER PROCEDURE privileges.
+ */
+ if (num_fields() <= 33)
+ {
+ if (access & CREATE_ACL)
+ access|= CREATE_PROC_ACL;
+ if (access & ALTER_ACL)
+ access|= ALTER_PROC_ACL;
+ }
+ /*
+ Pre 5.0.3 did not have CREATE_USER_ACL.
+ */
+ if (num_fields() <= 36 && (access & GRANT_ACL))
+ access|= CREATE_USER_ACL;
+ /*
+ If it is pre 5.1.6 privilege table then map CREATE privilege on
+ CREATE|ALTER|DROP|EXECUTE EVENT.
+ */
+ if (num_fields() <= 37 && (access & SUPER_ACL))
+ access|= EVENT_ACL;
+ /*
+ If it is pre 5.1.6 privilege then map TRIGGER privilege on CREATE.
+ */
+ if (num_fields() <= 38 && (access & SUPER_ACL))
+ access|= TRIGGER_ACL;
+
+ return access & GLOBAL_ACLS;
+ }
private:
friend class Grant_tables;
@@ -1974,42 +2024,6 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
{
user.access= user_table.get_access() & GLOBAL_ACLS;
- /*
- if it is pre 5.0.1 privilege table then map CREATE privilege on
- CREATE VIEW & SHOW VIEW privileges
- */
- if (user_table.num_fields() <= 31 && (user.access & CREATE_ACL))
- user.access|= (CREATE_VIEW_ACL | SHOW_VIEW_ACL);
-
- /*
- if it is pre 5.0.2 privilege table then map CREATE/ALTER privilege on
- CREATE PROCEDURE & ALTER PROCEDURE privileges
- */
- if (user_table.num_fields() <= 33 && (user.access & CREATE_ACL))
- user.access|= CREATE_PROC_ACL;
- if (user_table.num_fields() <= 33 && (user.access & ALTER_ACL))
- user.access|= ALTER_PROC_ACL;
-
- /*
- pre 5.0.3 did not have CREATE_USER_ACL
- */
- if (user_table.num_fields() <= 36 && (user.access & GRANT_ACL))
- user.access|= CREATE_USER_ACL;
-
-
- /*
- if it is pre 5.1.6 privilege table then map CREATE privilege on
- CREATE|ALTER|DROP|EXECUTE EVENT
- */
- if (user_table.num_fields() <= 37 && (user.access & SUPER_ACL))
- user.access|= EVENT_ACL;
-
- /*
- if it is pre 5.1.6 privilege then map TRIGGER privilege on CREATE.
- */
- if (user_table.num_fields() <= 38 && (user.access & SUPER_ACL))
- user.access|= TRIGGER_ACL;
-
user.sort= get_sort(2, user.host.hostname, user.user.str);
user.hostname_length= safe_strlen(user.host.hostname);
user.user_resource.user_conn= 0;