modutil.c: added modutil_reply_auth_error
mysql_backend.c:gw_change_user: instead of setting flags directly to replybuffer, set server command to backend's protocol object and reply the message directly to backend where flags are set and it is replied back to client.
This commit is contained in:
parent
f5d8e2366a
commit
fca674b16a
@ -616,6 +616,25 @@ void modutil_reply_parse_error(
|
||||
modutil_reply_routing_error(backend_dcb, 1064, "42000", errstr, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create authentication error and EPOLLIN event to event queue of the backend DCB.
|
||||
* When event is notified the error message is processed as error reply and routed
|
||||
* upstream to client.
|
||||
*
|
||||
* @param backend_dcb DCB where event is added
|
||||
* @param errstr Plain-text string error
|
||||
* @param flags GWBUF type flags
|
||||
*/
|
||||
void modutil_reply_auth_error(
|
||||
DCB* backend_dcb,
|
||||
char* errstr,
|
||||
uint32_t flags)
|
||||
{
|
||||
CHK_DCB(backend_dcb);
|
||||
modutil_reply_routing_error(backend_dcb, 1045, "28000", errstr, flags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create error message and EPOLLIN event to event queue of the backend DCB.
|
||||
* When event is notified the message is processed as error reply and routed
|
||||
@ -644,7 +663,7 @@ static void modutil_reply_routing_error(
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Creating buffer for error message failed.")));
|
||||
"Error : Creating routing error message failed.")));
|
||||
return;
|
||||
}
|
||||
/** Set flags that help router to process reply correctly */
|
||||
|
@ -51,6 +51,7 @@ GWBUF* modutil_get_next_MySQL_packet(GWBUF** p_readbuf);
|
||||
GWBUF* modutil_get_complete_packets(GWBUF** p_readbuf);
|
||||
int modutil_MySQL_query_len(GWBUF* buf, int* nbytes_missing);
|
||||
void modutil_reply_parse_error(DCB* backend_dcb, char* errstr, uint32_t flags);
|
||||
void modutil_reply_auth_error(DCB* backend_dcb, char* errstr, uint32_t flags);
|
||||
|
||||
GWBUF *modutil_create_mysql_err_msg(
|
||||
int packet_number,
|
||||
|
@ -1451,25 +1451,13 @@ static int gw_change_user(
|
||||
rv = 0;
|
||||
goto retblock;
|
||||
}
|
||||
/** TODO: Add custom message indicating that retry would probably help */
|
||||
buf = modutil_create_mysql_err_msg(1, 0, 1045, "28000", message);
|
||||
free(message);
|
||||
|
||||
if (buf == NULL)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Creating buffer for error message failed.")));
|
||||
rv = 0;
|
||||
goto retblock;
|
||||
}
|
||||
/** Set flags that help router to identify session commands reply */
|
||||
gwbuf_set_type(buf, GWBUF_TYPE_MYSQL);
|
||||
gwbuf_set_type(buf, GWBUF_TYPE_SESCMD_RESPONSE);
|
||||
gwbuf_set_type(buf, GWBUF_TYPE_RESPONSE_END);
|
||||
/** Create an incoming event for backend DCB */
|
||||
poll_add_epollin_event_to_dcb(backend, gwbuf_clone(buf));
|
||||
gwbuf_free(buf);
|
||||
/**
|
||||
* Add command to backend's protocol, create artificial reply
|
||||
* packet and add it to client's read buffer.
|
||||
*/
|
||||
protocol_add_srv_command((MySQLProtocol*)backend->protocol,
|
||||
MYSQL_COM_CHANGE_USER);
|
||||
modutil_reply_auth_error(backend, message, 0);
|
||||
rv = 1;
|
||||
} else {
|
||||
rv = gw_send_change_user_to_backend(database, username, client_sha1, backend_protocol);
|
||||
|
Loading…
x
Reference in New Issue
Block a user