MCPcopy Create free account
hub / github.com/MariaDB/server / check_show_access

Function check_show_access

sql/sql_parse.cc:6909–6994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6907
6908
6909static 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))

Callers 1

check_table_accessFunction · 0.85

Calls 8

get_schema_table_idxFunction · 0.85
check_global_accessFunction · 0.85
check_grant_dbFunction · 0.85
my_errorFunction · 0.85
check_grantFunction · 0.85
close_thread_tablesFunction · 0.85
open_temporary_tablesMethod · 0.80
check_accessFunction · 0.70

Tested by

no test coverage detected