diff --git a/lib/MySQL_Protocol.cpp b/lib/MySQL_Protocol.cpp index 98bc7f38c..e5c939397 100644 --- a/lib/MySQL_Protocol.cpp +++ b/lib/MySQL_Protocol.cpp @@ -1277,6 +1277,7 @@ bool MySQL_Protocol::process_pkt_OK(unsigned char *pkt, unsigned int len) { memcpy(&hdr,pkt,sizeof(mysql_hdr)); pkt += sizeof(mysql_hdr); + if (*pkt) return false; if (len!=hdr.pkt_length+sizeof(mysql_hdr)) return false; //MYSQL &myc=(*myds)->myconn->myconn; diff --git a/lib/Standard_ProxySQL_Admin.cpp b/lib/Standard_ProxySQL_Admin.cpp index dea8908de..d2537a850 100644 --- a/lib/Standard_ProxySQL_Admin.cpp +++ b/lib/Standard_ProxySQL_Admin.cpp @@ -254,6 +254,7 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_ * This function can modify the original query */ bool admin_handler_command_load_or_save(char *query_no_space, unsigned int query_no_space_length, MySQL_Session *sess, ProxySQL_Admin *pa, char **q, unsigned int *ql) { + proxy_debug(PROXY_DEBUG_ADMIN, 5, "Received command %s\n", query_no_space); #ifdef DEBUG if ((query_no_space_length>11) && ( (!strncasecmp("SAVE DEBUG ", query_no_space, 11)) || (!strncasecmp("LOAD DEBUG ", query_no_space, 11))) ) { diff --git a/lib/debug.cpp b/lib/debug.cpp index 29902b5f4..c3e854439 100644 --- a/lib/debug.cpp +++ b/lib/debug.cpp @@ -39,7 +39,7 @@ void proxy_debug_func(enum debug_module module, int verbosity, const char *fmt, }; */ -#define DEBUG_MSG_MAXSIZE 256 +#define DEBUG_MSG_MAXSIZE 1024 #ifdef DEBUG void proxy_debug_func(enum debug_module module, int verbosity, int thr, const char *__file, int __line, const char *__func, const char *fmt, ...) { diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index f2a0b79df..be030c90e 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -157,6 +157,7 @@ MySQL_Data_Stream::~MySQL_Data_Stream() { if (mypolls) mypolls->remove_index_fast(poll_fds_idx); if (fd>0) { if (myconn==NULL || myconn->reusable==false) { + proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "MySQL_Connection %p %s: shutdown socket\n", myconn, (myconn ? "not reusable" : "is empty")); shut_hard(); // shutdown(fd,SHUT_RDWR); // close(fd); diff --git a/lib/mysql_session.cpp b/lib/mysql_session.cpp index efe20bc88..ec912c431 100644 --- a/lib/mysql_session.cpp +++ b/lib/mysql_session.cpp @@ -293,6 +293,7 @@ int MySQL_Session::handler() { } } else { l_free(pkt.size,pkt.ptr); + proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Wrong credentials for frontend: disconnecting\n"); wrong_pass=true; // FIXME: this should become close connection client_myds->DSS=STATE_QUERY_SENT; @@ -314,6 +315,8 @@ int MySQL_Session::handler() { } else { l_free(pkt.size,pkt.ptr); // FIXME: this should become close connection + perror("Hitting a not implemented feature: https://github.com/sysown/proxysql-0.2/issues/124"); + assert(0); } break; default: @@ -651,7 +654,9 @@ __exit_DSS__STATE_NOT_INITIALIZED: ////status=WAITING_CLIENT_DATA; server_myds->DSS=STATE_CLIENT_HANDSHAKE; } else { - l_free(pkt.size,pkt.ptr); + // FIXME: what to do here? + l_free(pkt.size,pkt.ptr); + assert(0); } break; case STATE_CLIENT_HANDSHAKE: @@ -669,7 +674,17 @@ __exit_DSS__STATE_NOT_INITIALIZED: server_myds->DSS=STATE_QUERY_SENT; } } else { + proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Wrong credentials for backend: disconnecting\n"); l_free(pkt.size,pkt.ptr); + wrong_pass=true; + client_myds->DSS=STATE_QUERY_SENT; + char *_s=(char *)malloc(strlen(userinfo_client.username)+100); + sprintf(_s,"Access denied for user '%s' (using password: %s)", userinfo_client.username, (userinfo_client.password ? "YES" : "NO")); + myprot_client.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000", _s); + free(_s); + client_myds->DSS=STATE_SLEEP; + status=WAITING_CLIENT_DATA; + server_myds->myconn->reusable=false; } break; default: