This commit is contained in:
Markus Makela
2015-07-08 10:06:11 +03:00
8 changed files with 277 additions and 393 deletions

View File

@ -58,6 +58,7 @@ extern __thread log_info_t tls_log_info;
* Revision History
* Date Who Description
* 13/06/2014 Mark Riddoch Initial implementation
* 07/07/15 Martin Brampton Correct failure handling
*
* @endverbatim
*/
@ -270,9 +271,7 @@ int n_connect = 0;
{
atomic_add(&dcb->stats.n_accepts, 1);
client_dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER);
if (client_dcb == NULL)
{
close(so);
return n_connect;
@ -283,7 +282,8 @@ int n_connect = 0;
if ((maxscaled_pr = (MAXSCALED *)malloc(sizeof(MAXSCALED))) == NULL)
{
client_dcb->protocol = NULL;
dcb_add_to_zombieslist(client_dcb);
close(so);
dcb_close(client_dcb);
return n_connect;
}
maxscaled_pr->username = NULL;
@ -293,9 +293,9 @@ int n_connect = 0;
client_dcb->session =
session_alloc(dcb->session->service, client_dcb);
if (poll_add_dcb(client_dcb) == -1)
if (poll_add_dcb(client_dcb))
{
dcb_add_to_zombieslist(dcb);
dcb_close(dcb);
return n_connect;
}
n_connect++;

View File

@ -1451,8 +1451,8 @@ int gw_MySQLListener(
// add listening socket to poll structure
if (poll_add_dcb(listen_dcb) == -1) {
fprintf(stderr,
"\n* Failed to start polling the socket due error "
"%i, %s.\n\n",
"\n* MaxScale encountered system limit while "
"attempting to register on an epoll instance.\n\n",
errno,
strerror(errno));
return 0;
@ -1687,7 +1687,8 @@ int gw_MySQLAccept(DCB *listener)
client_dcb,
1,
0,
"MaxScale internal error.");
"MaxScale encountered system limit while "
"attempting to register on an epoll instance.");
/** close client_dcb */
dcb_close(client_dcb);

View File

@ -36,6 +36,7 @@
* 03/10/2014 Massimiliano Pinto Added netmask for wildcard in IPv4 hosts.
* 24/10/2014 Massimiliano Pinto Added Mysql user@host @db authentication support
* 10/11/2014 Massimiliano Pinto Charset at connect is passed to backend during authentication
* 07/07/15 Martin Brampton Fix problem recognising null password
*
*/
@ -46,6 +47,9 @@
#include <log_manager.h>
#include <netinet/tcp.h>
/* The following can be compared using memcmp to detect a null password */
uint8_t null_client_sha1[MYSQL_SCRAMBLE_LEN]="";
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
@ -577,7 +581,7 @@ int gw_send_authentication_to_backend(
if (strlen(dbname))
curr_db = dbname;
if (strlen((char *)passwd))
if (memcmp(passwd, null_client_sha1, MYSQL_SCRAMBLE_LEN))
curr_passwd = passwd;
dcb = conn->owner_dcb;
@ -1122,7 +1126,7 @@ GWBUF* gw_create_change_user_packet(
curr_db = db;
}
if (strlen((char *)pwd) > 0)
if (memcmp(pwd, null_client_sha1, MYSQL_SCRAMBLE_LEN))
{
curr_passwd = pwd;
}
@ -1358,12 +1362,7 @@ int gw_check_mysql_scramble_data(DCB *dcb, uint8_t *token, unsigned int token_le
gw_bin2hex(hex_double_sha1, password, SHA_DIGEST_LENGTH);
} else {
/* check if the password is not set in the user table */
if (!strlen((char *)password)) {
/* Username without password */
return 0;
} else {
return 1;
}
return memcmp(password, null_client_sha1, MYSQL_SCRAMBLE_LEN) ? 1 : 0;
}
/*<

View File

@ -67,6 +67,7 @@ extern __thread log_info_t tls_log_info;
* Date Who Description
* 17/06/2013 Mark Riddoch Initial version
* 17/07/2013 Mark Riddoch Addition of login phase
* 07/07/2015 Martin Brampton Call unified dcb_close on error
*
* @endverbatim
*/
@ -315,13 +316,13 @@ int n_connect = 0;
if (telnetd_pr == NULL)
{
dcb_add_to_zombieslist(client_dcb);
dcb_close(client_dcb);
return n_connect;
}
if (poll_add_dcb(client_dcb) == -1)
if (poll_add_dcb(client_dcb))
{
dcb_add_to_zombieslist(dcb);
dcb_close(dcb);
return n_connect;
}
n_connect++;