MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / run_plugin_auth

Function run_plugin_auth

sql-common/client.c:2969–3134  ·  view source on GitHub ↗

Client side of the plugin driver authentication. @note this is used by both the mysql_real_connect and mysql_change_user @param mysql mysql @param data pointer to the plugin auth data (scramble) in the handshake packet @param data_len the length of the data @param data_plugin a plugin that data were prepared for or 0 if it's mys

Source from the content-addressed store, hash-verified

2967 @retval 1 error
2968*/
2969int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
2970 const char *data_plugin, const char *db)
2971{
2972 const char *auth_plugin_name;
2973 auth_plugin_t *auth_plugin;
2974 MCPVIO_EXT mpvio;
2975 ulong pkt_length;
2976 int res;
2977
2978 DBUG_ENTER ("run_plugin_auth");
2979 /* determine the default/initial plugin to use */
2980 if (mysql->options.extension && mysql->options.extension->default_auth &&
2981 mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
2982 {
2983 auth_plugin_name= mysql->options.extension->default_auth;
2984 if (!(auth_plugin= (auth_plugin_t*) mysql_client_find_plugin(mysql,
2985 auth_plugin_name, MYSQL_CLIENT_AUTHENTICATION_PLUGIN)))
2986 DBUG_RETURN (1); /* oops, not found */
2987 }
2988 else
2989 {
2990 auth_plugin= mysql->server_capabilities & CLIENT_PROTOCOL_41 ?
2991 &native_password_client_plugin : &old_password_client_plugin;
2992 auth_plugin_name= auth_plugin->name;
2993 }
2994
2995 if (check_plugin_enabled(mysql, auth_plugin))
2996 DBUG_RETURN(1);
2997
2998 DBUG_PRINT ("info", ("using plugin %s", auth_plugin_name));
2999
3000 mysql->net.last_errno= 0; /* just in case */
3001
3002 if (data_plugin && strcmp(data_plugin, auth_plugin_name))
3003 {
3004 /* data was prepared for a different plugin, don't show it to this one */
3005 data= 0;
3006 data_len= 0;
3007 }
3008
3009 mpvio.mysql_change_user= data_plugin == 0;
3010 mpvio.cached_server_reply.pkt= (uchar*)data;
3011 mpvio.cached_server_reply.pkt_len= data_len;
3012 mpvio.read_packet= client_mpvio_read_packet;
3013 mpvio.write_packet= client_mpvio_write_packet;
3014 mpvio.info= client_mpvio_info;
3015 mpvio.mysql= mysql;
3016 mpvio.packets_read= mpvio.packets_written= 0;
3017 mpvio.db= db;
3018 mpvio.plugin= auth_plugin;
3019
3020 res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql);
3021 DBUG_PRINT ("info", ("authenticate_user returned %s",
3022 res == CR_OK ? "CR_OK" :
3023 res == CR_ERROR ? "CR_ERROR" :
3024 res == CR_OK_HANDSHAKE_COMPLETE ?
3025 "CR_OK_HANDSHAKE_COMPLETE" : "error"));
3026

Callers 1

client.cFile · 0.85

Calls 5

check_plugin_enabledFunction · 0.85
my_net_is_initedFunction · 0.85
set_mysql_errorFunction · 0.85
set_mysql_extended_errorFunction · 0.85
cli_safe_readFunction · 0.85

Tested by

no test coverage detected