Skip to content

Commit

Permalink
cleanup: create LEX_USER::reset_auth()
Browse files Browse the repository at this point in the history
as this is used quite often
  • Loading branch information
vuvova committed Jan 25, 2016
1 parent b01e2ff commit 1fea7e7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
6 changes: 2 additions & 4 deletions sql/sql_acl.cc
Expand Up @@ -984,7 +984,7 @@ static bool fix_user_plugin_ptr(ACL_USER *user)
- if user->plugin is specified, user->auth is the plugin auth data.
- if user->plugin is mysql_native_password or mysql_old_password,
user->auth if the password hash, and LEX_USER is transformed
user->auth is the password hash, and LEX_USER is transformed
to match the next case (that is, user->plugin is cleared).
- if user->plugin is NOT specified, built-in auth is assumed, that is
mysql_native_password or mysql_old_password. In that case,
Expand Down Expand Up @@ -10156,9 +10156,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
thd->make_lex_string(&combo->user, combo->user.str, strlen(combo->user.str));
thd->make_lex_string(&combo->host, combo->host.str, strlen(combo->host.str));

combo->password= null_lex_str;
combo->plugin= empty_lex_str;
combo->auth= empty_lex_str;
combo->reset_auth();

if(au)
{
Expand Down
4 changes: 1 addition & 3 deletions sql/sql_class.cc
Expand Up @@ -5160,9 +5160,7 @@ void THD::get_definer(LEX_USER *definer, bool role)
{
definer->user = invoker_user;
definer->host= invoker_host;
definer->password= null_lex_str;
definer->plugin= empty_lex_str;
definer->auth= empty_lex_str;
definer->reset_auth();
}
else
#endif
Expand Down
6 changes: 2 additions & 4 deletions sql/sql_parse.cc
Expand Up @@ -8949,9 +8949,7 @@ void get_default_definer(THD *thd, LEX_USER *definer, bool role)
}
definer->user.length= strlen(definer->user.str);

definer->password= null_lex_str;
definer->plugin= empty_lex_str;
definer->auth= empty_lex_str;
definer->reset_auth();
}


Expand Down Expand Up @@ -9009,7 +9007,7 @@ LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)

definer->user= *user_name;
definer->host= *host_name;
definer->password= null_lex_str;
definer->reset_auth();

return definer;
}
Expand Down
16 changes: 4 additions & 12 deletions sql/sql_yacc.yy
Expand Up @@ -14139,9 +14139,7 @@ user_maybe_role:
MYSQL_YYABORT;
$$->user = $1;
$$->host= null_lex_str; // User or Role, see get_current_user()
$$->password= null_lex_str;
$$->plugin= empty_lex_str;
$$->auth= empty_lex_str;
$$->reset_auth();

if (check_string_char_length(&$$->user, ER_USERNAME,
username_char_length,
Expand All @@ -14153,9 +14151,7 @@ user_maybe_role:
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
$$->user = $1; $$->host=$3;
$$->password= null_lex_str;
$$->plugin= empty_lex_str;
$$->auth= empty_lex_str;
$$->reset_auth();

if (check_string_char_length(&$$->user, ER_USERNAME,
username_char_length,
Expand Down Expand Up @@ -15417,9 +15413,7 @@ current_role:
if (!($$=(LEX_USER*) thd->calloc(sizeof(LEX_USER))))
MYSQL_YYABORT;
$$->user= current_role;
$$->password= null_lex_str;
$$->plugin= empty_lex_str;
$$->auth= empty_lex_str;
$$->reset_auth();
}
;

Expand All @@ -15438,9 +15432,7 @@ grant_role:
MYSQL_YYABORT;
$$->user = $1;
$$->host= empty_lex_str;
$$->password= null_lex_str;
$$->plugin= empty_lex_str;
$$->auth= empty_lex_str;
$$->reset_auth();

if (check_string_char_length(&$$->user, ER_USERNAME,
username_char_length,
Expand Down
6 changes: 6 additions & 0 deletions sql/structs.h
Expand Up @@ -211,6 +211,12 @@ typedef struct st_lex_user {
else
l->length= strxmov(l->str= buf, user.str, "@", host.str, NullS) - buf;
}
void reset_auth()
{
password.length= plugin.length= auth.length= 0;
password.str= 0;
plugin.str= auth.str= const_cast<char*>("");
}
} LEX_USER;

/*
Expand Down

0 comments on commit 1fea7e7

Please sign in to comment.