All changes 2.0.0...develop
973b983 Merge branch 'release-2.0.0' into develop 255dd23 Make spinlock functions take const argument 6e23bab Fix bitmask reallocation 338c189 Rename and clean up slavelag filter 3ea8f28 Fix possible NULL pointer dereference bfe6738 MXS-830: Add module information to logged messages 1fad962 Fix strncat usage d38997a Adjust log throttling policy 0be4e4b Add hashtable_item_strcasecmp 726100e Take hashtable convenience functions into use 5e7744a Fix typo in maxadmin.md c5778c8 Merge branch 'release-2.0.0' into develop b5762af Move from tmpnam to mkstemp d6f2c71 Add convenience functions to hashtable 359058a MXS-825: Add support for --execdir 636347c Enable runtime reconfiguration of log throttling ef9fba9 Improve log throttling documentation aef917a Implement log throttling e3a5349 Remove shardrouter.c 8051e80 Remove custom qc_sqlite allocation functions fd34d60 Initial implementation of the learning firewall a8752a8 Removed "filestem option" from example 1ef2519 Removed "filestem option" from example 0815cc8 Cleanup spinlock.h ab4dc99 Clean up hashtable.h ef2c078 Add prototypes for hashtable copy and free functions fb5cfaf Add 'log_throttling' configuration entry 300d823 Add proper prototypes for hashtable hash and cmp functions 1c649aa qc_mysqlembedded: Include skygw_...h without path. d276160 Add missing RPM scripts e70e644 Fix HTTPAuth installation 1b2b389 Combine utils into the server directory 3ff9913 Add missing utils headers to devel package 407efb2 Fix minor packaging problems 99aa6ad Split MaxScale into core, experimental and devel packages 1290386 Merge branch 'develop' of ssh://github.com/mariadb-corporation/maxscale-new into develop e59f148 Make scripts POSIX sh compatible 7319266 Fixed SHOW SLAVE STATUS in bonlog router f8d760a Update Binlogrouter.md 0a904ed Update Replication-Proxy-Binlog-Router-Tutorial.md 75d4202 Update Replication-Proxy-Binlog-Router-Tutorial.md b8651fc Add missing newline in listmanager.h c7ad047 Add note about user data caches to release notes 70ccc2b Merge branch 'release-2.0.0' into develop 575d1b6 Mistake - dummy session needs list markers set. 8364508 Merge branch 'develop' into binlog_server_semisync 868b902 Update MaxScale limitations 2c8b327 Store listener caches in separate directories 6e183ec Create unique user data caches for each listeners f643685 Don't free orphaned tee filter sessions 4179afa Allow binlogrouter to be used without a listener 7ad79af Add function for freeing a listener 677a0a2 Move authentication data from services to listeners 4f12af7 Merge remote-tracking branch 'origin/MXS-677' into develop 1419b81 Semi-Sync support to binlog server: code review updtate 0ea0f01 Semi-Sync support to binlog server: added missing routine 4aad909 Semi-Sync support to binlog server b824e1e Add authenticator support to httpd.c 705a688 Change tabs to spaces d0c419e Change method of adding list fields to e.g. DCB 25504fc Document the changed routing priority of hints 41666d1 Remove use_ssl_if_enabled global option a3584e9 Make routing hints have highest priority 34a1d24 Updated document with new binlog router option 01eedc5 Updated documentation with SSL usage 8a4c0f6 Update Replication-Proxy-Binlog-Router-Tutorial.md 4e374aa Update Replication-Proxy-Binlog-Router-Tutorial.md f3f3c57 Update Replication-Proxy-Binlog-Router-Tutorial.md 617b79f Binlog Server: error messages typo fix fa8dfae Binlog Server: error messages review 1b8819c Fix freeing of schemarouter session memory 07f49e1 MXS-788: new code review fix 1fd3b09 MXS-788: show services now displays SSL info 6ca2584 MXS-788 code review fix ae6a7d0 MXS-788 code review 43d3474 Master server SSL connection 90b2377 Use correct variable in listmanager pre-allocation 9a5b238 Fix listmanager pre-allocation 9c78625 Fix a memory leak when backend authentication fails e59a966 Fix hang in list_find_free ff30223 Fix freeing of shared data in schemarouter fc8f9d3 Add missing include in luafilter ecf7f53 Add missing NULL value to filter parameter array 636d849 Update memory allocation approach f0d1d38 Add new allocation functions 97d00a0 Fix writing of uninitialized data to logs e72c9b2 Merge branch 'release-2.0.0' into develop cf2b712 Merge branch 'release-2.0.0' into develop 8917c5c Change the logic behind valid list entry checks c10deff Improve documentation about version_string f59f1f7 Merge branch 'develop' of ssh://github.com/mariadb-corporation/maxscale-new into develop c88edb3 Backend authentication failure improvement abd5bee Revert "Backend authentication failure improvement" 5bb3107 Backend authentication failure improvement b7f434a Add new allocation functions 3f022fa Fix stupid mistake 99c4317 Merge remote-tracking branch 'origin/MXS-677' into develop 3c1ded6 Added connection/authentication failure error reporting in SHOW SLAVE STATUS 0a60f7b Tidy up and deal with review points. ba103ff blr_slave.c: Update strncpy usage 467331e blr_master.c: Strncpy usage updates d2b7c0c Merge remote-tracking branch 'origin/develop-nullauth-merge' into develop 5a8c1d0 qc: Measure execution time at the right place. bccdb93 Merge branch 'NullAuthDeny' into develop 2e6511c Add 5.5.5 prefix to all version strings that lack it 314655a Improve DCB and session initialization and list handling e1c43f0 MXS-655: Make MaxScale logging logrotate(8) compatible ce36afd MXS-626: Don't log a header unless maxlog enabled dcd47a7 blr_file.c: Replace uses of strncpy 6b8f576 bls_slave.c: Replace strncpy with memcpy 68a0039 Add list preallocation, tidy up, simplify init. cb37d1b Fix copyright etc headers. 11a400d Tidy; comment; fix bad copies and mistakes. 7e36ec4 Add list manager files. c4794e3 Initial code for list manager. 1b42e25 Merge remote-tracking branch 'origin/MXS-765' into develop d50f617 Fix problems, extend tests, respond to review. dcb4a91 Filter test folder removed 0b60dbe Add a couple of comments. 83cdba0 Fix overwriting problem. ba5d353 Fix overwriting problem. 53671cb Small fixes in response to review. 173d049 blr.c: Review strncpy usage 4ff6ef2 binlog_common.c: Replace strncpy with memcpy f238e03 maxbinlogcheck.s: Replace strncpy 9807f8d harness: Replace unnecessary use of strncpy 8c7fe6a avro: Modify strncpy usage 9b8008e Small improvements. b7f784f Fix mistakes in testqueuemanager.c cc26962 Restore missing poll.c code; add testqueuemanager.c. 2e91806 Format the filter harness 22059e6 Initial implementation connection queueing. c604dc2 readwritesplit.c: Improve COM_INIT_DB handling 454d920 schemarouter.c: Replace strncpy with strcpy 8e85d66 sharding_common.c: Too long a database name handled explicitly 77f4446 Astyle schemarouter 491f7c2 maxinfo.c: Replace strncpy with memcpy 6b98105 maxinfo: Reformat with astyle c1dbf08 Handle oversize user and database names 5fa4a0f Merge branch 'develop' of ssh://github.com/mariadb-corporation/maxscale-new into develop 706963b BLR_DBUSERS_TAIL new var in blr.h d75b9af Tweak comments, remove trailing blanks. ab2400a Optimise statistics gathering by inline & simpler fns. fb59ddc Remove unnecessary strncpy/strncat usage in Binlog Server bdcd551 resultset.c: Change strncpy to memcpy c6b1c5e Reject rather than cut too long a path 6d8f112 Remove unnecessary strncpy/strncat usage 18bf5ed Remove unnecessary strncpy usage dc0e2db Make maxpasswd more userfriendly c9c8695 Fix calculation of padded_len in encryptPassword 2cfd2c6 dbusers.c: Check strncpy usage 7ab9342 Make more thorough checks in secrets_readKeys be7d593 Format cli.c debugcli.c testroute.c webserver.c 1ee5efb config.c: Check usage of strncpy 3043b12 gq_utils.c: Unnecessary use of strncpy removed 77874ac Add help to maxkeys 38392a3 Update secrets_writeKeys documentation 2d1325c Make SSL optional in MaxScale's own communication bda00da Fix avro build failures b2cb31a Add more OOM macros 41ccf17 Fix strdup usage a48f732 Fix realloc calls 20771f6 Add forgotten extern "C" block 8faf35a Add maxscale allocation functions bb47890 Add macros for OOM logging afea388 Fix silly mistakes. 6dafd22 Make deny default for null auth; move code from common to auth.
This commit is contained in:
@ -1,37 +1,37 @@
|
||||
add_library(MySQLClient SHARED mysql_client.c mysql_common.c)
|
||||
target_link_libraries(MySQLClient maxscale-common MySQLAuth)
|
||||
set_target_properties(MySQLClient PROPERTIES VERSION "1.0.0")
|
||||
install(TARGETS MySQLClient DESTINATION ${MAXSCALE_LIBDIR})
|
||||
install_module(MySQLClient core)
|
||||
|
||||
add_library(MySQLBackend SHARED mysql_backend.c mysql_common.c)
|
||||
target_link_libraries(MySQLBackend maxscale-common MySQLAuth)
|
||||
set_target_properties(MySQLBackend PROPERTIES VERSION "2.0.0")
|
||||
install(TARGETS MySQLBackend DESTINATION ${MAXSCALE_LIBDIR})
|
||||
install_module(MySQLBackend core)
|
||||
|
||||
add_library(telnetd SHARED telnetd.c)
|
||||
target_link_libraries(telnetd maxscale-common)
|
||||
set_target_properties(telnetd PROPERTIES VERSION "1.0.1")
|
||||
install(TARGETS telnetd DESTINATION ${MAXSCALE_LIBDIR})
|
||||
install_module(telnetd core)
|
||||
|
||||
add_library(HTTPD SHARED httpd.c)
|
||||
target_link_libraries(HTTPD maxscale-common)
|
||||
set_target_properties(HTTPD PROPERTIES VERSION "1.0.1")
|
||||
install(TARGETS HTTPD DESTINATION ${MAXSCALE_LIBDIR})
|
||||
install_module(HTTPD core)
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_library(testprotocol SHARED testprotocol.c)
|
||||
set_target_properties(testprotocol PROPERTIES VERSION "1.0.0")
|
||||
install(TARGETS testprotocol DESTINATION ${MAXSCALE_LIBDIR})
|
||||
install_module(testprotocol core)
|
||||
endif()
|
||||
|
||||
add_library(maxscaled SHARED maxscaled.c)
|
||||
target_link_libraries(maxscaled maxscale-common)
|
||||
set_target_properties(maxscaled PROPERTIES VERSION "1.0.0")
|
||||
install(TARGETS maxscaled DESTINATION ${MAXSCALE_LIBDIR})
|
||||
install_module(maxscaled core)
|
||||
|
||||
if(BUILD_CDC)
|
||||
add_library(CDC SHARED cdc.c)
|
||||
target_link_libraries(CDC maxscale-common)
|
||||
set_target_properties(CDC PROPERTIES VERSION "1.0.1")
|
||||
install(TARGETS CDC DESTINATION ${MAXSCALE_LIBDIR})
|
||||
install_module(CDC core)
|
||||
endif()
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-01-01
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
@ -31,6 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <cdc.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <gw.h>
|
||||
#include <modinfo.h>
|
||||
#include <log_manager.h>
|
||||
@ -321,7 +322,7 @@ cdc_accept(DCB *listener)
|
||||
|
||||
/* create the session data for CDC */
|
||||
/* this coud be done in anothe routine, let's keep it here for now */
|
||||
client_data = (CDC_session *) calloc(1, sizeof(CDC_session));
|
||||
client_data = (CDC_session *) MXS_CALLOC(1, sizeof(CDC_session));
|
||||
if (client_data == NULL)
|
||||
{
|
||||
dcb_close(client_dcb);
|
||||
@ -388,18 +389,10 @@ cdc_protocol_init(DCB* dcb)
|
||||
{
|
||||
CDC_protocol* p;
|
||||
|
||||
p = (CDC_protocol *) calloc(1, sizeof(CDC_protocol));
|
||||
p = (CDC_protocol *) MXS_CALLOC(1, sizeof(CDC_protocol));
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
MXS_ERROR("%lu [CDC_protocol_init] CDC protocol init failed : "
|
||||
"memory allocation due error %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-01-01
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <httpd.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <gw_protocol.h>
|
||||
#include <gw.h>
|
||||
#include <modinfo.h>
|
||||
@ -54,7 +55,7 @@ MODULE_INFO info =
|
||||
|
||||
#define ISspace(x) isspace((int)(x))
|
||||
#define HTTP_SERVER_STRING "MaxScale(c) v.1.0.0"
|
||||
static char *version_str = "V1.1.1";
|
||||
static char *version_str = "V1.2.0";
|
||||
|
||||
static int httpd_read_event(DCB* dcb);
|
||||
static int httpd_write_event(DCB *dcb);
|
||||
@ -65,7 +66,7 @@ static int httpd_accept(DCB *dcb);
|
||||
static int httpd_close(DCB *dcb);
|
||||
static int httpd_listen(DCB *dcb, char *config);
|
||||
static int httpd_get_line(int sock, char *buf, int size);
|
||||
static void httpd_send_headers(DCB *dcb, int final);
|
||||
static void httpd_send_headers(DCB *dcb, int final, bool auth_ok);
|
||||
static char *httpd_default_auth();
|
||||
|
||||
/**
|
||||
@ -124,6 +125,8 @@ GWPROTOCOL* GetModuleObject()
|
||||
}
|
||||
/*lint +e14 */
|
||||
|
||||
static const char* default_auth = "NullAuthAllow";
|
||||
|
||||
/**
|
||||
* The default authenticator name for this protocol
|
||||
*
|
||||
@ -131,7 +134,7 @@ GWPROTOCOL* GetModuleObject()
|
||||
*/
|
||||
static char *httpd_default_auth()
|
||||
{
|
||||
return "NullAuth";
|
||||
return (char*)default_auth;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,6 +215,10 @@ static int httpd_read_event(DCB* dcb)
|
||||
}
|
||||
}
|
||||
|
||||
/** If listener->authenticator is NULL, it means we're using the default
|
||||
* authenticator and we don't need to check the user credentials. */
|
||||
bool auth_ok = dcb->listener->authenticator == 0;
|
||||
|
||||
/**
|
||||
* Get the request headers
|
||||
*/
|
||||
@ -236,6 +243,21 @@ static int httpd_read_event(DCB* dcb)
|
||||
{
|
||||
strcpy(client_data->useragent, value);
|
||||
}
|
||||
|
||||
if (strcmp(buf, "Authorization") == 0)
|
||||
{
|
||||
GWBUF *auth_data = gwbuf_alloc_and_load(strlen(value), value);
|
||||
MXS_OOM_IFNULL(auth_data);
|
||||
|
||||
if (auth_data)
|
||||
{
|
||||
/** The freeing entry point is called automatically when
|
||||
* the client DCB is closed */
|
||||
dcb->authfunc.extract(dcb, auth_data);
|
||||
auth_ok = dcb->authfunc.authenticate(dcb) == 0;
|
||||
gwbuf_free(auth_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +272,7 @@ static int httpd_read_event(DCB* dcb)
|
||||
*/
|
||||
|
||||
/* send all the basic headers and close with \r\n */
|
||||
httpd_send_headers(dcb, 1);
|
||||
httpd_send_headers(dcb, 1, auth_ok);
|
||||
|
||||
#if 0
|
||||
/**
|
||||
@ -281,7 +303,7 @@ static int httpd_read_event(DCB* dcb)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if ((uri = gwbuf_alloc(strlen(url) + 1)) != NULL)
|
||||
if (auth_ok && (uri = gwbuf_alloc(strlen(url) + 1)) != NULL)
|
||||
{
|
||||
strcpy((char *)GWBUF_DATA(uri), url);
|
||||
gwbuf_set_type(uri, GWBUF_TYPE_HTTP);
|
||||
@ -359,7 +381,7 @@ static int httpd_accept(DCB *listener)
|
||||
HTTPD_session *client_data = NULL;
|
||||
|
||||
/* create the session data for HTTPD */
|
||||
if ((client_data = (HTTPD_session *)calloc(1, sizeof(HTTPD_session))) == NULL)
|
||||
if ((client_data = (HTTPD_session *)MXS_CALLOC(1, sizeof(HTTPD_session))) == NULL)
|
||||
{
|
||||
dcb_close(client_dcb);
|
||||
continue;
|
||||
@ -449,7 +471,7 @@ static int httpd_get_line(int sock, char *buf, int size)
|
||||
/**
|
||||
* HTTPD send basic headers with 200 OK
|
||||
*/
|
||||
static void httpd_send_headers(DCB *dcb, int final)
|
||||
static void httpd_send_headers(DCB *dcb, int final, bool auth_ok)
|
||||
{
|
||||
char date[64] = "";
|
||||
const char *fmt = "%a, %d %b %Y %H:%M:%S GMT";
|
||||
@ -458,11 +480,15 @@ static void httpd_send_headers(DCB *dcb, int final)
|
||||
struct tm tm;
|
||||
localtime_r(&httpd_current_time, &tm);
|
||||
strftime(date, sizeof(date), fmt, &tm);
|
||||
|
||||
const char *response = auth_ok ? "200 OK" : "401 Unauthorized";
|
||||
dcb_printf(dcb,
|
||||
"HTTP/1.1 200 OK\r\nDate: %s\r\nServer: %s\r\nConnection: "
|
||||
"close\r\nContent-Type: application/json\r\n",
|
||||
date, HTTP_SERVER_STRING);
|
||||
"HTTP/1.1 %s\r\n"
|
||||
"Date: %s\r\n"
|
||||
"Server: %s\r\n"
|
||||
"Connection: close\r\n"
|
||||
"WWW-Authenticate: Basic realm=\"MaxInfo\"\r\n"
|
||||
"Content-Type: application/json\r\n",
|
||||
response, date, HTTP_SERVER_STRING);
|
||||
|
||||
/* close the headers */
|
||||
if (final)
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-01-01
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
@ -35,6 +35,7 @@
|
||||
#include <modinfo.h>
|
||||
#include <maxscaled.h>
|
||||
#include <maxadmin.h>
|
||||
#include <maxscale/alloc.h>
|
||||
|
||||
/* @see function load_module in load_utils.c for explanation of the following
|
||||
* lint directives.
|
||||
@ -242,7 +243,7 @@ static int maxscaled_accept(DCB *listener)
|
||||
{
|
||||
MAXSCALED *maxscaled_protocol = NULL;
|
||||
|
||||
if ((maxscaled_protocol = (MAXSCALED *)calloc(1, sizeof(MAXSCALED))) == NULL)
|
||||
if ((maxscaled_protocol = (MAXSCALED *)MXS_CALLOC(1, sizeof(MAXSCALED))) == NULL)
|
||||
{
|
||||
dcb_close(client_dcb);
|
||||
continue;
|
||||
@ -270,7 +271,7 @@ static int maxscaled_accept(DCB *listener)
|
||||
GWBUF *username;
|
||||
|
||||
/* Set user in protocol */
|
||||
maxscaled_protocol->username = strdup(pw_entry.pw_name);
|
||||
maxscaled_protocol->username = MXS_STRDUP_A(pw_entry.pw_name);
|
||||
|
||||
username = gwbuf_alloc(strlen(maxscaled_protocol->username) + 1);
|
||||
|
||||
@ -282,7 +283,7 @@ static int maxscaled_accept(DCB *listener)
|
||||
{
|
||||
dcb_printf(client_dcb, "OK----");
|
||||
maxscaled_protocol->state = MAXSCALED_STATE_DATA;
|
||||
client_dcb->user = strdup(maxscaled_protocol->username);
|
||||
client_dcb->user = MXS_STRDUP_A(maxscaled_protocol->username);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -332,7 +333,7 @@ static int maxscaled_close(DCB *dcb)
|
||||
spinlock_acquire(&maxscaled->lock);
|
||||
if (maxscaled->username)
|
||||
{
|
||||
free(maxscaled->username);
|
||||
MXS_FREE(maxscaled->username);
|
||||
maxscaled->username = NULL;
|
||||
}
|
||||
spinlock_release(&maxscaled->lock);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-01-01
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
@ -51,6 +51,7 @@ uint8_t null_client_sha1[MYSQL_SCRAMBLE_LEN]="";
|
||||
* 23/05/2016 Martin Brampton Provide for backend SSL
|
||||
*
|
||||
*/
|
||||
#include <maxscale/alloc.h>
|
||||
#include <modinfo.h>
|
||||
#include <gw_protocol.h>
|
||||
#include <mysql_auth.h>
|
||||
@ -652,7 +653,7 @@ gw_read_backend_handshake(MySQLProtocol *conn)
|
||||
server_set_status(dcb->server, SERVER_MAINT);
|
||||
}
|
||||
|
||||
free(bufstr);
|
||||
MXS_FREE(bufstr);
|
||||
}
|
||||
//get mysql packet size, 3 bytes
|
||||
packet_len = gw_mysql_get_byte3(payload);
|
||||
@ -1779,8 +1780,17 @@ static int gw_change_user(DCB *backend,
|
||||
|
||||
/* now get the user, after 4 bytes header and 1 byte command */
|
||||
client_auth_packet += 5;
|
||||
size_t len = strlen((char *)client_auth_packet);
|
||||
if (len > MYSQL_USER_MAXLEN)
|
||||
{
|
||||
MXS_ERROR("Client sent user name \"%s\",which is %lu characters long, "
|
||||
"while a maximum length of %d is allowed. Cutting trailing "
|
||||
"characters.", (char*)client_auth_packet, len, MYSQL_USER_MAXLEN);
|
||||
}
|
||||
strncpy(username, (char *)client_auth_packet, MYSQL_USER_MAXLEN);
|
||||
client_auth_packet += strlen(username) + 1;
|
||||
username[MYSQL_USER_MAXLEN] = 0;
|
||||
|
||||
client_auth_packet += (len + 1);
|
||||
|
||||
/* get the auth token len */
|
||||
memcpy(&auth_token_len, client_auth_packet, 1);
|
||||
@ -1790,7 +1800,7 @@ static int gw_change_user(DCB *backend,
|
||||
/* allocate memory for token only if auth_token_len > 0 */
|
||||
if (auth_token_len > 0)
|
||||
{
|
||||
auth_token = (uint8_t *)malloc(auth_token_len);
|
||||
auth_token = (uint8_t *)MXS_MALLOC(auth_token_len);
|
||||
ss_dassert(auth_token != NULL);
|
||||
|
||||
if (auth_token == NULL)
|
||||
@ -1802,19 +1812,19 @@ static int gw_change_user(DCB *backend,
|
||||
}
|
||||
|
||||
/* get new database name */
|
||||
len = strlen((char *)client_auth_packet);
|
||||
if (len > MYSQL_DATABASE_MAXLEN)
|
||||
{
|
||||
MXS_ERROR("Client sent database name \"%s\", which is %lu characters long, "
|
||||
"while a maximum length of %d is allowed. Cutting trailing "
|
||||
"characters.", (char*)client_auth_packet, len, MYSQL_DATABASE_MAXLEN);
|
||||
}
|
||||
strncpy(database, (char *)client_auth_packet, MYSQL_DATABASE_MAXLEN);
|
||||
database[MYSQL_DATABASE_MAXLEN] = 0;
|
||||
|
||||
/* get character set */
|
||||
if (strlen(database))
|
||||
{
|
||||
client_auth_packet += strlen(database) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
client_auth_packet++;
|
||||
}
|
||||
client_auth_packet += (len + 1);
|
||||
|
||||
if (client_auth_packet && *client_auth_packet)
|
||||
if (*client_auth_packet)
|
||||
{
|
||||
memcpy(&backend_protocol->charset, client_auth_packet, sizeof(int));
|
||||
}
|
||||
@ -1822,13 +1832,13 @@ static int gw_change_user(DCB *backend,
|
||||
spinlock_acquire(&in_session->ses_lock);
|
||||
|
||||
/* save current_database name */
|
||||
strncpy(current_database, current_session->db, MYSQL_DATABASE_MAXLEN);
|
||||
strcpy(current_database, current_session->db);
|
||||
|
||||
/*
|
||||
* Now clear database name in dcb as we don't do local authentication on db name for change user.
|
||||
* Local authentication only for user@host and if successful the database name change is sent to backend.
|
||||
*/
|
||||
strncpy(current_session->db, "", MYSQL_DATABASE_MAXLEN);
|
||||
*current_session->db = 0;
|
||||
|
||||
/*
|
||||
* Decode the token and check the password.
|
||||
@ -1839,7 +1849,7 @@ static int gw_change_user(DCB *backend,
|
||||
client_protocol->scramble,
|
||||
sizeof(client_protocol->scramble),
|
||||
username, client_sha1);
|
||||
strncpy(current_session->db, current_database, MYSQL_DATABASE_MAXLEN);
|
||||
strcpy(current_session->db, current_database);
|
||||
spinlock_release(&in_session->ses_lock);
|
||||
|
||||
if (auth_ret != 0)
|
||||
@ -1849,14 +1859,14 @@ static int gw_change_user(DCB *backend,
|
||||
/* Try authentication again with new repository data */
|
||||
/* Note: if no auth client authentication will fail */
|
||||
spinlock_acquire(&in_session->ses_lock);
|
||||
strncpy(current_session->db, "", MYSQL_DATABASE_MAXLEN);
|
||||
*current_session->db = 0;
|
||||
auth_ret = gw_check_mysql_scramble_data(
|
||||
backend->session->client_dcb,
|
||||
auth_token, auth_token_len,
|
||||
client_protocol->scramble,
|
||||
sizeof(client_protocol->scramble),
|
||||
username, client_sha1);
|
||||
strncpy(current_session->db, current_database, MYSQL_DATABASE_MAXLEN);
|
||||
strcpy(current_session->db, current_database);
|
||||
spinlock_release(&in_session->ses_lock);
|
||||
}
|
||||
}
|
||||
@ -1864,7 +1874,7 @@ static int gw_change_user(DCB *backend,
|
||||
/* let's free the auth_token now */
|
||||
if (auth_token)
|
||||
{
|
||||
free(auth_token);
|
||||
MXS_FREE(auth_token);
|
||||
}
|
||||
|
||||
if (auth_ret != 0)
|
||||
@ -2279,8 +2289,8 @@ gw_receive_backend_auth(MySQLProtocol *protocol)
|
||||
err,
|
||||
bufstr);
|
||||
|
||||
free(bufstr);
|
||||
free(err);
|
||||
MXS_FREE(bufstr);
|
||||
MXS_FREE(err);
|
||||
rc = -1;
|
||||
}
|
||||
else
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-01-01
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
@ -47,6 +47,7 @@
|
||||
*/
|
||||
#include <gw_protocol.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <log_manager.h>
|
||||
#include <mysql_client_server_protocol.h>
|
||||
#include <mysql_auth.h>
|
||||
@ -94,6 +95,7 @@ static int gw_read_normal_data(DCB *dcb, GWBUF *read_buffer, int nbytes_read);
|
||||
static int gw_read_finish_processing(DCB *dcb, GWBUF *read_buffer, uint8_t capabilities);
|
||||
extern char* create_auth_fail_str(char *username, char *hostaddr, char *sha1, char *db,int);
|
||||
static bool ensure_complete_packet(DCB *dcb, GWBUF **read_buffer, int nbytes_read);
|
||||
static void gw_process_one_new_client(DCB *client_dcb);
|
||||
|
||||
/*
|
||||
* The "module object" for the mysqld client protocol module.
|
||||
@ -990,7 +992,8 @@ mysql_client_auth_error_handling(DCB *dcb, int auth_val)
|
||||
/** Send error 1049 to client */
|
||||
message_len = 25 + MYSQL_DATABASE_MAXLEN;
|
||||
|
||||
fail_str = calloc(1, message_len+1);
|
||||
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);
|
||||
|
||||
@ -1046,7 +1049,7 @@ mysql_client_auth_error_handling(DCB *dcb, int auth_val)
|
||||
(char*)((MYSQL_session *)dcb->data)->db, auth_val);
|
||||
modutil_send_mysql_err_packet(dcb, packet_number, 0, 1045, "28000", fail_str);
|
||||
}
|
||||
free(fail_str);
|
||||
MXS_FREE(fail_str);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1151,68 +1154,90 @@ int gw_MySQLAccept(DCB *listener)
|
||||
|
||||
CHK_DCB(listener);
|
||||
|
||||
while ((client_dcb = dcb_accept(listener, &MyObject)) != NULL)
|
||||
if (DCB_STATE_WAITING == listener->state)
|
||||
{
|
||||
CHK_DCB(client_dcb);
|
||||
protocol = mysql_protocol_init(client_dcb, client_dcb->fd);
|
||||
|
||||
if (protocol == NULL)
|
||||
gw_process_one_new_client(listener);
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((client_dcb = dcb_accept(listener, &MyObject)) != NULL)
|
||||
{
|
||||
/** delete client_dcb */
|
||||
dcb_close(client_dcb);
|
||||
MXS_ERROR("%lu [gw_MySQLAccept] Failed to create "
|
||||
"protocol object for client connection.",
|
||||
pthread_self());
|
||||
continue;
|
||||
}
|
||||
CHK_PROTOCOL(protocol);
|
||||
client_dcb->protocol = protocol;
|
||||
atomic_add(&client_dcb->service->client_count, 1);
|
||||
//send handshake to the client_dcb
|
||||
MySQLSendHandshake(client_dcb);
|
||||
|
||||
// client protocol state change
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_SENT;
|
||||
|
||||
/**
|
||||
* Set new descriptor to event set. At the same time,
|
||||
* change state to DCB_STATE_POLLING so that
|
||||
* thread which wakes up sees correct state.
|
||||
*/
|
||||
if (poll_add_dcb(client_dcb) == -1)
|
||||
{
|
||||
/* Send a custom error as MySQL command reply */
|
||||
mysql_send_custom_error(client_dcb,
|
||||
1,
|
||||
0,
|
||||
"MaxScale encountered system limit while "
|
||||
"attempting to register on an epoll instance.");
|
||||
|
||||
/** close client_dcb */
|
||||
dcb_close(client_dcb);
|
||||
|
||||
/** Previous state is recovered in poll_add_dcb. */
|
||||
MXS_ERROR("%lu [gw_MySQLAccept] Failed to add dcb %p for "
|
||||
"fd %d to epoll set.",
|
||||
pthread_self(),
|
||||
client_dcb,
|
||||
client_dcb->fd);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_DEBUG("%lu [gw_MySQLAccept] Added dcb %p for fd "
|
||||
"%d to epoll set.",
|
||||
pthread_self(),
|
||||
client_dcb,
|
||||
client_dcb->fd);
|
||||
}
|
||||
} /**< while client_dcb != NULL */
|
||||
gw_process_one_new_client(client_dcb);
|
||||
} /**< while client_dcb != NULL */
|
||||
}
|
||||
|
||||
/* Must have broken out of while loop or received NULL client_dcb */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void gw_process_one_new_client(DCB *client_dcb)
|
||||
{
|
||||
MySQLProtocol *protocol;
|
||||
|
||||
CHK_DCB(client_dcb);
|
||||
protocol = mysql_protocol_init(client_dcb, client_dcb->fd);
|
||||
|
||||
if (protocol == NULL)
|
||||
{
|
||||
/** delete client_dcb */
|
||||
dcb_close(client_dcb);
|
||||
MXS_ERROR("%lu [gw_MySQLAccept] Failed to create "
|
||||
"protocol object for client connection.",
|
||||
pthread_self());
|
||||
return;
|
||||
}
|
||||
CHK_PROTOCOL(protocol);
|
||||
client_dcb->protocol = protocol;
|
||||
if (DCB_STATE_WAITING == client_dcb->state)
|
||||
{
|
||||
client_dcb->state = DCB_STATE_ALLOC;
|
||||
}
|
||||
else
|
||||
{
|
||||
atomic_add(&client_dcb->service->client_count, 1);
|
||||
}
|
||||
//send handshake to the client_dcb
|
||||
MySQLSendHandshake(client_dcb);
|
||||
|
||||
// client protocol state change
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_SENT;
|
||||
|
||||
/**
|
||||
* Set new descriptor to event set. At the same time,
|
||||
* change state to DCB_STATE_POLLING so that
|
||||
* thread which wakes up sees correct state.
|
||||
*/
|
||||
if (poll_add_dcb(client_dcb) == -1)
|
||||
{
|
||||
/* Send a custom error as MySQL command reply */
|
||||
mysql_send_custom_error(client_dcb,
|
||||
1,
|
||||
0,
|
||||
"MaxScale encountered system limit while "
|
||||
"attempting to register on an epoll instance.");
|
||||
|
||||
/** close client_dcb */
|
||||
dcb_close(client_dcb);
|
||||
|
||||
/** Previous state is recovered in poll_add_dcb. */
|
||||
MXS_ERROR("%lu [gw_MySQLAccept] Failed to add dcb %p for "
|
||||
"fd %d to epoll set.",
|
||||
pthread_self(),
|
||||
client_dcb,
|
||||
client_dcb->fd);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_DEBUG("%lu [gw_MySQLAccept] Added dcb %p for fd "
|
||||
"%d to epoll set.",
|
||||
pthread_self(),
|
||||
client_dcb,
|
||||
client_dcb->fd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static int gw_error_client_event(DCB* dcb)
|
||||
{
|
||||
SESSION* session;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-01-01
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
@ -44,7 +44,8 @@
|
||||
|
||||
#include <gw.h>
|
||||
#include <utils.h>
|
||||
#include "mysql_client_server_protocol.h"
|
||||
#include <mysql_client_server_protocol.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <skygw_types.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
@ -69,19 +70,11 @@ MySQLProtocol* mysql_protocol_init(DCB* dcb, int fd)
|
||||
{
|
||||
MySQLProtocol* p;
|
||||
|
||||
p = (MySQLProtocol *) calloc(1, sizeof(MySQLProtocol));
|
||||
p = (MySQLProtocol *) MXS_CALLOC(1, sizeof(MySQLProtocol));
|
||||
ss_dassert(p != NULL);
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
int eno = errno;
|
||||
errno = 0;
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
MXS_ERROR("%lu [mysql_init_protocol] MySQL protocol init failed : "
|
||||
"memory allocation due error %d, %s.",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
goto return_p;
|
||||
}
|
||||
p->protocol_state = MYSQL_PROTOCOL_ALLOC;
|
||||
@ -130,7 +123,7 @@ void mysql_protocol_done(DCB* dcb)
|
||||
while (scmd != NULL)
|
||||
{
|
||||
scmd2 = scmd->scom_next;
|
||||
free(scmd);
|
||||
MXS_FREE(scmd);
|
||||
scmd = scmd2;
|
||||
}
|
||||
p->protocol_state = MYSQL_PROTOCOL_DONE;
|
||||
@ -423,7 +416,6 @@ int mysql_send_custom_error(DCB *dcb,
|
||||
}
|
||||
|
||||
/**
|
||||
>>>>>>> origin/develop
|
||||
* mysql_send_auth_error
|
||||
*
|
||||
* Send a MySQL protocol ERR message, for gateway authentication error to the dcb
|
||||
@ -619,7 +611,7 @@ static server_command_t* server_command_init(server_command_t* srvcmd,
|
||||
}
|
||||
else
|
||||
{
|
||||
c = (server_command_t *)malloc(sizeof(server_command_t));
|
||||
c = (server_command_t *)MXS_MALLOC(sizeof(server_command_t));
|
||||
}
|
||||
if (c != NULL)
|
||||
{
|
||||
@ -634,12 +626,8 @@ static server_command_t* server_command_init(server_command_t* srvcmd,
|
||||
|
||||
static server_command_t* server_command_copy(server_command_t* srvcmd)
|
||||
{
|
||||
server_command_t* c = (server_command_t *)malloc(sizeof(server_command_t));
|
||||
if (NULL == c)
|
||||
{
|
||||
MXS_ERROR("Memory failure while attempting server_command_copy");
|
||||
}
|
||||
else
|
||||
server_command_t* c = (server_command_t *)MXS_MALLOC(sizeof(server_command_t));
|
||||
if (c)
|
||||
{
|
||||
*c = *srvcmd;
|
||||
}
|
||||
@ -692,7 +680,7 @@ void protocol_archive_srv_command(MySQLProtocol* p)
|
||||
{
|
||||
server_command_t* c = p->protocol_cmd_history;
|
||||
p->protocol_cmd_history = p->protocol_cmd_history->scom_next;
|
||||
free(c);
|
||||
MXS_FREE(c);
|
||||
}
|
||||
|
||||
/** Remove from command list */
|
||||
@ -703,7 +691,7 @@ void protocol_archive_srv_command(MySQLProtocol* p)
|
||||
else
|
||||
{
|
||||
p->protocol_command = *(s1->scom_next);
|
||||
free(s1->scom_next);
|
||||
MXS_FREE(s1->scom_next);
|
||||
}
|
||||
|
||||
retblock:
|
||||
@ -783,7 +771,7 @@ void protocol_remove_srv_command(MySQLProtocol* p)
|
||||
else
|
||||
{
|
||||
p->protocol_command = *(s->scom_next);
|
||||
free(s->scom_next);
|
||||
MXS_FREE(s->scom_next);
|
||||
}
|
||||
|
||||
spinlock_release(&p->protocol_lock);
|
||||
@ -928,7 +916,7 @@ char* create_auth_failed_msg(GWBUF*readbuf,
|
||||
const char* ferrstr = "Access denied for user '%s'@'%s' (using password: %s)";
|
||||
|
||||
/** -4 comes from 2X'%s' minus terminating char */
|
||||
errstr = (char *)malloc(strlen(uname) + strlen(ferrstr) + strlen(hostaddr) + strlen("YES") - 6 + 1);
|
||||
errstr = (char *)MXS_MALLOC(strlen(uname) + strlen(ferrstr) + strlen(hostaddr) + strlen("YES") - 6 + 1);
|
||||
|
||||
if (errstr != NULL)
|
||||
{
|
||||
@ -979,15 +967,12 @@ char *create_auth_fail_str(char *username,
|
||||
{
|
||||
ferrstr = "Access denied for user '%s'@'%s' (using password: %s)";
|
||||
}
|
||||
errstr = (char *)malloc(strlen(username) + strlen(ferrstr) +
|
||||
strlen(hostaddr) + strlen("YES") - 6 +
|
||||
db_len + ((db_len > 0) ? (strlen(" to database ") +2) : 0) + 1);
|
||||
errstr = (char *)MXS_MALLOC(strlen(username) + strlen(ferrstr) +
|
||||
strlen(hostaddr) + strlen("YES") - 6 +
|
||||
db_len + ((db_len > 0) ? (strlen(" to database ") + 2) : 0) + 1);
|
||||
|
||||
if (errstr == NULL)
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
MXS_ERROR("Memory allocation failed due to %s.",
|
||||
strerror_r(errno, errbuf, sizeof(errbuf)));
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-01-01
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
@ -14,6 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <maxscale/alloc.h>
|
||||
#include <dcb.h>
|
||||
#include <buffer.h>
|
||||
#include <service.h>
|
||||
@ -148,7 +149,7 @@ GWPROTOCOL* GetModuleObject()
|
||||
*/
|
||||
static char *telnetd_default_auth()
|
||||
{
|
||||
return "NullAuth";
|
||||
return "NullAuthAllow";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,10 +214,10 @@ static int telnetd_read_event(DCB* dcb)
|
||||
dcb_printf(dcb, "\n\rLogin incorrect\n\rLogin: ");
|
||||
telnetd_echo(dcb, 1);
|
||||
telnetd->state = TELNETD_STATE_LOGIN;
|
||||
free(telnetd->username);
|
||||
MXS_FREE(telnetd->username);
|
||||
}
|
||||
gwbuf_consume(head, GWBUF_LENGTH(head));
|
||||
free(password);
|
||||
MXS_FREE(password);
|
||||
break;
|
||||
case TELNETD_STATE_DATA:
|
||||
SESSION_ROUTE_QUERY(session, head);
|
||||
@ -296,7 +297,7 @@ static int telnetd_accept(DCB *listener)
|
||||
{
|
||||
TELNETD* telnetd_protocol = NULL;
|
||||
|
||||
if ((telnetd_protocol = (TELNETD *)calloc(1, sizeof(TELNETD))) == NULL)
|
||||
if ((telnetd_protocol = (TELNETD *)MXS_CALLOC(1, sizeof(TELNETD))) == NULL)
|
||||
{
|
||||
dcb_close(client_dcb);
|
||||
continue;
|
||||
@ -333,7 +334,7 @@ static int telnetd_close(DCB *dcb)
|
||||
|
||||
if (telnetd && telnetd->username)
|
||||
{
|
||||
free(telnetd->username);
|
||||
MXS_FREE(telnetd->username);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-01-01
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
@ -56,7 +56,7 @@ 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 "NullAuth";}
|
||||
static char *test_default_auth(){return "NullAuthAllow";}
|
||||
static int test_connection_limit(DCB *dcb, int limit){return 0;}
|
||||
/**
|
||||
* The "module object" for the httpd protocol module.
|
||||
|
Reference in New Issue
Block a user