Authentication Plugin Example
static int skey_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info)
{
unsigned char *pkt;
int pkt_len;
struct skey mp;
char buf[SKEY_MAX_CHALLENGE+3];
buf[0] = 2; /* ordinary question */
if (skeychallenge(&mp, info->user_name, buf+1, SKEY_MAX_CHALLENGE) < 0)
return CR_ERROR;
strcat(buf, ":");
if (vio->write_packet(vio, buf, strlen(buf)))
return CR_ERROR;
if ((pkt_len= vio->read_packet(vio, &pkt)) < 0)
return CR_ERROR;
info->password_used = 1;
return skeyverify(&mp, pkt) ? CR_ERROR : CR_OK;
}
Demo
$ mysql --user=sktest
[mariadb] otp-md5 98 janu76882: HERB JESS BLAB VERB DAWN BEN
Your MariaDB connection id is 3
Server version: 5.2.0-MariaDB-alpha-debug Source distribution
MariaDB [test]> quit
Bye
$ mysql --user=sktest
[mariadb] otp-md5 97 janu76882: MOS BLOT QUAD JANE HUGE FOOL
Your MariaDB connection id is 4
Server version: 5.2.0-MariaDB-alpha-debug Source distribution
MariaDB [test]> quit
Bye
$ mysql --user=sktest
[mariadb] otp-md5 96 janu76882: MOS BLOT QUAD JANE HUGE FOOL
ERROR 1045 (28000): Access denied for user 'sktest'@'localhost' (using password: YES)