vio->read_packet() callback method for server authentication plugins This function is called by a server authentication plugin, when it wants to read data from the client. It transparently extracts the client plugin data, if embedded into a client authentication handshake packet, and handles plugin negotiation with the client, if necessary. */
| 14728 | with the client, if necessary. |
| 14729 | */ |
| 14730 | static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf) |
| 14731 | { |
| 14732 | MPVIO_EXT * const mpvio= (MPVIO_EXT *) param; |
| 14733 | MYSQL_SERVER_AUTH_INFO * const ai= &mpvio->auth_info; |
| 14734 | ulong pkt_len; |
| 14735 | DBUG_ENTER("server_mpvio_read_packet"); |
| 14736 | if (mpvio->status == MPVIO_EXT::RESTART) |
| 14737 | { |
| 14738 | const char *client_auth_plugin= |
| 14739 | ((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin; |
| 14740 | if (client_auth_plugin == 0) |
| 14741 | { |
| 14742 | mpvio->status= MPVIO_EXT::FAILURE; |
| 14743 | pkt_len= 0; |
| 14744 | *buf= 0; |
| 14745 | goto done; |
| 14746 | } |
| 14747 | |
| 14748 | if (mpvio->cached_client_reply.pkt) |
| 14749 | { |
| 14750 | DBUG_ASSERT(mpvio->packets_read > 0); |
| 14751 | /* |
| 14752 | if the have the data cached from the last server_mpvio_read_packet |
| 14753 | (which can be the case if it's a restarted authentication) |
| 14754 | and a client has used the correct plugin, then we can return the |
| 14755 | cached data straight away and avoid one round trip. |
| 14756 | */ |
| 14757 | if (Lex_ident_plugin(Lex_cstring_strlen(client_auth_plugin)). |
| 14758 | streq(mpvio->cached_client_reply.plugin)) |
| 14759 | { |
| 14760 | mpvio->status= MPVIO_EXT::FAILURE; |
| 14761 | pkt_len= mpvio->cached_client_reply.pkt_len; |
| 14762 | *buf= (uchar*) mpvio->cached_client_reply.pkt; |
| 14763 | mpvio->packets_read++; |
| 14764 | goto done; |
| 14765 | } |
| 14766 | } |
| 14767 | |
| 14768 | /* |
| 14769 | plugin wants to read the data without sending anything first. |
| 14770 | send an empty packet to force a server handshake packet to be sent |
| 14771 | */ |
| 14772 | if (server_mpvio_write_packet(mpvio, 0, 0)) |
| 14773 | pkt_len= packet_error; |
| 14774 | else |
| 14775 | pkt_len= my_net_read(&ai->thd->net); |
| 14776 | } |
| 14777 | else |
| 14778 | pkt_len= my_net_read(&ai->thd->net); |
| 14779 | |
| 14780 | if (unlikely(pkt_len == packet_error)) |
| 14781 | goto err; |
| 14782 | |
| 14783 | mpvio->packets_read++; |
| 14784 | |
| 14785 | /* |
| 14786 | the 1st packet has the plugin data wrapped into the client authentication |
| 14787 | handshake packet |
nothing calls this directly
no test coverage detected