diff options
author | Sergei Golubchik <serg@mariadb.org> | 2014-11-25 19:05:49 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2014-12-04 10:41:54 +0100 |
commit | b5357f025b071574f07d307f37957df2931d83d5 (patch) | |
tree | f7c9089bb80393625f831e88306caa3b525818ed /sql/sql_acl.cc | |
parent | 7bd9eb1f410be849edef2be3548ec9cd14d67c3a (diff) | |
download | mariadb-git-b5357f025b071574f07d307f37957df2931d83d5.tar.gz |
GRANT: calculate pasword hash in sql_acl.cc
don't do it in the parser, one should not make run-time
decisions (like, checking thd->variables.old_passwords variable)
during parsing.
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r-- | sql/sql_acl.cc | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 10c14d5a4a8..c5e47d6633e 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -52,6 +52,7 @@ #include "sql_db.h" #include "sql_array.h" #include "sql_hset.h" +#include "password.h" #include "sql_plugin_compat.h" @@ -950,7 +951,7 @@ static bool fix_user_plugin_ptr(ACL_USER *user) username IDENTIFIED VIA mysql_native_password USING xxx etc */ -static bool fix_lex_user(LEX_USER *user) +static bool fix_lex_user(THD *thd, LEX_USER *user) { size_t check_length; @@ -976,6 +977,30 @@ static bool fix_lex_user(LEX_USER *user) return true; } + if (user->password.length) + { + size_t scramble_length; + void (*make_scramble)(char *, const char *, size_t); + + if (thd->variables.old_passwords == 1) + { + scramble_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; + make_scramble= my_make_scrambled_password_323; + } + else + { + scramble_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; + make_scramble= my_make_scrambled_password; + } + + char *buff= (char *) thd->alloc(scramble_length + 1); + if (buff == NULL) + return true; + make_scramble(buff, user->password.str, user->password.length); + user->auth.str= buff; + user->auth.length= scramble_length; + } + user->password= user->auth.length ? user->auth : null_lex_str; user->plugin= empty_lex_str; user->auth= empty_lex_str; @@ -5609,7 +5634,7 @@ static bool has_auth(LEX_USER *user, LEX *lex) static bool copy_and_check_auth(LEX_USER *to, LEX_USER *from, THD *thd) { - if (fix_lex_user(from)) + if (fix_lex_user(thd, from)) return true; if (to != from) @@ -9308,7 +9333,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list, bool handle_as_role) if (!user_name->host.str) user_name->host= host_not_specified; - if (fix_lex_user(user_name)) + if (fix_lex_user(thd, user_name)) { append_user(thd, &wrong_users, user_name); result= TRUE; |