MXS-1826: Respond with AuthSwitchRequest to COM_CHANGE_USER

To support a wider range of client connectors, MaxScale should respond
with an AuthSwitchRequest packet to all COM_CHANGE_USER commands. Only
MariaDB connectors understand the OK packet as the only response to a
COM_CHANGE_USER but all connectors understand the AuthSwitchRequest
packet.
This commit is contained in:
Markus Mäkelä
2018-04-30 07:15:20 +03:00
parent 66d7281d97
commit e311b86800
3 changed files with 84 additions and 4 deletions

View File

@ -1404,6 +1404,23 @@ int send_mysql_native_password_response(DCB* dcb)
return dcb_write(dcb, buffer);
}
bool send_auth_switch_request_packet(DCB* dcb)
{
MySQLProtocol* proto = (MySQLProtocol*) dcb->protocol;
const char plugin[] = DEFAULT_MYSQL_AUTH_PLUGIN;
uint32_t len = 1 + sizeof(plugin) + GW_MYSQL_SCRAMBLE_SIZE;
GWBUF* buffer = gwbuf_alloc(MYSQL_HEADER_LEN + len);
uint8_t* data = GWBUF_DATA(buffer);
gw_mysql_set_byte3(data, len);
data[3] = 1; // First response to the COM_CHANGE_USER
data[MYSQL_HEADER_LEN] = MYSQL_REPLY_AUTHSWITCHREQUEST;
memcpy(data + MYSQL_HEADER_LEN + 1, plugin, sizeof(plugin));
memcpy(data + MYSQL_HEADER_LEN + 1 + sizeof(plugin), proto->scramble, GW_MYSQL_SCRAMBLE_SIZE);
return dcb_write(dcb, buffer) != 0;
}
/**
* Decode mysql server handshake
*