mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-19948 SHOW GRANTS
return privileges individually update in 10.2
This commit is contained in:
@ -997,6 +997,56 @@ class User_table: public Grant_table_base
|
|||||||
return get_YN_as_bool(is_role());
|
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:
|
private:
|
||||||
friend class Grant_tables;
|
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;
|
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.sort= get_sort(2, user.host.hostname, user.user.str);
|
||||||
user.hostname_length= safe_strlen(user.host.hostname);
|
user.hostname_length= safe_strlen(user.host.hostname);
|
||||||
user.user_resource.user_conn= 0;
|
user.user_resource.user_conn= 0;
|
||||||
|
Reference in New Issue
Block a user