Skip to content

Commit

Permalink
Overlooked that mysql will attempt auth twice for any nonstandard plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoagx committed Feb 15, 2018
1 parent b6e2c43 commit fa485aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Expand Up @@ -29,9 +29,9 @@ To apply:


(patch created with `diff -Naur`) (patch created with `diff -Naur`)


diff -Naur mysql-5.5.59-dist/include/mysql.h mysql-5.5.59/include/mysql.h diff -Naur mysql-5.5.59-p002/include/mysql.h mysql-5.5.59-p003/include/mysql.h
--- mysql-5.5.59-dist/include/mysql.h 2017-11-27 13:03:17.000000000 +0100 --- mysql-5.5.59-p002/include/mysql.h 2017-11-27 13:03:17.000000000 +0100
+++ mysql-5.5.59/include/mysql.h 2018-02-14 00:28:26.000000000 +0100 +++ mysql-5.5.59-p003/include/mysql.h 2018-02-16 00:23:19.000000000 +0100
@@ -288,6 +288,18 @@ @@ -288,6 +288,18 @@
/* needed for embedded server - no net buffer to store the 'info' */ /* needed for embedded server - no net buffer to store the 'info' */
char *info_buffer; char *info_buffer;
Expand All @@ -51,9 +51,9 @@ diff -Naur mysql-5.5.59-dist/include/mysql.h mysql-5.5.59/include/mysql.h
} MYSQL; } MYSQL;




diff -Naur mysql-5.5.59-dist/sql-common/client.c mysql-5.5.59/sql-common/client.c diff -Naur mysql-5.5.59-p002/sql-common/client.c mysql-5.5.59-p003/sql-common/client.c
--- mysql-5.5.59-dist/sql-common/client.c 2017-11-27 13:03:17.000000000 +0100 --- mysql-5.5.59-p002/sql-common/client.c 2017-11-27 13:03:17.000000000 +0100
+++ mysql-5.5.59/sql-common/client.c 2018-02-14 00:34:26.000000000 +0100 +++ mysql-5.5.59-p003/sql-common/client.c 2018-02-16 00:27:37.000000000 +0100
@@ -2952,7 +2952,7 @@ @@ -2952,7 +2952,7 @@
auth_plugin_t *auth_plugin; auth_plugin_t *auth_plugin;
MCPVIO_EXT mpvio; MCPVIO_EXT mpvio;
Expand Down Expand Up @@ -94,3 +94,18 @@ diff -Naur mysql-5.5.59-dist/sql-common/client.c mysql-5.5.59/sql-common/client.
DBUG_PRINT ("info", ("authenticate_user returned %s", DBUG_PRINT ("info", ("authenticate_user returned %s",
res == CR_OK ? "CR_OK" : res == CR_OK ? "CR_OK" :
res == CR_ERROR ? "CR_ERROR" : res == CR_ERROR ? "CR_ERROR" :
@@ -3069,7 +3091,13 @@
DBUG_RETURN(1);

mpvio.plugin= auth_plugin;
- res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql);
+ res = CR_ERROR; //fallback, if block is never invoked
+ mysql->passwd_callback(mysql, auth_plugin_name, ^(const char *passwd) {
+ char *saved_passwd = mysql->passwd;
+ mysql->passwd = (char *)(passwd ? passwd : ""); // see mysql_change_user
+ res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql);
+ mysql->passwd = saved_passwd;
+ });

DBUG_PRINT ("info", ("second authenticate_user returned %s",
res == CR_OK ? "CR_OK" :
Binary file not shown.

0 comments on commit fa485aa

Please sign in to comment.