Format protocol modules
Formatted protocol modules with Astyle.
This commit is contained in:
parent
0b6b9c3d81
commit
1766e3a06b
@ -127,88 +127,88 @@ cdc_read_event(DCB* dcb)
|
||||
{
|
||||
switch (protocol->state)
|
||||
{
|
||||
case CDC_STATE_WAIT_FOR_AUTH:
|
||||
if (CDC_STATE_AUTH_OK == (
|
||||
/* Fill CDC_session from incoming packet */
|
||||
auth_val = dcb->authfunc.extract(dcb, head)))
|
||||
case CDC_STATE_WAIT_FOR_AUTH:
|
||||
if (CDC_STATE_AUTH_OK == (
|
||||
/* Fill CDC_session from incoming packet */
|
||||
auth_val = dcb->authfunc.extract(dcb, head)))
|
||||
{
|
||||
/* Call protocol authentication */
|
||||
auth_val = dcb->authfunc.authenticate(dcb);
|
||||
}
|
||||
|
||||
/* Discard input buffer */
|
||||
gwbuf_free(head);
|
||||
|
||||
if (auth_val == CDC_STATE_AUTH_OK)
|
||||
{
|
||||
/* start a real session */
|
||||
session = session_alloc(dcb->service, dcb);
|
||||
|
||||
if (session != NULL)
|
||||
{
|
||||
/* Call protocol authentication */
|
||||
auth_val = dcb->authfunc.authenticate(dcb);
|
||||
}
|
||||
protocol->state = CDC_STATE_HANDLE_REQUEST;
|
||||
|
||||
/* Discard input buffer */
|
||||
gwbuf_free(head);
|
||||
write_auth_ack(dcb);
|
||||
|
||||
if (auth_val == CDC_STATE_AUTH_OK)
|
||||
{
|
||||
/* start a real session */
|
||||
session = session_alloc(dcb->service, dcb);
|
||||
|
||||
if (session != NULL)
|
||||
{
|
||||
protocol->state = CDC_STATE_HANDLE_REQUEST;
|
||||
|
||||
write_auth_ack(dcb);
|
||||
|
||||
MXS_INFO("%s: Client [%s] authenticated with user [%s]",
|
||||
dcb->service->name, dcb->remote != NULL ? dcb->remote : "",
|
||||
client_data->user);
|
||||
}
|
||||
else
|
||||
{
|
||||
auth_val = CDC_STATE_AUTH_NO_SESSION;
|
||||
}
|
||||
}
|
||||
|
||||
if (auth_val != CDC_STATE_AUTH_OK)
|
||||
{
|
||||
protocol->state = CDC_STATE_AUTH_ERR;
|
||||
|
||||
write_auth_err(dcb);
|
||||
MXS_ERROR("%s: authentication failure from [%s], user [%s]",
|
||||
dcb->service->name, dcb->remote != NULL ? dcb->remote : "",
|
||||
client_data->user);
|
||||
|
||||
/* force the client connection close */
|
||||
dcb_close(dcb);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CDC_STATE_HANDLE_REQUEST:
|
||||
// handle CLOSE command, it shoudl be routed as well and client connection closed after last transmission
|
||||
if (strncmp((char*)GWBUF_DATA(head), "CLOSE", GWBUF_LENGTH(head)) == 0)
|
||||
{
|
||||
MXS_INFO("%s: Client [%s] has requested CLOSE action",
|
||||
dcb->service->name, dcb->remote != NULL ? dcb->remote : "");
|
||||
|
||||
// gwbuf_set_type(head, GWBUF_TYPE_CDC);
|
||||
// the router will close the client connection
|
||||
//rc = SESSION_ROUTE_QUERY(session, head);
|
||||
|
||||
// buffer not handled by router right now, consume it
|
||||
gwbuf_free(head);
|
||||
|
||||
/* right now, just force the client connection close */
|
||||
dcb_close(dcb);
|
||||
MXS_INFO("%s: Client [%s] authenticated with user [%s]",
|
||||
dcb->service->name, dcb->remote != NULL ? dcb->remote : "",
|
||||
client_data->user);
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_INFO("%s: Client [%s] requested [%.*s] action",
|
||||
dcb->service->name, dcb->remote != NULL ? dcb->remote : "",
|
||||
(int)GWBUF_LENGTH(head), (char*)GWBUF_DATA(head));
|
||||
|
||||
// gwbuf_set_type(head, GWBUF_TYPE_CDC);
|
||||
rc = SESSION_ROUTE_QUERY(session, head);
|
||||
auth_val = CDC_STATE_AUTH_NO_SESSION;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
MXS_INFO("%s: Client [%s] in unknown state %d", dcb->service->name,
|
||||
dcb->remote != NULL ? dcb->remote : "", protocol->state);
|
||||
if (auth_val != CDC_STATE_AUTH_OK)
|
||||
{
|
||||
protocol->state = CDC_STATE_AUTH_ERR;
|
||||
|
||||
write_auth_err(dcb);
|
||||
MXS_ERROR("%s: authentication failure from [%s], user [%s]",
|
||||
dcb->service->name, dcb->remote != NULL ? dcb->remote : "",
|
||||
client_data->user);
|
||||
|
||||
/* force the client connection close */
|
||||
dcb_close(dcb);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case CDC_STATE_HANDLE_REQUEST:
|
||||
// handle CLOSE command, it shoudl be routed as well and client connection closed after last transmission
|
||||
if (strncmp((char*)GWBUF_DATA(head), "CLOSE", GWBUF_LENGTH(head)) == 0)
|
||||
{
|
||||
MXS_INFO("%s: Client [%s] has requested CLOSE action",
|
||||
dcb->service->name, dcb->remote != NULL ? dcb->remote : "");
|
||||
|
||||
// gwbuf_set_type(head, GWBUF_TYPE_CDC);
|
||||
// the router will close the client connection
|
||||
//rc = SESSION_ROUTE_QUERY(session, head);
|
||||
|
||||
// buffer not handled by router right now, consume it
|
||||
gwbuf_free(head);
|
||||
|
||||
break;
|
||||
/* right now, just force the client connection close */
|
||||
dcb_close(dcb);
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_INFO("%s: Client [%s] requested [%.*s] action",
|
||||
dcb->service->name, dcb->remote != NULL ? dcb->remote : "",
|
||||
(int)GWBUF_LENGTH(head), (char*)GWBUF_DATA(head));
|
||||
|
||||
// gwbuf_set_type(head, GWBUF_TYPE_CDC);
|
||||
rc = SESSION_ROUTE_QUERY(session, head);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
MXS_INFO("%s: Client [%s] in unknown state %d", dcb->service->name,
|
||||
dcb->remote != NULL ? dcb->remote : "", protocol->state);
|
||||
gwbuf_free(head);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,48 +211,48 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
/*< Set protocol state */
|
||||
switch (rv)
|
||||
{
|
||||
case 0:
|
||||
ss_dassert(fd > 0);
|
||||
protocol->fd = fd;
|
||||
protocol->protocol_auth_state = MXS_AUTH_STATE_CONNECTED;
|
||||
MXS_DEBUG("%lu [gw_create_backend_connection] Established "
|
||||
"connection to %s:%i, protocol fd %d client "
|
||||
"fd %d.",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
case 0:
|
||||
ss_dassert(fd > 0);
|
||||
protocol->fd = fd;
|
||||
protocol->protocol_auth_state = MXS_AUTH_STATE_CONNECTED;
|
||||
MXS_DEBUG("%lu [gw_create_backend_connection] Established "
|
||||
"connection to %s:%i, protocol fd %d client "
|
||||
"fd %d.",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
/* The state MYSQL_PENDING_CONNECT is likely to be transitory, */
|
||||
/* as it means the calls have been successful but the connection */
|
||||
/* has not yet completed and the calls are non-blocking. */
|
||||
ss_dassert(fd > 0);
|
||||
protocol->protocol_auth_state = MXS_AUTH_STATE_PENDING_CONNECT;
|
||||
protocol->fd = fd;
|
||||
MXS_DEBUG("%lu [gw_create_backend_connection] Connection "
|
||||
"pending to %s:%i, protocol fd %d client fd %d.",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
case 1:
|
||||
/* The state MYSQL_PENDING_CONNECT is likely to be transitory, */
|
||||
/* as it means the calls have been successful but the connection */
|
||||
/* has not yet completed and the calls are non-blocking. */
|
||||
ss_dassert(fd > 0);
|
||||
protocol->protocol_auth_state = MXS_AUTH_STATE_PENDING_CONNECT;
|
||||
protocol->fd = fd;
|
||||
MXS_DEBUG("%lu [gw_create_backend_connection] Connection "
|
||||
"pending to %s:%i, protocol fd %d client fd %d.",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Failure - the state reverts to its initial value */
|
||||
ss_dassert(fd == -1);
|
||||
ss_dassert(protocol->protocol_auth_state == MXS_AUTH_STATE_INIT);
|
||||
MXS_DEBUG("%lu [gw_create_backend_connection] Connection "
|
||||
"failed to %s:%i, protocol fd %d client fd %d.",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
default:
|
||||
/* Failure - the state reverts to its initial value */
|
||||
ss_dassert(fd == -1);
|
||||
ss_dassert(protocol->protocol_auth_state == MXS_AUTH_STATE_INIT);
|
||||
MXS_DEBUG("%lu [gw_create_backend_connection] Connection "
|
||||
"failed to %s:%i, protocol fd %d client fd %d.",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
} /*< switch */
|
||||
|
||||
return_fd:
|
||||
@ -454,16 +454,16 @@ mxs_auth_state_t handle_server_response(DCB *dcb, GWBUF *buffer)
|
||||
{
|
||||
switch (dcb->authfunc.authenticate(dcb))
|
||||
{
|
||||
case MXS_AUTH_INCOMPLETE:
|
||||
case MXS_AUTH_SSL_INCOMPLETE:
|
||||
rval = MXS_AUTH_STATE_RESPONSE_SENT;
|
||||
break;
|
||||
case MXS_AUTH_INCOMPLETE:
|
||||
case MXS_AUTH_SSL_INCOMPLETE:
|
||||
rval = MXS_AUTH_STATE_RESPONSE_SENT;
|
||||
break;
|
||||
|
||||
case MXS_AUTH_SUCCEEDED:
|
||||
rval = MXS_AUTH_STATE_COMPLETE;
|
||||
case MXS_AUTH_SUCCEEDED:
|
||||
rval = MXS_AUTH_STATE_COMPLETE;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -691,7 +691,7 @@ static inline bool session_ok_to_route(DCB *dcb)
|
||||
static inline bool expecting_resultset(MySQLProtocol *proto)
|
||||
{
|
||||
return proto->current_command == MYSQL_COM_QUERY ||
|
||||
proto->current_command == MYSQL_COM_STMT_FETCH;
|
||||
proto->current_command == MYSQL_COM_STMT_FETCH;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1011,24 +1011,24 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
*/
|
||||
switch (backend_protocol->protocol_auth_state)
|
||||
{
|
||||
case MXS_AUTH_STATE_HANDSHAKE_FAILED:
|
||||
case MXS_AUTH_STATE_FAILED:
|
||||
if (dcb->session->state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
MXS_ERROR("Unable to write to backend '%s' due to "
|
||||
"%s failure. Server in state %s.",
|
||||
dcb->server->unique_name,
|
||||
backend_protocol->protocol_auth_state == MXS_AUTH_STATE_HANDSHAKE_FAILED ?
|
||||
"handshake" : "authentication",
|
||||
STRSRVSTATUS(dcb->server));
|
||||
}
|
||||
case MXS_AUTH_STATE_HANDSHAKE_FAILED:
|
||||
case MXS_AUTH_STATE_FAILED:
|
||||
if (dcb->session->state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
MXS_ERROR("Unable to write to backend '%s' due to "
|
||||
"%s failure. Server in state %s.",
|
||||
dcb->server->unique_name,
|
||||
backend_protocol->protocol_auth_state == MXS_AUTH_STATE_HANDSHAKE_FAILED ?
|
||||
"handshake" : "authentication",
|
||||
STRSRVSTATUS(dcb->server));
|
||||
}
|
||||
|
||||
gwbuf_free(queue);
|
||||
rc = 0;
|
||||
gwbuf_free(queue);
|
||||
rc = 0;
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_COMPLETE:
|
||||
case MXS_AUTH_STATE_COMPLETE:
|
||||
{
|
||||
uint8_t* ptr = GWBUF_DATA(queue);
|
||||
mysql_server_cmd_t cmd = MYSQL_GET_COMMAND(ptr);
|
||||
@ -1076,7 +1076,7 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
{
|
||||
MXS_DEBUG("%lu [gw_MySQLWrite_backend] delayed write to "
|
||||
"dcb %p fd %d protocol state %s.",
|
||||
|
@ -462,22 +462,22 @@ int gw_read_client_event(DCB* dcb)
|
||||
|
||||
switch (protocol->protocol_auth_state)
|
||||
{
|
||||
/**
|
||||
*
|
||||
* When a listener receives a new connection request, it creates a
|
||||
* request handler DCB to for the client connection. The listener also
|
||||
* sends the initial authentication request to the client. The first
|
||||
* time this function is called from the poll loop, the client reply
|
||||
* to the authentication request should be available.
|
||||
*
|
||||
* If the authentication is successful the protocol authentication state
|
||||
* will be changed to MYSQL_IDLE (see below).
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* When a listener receives a new connection request, it creates a
|
||||
* request handler DCB to for the client connection. The listener also
|
||||
* sends the initial authentication request to the client. The first
|
||||
* time this function is called from the poll loop, the client reply
|
||||
* to the authentication request should be available.
|
||||
*
|
||||
* If the authentication is successful the protocol authentication state
|
||||
* will be changed to MYSQL_IDLE (see below).
|
||||
*
|
||||
*/
|
||||
case MXS_AUTH_STATE_MESSAGE_READ:
|
||||
/* After this call read_buffer will point to freed data */
|
||||
if (nbytes_read < 3 || (0 == max_bytes && nbytes_read <
|
||||
(MYSQL_GET_PAYLOAD_LEN((uint8_t *) GWBUF_DATA(read_buffer)) + 4)) ||
|
||||
(MYSQL_GET_PAYLOAD_LEN((uint8_t *) GWBUF_DATA(read_buffer)) + 4)) ||
|
||||
(0 != max_bytes && nbytes_read < max_bytes))
|
||||
{
|
||||
|
||||
@ -488,26 +488,26 @@ int gw_read_client_event(DCB* dcb)
|
||||
return_code = gw_read_do_authentication(dcb, read_buffer, nbytes_read);
|
||||
break;
|
||||
|
||||
/**
|
||||
*
|
||||
* Once a client connection is authenticated, the protocol authentication
|
||||
* state will be MYSQL_IDLE and so every event of data received will
|
||||
* result in a call that comes to this section of code.
|
||||
*
|
||||
*/
|
||||
case MXS_AUTH_STATE_COMPLETE:
|
||||
/* After this call read_buffer will point to freed data */
|
||||
return_code = gw_read_normal_data(dcb, read_buffer, nbytes_read);
|
||||
break;
|
||||
/**
|
||||
*
|
||||
* Once a client connection is authenticated, the protocol authentication
|
||||
* state will be MYSQL_IDLE and so every event of data received will
|
||||
* result in a call that comes to this section of code.
|
||||
*
|
||||
*/
|
||||
case MXS_AUTH_STATE_COMPLETE:
|
||||
/* After this call read_buffer will point to freed data */
|
||||
return_code = gw_read_normal_data(dcb, read_buffer, nbytes_read);
|
||||
break;
|
||||
|
||||
case MXS_AUTH_STATE_FAILED:
|
||||
gwbuf_free(read_buffer);
|
||||
return_code = 1;
|
||||
break;
|
||||
case MXS_AUTH_STATE_FAILED:
|
||||
gwbuf_free(read_buffer);
|
||||
return_code = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
MXS_ERROR("In mysql_client.c unexpected protocol authentication state");
|
||||
break;
|
||||
default:
|
||||
MXS_ERROR("In mysql_client.c unexpected protocol authentication state");
|
||||
break;
|
||||
}
|
||||
|
||||
return return_code;
|
||||
@ -527,7 +527,7 @@ static void store_client_information(DCB *dcb, GWBUF *buffer)
|
||||
|
||||
gwbuf_copy_data(buffer, 0, len, data);
|
||||
ss_dassert(MYSQL_GET_PAYLOAD_LEN(data) + MYSQL_HEADER_LEN == len ||
|
||||
len == MYSQL_AUTH_PACKET_BASE_SIZE); // For SSL request packet
|
||||
len == MYSQL_AUTH_PACKET_BASE_SIZE); // For SSL request packet
|
||||
|
||||
proto->client_capabilities = gw_mysql_get_byte4(data + MYSQL_CLIENT_CAP_OFFSET);
|
||||
proto->charset = data[MYSQL_CHARSET_OFFSET];
|
||||
@ -1016,84 +1016,84 @@ mysql_client_auth_error_handling(DCB *dcb, int auth_val, int packet_number)
|
||||
|
||||
switch (auth_val)
|
||||
{
|
||||
case MXS_AUTH_NO_SESSION:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] session "
|
||||
"creation failed. fd %d, "
|
||||
"state = MYSQL_AUTH_NO_SESSION.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
case MXS_AUTH_NO_SESSION:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] session "
|
||||
"creation failed. fd %d, "
|
||||
"state = MYSQL_AUTH_NO_SESSION.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
|
||||
/** Send ERR 1045 to client */
|
||||
mysql_send_auth_error(dcb,
|
||||
packet_number,
|
||||
0,
|
||||
"failed to create new session");
|
||||
break;
|
||||
case MXS_AUTH_FAILED_DB:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] database "
|
||||
"specified was not valid. fd %d, "
|
||||
"state = MYSQL_FAILED_AUTH_DB.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
/** Send error 1049 to client */
|
||||
message_len = 25 + MYSQL_DATABASE_MAXLEN;
|
||||
/** Send ERR 1045 to client */
|
||||
mysql_send_auth_error(dcb,
|
||||
packet_number,
|
||||
0,
|
||||
"failed to create new session");
|
||||
break;
|
||||
case MXS_AUTH_FAILED_DB:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] database "
|
||||
"specified was not valid. fd %d, "
|
||||
"state = MYSQL_FAILED_AUTH_DB.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
/** Send error 1049 to client */
|
||||
message_len = 25 + MYSQL_DATABASE_MAXLEN;
|
||||
|
||||
fail_str = MXS_CALLOC(1, message_len + 1);
|
||||
MXS_ABORT_IF_NULL(fail_str);
|
||||
snprintf(fail_str, message_len, "Unknown database '%s'",
|
||||
(char*)((MYSQL_session *)dcb->data)->db);
|
||||
fail_str = MXS_CALLOC(1, message_len + 1);
|
||||
MXS_ABORT_IF_NULL(fail_str);
|
||||
snprintf(fail_str, message_len, "Unknown database '%s'",
|
||||
(char*)((MYSQL_session *)dcb->data)->db);
|
||||
|
||||
modutil_send_mysql_err_packet(dcb, packet_number, 0, 1049, "42000", fail_str);
|
||||
break;
|
||||
case MXS_AUTH_FAILED_SSL:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] client is "
|
||||
"not SSL capable for SSL listener. fd %d, "
|
||||
"state = MYSQL_FAILED_AUTH_SSL.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
modutil_send_mysql_err_packet(dcb, packet_number, 0, 1049, "42000", fail_str);
|
||||
break;
|
||||
case MXS_AUTH_FAILED_SSL:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] client is "
|
||||
"not SSL capable for SSL listener. fd %d, "
|
||||
"state = MYSQL_FAILED_AUTH_SSL.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
|
||||
/** Send ERR 1045 to client */
|
||||
mysql_send_auth_error(dcb,
|
||||
packet_number,
|
||||
0,
|
||||
"Access without SSL denied");
|
||||
break;
|
||||
case MXS_AUTH_SSL_INCOMPLETE:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] unable to "
|
||||
"complete SSL authentication. fd %d, "
|
||||
"state = MYSQL_AUTH_SSL_INCOMPLETE.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
/** Send ERR 1045 to client */
|
||||
mysql_send_auth_error(dcb,
|
||||
packet_number,
|
||||
0,
|
||||
"Access without SSL denied");
|
||||
break;
|
||||
case MXS_AUTH_SSL_INCOMPLETE:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] unable to "
|
||||
"complete SSL authentication. fd %d, "
|
||||
"state = MYSQL_AUTH_SSL_INCOMPLETE.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
|
||||
/** Send ERR 1045 to client */
|
||||
mysql_send_auth_error(dcb,
|
||||
packet_number,
|
||||
0,
|
||||
"failed to complete SSL authentication");
|
||||
break;
|
||||
case MXS_AUTH_FAILED:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] authentication failed. fd %d, "
|
||||
"state = MYSQL_FAILED_AUTH.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
/** Send error 1045 to client */
|
||||
fail_str = create_auth_fail_str((char *)((MYSQL_session *)dcb->data)->user,
|
||||
dcb->remote,
|
||||
(char*)((MYSQL_session *)dcb->data)->client_sha1,
|
||||
(char*)((MYSQL_session *)dcb->data)->db, auth_val);
|
||||
modutil_send_mysql_err_packet(dcb, packet_number, 0, 1045, "28000", fail_str);
|
||||
break;
|
||||
default:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] authentication failed. fd %d, "
|
||||
"state unrecognized.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
/** Send error 1045 to client */
|
||||
fail_str = create_auth_fail_str((char *)((MYSQL_session *)dcb->data)->user,
|
||||
dcb->remote,
|
||||
(char*)((MYSQL_session *)dcb->data)->client_sha1,
|
||||
(char*)((MYSQL_session *)dcb->data)->db, auth_val);
|
||||
modutil_send_mysql_err_packet(dcb, packet_number, 0, 1045, "28000", fail_str);
|
||||
/** Send ERR 1045 to client */
|
||||
mysql_send_auth_error(dcb,
|
||||
packet_number,
|
||||
0,
|
||||
"failed to complete SSL authentication");
|
||||
break;
|
||||
case MXS_AUTH_FAILED:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] authentication failed. fd %d, "
|
||||
"state = MYSQL_FAILED_AUTH.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
/** Send error 1045 to client */
|
||||
fail_str = create_auth_fail_str((char *)((MYSQL_session *)dcb->data)->user,
|
||||
dcb->remote,
|
||||
(char*)((MYSQL_session *)dcb->data)->client_sha1,
|
||||
(char*)((MYSQL_session *)dcb->data)->db, auth_val);
|
||||
modutil_send_mysql_err_packet(dcb, packet_number, 0, 1045, "28000", fail_str);
|
||||
break;
|
||||
default:
|
||||
MXS_DEBUG("%lu [gw_read_client_event] authentication failed. fd %d, "
|
||||
"state unrecognized.",
|
||||
pthread_self(),
|
||||
dcb->fd);
|
||||
/** Send error 1045 to client */
|
||||
fail_str = create_auth_fail_str((char *)((MYSQL_session *)dcb->data)->user,
|
||||
dcb->remote,
|
||||
(char*)((MYSQL_session *)dcb->data)->client_sha1,
|
||||
(char*)((MYSQL_session *)dcb->data)->db, auth_val);
|
||||
modutil_send_mysql_err_packet(dcb, packet_number, 0, 1045, "28000", fail_str);
|
||||
}
|
||||
MXS_FREE(fail_str);
|
||||
}
|
||||
|
@ -166,22 +166,22 @@ const char* gw_mysql_protocol_state2string (int state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case MXS_AUTH_STATE_INIT:
|
||||
return "Authentication initialized";
|
||||
case MXS_AUTH_STATE_PENDING_CONNECT:
|
||||
return "Network connection pending";
|
||||
case MXS_AUTH_STATE_CONNECTED:
|
||||
return "Network connection created";
|
||||
case MXS_AUTH_STATE_MESSAGE_READ:
|
||||
return "Read server handshake";
|
||||
case MXS_AUTH_STATE_RESPONSE_SENT:
|
||||
return "Response to handshake sent";
|
||||
case MXS_AUTH_STATE_FAILED:
|
||||
return "Authentication failed";
|
||||
case MXS_AUTH_STATE_COMPLETE:
|
||||
return "Authentication is complete.";
|
||||
default:
|
||||
return "MySQL (unknown protocol state)";
|
||||
case MXS_AUTH_STATE_INIT:
|
||||
return "Authentication initialized";
|
||||
case MXS_AUTH_STATE_PENDING_CONNECT:
|
||||
return "Network connection pending";
|
||||
case MXS_AUTH_STATE_CONNECTED:
|
||||
return "Network connection created";
|
||||
case MXS_AUTH_STATE_MESSAGE_READ:
|
||||
return "Read server handshake";
|
||||
case MXS_AUTH_STATE_RESPONSE_SENT:
|
||||
return "Response to handshake sent";
|
||||
case MXS_AUTH_STATE_FAILED:
|
||||
return "Authentication failed";
|
||||
case MXS_AUTH_STATE_COMPLETE:
|
||||
return "Authentication is complete.";
|
||||
default:
|
||||
return "MySQL (unknown protocol state)";
|
||||
}
|
||||
}
|
||||
|
||||
@ -841,27 +841,27 @@ void init_response_status(GWBUF* buf,
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case MYSQL_COM_STMT_PREPARE:
|
||||
gwbuf_copy_data(buf, 9, 2, readbuf);
|
||||
nparam = gw_mysql_get_byte2(readbuf);
|
||||
gwbuf_copy_data(buf, 11, 2, readbuf);
|
||||
nattr = gw_mysql_get_byte2(readbuf);
|
||||
*npackets = 1 + nparam + MXS_MIN(1, nparam) + nattr + MXS_MIN(nattr, 1);
|
||||
break;
|
||||
case MYSQL_COM_STMT_PREPARE:
|
||||
gwbuf_copy_data(buf, 9, 2, readbuf);
|
||||
nparam = gw_mysql_get_byte2(readbuf);
|
||||
gwbuf_copy_data(buf, 11, 2, readbuf);
|
||||
nattr = gw_mysql_get_byte2(readbuf);
|
||||
*npackets = 1 + nparam + MXS_MIN(1, nparam) + nattr + MXS_MIN(nattr, 1);
|
||||
break;
|
||||
|
||||
case MYSQL_COM_QUIT:
|
||||
case MYSQL_COM_STMT_SEND_LONG_DATA:
|
||||
case MYSQL_COM_STMT_CLOSE:
|
||||
*npackets = 0; /*< these don't reply anything */
|
||||
break;
|
||||
case MYSQL_COM_QUIT:
|
||||
case MYSQL_COM_STMT_SEND_LONG_DATA:
|
||||
case MYSQL_COM_STMT_CLOSE:
|
||||
*npackets = 0; /*< these don't reply anything */
|
||||
break;
|
||||
|
||||
default:
|
||||
/**
|
||||
* assume that other session commands respond
|
||||
* OK or ERR
|
||||
*/
|
||||
*npackets = 1;
|
||||
break;
|
||||
default:
|
||||
/**
|
||||
* assume that other session commands respond
|
||||
* OK or ERR
|
||||
*/
|
||||
*npackets = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1570,18 +1570,18 @@ bool mxs_mysql_is_result_set(GWBUF *buffer)
|
||||
switch (cmd)
|
||||
{
|
||||
|
||||
case MYSQL_REPLY_OK:
|
||||
case MYSQL_REPLY_ERR:
|
||||
case MYSQL_REPLY_LOCAL_INFILE:
|
||||
case MYSQL_REPLY_EOF:
|
||||
/** Not a result set */
|
||||
break;
|
||||
default:
|
||||
if (gwbuf_copy_data(buffer, MYSQL_HEADER_LEN + 1, 1, &cmd) && cmd > 1)
|
||||
{
|
||||
rval = true;
|
||||
}
|
||||
break;
|
||||
case MYSQL_REPLY_OK:
|
||||
case MYSQL_REPLY_ERR:
|
||||
case MYSQL_REPLY_LOCAL_INFILE:
|
||||
case MYSQL_REPLY_EOF:
|
||||
/** Not a result set */
|
||||
break;
|
||||
default:
|
||||
if (gwbuf_copy_data(buffer, MYSQL_HEADER_LEN + 1, 1, &cmd) && cmd > 1)
|
||||
{
|
||||
rval = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ static int maxscaled_listen(DCB *listener, char *config)
|
||||
/* check for default UNIX socket */
|
||||
if (strncmp(config, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG, MAXADMIN_CONFIG_DEFAULT_SOCKET_TAG_LEN) == 0)
|
||||
{
|
||||
socket_path = MAXADMIN_DEFAULT_SOCKET;
|
||||
socket_path = MAXADMIN_DEFAULT_SOCKET;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -30,19 +30,58 @@
|
||||
#include <maxscale/buffer.h>
|
||||
#include <maxscale/protocol.h>
|
||||
|
||||
static int test_read(DCB* dcb){ return 1;}
|
||||
static int test_write(DCB *dcb, GWBUF* buf){ return 1;}
|
||||
static int test_write_ready(DCB *dcb){ return 1;}
|
||||
static int test_error(DCB *dcb){ return 1;}
|
||||
static int test_hangup(DCB *dcb){ return 1;}
|
||||
static int test_accept(DCB *dcb){ return 1;}
|
||||
static int test_connect(struct dcb *dcb, struct server *srv, struct session *ses){ return 1;}
|
||||
static int test_close(DCB *dcb){ return 1;}
|
||||
static int test_listen(DCB *dcb, char *config){ return 1;}
|
||||
static int test_auth(DCB* dcb, struct server *srv, struct session *ses, GWBUF *buf){ return 1;}
|
||||
static int test_session(DCB *dcb, void* data){ return 1;}
|
||||
static char *test_default_auth(){return "NullAuthAllow";}
|
||||
static int test_connection_limit(DCB *dcb, int limit){return 0;}
|
||||
static int test_read(DCB* dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_write(DCB *dcb, GWBUF* buf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_write_ready(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_error(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_hangup(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_accept(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_connect(struct dcb *dcb, struct server *srv, struct session *ses)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_close(DCB *dcb)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_listen(DCB *dcb, char *config)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_auth(DCB* dcb, struct server *srv, struct session *ses, GWBUF *buf)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static int test_session(DCB *dcb, void* data)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
static char *test_default_auth()
|
||||
{
|
||||
return "NullAuthAllow";
|
||||
}
|
||||
static int test_connection_limit(DCB *dcb, int limit)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The module entry point routine. It is this routine that
|
||||
|
Loading…
x
Reference in New Issue
Block a user