Perform the handshake, authorize the client and update thd sctx variables. @param thd thread handle @param com_change_user_pkt_len size of the COM_CHANGE_USER packet (without the first, command, byte) or 0 if it's not a COM_CHANGE_USER (that is, if it's a new connection) @
| 11405 | @retval 1 error |
| 11406 | */ |
| 11407 | int |
| 11408 | acl_authenticate(THD *thd, uint com_change_user_pkt_len) |
| 11409 | { |
| 11410 | int res= CR_OK; |
| 11411 | MPVIO_EXT mpvio; |
| 11412 | Thd_charset_adapter charset_adapter(thd); |
| 11413 | |
| 11414 | LEX_STRING auth_plugin_name= default_auth_plugin_name; |
| 11415 | enum enum_server_command command= com_change_user_pkt_len ? COM_CHANGE_USER |
| 11416 | : COM_CONNECT; |
| 11417 | |
| 11418 | DBUG_ENTER("acl_authenticate"); |
| 11419 | compile_time_assert(MYSQL_USERNAME_LENGTH == USERNAME_LENGTH); |
| 11420 | |
| 11421 | server_mpvio_initialize(thd, &mpvio, &charset_adapter); |
| 11422 | |
| 11423 | DBUG_PRINT("info", ("com_change_user_pkt_len=%u", com_change_user_pkt_len)); |
| 11424 | |
| 11425 | /* |
| 11426 | Clear thd->db as it points to something, that will be freed when |
| 11427 | connection is closed. We don't want to accidentally free a wrong |
| 11428 | pointer if connect failed. |
| 11429 | */ |
| 11430 | thd->reset_db(NULL, 0); |
| 11431 | |
| 11432 | if (command == COM_CHANGE_USER) |
| 11433 | { |
| 11434 | mpvio.packets_written++; // pretend that a server handshake packet was sent |
| 11435 | mpvio.packets_read++; // take COM_CHANGE_USER packet into account |
| 11436 | |
| 11437 | /* Clear variables that are allocated */ |
| 11438 | thd->set_user_connect(NULL); |
| 11439 | |
| 11440 | if (parse_com_change_user_packet(&mpvio, com_change_user_pkt_len)) |
| 11441 | { |
| 11442 | if (!thd->is_error()) |
| 11443 | login_failed_error(&mpvio, mpvio.auth_info.password_used); |
| 11444 | server_mpvio_update_thd(thd, &mpvio); |
| 11445 | DBUG_RETURN(1); |
| 11446 | } |
| 11447 | |
| 11448 | DBUG_ASSERT(mpvio.status == MPVIO_EXT::RESTART || |
| 11449 | mpvio.status == MPVIO_EXT::SUCCESS); |
| 11450 | } |
| 11451 | else |
| 11452 | { |
| 11453 | /* mark the thd as having no scramble yet */ |
| 11454 | mpvio.scramble[SCRAMBLE_LENGTH]= 1; |
| 11455 | |
| 11456 | /* |
| 11457 | perform the first authentication attempt, with the default plugin. |
| 11458 | This sends the server handshake packet, reads the client reply |
| 11459 | with a user name, and performs the authentication if everyone has used |
| 11460 | the correct plugin. |
| 11461 | */ |
| 11462 | |
| 11463 | res= do_auth_once(thd, &auth_plugin_name, &mpvio); |
| 11464 | } |
nothing calls this directly
no test coverage detected