diff options
author | Anel Husakovic <anel@mariadb.org> | 2022-07-04 08:27:36 -0500 |
---|---|---|
committer | Vicențiu-Marian Ciorbaru <vicentiu@mariadb.org> | 2022-10-18 10:25:55 +0300 |
commit | 64f822c14264c65ed94d48d3cee1bad01e5c5e84 (patch) | |
tree | 7ebbc863e4bdc25bdbfe24456daf9d944c7411e3 /sql | |
parent | bd9274faa469cc164099c7497c18a0e0a9b1184b (diff) | |
download | mariadb-git-64f822c14264c65ed94d48d3cee1bad01e5c5e84.tar.gz |
MDEV-28455: CREATE TEMPORARY TABLES privilege is insufficient for SHOW COLUMNS
=========== Problem =============
- `show columns` is not working for temporary tables, even though there
is enough privilege `create temporary tables`.
=========== Solution =============
- Append `TMP_TABLE_ACLS` privilege when running `show columns` for temp
tables.
- Additionally `check_access()` for database only once, not for each
field
=========== Additionally =============
- Update comments for function `check_table_access` arguments
Reviewed by: <vicentiu@mariadb.org>
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_acl.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 6 | ||||
-rw-r--r-- | sql/sql_show.cc | 13 |
3 files changed, 15 insertions, 6 deletions
diff --git a/sql/sql_acl.h b/sql/sql_acl.h index dc8a085c96c..3d415051f28 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -103,7 +103,7 @@ */ #define TMP_TABLE_ACLS \ (SELECT_ACL | INSERT_ACL | UPDATE_ACL | DELETE_ACL | CREATE_ACL | DROP_ACL | \ - INDEX_ACL | ALTER_ACL) + INDEX_ACL | ALTER_ACL | REFERENCES_ACL) /* Defines to change the above bits to how things are stored in tables diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ca82c36d568..385360168a1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6892,13 +6892,13 @@ static bool check_show_access(THD *thd, TABLE_LIST *table) @brief Check if the requested privileges exists in either User-, Host- or Db-tables. @param thd Thread context - @param want_access Privileges requested + @param requirements Privileges requested @param tables List of tables to be compared against - @param no_errors Don't report error to the client (using my_error() call). @param any_combination_of_privileges_will_do TRUE if any privileges on any column combination is enough. @param number Only the first 'number' tables in the linked list are relevant. + @param no_errors Don't report error to the client (using my_error() call). The suppled table list contains cached privileges. This functions calls the help functions check_access and check_grant to verify the first three steps @@ -6925,7 +6925,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table) bool check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables, - bool any_combination_of_privileges_will_do, + bool any_combination_of_privileges_will_do, uint number, bool no_errors) { TABLE_LIST *org_tables= tables; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index bae712a407d..17437e683f4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -6029,6 +6029,15 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, show_table->use_all_columns(); // Required for default restore_record(show_table, s->default_values); +#ifndef NO_EMBEDDED_ACCESS_CHECKS + check_access(thd, SELECT_ACL, db_name->str, + &tables->grant.privilege, 0, 0, MY_TEST(tables->schema_table)); + if (is_temporary_table(tables)) + { + tables->grant.privilege|= TMP_TABLE_ACLS; + } +#endif + for (; (field= *ptr) ; ptr++) { if(field->invisible > INVISIBLE_USER) @@ -6049,13 +6058,13 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, #ifndef NO_EMBEDDED_ACCESS_CHECKS uint col_access; - check_access(thd,SELECT_ACL, db_name->str, - &tables->grant.privilege, 0, 0, MY_TEST(tables->schema_table)); col_access= get_column_grant(thd, &tables->grant, db_name->str, table_name->str, field->field_name.str) & COL_ACLS; + if (!tables->schema_table && !col_access) continue; + char *end= tmp; for (uint bitnr=0; col_access ; col_access>>=1,bitnr++) { |