Commit c3710738 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: LEX_USER::pwtext and LEX_USER::pwhash

Was:
* LEX_USER::password was storing sometimes
  plaintext password and sometimes password hash
* LEX_USER::auth was storing sometimes password hash and
  sometimes plugin authentication string

Now:
* LEX_USER::pwtext stores the password in plain-text
* LEX_USER::pwhash stores the password hash
* LEX_USER::auth stores the plugin authentication string
parent 1fea7e78
This diff is collapsed.
...@@ -15067,14 +15067,14 @@ opt_for_user: ...@@ -15067,14 +15067,14 @@ opt_for_user:
; ;
text_or_password: text_or_password:
TEXT_STRING { Lex->definer->auth= $1;} TEXT_STRING { Lex->definer->pwhash= $1;}
| PASSWORD_SYM '(' TEXT_STRING ')' { Lex->definer->password= $3; } | PASSWORD_SYM '(' TEXT_STRING ')' { Lex->definer->pwtext= $3; }
| OLD_PASSWORD_SYM '(' TEXT_STRING ')' | OLD_PASSWORD_SYM '(' TEXT_STRING ')'
{ {
Lex->definer->password= $3; Lex->definer->pwtext= $3;
Lex->definer->auth.str= Item_func_password::alloc(thd, Lex->definer->pwhash.str= Item_func_password::alloc(thd,
$3.str, $3.length, Item_func_password::OLD); $3.str, $3.length, Item_func_password::OLD);
Lex->definer->auth.length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; Lex->definer->pwhash.length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323;
} }
; ;
...@@ -15648,14 +15648,15 @@ using_or_as: USING | AS ; ...@@ -15648,14 +15648,15 @@ using_or_as: USING | AS ;
grant_user: grant_user:
user IDENTIFIED_SYM BY TEXT_STRING user IDENTIFIED_SYM BY TEXT_STRING
{ {
$$=$1; $1->password=$4; $$= $1;
$1->pwtext= $4;
if (Lex->sql_command == SQLCOM_REVOKE) if (Lex->sql_command == SQLCOM_REVOKE)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
| user IDENTIFIED_SYM BY PASSWORD_SYM TEXT_STRING | user IDENTIFIED_SYM BY PASSWORD_SYM TEXT_STRING
{ {
$$= $1; $$= $1;
$1->auth= $5; $1->pwhash= $5;
} }
| user IDENTIFIED_SYM via_or_with ident_or_text | user IDENTIFIED_SYM via_or_with ident_or_text
{ {
......
...@@ -202,7 +202,8 @@ extern const char *show_comp_option_name[]; ...@@ -202,7 +202,8 @@ extern const char *show_comp_option_name[];
typedef int *(*update_var)(THD *, struct st_mysql_show_var *); typedef int *(*update_var)(THD *, struct st_mysql_show_var *);
typedef struct st_lex_user { typedef struct st_lex_user {
LEX_STRING user, host, password, plugin, auth; LEX_STRING user, host, plugin, auth;
LEX_STRING pwtext, pwhash;
bool is_role() { return user.str[0] && !host.str[0]; } bool is_role() { return user.str[0] && !host.str[0]; }
void set_lex_string(LEX_STRING *l, char *buf) void set_lex_string(LEX_STRING *l, char *buf)
{ {
...@@ -213,8 +214,8 @@ typedef struct st_lex_user { ...@@ -213,8 +214,8 @@ typedef struct st_lex_user {
} }
void reset_auth() void reset_auth()
{ {
password.length= plugin.length= auth.length= 0; pwtext.length= pwhash.length= plugin.length= auth.length= 0;
password.str= 0; pwtext.str= pwhash.str= 0;
plugin.str= auth.str= const_cast<char*>(""); plugin.str= auth.str= const_cast<char*>("");
} }
} LEX_USER; } LEX_USER;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment