MXS-862: Move sending of OK packet to mysql_client
Moving the sending of the final OK packet of the authentication process to the client protocol plugin makes the authentication plugins simpler. By reading the client's sequence and incrementing that by one, the client protocol module will always send the correct sequence byte in the final OK packet.
This commit is contained in:
parent
239b53e156
commit
5d96faedd8
@ -281,8 +281,7 @@ int gssapi_auth_authenticate(DCB *dcb)
|
||||
|
||||
MYSQL_session *ses = (MYSQL_session*)dcb->data;
|
||||
|
||||
if (validate_gssapi_token(ses->auth_token, ses->auth_token_len) &&
|
||||
mxs_mysql_send_ok(dcb, 4, 0, NULL))
|
||||
if (validate_gssapi_token(ses->auth_token, ses->auth_token_len))
|
||||
{
|
||||
rval = MXS_AUTH_SUCCEEDED;
|
||||
}
|
||||
|
@ -193,7 +193,6 @@ mysql_auth_authenticate(DCB *dcb)
|
||||
{
|
||||
dcb->user = MXS_STRDUP_A(client_data->user);
|
||||
/** Send an OK packet to the client */
|
||||
mxs_mysql_send_ok(dcb, ssl_required_by_dcb(dcb) ? 3 : 2, 0, NULL);
|
||||
}
|
||||
else if (dcb->service->log_auth_warnings)
|
||||
{
|
||||
|
@ -70,6 +70,10 @@
|
||||
#define MYSQL_HEADER_LEN 4L
|
||||
#define MYSQL_CHECKSUM_LEN 4L
|
||||
|
||||
/** Offsets to various parts of the client packet */
|
||||
#define MYSQL_SEQ_OFFSET 3
|
||||
#define MYSQL_COM_OFFSET 4
|
||||
|
||||
#define GW_MYSQL_PROTOCOL_VERSION 10 // version is 10
|
||||
#define GW_MYSQL_HANDSHAKE_FILLER 0x00
|
||||
#define GW_MYSQL_SERVER_CAPABILITIES_BYTE1 0xff
|
||||
|
@ -486,6 +486,11 @@ gw_read_do_authentication(DCB *dcb, GWBUF *read_buffer, int nbytes_read)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Read the client's packet sequence and increment that by one */
|
||||
uint8_t next_sequence;
|
||||
gwbuf_copy_data(read_buffer, MYSQL_SEQ_OFFSET, 1, &next_sequence);
|
||||
next_sequence++;
|
||||
|
||||
/**
|
||||
* The first step in the authentication process is to extract the
|
||||
* relevant information from the buffer supplied and place it
|
||||
@ -542,6 +547,7 @@ gw_read_do_authentication(DCB *dcb, GWBUF *read_buffer, int nbytes_read)
|
||||
ss_dassert(session->state != SESSION_STATE_ALLOC &&
|
||||
session->state != SESSION_STATE_DUMMY);
|
||||
protocol->protocol_auth_state = MXS_AUTH_STATE_COMPLETE;
|
||||
mxs_mysql_send_ok(dcb, next_sequence, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user