Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Nov 1, 2022
1 parent b4e7803 commit 0b519a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
28 changes: 11 additions & 17 deletions sql/sql_acl.cc
Expand Up @@ -281,8 +281,8 @@ class ACL_ROLE :public ACL_USER_BASE
uint counter;
DYNAMIC_ARRAY parent_grantee; // array of backlinks to elements granted

ACL_ROLE(ACL_USER * user, MEM_ROOT *mem);
ACL_ROLE(const char * rolename, privilege_t privileges, MEM_ROOT *mem);
ACL_ROLE(ACL_USER *user);
ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *mem);

};

Expand Down Expand Up @@ -2182,7 +2182,7 @@ enum enum_acl_lists
ROLES_MAPPINGS_HASH
};

ACL_ROLE::ACL_ROLE(ACL_USER *user, MEM_ROOT *root)
ACL_ROLE::ACL_ROLE(ACL_USER *user)
:
/* set initial role access the same as the table row privileges */
initial_role_access(user->access),
Expand All @@ -2194,9 +2194,8 @@ ACL_ROLE::ACL_ROLE(ACL_USER *user, MEM_ROOT *root)
flags= IS_ROLE;
}

ACL_ROLE::ACL_ROLE(const char * rolename, privilege_t privileges,
MEM_ROOT *root) :
initial_role_access(privileges), counter(0)
ACL_ROLE::ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *root)
: initial_role_access(privileges), counter(0)
{
this->access= initial_role_access;
this->user.str= safe_strdup_root(root, rolename);
Expand Down Expand Up @@ -2666,7 +2665,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
continue;
}

ACL_ROLE *entry= new (&acl_memroot) ACL_ROLE(&user, &acl_memroot);
ACL_ROLE *entry= new (&acl_memroot) ACL_ROLE(&user);
entry->role_grants = user.role_grants;
my_init_dynamic_array(key_memory_acl_mem, &entry->parent_grantee,
sizeof(ACL_USER_BASE *), 0, 8, MYF(0));
Expand Down Expand Up @@ -8518,16 +8517,13 @@ void GRANT_INFO::read(const Security_context *sctx,
grant_table_user= grant_table_role= grant_public= NULL;
#else
grant_table_user=
table_hash_search(sctx->host, sctx->ip, db,
sctx->priv_user,
table_hash_search(sctx->host, sctx->ip, db, sctx->priv_user,
table, FALSE); /* purecov: inspected */
grant_table_role=
sctx->priv_role[0] ? table_hash_search("", NULL, db,
sctx->priv_role,
sctx->priv_role[0] ? table_hash_search("", NULL, db, sctx->priv_role,
table, TRUE) : NULL;
grant_public=
acl_public ? table_hash_search("", NULL, db,
public_name.str,
acl_public ? table_hash_search("", NULL, db, public_name.str,
table, TRUE) : NULL;
#endif
version= grant_version; /* purecov: inspected */
Expand Down Expand Up @@ -11211,8 +11207,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
int rc;
user_name= get_current_user(thd, tmp_user_name, false);
if (!user_name || (handle_as_role &&
(strcasecmp(user_name->user.str,
public_name.str) == 0)))
(strcasecmp(user_name->user.str, public_name.str) == 0)))
{
thd->clear_error();
if (!user_name)
Expand Down Expand Up @@ -13010,8 +13005,7 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock)
return dup;
}

role_name_check_result result= check_role_name(user->user.str,
user->host.length == 0);
role_name_check_result result= check_role_name(user->user.str, true);
if (result == ROLE_NAME_INVALID)
return 0;
if (result == ROLE_NAME_PUBLIC)
Expand Down
6 changes: 1 addition & 5 deletions sql/sql_class.cc
Expand Up @@ -6024,11 +6024,7 @@ void THD::get_definer(LEX_USER *definer, bool role)
{
binlog_invoker(role);
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
#ifdef WITH_WSREP
if ((wsrep_applier || slave_thread) && has_invoker())
#else
if (slave_thread && has_invoker())
#endif
if ((IF_WSREP(wsrep_applier, 0) || slave_thread) && has_invoker())
{
definer->user= invoker.user;
definer->host= invoker.host;
Expand Down
3 changes: 1 addition & 2 deletions sql/sql_yacc.yy
Expand Up @@ -17156,8 +17156,7 @@ grant_role:
$$->host= empty_clex_str;

if (unlikely(check_string_char_length(&$$->user, ER_USERNAME,
username_char_length,
cs, 0)))
username_char_length, cs, 0)))
MYSQL_YYABORT;
}
| current_role
Expand Down

0 comments on commit 0b519a4

Please sign in to comment.