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

Function check_access

sql/sql_parse.cc:6626–6820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6624*/
6625
6626bool
6627check_access(THD *thd, privilege_t want_access,
6628 const char *db, privilege_t *save_priv,
6629 GRANT_INTERNAL_INFO *grant_internal_info,
6630 bool dont_check_global_grants, bool no_errors)
6631{
6632#ifdef NO_EMBEDDED_ACCESS_CHECKS
6633 if (save_priv)
6634 *save_priv= GLOBAL_ACLS;
6635 return false;
6636#else
6637 Security_context *sctx= thd->security_ctx;
6638 privilege_t db_access(NO_ACL);
6639
6640 /*
6641 GRANT command:
6642 In case of database level grant the database name may be a pattern,
6643 in case of table|column level grant the database name can not be a pattern.
6644 We use 'dont_check_global_grants' as a flag to determine
6645 if it's database level grant command
6646 (see SQLCOM_GRANT case, mysql_execute_command() function) and
6647 set db_is_pattern according to 'dont_check_global_grants' value.
6648 */
6649 bool db_is_pattern= ((want_access & GRANT_ACL) && dont_check_global_grants);
6650 privilege_t dummy(NO_ACL);
6651 DBUG_ENTER("check_access");
6652 DBUG_PRINT("enter",("db: %s want_access: %llx master_access: %llx",
6653 db ? db : "",
6654 (longlong) want_access,
6655 (longlong) sctx->master_access));
6656
6657 if (save_priv)
6658 *save_priv= NO_ACL;
6659 else
6660 {
6661 save_priv= &dummy;
6662 dummy= NO_ACL;
6663 }
6664
6665 /* check access may be called twice in a row. Don't change to same stage */
6666 if (thd->proc_info != stage_checking_permissions.m_name)
6667 THD_STAGE_INFO(thd, stage_checking_permissions);
6668 if (unlikely((!db || !db[0]) && !thd->db.str && !dont_check_global_grants))
6669 {
6670 DBUG_RETURN(FALSE); // CTE reference or an error later
6671 }
6672
6673 if (likely((db != NULL) && (db != any_db.str)))
6674 {
6675 /*
6676 Check if this is reserved database, like information schema or
6677 performance schema
6678 */
6679 const ACL_internal_schema_access *access;
6680 access= get_cached_schema_access(grant_internal_info, db);
6681 if (access)
6682 {
6683 switch (access->check(want_access, save_priv))

Callers 15

check_db_routine_accessFunction · 0.70
get_all_tablesFunction · 0.70
get_schema_column_recordFunction · 0.70
executeMethod · 0.70
fill_sysvarsFunction · 0.70
create_eventMethod · 0.70
update_eventMethod · 0.70

Calls 5

get_cached_schema_accessFunction · 0.85
my_errorFunction · 0.85
acl_get_all3Function · 0.85
access_denied_error_codeFunction · 0.85
checkMethod · 0.45

Tested by

no test coverage detected