From 8934794a7043d3d62422613df26df9b37e450e0b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 25 Nov 2014 18:53:40 +0100 Subject: password validation function in sql_acl.cc --- sql/sql_acl.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'sql/sql_acl.cc') diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index c5e47d6633e..1a27fa8209b 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -47,6 +47,7 @@ #include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT #include #include +#include #include "sql_connect.h" #include "hostname.h" #include "sql_db.h" @@ -872,6 +873,24 @@ static void free_acl_role(ACL_ROLE *role) delete_dynamic(&(role->parent_grantee)); } +struct validation_data { LEX_STRING *user, *password; }; + +static my_bool do_validate(THD *, plugin_ref plugin, void *arg) +{ + struct validation_data *data= (struct validation_data *)arg; + struct st_mysql_password_validation *handler= + (st_mysql_password_validation *)plugin_decl(plugin)->info; + return handler->validate_password(data->user, data->password); +} + + +static bool validate_password(LEX_STRING *user, LEX_STRING *password) +{ + struct validation_data data= { user, password }; + return plugin_foreach(NULL, do_validate, + MariaDB_PASSWORD_VALIDATION_PLUGIN, &data); +} + /** Convert scrambled password to binary form, according to scramble type, Binary form is stored in user.salt. @@ -977,6 +996,15 @@ static bool fix_lex_user(THD *thd, LEX_USER *user) return true; } + if (user->password.length || !user->auth.length) + { + if (validate_password(&user->user, &user->password)) + { + my_error(ER_NOT_VALID_PASSWORD, MYF(0)); + return true; + } + } + if (user->password.length) { size_t scramble_length; -- cgit v1.2.1