| 6907 | |
| 6908 | |
| 6909 | static bool check_show_access(THD *thd, TABLE_LIST *table) |
| 6910 | { |
| 6911 | /* |
| 6912 | This is a SHOW command using an INFORMATION_SCHEMA table. |
| 6913 | check_access() has not been called for 'table', |
| 6914 | and SELECT is currently always granted on the I_S, so we automatically |
| 6915 | grant SELECT on table here, to bypass a call to check_access(). |
| 6916 | Note that not calling check_access(table) is an optimization, |
| 6917 | which needs to be revisited if the INFORMATION_SCHEMA does |
| 6918 | not always automatically grant SELECT but use the grant tables. |
| 6919 | See Bug#38837 need a way to disable information_schema for security |
| 6920 | */ |
| 6921 | table->grant.privilege= SELECT_ACL; |
| 6922 | |
| 6923 | switch (get_schema_table_idx(table->schema_table)) { |
| 6924 | case SCH_SCHEMATA: |
| 6925 | return (specialflag & SPECIAL_SKIP_SHOW_DB) && |
| 6926 | check_global_access(thd, SHOW_DB_ACL); |
| 6927 | |
| 6928 | case SCH_TABLE_NAMES: |
| 6929 | case SCH_TABLES: |
| 6930 | case SCH_VIEWS: |
| 6931 | case SCH_TRIGGERS: |
| 6932 | case SCH_EVENTS: |
| 6933 | { |
| 6934 | const char *dst_db_name= table->schema_select_lex->db.str; |
| 6935 | |
| 6936 | DBUG_ASSERT(dst_db_name); |
| 6937 | |
| 6938 | if (check_access(thd, SELECT_ACL, dst_db_name, |
| 6939 | &thd->col_access, NULL, FALSE, FALSE)) |
| 6940 | return TRUE; |
| 6941 | |
| 6942 | if (!thd->col_access && check_grant_db(thd, dst_db_name)) |
| 6943 | { |
| 6944 | status_var_increment(thd->status_var.access_denied_errors); |
| 6945 | my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), |
| 6946 | thd->security_ctx->priv_user, |
| 6947 | thd->security_ctx->priv_host, |
| 6948 | dst_db_name); |
| 6949 | return TRUE; |
| 6950 | } |
| 6951 | |
| 6952 | return FALSE; |
| 6953 | } |
| 6954 | |
| 6955 | case SCH_COLUMNS: |
| 6956 | case SCH_STATISTICS: |
| 6957 | { |
| 6958 | TABLE_LIST *dst_table; |
| 6959 | dst_table= table->schema_select_lex->table_list.first; |
| 6960 | |
| 6961 | DBUG_ASSERT(dst_table); |
| 6962 | |
| 6963 | /* |
| 6964 | Open temporary tables to be able to detect them during privilege check. |
| 6965 | */ |
| 6966 | if (thd->open_temporary_tables(dst_table)) |
no test coverage detected