sends a "change plugin" packet, requesting a client to restart authentication using a different authentication plugin Packet format: Bytes Content ----- ---- 1 byte with the value 254 n client plugin to use, \0-terminated n plugin provided data In a special case of switching from native_password_plugin to old_password_plugin,
| 13951 | @retval 1 error |
| 13952 | */ |
| 13953 | static bool send_plugin_request_packet(MPVIO_EXT *mpvio, |
| 13954 | const uchar *data, uint data_len) |
| 13955 | { |
| 13956 | NET *net= &mpvio->auth_info.thd->net; |
| 13957 | static uchar switch_plugin_request_buf[]= { 254 }; |
| 13958 | DBUG_ENTER("send_plugin_request_packet"); |
| 13959 | |
| 13960 | const char *client_auth_plugin= |
| 13961 | ((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin; |
| 13962 | |
| 13963 | DBUG_EXECUTE_IF("auth_disconnect", { DBUG_RETURN(1); }); |
| 13964 | DBUG_EXECUTE_IF("auth_invalid_plugin", client_auth_plugin="foo/bar"; ); |
| 13965 | DBUG_ASSERT(client_auth_plugin); |
| 13966 | |
| 13967 | /* |
| 13968 | we send an old "short 4.0 scramble request", if we need to request a |
| 13969 | client to use 4.0 auth plugin (short scramble) and the scramble was |
| 13970 | already sent to the client |
| 13971 | |
| 13972 | below, cached_client_reply.plugin is the plugin name that client has used, |
| 13973 | client_auth_plugin is derived from mysql.user table, for the given |
| 13974 | user account, it's the plugin that the client need to use to login. |
| 13975 | */ |
| 13976 | bool switch_from_long_to_short_scramble= |
| 13977 | client_auth_plugin == old_password_plugin_name.str && |
| 13978 | Lex_ident_plugin(mpvio->cached_client_reply.plugin). |
| 13979 | streq(native_password_plugin_name); |
| 13980 | |
| 13981 | if (switch_from_long_to_short_scramble) |
| 13982 | DBUG_RETURN (secure_auth(mpvio->auth_info.thd) || |
| 13983 | my_net_write(net, switch_plugin_request_buf, 1) || |
| 13984 | net_flush(net)); |
| 13985 | |
| 13986 | /* |
| 13987 | We never request a client to switch from a short to long scramble. |
| 13988 | Plugin-aware clients can do that, but traditionally it meant to |
| 13989 | ask an old 4.0 client to use the new 4.1 authentication protocol. |
| 13990 | */ |
| 13991 | bool switch_from_short_to_long_scramble= |
| 13992 | client_auth_plugin == native_password_plugin_name.str && |
| 13993 | Lex_ident_plugin(mpvio->cached_client_reply.plugin). |
| 13994 | streq(old_password_plugin_name); |
| 13995 | |
| 13996 | if (switch_from_short_to_long_scramble) |
| 13997 | { |
| 13998 | my_error(ER_NOT_SUPPORTED_AUTH_MODE, MYF(0)); |
| 13999 | general_log_print(mpvio->auth_info.thd, COM_CONNECT, "%s", |
| 14000 | ER_THD(mpvio->auth_info.thd, ER_NOT_SUPPORTED_AUTH_MODE)); |
| 14001 | DBUG_RETURN (1); |
| 14002 | } |
| 14003 | |
| 14004 | DBUG_PRINT("info", ("requesting client to use the %s plugin", |
| 14005 | client_auth_plugin)); |
| 14006 | DBUG_RETURN(net_write_command(net, switch_plugin_request_buf[0], |
| 14007 | (uchar*) client_auth_plugin, |
| 14008 | strlen(client_auth_plugin) + 1, |
| 14009 | (uchar*) data, data_len)); |
| 14010 | } |
no test coverage detected