From 3f630b9f3a9e6968c764de84b9498f8d2d2a1696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 27 Oct 2014 10:26:20 +0100 Subject: [PATCH] Make auth_socket more flexible. Now supports "AS ''" so it doesn't have to be a 1-on-1 mapping. Example: CREATE USER 'foo'@'localhost IDENTIFIED WITH auth_socket AS 'myuser'; --- plugin/auth/auth_socket.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugin/auth/auth_socket.c b/plugin/auth/auth_socket.c index 7990552..f9e9b8f 100644 --- a/plugin/auth/auth_socket.c +++ b/plugin/auth/auth_socket.c @@ -64,8 +64,14 @@ static int socket_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) if (pwd == NULL) return CR_ERROR; - /* now it's simple as that */ - return strcmp(pwd->pw_name, info->user_name) ? CR_ERROR : CR_OK; + /* now it's simple as that: username matches socket */ + if (!strcmp(pwd->pw_name, info->user_name)) + { + return CR_OK; + } + + /* username matches auth_string */ + return strcmp(pwd->pw_name, info->auth_string) ? CR_ERROR : CR_OK; } static struct st_mysql_auth socket_auth_handler= @@ -85,7 +91,7 @@ mysql_declare_plugin(socket_auth) PLUGIN_LICENSE_GPL, NULL, NULL, - 0x0100, + 0x0101, NULL, NULL, NULL, -- 2.1.0