diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index cdfd731ffcb58..71dedd30aaf51 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -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, @@ -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) { diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 729b23cf993a1..421ad6271903b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -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 diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ba9dc7eb85499..663864a95bddc 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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(); } @@ -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; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 302c2fda7f00d..241016672d8c3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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, @@ -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, @@ -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(); } ; @@ -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, diff --git a/sql/structs.h b/sql/structs.h index 191463af344ff..986b0d64bb051 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -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(""); + } } LEX_USER; /*