MySQL Authentication with DBname

MySQL Authentication with DBname
This commit is contained in:
MassimilianoPinto
2014-10-15 17:26:46 +02:00
64 changed files with 819 additions and 321 deletions

View File

@ -1,6 +1,3 @@
add_subdirectory(core)
add_subdirectory(modules)
add_subdirectory(inih)
if(BUILD_TESTS)
add_subdirectory(test)
endif()

View File

@ -817,7 +817,7 @@ int error_count = 0;
int found = 0;
while (obj1)
{
if (strcmp(s, obj1->object) == 0 &&
if (strcmp(trim(s), obj1->object) == 0 &&
obj->element && obj1->element)
{
found = 1;
@ -1449,7 +1449,7 @@ SERVER *server;
int found = 0;
while (obj1)
{
if (strcmp(s, obj1->object) == 0 &&
if (strcmp(trim(s), obj1->object) == 0 &&
obj->element && obj1->element)
{
found = 1;

View File

@ -130,8 +130,10 @@ USERS *newusers, *oldusers;
i = getUsers(service, newusers);
if (i <= 0)
if (i <= 0) {
users_free(newusers);
return i;
}
spinlock_acquire(&service->spin);
oldusers = service->users;
@ -843,6 +845,7 @@ char *mysql_format_user_entry(void *data)
return NULL;
/* format user@host based on wildcards */
if (entry->ipv4.sin_addr.s_addr == INADDR_ANY && entry->netmask == 0) {
snprintf(mysql_user, mysql_user_len-1, "%s@%%", entry->user);
} else if ( (entry->ipv4.sin_addr.s_addr & 0xFF000000) == 0 && entry->netmask == 24) {
@ -859,7 +862,6 @@ char *mysql_format_user_entry(void *data)
snprintf(mysql_user, MYSQL_USER_MAXLEN-5, "Err: %s", entry->user);
strcat(mysql_user, "@");
inet_ntop(AF_INET, &(entry->ipv4).sin_addr, mysql_user+strlen(mysql_user), INET_ADDRSTRLEN);
}
if (entry->resource) {

View File

@ -73,7 +73,9 @@
#include <execinfo.h>
/** for procname */
#define _GNU_SOURCE
#if !defined(_GNU_SOURCE)
# define _GNU_SOURCE
#endif
extern char *program_invocation_name;
extern char *program_invocation_short_name;
@ -174,6 +176,9 @@ static bool resolve_maxscale_conf_fname(
char* cnf_file_arg);
static bool resolve_maxscale_homedir(
char** p_home_dir);
static char* check_dir_access(char* dirname);
/**
* Handler for SIGHUP signal. Reload the configuration for the
* gateway.
@ -534,7 +539,7 @@ return_succp:
static bool resolve_maxscale_homedir(
char** p_home_dir)
{
bool succp = false;
bool succp;
char* tmp;
char* log_context = NULL;
@ -593,65 +598,55 @@ static bool resolve_maxscale_homedir(
if (*p_home_dir != NULL)
{
log_context = strdup("Current working directory");
goto check_home_dir;
}
check_home_dir:
if (*p_home_dir != NULL)
{
if (!file_is_readable(*p_home_dir))
{
char* tailstr = "MaxScale doesn't have read permission "
"to MAXSCALE_HOME.";
char* logstr = (char*)malloc(strlen(log_context)+
1+
strlen(tailstr)+
1);
snprintf(logstr,
strlen(log_context)+
1+
strlen(tailstr)+1,
"%s:%s",
log_context,
tailstr);
print_log_n_stderr(true, true, logstr, logstr, 0);
free(logstr);
goto return_succp;
}
if (!file_is_writable(*p_home_dir))
{
char* tailstr = "MaxScale doesn't have write permission "
"to MAXSCALE_HOME. Exiting.";
char* logstr = (char*)malloc(strlen(log_context)+
1+
strlen(tailstr)+
1);
snprintf(logstr,
strlen(log_context)+
1+
strlen(tailstr)+1,
"%s:%s",
log_context,
tailstr);
print_log_n_stderr(true, true, logstr, logstr, 0);
free(logstr);
goto return_succp;
}
if (!daemon_mode)
{
fprintf(stderr,
"Using %s as MAXSCALE_HOME = %s\n",
log_context,
tmp);
}
succp = true;
goto return_succp;
}
return_succp:
free (tmp);
if (*p_home_dir != NULL)
{
char* errstr;
errstr = check_dir_access(*p_home_dir);
if (errstr != NULL)
{
char* logstr = (char*)malloc(strlen(log_context)+
1+
strlen(errstr)+
1);
snprintf(logstr,
strlen(log_context)+
1+
strlen(errstr)+1,
"%s: %s",
log_context,
errstr);
print_log_n_stderr(true, true, logstr, logstr, 0);
free(errstr);
free(logstr);
succp = false;
}
else
{
succp = true;
if (!daemon_mode)
{
fprintf(stderr,
"Using %s as MAXSCALE_HOME = %s\n",
log_context,
tmp);
}
}
}
else
{
succp = false;
}
free (tmp);
if (log_context != NULL)
{
@ -668,6 +663,42 @@ return_succp:
return succp;
}
/**
* Check read and write accessibility to a directory.
* @param dirname directory to be checked
*
* @return NULL if directory can be read and written, an error message if either
* read or write is not permitted.
*/
static char* check_dir_access(
char* dirname)
{
char* errstr = NULL;
if (dirname == NULL)
{
errstr = strdup("Directory argument is NULL");
goto retblock;
}
if (!file_is_readable(dirname))
{
errstr = strdup("MaxScale doesn't have read permission "
"to MAXSCALE_HOME.");
goto retblock;
}
if (!file_is_writable(dirname))
{
errstr = strdup("MaxScale doesn't have write permission "
"to MAXSCALE_HOME. Exiting.");
goto retblock;
}
retblock:
return errstr;
}
/**
* @node Provides error printing for non-formatted error strings.
@ -1371,13 +1402,51 @@ int main(int argc, char **argv)
{
if (!resolve_maxscale_homedir(&home_dir))
{
ss_dassert(home_dir == NULL);
ss_dassert(home_dir != NULL);
rc = MAXSCALE_HOMELESS;
goto return_main;
}
sprintf(mysql_home, "%s/mysql", home_dir);
setenv("MYSQL_HOME", mysql_home, 1);
}
else
{
char* log_context = strdup("Home directory command-line argument");
char* errstr;
errstr = check_dir_access(home_dir);
if (errstr != NULL)
{
char* logstr = (char*)malloc(strlen(log_context)+
1+
strlen(errstr)+
1);
snprintf(logstr,
strlen(log_context)+
1+
strlen(errstr)+1,
"%s: %s",
log_context,
errstr);
print_log_n_stderr(true, true, logstr, logstr, 0);
free(errstr);
free(logstr);
rc = MAXSCALE_HOMELESS;
goto return_main;
}
else if (!daemon_mode)
{
fprintf(stderr,
"Using %s as MAXSCALE_HOME = %s\n",
log_context,
home_dir);
}
free(log_context);
}
/*<
* Init Log Manager for MaxScale.
@ -1387,8 +1456,9 @@ int main(int argc, char **argv)
* argv[0]
*/
{
char buf[1024];
char *argv[8];
char buf[1024];
char *argv[8];
bool succp;
sprintf(buf, "%s/log", home_dir);
mkdir(buf, 0777);
@ -1401,7 +1471,7 @@ int main(int argc, char **argv)
argv[4] = "LOGFILE_MESSAGE,LOGFILE_ERROR"
"LOGFILE_DEBUG,LOGFILE_TRACE";
argv[5] = NULL;
skygw_logmanager_init(5, argv);
succp = skygw_logmanager_init(5, argv);
}
else
{
@ -1410,7 +1480,13 @@ int main(int argc, char **argv)
argv[5] = "-l"; /*< write to syslog */
argv[6] = "LOGFILE_MESSAGE,LOGFILE_ERROR"; /*< ..these logs to syslog */
argv[7] = NULL;
skygw_logmanager_init(7, argv);
succp = skygw_logmanager_init(7, argv);
}
if (!succp)
{
rc = MAXSCALE_BADCONFIG;
goto return_main;
}
}

View File

@ -116,7 +116,7 @@ HINT *hint;
return head;
hint->next = head;
hint->type = HINT_PARAMETER;
hint->data = pname;
hint->data = strdup(pname);
hint->value = strdup(value);
return hint;
}
@ -151,4 +151,4 @@ bool hint_exists(
p_hint = &(*p_hint)->next;
}
return succp;
}
}

View File

@ -1,3 +1,4 @@
add_executable(test_mysql_users test_mysql_users.c)
add_executable(test_hash testhash.c)
add_executable(test_hint testhint.c)
add_executable(test_spinlock testspinlock.c)
@ -9,8 +10,8 @@ add_executable(test_poll testpoll.c)
add_executable(test_service testservice.c)
add_executable(test_server testserver.c)
add_executable(test_users testusers.c)
add_executable(test_mysql_users test_mysql_users.c)
add_executable(test_adminusers testadminusers.c)
target_link_libraries(test_mysql_users fullcore MySQLClient)
target_link_libraries(test_hash fullcore)
target_link_libraries(test_hint fullcore)
target_link_libraries(test_spinlock fullcore)
@ -22,8 +23,8 @@ target_link_libraries(test_poll fullcore)
target_link_libraries(test_service fullcore)
target_link_libraries(test_server fullcore)
target_link_libraries(test_users fullcore)
target_link_libraries(test_mysql_users fullcore MySQLClient)
target_link_libraries(test_adminusers fullcore)
add_test(testMySQLUsers test_mysql_users)
add_test(TestHash test_hash)
add_test(TestHint test_hint)
add_test(TestSpinlock test_spinlock)
@ -35,5 +36,4 @@ add_test(TestPoll test_poll)
add_test(TestService test_service)
add_test(TestServer test_server)
add_test(TestUsers test_users)
add_test(testMySQLUsers test_mysql_users)
add_test(TestAdminUsers test_adminusers)

View File

@ -1,32 +0,0 @@
# cleantests - clean local and subdirectories' tests
# buildtests - build all local and subdirectories' tests
# runtests - run all local tests
# testall - clean, build and run local and subdirectories' tests
include ../../../build_gateway.inc
include ../../../makefile.inc
CC=cc
DEBUG=Y
cleantests:
- $(DEL) *.o
- $(DEL) test_mysql_users
- $(DEL) *~
testall: cleantests buildtests runtests
buildtests :
$(CC) $(CFLAGS) \
-I$(ROOT_PATH)/server/include \
-I$(ROOT_PATH)/utils \
-I$(ROOT_PATH)/log_manager \
test_mysql_users.c ../secrets.o ../service.o ../gwbitmask.o ../load_utils.o ../session.o ../poll.o ../dcb.o ../utils.o ../buffer.o ../gw_utils.o ../hashtable.o ../atomic.o ../spinlock.o ../users.o ../dbusers.o ../../../utils/skygw_utils.o ../../../log_manager/log_manager.o -o test_mysql_users -L$(EMBEDDED_LIB) -lmysqlclient -lpthread -lssl -lz -lm -lcrypt -lcrypto -ldl -laio -lrt -lstdc++
runtests:
@echo ""
@echo "-------------------------------"
@echo $(shell date)
@echo "Test MaxScale core"
@echo "-------------------------------"
@echo ""
@echo "MaxSclale Load MySQL users"
@./test_mysql_users

View File

@ -81,6 +81,7 @@ int set_and_get_single_mysql_users_ipv4(char *username, unsigned long ipv4, char
/* add user@host as key and passwd as value in the MySQL users hash table */
if (!mysql_users_add(mysql_users, &key, password)) {
fprintf(stderr, "Failed adding %s@%s(%lu)\n", username, ret_ip, fix_ipv4);
users_free(mysql_users);
return 1;
}
@ -112,6 +113,7 @@ int set_and_get_single_mysql_users(char *username, char *hostname, char *passwor
char *db="";
mysql_users = mysql_users_alloc();
/* prepare the user@host data struct */
memset(&serv_addr, 0, sizeof(serv_addr));
memset(&key, 0, sizeof(key));
@ -120,6 +122,7 @@ int set_and_get_single_mysql_users(char *username, char *hostname, char *passwor
if (hostname)
if(!setipaddress(&serv_addr.sin_addr, hostname)) {
fprintf(stderr, "setipaddress failed for host [%s]\n", hostname);
users_free(mysql_users);
return 1;
}
if (username)
@ -135,6 +138,7 @@ int set_and_get_single_mysql_users(char *username, char *hostname, char *passwor
/* add user@host as key and passwd as value in the MySQL users hash table */
if (!mysql_users_add(mysql_users, &key, password)) {
fprintf(stderr, "mysql_users_add() failed for %s@%s\n", username, hostname);
users_free(mysql_users);
return 1;
}
@ -143,6 +147,7 @@ int set_and_get_single_mysql_users(char *username, char *hostname, char *passwor
if (hostname)
if(!setipaddress(&serv_addr.sin_addr, hostname)) {
fprintf(stderr, "setipaddress failed for host [%s]\n", hostname);
users_free(mysql_users);
return 1;
}
key.user = username;
@ -175,6 +180,7 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
}
if ((service = (SERVICE *)calloc(1, sizeof(SERVICE))) == NULL) {
fprintf(stderr, "service_alloc() failed\n");
dcb_free(dcb);
return 1;
}
@ -183,6 +189,8 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
if (hostname) {
if(!setipaddress(&client_addr.sin_addr, from)) {
fprintf(stderr, "setipaddress failed for host [%s]\n", from);
free(service);
dcb_free(dcb);
return 1;
}
}
@ -219,6 +227,10 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
if (!ret) {
fprintf(stderr, "add_mysql_users_with_host_ipv4 (%s@%s, %s) FAILED\n", username, hostname, password);
users_free(mysql_users);
free(service);
dcb_free(dcb);
return 1;
} else {
char db_passwd[100]="";
@ -232,6 +244,10 @@ int set_and_get_mysql_users_wildcards(char *username, char *hostname, char *pass
ret = gw_find_mysql_user_password_sha1(username, db_passwd, dcb);
}
users_free(mysql_users);
free(service);
dcb_free(dcb);
return ret;
}
@ -262,6 +278,7 @@ int main() {
assert(ret == 1);
ret = set_and_get_single_mysql_users(NULL, NULL, NULL);
assert(ret == 1);
ret = set_and_get_single_mysql_users_ipv4("negative", -467295, "_ncd");
assert(ret == 1);
ret = set_and_get_single_mysql_users_ipv4("extra", 0xFFFFFFFFFUL * 100, "JJcd");
@ -271,6 +288,7 @@ int main() {
ret = set_and_get_single_mysql_users_ipv4(NULL, '\0', "JJcd");
assert(ret == 1);
for (i = 256*256*256; i <= 256*256*256 + 5; i++) {
char user[129] = "";
snprintf(user, 128, "user_%i", k);
@ -361,10 +379,15 @@ int main() {
if (ret) fprintf(stderr, "\t-- Expecting no match\n");
assert(ret == 1);
ret = set_and_get_mysql_users_wildcards("pippo", "192.%.%.%", "foo", "192.254.254.245", "Y", NULL, NULL);
ret = set_and_get_mysql_users_wildcards("pippo", "192.%.%.%", "12345678901234567890123456789012345678901234", "192.254.254.245", "Y", NULL, NULL);
if (!ret) fprintf(stderr, "\t-- Expecting ok\n");
assert(ret == 0);
ret = set_and_get_mysql_users_wildcards("pippo", "192.0.0.%", "1234567890123456789012345678901", "192.3.2.1");
if (ret) fprintf(stderr, "\t-- Expecting no match\n");
assert(ret == 1);
fprintf(stderr, "----------------\n");
fprintf(stderr, "<<< Test completed\n");

View File

@ -266,6 +266,14 @@ int
main(int argc, char **argv)
{
int result = 0;
char *home, buf[1024];
/* Unlink any existing password file before running this test */
if ((home = getenv("MAXSCALE_HOME")) == NULL)
home = "/usr/local/skysql";
sprintf(buf, "%s/etc/passwd", home);
if (strcmp(buf, "/etc/passwd") != 0)
unlink(buf);
result += test1();
result += test2();

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2014
* Copyright MariaDB Corporation Ab 2014
*/
/**
@ -32,6 +32,7 @@
#include <string.h>
#include <buffer.h>
#include <hint.h>
/**
* test1 Allocate a buffer and do lots of things
@ -41,6 +42,7 @@ static int
test1()
{
GWBUF *buffer, *extra, *clone, *partclone, *transform;
HINT *hint;
int size = 100;
int bite1 = 35;
int bite2 = 60;
@ -58,6 +60,10 @@ int buflen;
ss_info_dassert(size == buflen, "Incorrect buffer size");
ss_info_dassert(0 == GWBUF_EMPTY(buffer), "Buffer should not be empty");
ss_info_dassert(GWBUF_IS_TYPE_UNDEFINED(buffer), "Buffer type should be undefined");
ss_dfprintf(stderr, "\t..done\nSet a hint for the buffer");
hint = hint_create_parameter(NULL, strdup("name"), "value");
gwbuf_add_hint(buffer, hint);
ss_info_dassert(hint == buffer->hint, "Buffer should point to first and only hint");
ss_dfprintf(stderr, "\t..done\nSet a property for the buffer");
gwbuf_add_property(buffer, "name", "value");
ss_info_dassert(0 == strcmp("value", gwbuf_get_property(buffer, "name")), "Should now have correct property");

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2014
* Copyright MariaDB Corporation Ab 2014
*/
/**
@ -51,6 +51,7 @@ int buflen;
ss_dfprintf(stderr,
"testdcb : creating buffer with type DCB_ROLE_SERVICE_LISTENER");
dcb = dcb_alloc(DCB_ROLE_SERVICE_LISTENER);
printDCB(dcb);
ss_info_dassert(dcb_isvalid(dcb), "New DCB must be valid");
ss_dfprintf(stderr, "\t..done\nAllocated dcb.");
clone = dcb_clone(dcb);

View File

@ -0,0 +1,83 @@
/*
* This file is distributed as part of MaxScale. It is free
* software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright MariaDB Corporation Ab 2014
*/
/**
*
* @verbatim
* Revision History
*
* Date Who Description
* 13-10-2014 Martin Brampton Initial implementation
*
* @endverbatim
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gwbitmask.h>
#include <skygw_debug.h>
/**
* test1 Allocate table of users and mess around with it
*
*/
static int
test1()
{
static GWBITMASK bitmask, another;
int i;
/* Hint tests */
ss_dfprintf(stderr,
"testgwbitmask : Initialise a bitmask");
bitmask_init(&bitmask);
ss_info_dassert(BIT_LENGTH_INITIAL == bitmask.length, "Length should be initial length.");
for (i = 0; i < BIT_LENGTH_INITIAL; i++) {
ss_info_dassert(0 == bitmask_isset(&bitmask, i), "All bits should initially be zero");
}
ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear");
ss_dfprintf(stderr, "\t..done\nSet an arbitrary bit.");
bitmask_set(&bitmask, 17);
bitmask_copy(&another, &bitmask);
ss_info_dassert(0 != bitmask_isset(&another, 17), "Test bit should be set");
ss_dfprintf(stderr, "\t..done\nClear the arbitrary bit.");
bitmask_clear(&bitmask, 17);
ss_info_dassert(0 == bitmask_isset(&bitmask, 17), "Test bit should be clear");
ss_info_dassert(0 != bitmask_isallclear(&bitmask), "Should be all clear");
ss_dfprintf(stderr, "\t..done\nFree the bitmask.");
bitmask_free(&bitmask);
ss_info_dassert(0 == bitmask.length, "Length should be zero after bit mask freed.");
ss_dfprintf(stderr, "\t..done\n");
return 0;
}
int main(int argc, char **argv)
{
int result = 0;
result += test1();
exit(result);
}

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2014
* Copyright MariaDB Corporation Ab 2014
*/
/**
@ -49,7 +49,7 @@ HINT *hint;
hint = hint_create_parameter(NULL, strdup("name"), "value");
ss_info_dassert(NULL != hint, "New hint list should not be null");
ss_info_dassert(0 == strcmp("value", hint->value), "Hint value should be correct");
ss_info_dassert(0 != hint_exists(hint, HINT_PARAMETER), "Hint of parameter type should exist");
ss_info_dassert(0 != hint_exists(&hint, HINT_PARAMETER), "Hint of parameter type should exist");
ss_dfprintf(stderr, "\t..done\nFree hints.");
if (NULL != hint) hint_free(hint);
ss_dfprintf(stderr, "\t..done\n");

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2014
* Copyright MariaDB Corporation Ab 2014
*/
/**

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2014
* Copyright MariaDB Corporation Ab 2014
*/
/**

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2014
* Copyright MariaDB Corporation Ab 2014
*/
/**

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2014
* Copyright MariaDB Corporation Ab 2014
*/
/**

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2014
* Copyright MariaDB Corporation Ab 2014
*/
/**

4
server/modules/filter/test/Makefile Executable file → Normal file
View File

@ -1,4 +1,4 @@
# This file is distributed as part of MaxScale form SkySQL. It is free
# This file is distributed as part of MaxScale form MariaDB Corporation. It is free
# software: you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation,
# version 2.
@ -12,7 +12,7 @@
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright SkySQL Ab 2014
# Copyright MariaDB Corporation Ab 2014
include ../../../../build_gateway.inc

View File

@ -575,6 +575,7 @@ static char* create_auth_fail_str(
{
sprintf(errstr, ferrstr, uname, hostaddr, (*sha1 == '\0' ? "NO" : "YES"));
}
free(uname);
retblock:
return errstr;

View File

@ -1313,8 +1313,9 @@ int gw_check_mysql_scramble_data(DCB *dcb, uint8_t *token, unsigned int token_le
/**
* gw_find_mysql_user_password_sha1
*
* The routine fetches look for an user in the MaxScale users' table
* The routine fetches an user from the MaxScale users' table
* The users' table is dcb->service->users or a different one specified with void *repository
* The user lookup uses username,host and db name (if passed in connection or change user)
*
* If found the HEX password, representing sha1(sha1(password)), is converted in binary data and
* copied into gateway_password
@ -1350,11 +1351,11 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password,
key.user,
dcb->remote)));
/* look for user@current_host now */
/* look for user@current_ipv4 now */
user_password = mysql_users_fetch(service->users, &key);
if (!user_password) {
/* The user is not authenticated @ current host */
/* The user is not authenticated @ current IPv4 */
while (1) {
/*
@ -1375,7 +1376,7 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password,
break;
}
/*
* (2) check for possible IPv4 class C,B,A networks
*/
@ -1453,12 +1454,13 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password,
* The gateway_password represents the SHA1(SHA1(real_password)).
* Please note: the real_password is unknown and SHA1(real_password) is unknown as well
*/
int passwd_len=strlen(user_password);
if (passwd_len) {
passwd_len = (passwd_len <= (SHA_DIGEST_LENGTH * 2)) ? passwd_len : (SHA_DIGEST_LENGTH * 2);
gw_hex2bin(gateway_password, user_password, passwd_len);
}
if (strlen(user_password))
gw_hex2bin(gateway_password, user_password, SHA_DIGEST_LENGTH * 2);
return 0;
return 0;
} else {
return 1;
}
@ -1704,11 +1706,9 @@ void protocol_archive_srv_command(
s1 = &p->protocol_command;
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [protocol_archive_srv_command] Move command %s from fd %d "
"to command history.",
pthread_self(),
LOGIF(LT, (skygw_log_write(
LOGFILE_TRACE,
"Move command %s from fd %d to command history.",
STRPACKETTYPE(s1->scom_cmd),
p->owner_dcb->fd)));
@ -1780,8 +1780,8 @@ void protocol_add_srv_command(
p->protocol_command.scom_next = server_command_init(NULL, cmd);
}
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
LOGIF(LT, (skygw_log_write(
LOGFILE_TRACE,
"Added command %s to fd %d.",
STRPACKETTYPE(cmd),
p->owner_dcb->fd)));
@ -1791,8 +1791,8 @@ void protocol_add_srv_command(
while (c != NULL && c->scom_cmd != MYSQL_COM_UNDEFINED)
{
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
LOGIF(LT, (skygw_log_write(
LOGFILE_TRACE,
"fd %d : %d %s",
p->owner_dcb->fd,
c->scom_cmd,

View File

@ -1708,6 +1708,12 @@ static int routeQuery(
}
goto retblock;
}
/** If buffer is not contiguous, make it such */
if (querybuf->next != NULL)
{
querybuf = gwbuf_make_contiguous(querybuf);
}
master_dcb = router_cli_ses->rses_master_ref->bref_dcb;
CHK_DCB(master_dcb);

View File

@ -18,7 +18,7 @@ echo ""
exit 1
fi
if [ "$#" == "$NARGS" ]
if [ "$#" = "$NARGS" ]
then
echo "CTest mode"
TDIR=$7 #this is only used by CMake
@ -267,7 +267,7 @@ do
break
fi
done
if [[ "$err" == "" ]]
if [[ "$err" = "" ]]
then
echo "TEST PASSED" >> $TLOG
else
@ -293,7 +293,7 @@ do
break
fi
done
if [[ "$err" == "" ]]
if [[ "$err" = "" ]]
then
echo "TEST PASSED" >> $TLOG
else

View File

@ -1,3 +0,0 @@
if(BUILD_TESTS)
install(FILES MaxScale_test.cnf DESTINATION etc RENAME MaxScale.cnf)
endif()