| 13533 | */ |
| 13534 | |
| 13535 | LEX_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 | |
| 13585 | struct ACL_internal_schema_registry_entry |
| 13586 | { |
no test coverage detected