diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2019-04-24 22:13:12 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2019-04-28 12:49:59 +0200 |
commit | 7590861779e3da5760153c0d01ffbf26048e4cef (patch) | |
tree | 214daaeeed37c7842ccf90c03ad560e6e2be4447 /sql/sql_acl.cc | |
parent | 6c9a6bad4fe90c8bfcfe6dbf46835a39edc95c6f (diff) | |
download | mariadb-git-7590861779e3da5760153c0d01ffbf26048e4cef.tar.gz |
MDEV-19276 during connect, write error log warning for ER_DBACCESS_DENIED_ERROR,
if log_warnings > 1.
This makes ER_DBACCESS_DENIED_ERROR handling the same as we do for other
"access denied"
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r-- | sql/sql_acl.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 83526532bdd..6448f65a2cd 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -11295,7 +11295,7 @@ struct MPVIO_EXT :public MYSQL_PLUGIN_VIO }; /** - a helper function to report an access denied error in all the proper places + a helper function to report an access denied error in most proper places */ static void login_failed_error(THD *thd) { @@ -12715,10 +12715,26 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len) /* Change a database if necessary */ if (mpvio.db.length) { - if (mysql_change_db(thd, &mpvio.db, FALSE)) + uint err = mysql_change_db(thd, &mpvio.db, FALSE); + if(err) { - /* mysql_change_db() has pushed the error message. */ - status_var_increment(thd->status_var.access_denied_errors); + if (err == ER_DBACCESS_DENIED_ERROR) + { + /* + Got an "access denied" error, which must be handled + other access denied errors (see login_failed_error()). + mysql_change_db() already sent error to client, and + wrote to general log, we only need to increment the counter + and maybe write a warning to error log. + */ + status_var_increment(thd->status_var.access_denied_errors); + if (global_system_variables.log_warnings > 1) + { + Security_context* sctx = thd->security_ctx; + sql_print_warning(ER_THD(thd, err), + sctx->priv_user, sctx->priv_host, mpvio.db.str); + } + } DBUG_RETURN(1); } } |