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

Function get_current_user

sql/sql_acl.cc:13535–13583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13533*/
13534
13535LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock)
13536{
13537 if (user->user.str == current_user.str) // current_user
13538 return create_default_definer(thd, false);
13539
13540 if (user->user.str == current_role.str) // current_role
13541 return create_default_definer(thd, true);
13542
13543 if (user->host.str == NULL) // Possibly a role
13544 {
13545 // to be reexecution friendly we have to make a copy
13546 LEX_USER *dup= (LEX_USER*) thd->memdup(user, sizeof(*user));
13547 if (!dup)
13548 return 0;
13549
13550#ifndef NO_EMBEDDED_ACCESS_CHECKS
13551 if (has_auth(user, thd->lex))
13552 {
13553 dup->host= host_not_specified;
13554 return dup;
13555 }
13556
13557 role_name_check_result result= check_role_name(&dup->user, true);
13558 if (result == ROLE_NAME_INVALID)
13559 return 0;
13560 if (result == ROLE_NAME_PUBLIC)
13561 {
13562 dup->host= empty_clex_str;
13563 return dup;
13564 }
13565
13566 if (!initialized)
13567 return dup;
13568
13569 if (lock)
13570 mysql_mutex_lock(&acl_cache->lock);
13571 if (find_acl_role(dup->user, false))
13572 dup->host= empty_clex_str;
13573 else
13574 dup->host= host_not_specified;
13575 if (lock)
13576 mysql_mutex_unlock(&acl_cache->lock);
13577#endif
13578
13579 return dup;
13580 }
13581
13582 return user;
13583}
13584
13585struct ACL_internal_schema_registry_entry
13586{

Callers 15

create_view_queryFunction · 0.85
checkMethod · 0.85
sp_process_definerFunction · 0.85
sql_parse.ccFile · 0.85
check_change_passwordFunction · 0.85
mysql_table_grantFunction · 0.85
mysql_routine_grantFunction · 0.85
mysql_grant_roleFunction · 0.85
mysql_grantFunction · 0.85
get_show_userFunction · 0.85
mysql_drop_userFunction · 0.85

Calls 5

create_default_definerFunction · 0.85
has_authFunction · 0.85
check_role_nameFunction · 0.85
find_acl_roleFunction · 0.85
memdupMethod · 0.80

Tested by

no test coverage detected