MySQL Server Password Authentication Plugin In the MySQL authentication protocol: 1. the server sends the random scramble to the client 2. client sends the encrypted password back to the server 3. the server checks the password. */
| 11768 | 3. the server checks the password. |
| 11769 | */ |
| 11770 | static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio, |
| 11771 | MYSQL_SERVER_AUTH_INFO *info) |
| 11772 | { |
| 11773 | uchar *pkt; |
| 11774 | int pkt_len; |
| 11775 | MPVIO_EXT *mpvio= (MPVIO_EXT *) vio; |
| 11776 | |
| 11777 | DBUG_ENTER("native_password_authenticate"); |
| 11778 | |
| 11779 | /* generate the scramble, or reuse the old one */ |
| 11780 | if (mpvio->scramble[SCRAMBLE_LENGTH]) |
| 11781 | create_random_string(mpvio->scramble, SCRAMBLE_LENGTH, mpvio->rand); |
| 11782 | |
| 11783 | /* send it to the client */ |
| 11784 | if (mpvio->write_packet(mpvio, (uchar*) mpvio->scramble, SCRAMBLE_LENGTH + 1)) |
| 11785 | DBUG_RETURN(CR_AUTH_HANDSHAKE); |
| 11786 | |
| 11787 | /* reply and authenticate */ |
| 11788 | |
| 11789 | /* |
| 11790 | <digression> |
| 11791 | This is more complex than it looks. |
| 11792 | |
| 11793 | The plugin (we) may be called right after the client was connected - |
| 11794 | and will need to send a scramble, read reply, authenticate. |
| 11795 | |
| 11796 | Or the plugin may be called after another plugin has sent a scramble, |
| 11797 | and read the reply. If the client has used the correct client-plugin, |
| 11798 | we won't need to read anything here from the client, the client |
| 11799 | has already sent a reply with everything we need for authentication. |
| 11800 | |
| 11801 | Or the plugin may be called after another plugin has sent a scramble, |
| 11802 | and read the reply, but the client has used the wrong client-plugin. |
| 11803 | We'll need to sent a "switch to another plugin" packet to the |
| 11804 | client and read the reply. "Use the short scramble" packet is a special |
| 11805 | case of "switch to another plugin" packet. |
| 11806 | |
| 11807 | Or, perhaps, the plugin may be called after another plugin has |
| 11808 | done the handshake but did not send a useful scramble. We'll need |
| 11809 | to send a scramble (and perhaps a "switch to another plugin" packet) |
| 11810 | and read the reply. |
| 11811 | |
| 11812 | Besides, a client may be an old one, that doesn't understand plugins. |
| 11813 | Or doesn't even understand 4.0 scramble. |
| 11814 | |
| 11815 | And we want to keep the same protocol on the wire unless non-native |
| 11816 | plugins are involved. |
| 11817 | |
| 11818 | Anyway, it still looks simple from a plugin point of view: |
| 11819 | "send the scramble, read the reply and authenticate" |
| 11820 | All the magic is transparently handled by the server. |
| 11821 | </digression> |
| 11822 | */ |
| 11823 | |
| 11824 | /* read the reply with the encrypted password */ |
| 11825 | if ((pkt_len= mpvio->read_packet(mpvio, &pkt)) < 0) |
| 11826 | DBUG_RETURN(CR_AUTH_HANDSHAKE); |
| 11827 | DBUG_PRINT("info", ("reply read : pkt_len=%d", pkt_len)); |
nothing calls this directly
no outgoing calls
no test coverage detected