client authentication plugin that does old MySQL authentication using an 8-byte (4.0-) scramble */
| 4807 | using an 8-byte (4.0-) scramble |
| 4808 | */ |
| 4809 | static int old_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) |
| 4810 | { |
| 4811 | uchar *pkt; |
| 4812 | int pkt_len; |
| 4813 | |
| 4814 | DBUG_ENTER("old_password_auth_client"); |
| 4815 | |
| 4816 | if (((MCPVIO_EXT *)vio)->mysql_change_user) |
| 4817 | { |
| 4818 | /* |
| 4819 | in mysql_change_user() the client sends the first packet. |
| 4820 | we use the old scramble. |
| 4821 | */ |
| 4822 | pkt= (uchar*)mysql->scramble; |
| 4823 | pkt_len= SCRAMBLE_LENGTH_323 + 1; |
| 4824 | } |
| 4825 | else |
| 4826 | { |
| 4827 | /* read the scramble */ |
| 4828 | if ((pkt_len= vio->read_packet(vio, &pkt)) < 0) |
| 4829 | DBUG_RETURN(CR_ERROR); |
| 4830 | |
| 4831 | if (pkt_len != SCRAMBLE_LENGTH_323 + 1 && |
| 4832 | pkt_len != SCRAMBLE_LENGTH + 1) |
| 4833 | DBUG_RETURN(CR_SERVER_HANDSHAKE_ERR); |
| 4834 | |
| 4835 | /* |
| 4836 | save it in MYSQL. |
| 4837 | Copy data of length SCRAMBLE_LENGTH_323 or SCRAMBLE_LENGTH |
| 4838 | to ensure that buffer overflow does not occur. |
| 4839 | */ |
| 4840 | memcpy(mysql->scramble, pkt, (pkt_len - 1)); |
| 4841 | mysql->scramble[pkt_len-1] = 0; |
| 4842 | } |
| 4843 | |
| 4844 | if (mysql->passwd[0]) |
| 4845 | { |
| 4846 | /* |
| 4847 | If --secure-auth option is used, throw an error. |
| 4848 | Note that, we do not need to check for CLIENT_SECURE_CONNECTION |
| 4849 | capability of server. If server is not capable of handling secure |
| 4850 | connections, we would have raised error before reaching here. |
| 4851 | |
| 4852 | TODO: Change following code to access MYSQL structure through |
| 4853 | client-side plugin service. |
| 4854 | */ |
| 4855 | if (mysql->options.secure_auth) |
| 4856 | { |
| 4857 | set_mysql_error(mysql, CR_SECURE_AUTH, unknown_sqlstate); |
| 4858 | DBUG_RETURN(CR_ERROR); |
| 4859 | } |
| 4860 | else |
| 4861 | { |
| 4862 | char scrambled[SCRAMBLE_LENGTH_323 + 1]; |
| 4863 | scramble_323(scrambled, (char*)pkt, mysql->passwd); |
| 4864 | if (vio->write_packet(vio, (uchar*)scrambled, SCRAMBLE_LENGTH_323 + 1)) |
| 4865 | DBUG_RETURN(CR_ERROR); |
| 4866 | } |
nothing calls this directly
no test coverage detected