This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
core/tags
|
server/core/tags
|
||||||
gateway
|
server/core/maxscale
|
||||||
core/maxscale
|
server/core/maxkeys
|
||||||
core/maxkeys
|
server/core/maxpasswd
|
||||||
core/maxpasswd
|
|
||||||
|
5
log_manager/.gitignore
vendored
Normal file
5
log_manager/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
depend.mk
|
||||||
|
|
5
query_classifier/.gitignore
vendored
Normal file
5
query_classifier/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
depend.mk
|
||||||
|
|
@ -36,6 +36,7 @@ passwd=maxpwd
|
|||||||
# servers=<server name>,<server name>,...
|
# servers=<server name>,<server name>,...
|
||||||
# user=<User to fetch password inforamtion with>
|
# user=<User to fetch password inforamtion with>
|
||||||
# passwd=<Password of the user, plain text currently>
|
# passwd=<Password of the user, plain text currently>
|
||||||
|
# enable_root_user=<0 or 1, default is 0>
|
||||||
#
|
#
|
||||||
# Valid router modules currently are:
|
# Valid router modules currently are:
|
||||||
# readwritesplit, readconnroute and debugcli
|
# readwritesplit, readconnroute and debugcli
|
||||||
|
3
server/core/.gitignore
vendored
Normal file
3
server/core/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.o
|
||||||
|
maxscale
|
||||||
|
depend.mk
|
@ -63,7 +63,7 @@ HDRS= ../include/atomic.h ../include/buffer.h ../include/dcb.h \
|
|||||||
../include/session.h ../include/spinlock.h ../include/thread.h \
|
../include/session.h ../include/spinlock.h ../include/thread.h \
|
||||||
../include/modules.h ../include/poll.h ../include/config.h \
|
../include/modules.h ../include/poll.h ../include/config.h \
|
||||||
../include/users.h ../include/hashtable.h ../include/gwbitmask.h \
|
../include/users.h ../include/hashtable.h ../include/gwbitmask.h \
|
||||||
../include/adminusers.h
|
../include/adminusers.h ../include/version.h ../include/maxscale.h
|
||||||
|
|
||||||
OBJ=$(SRCS:.c=.o)
|
OBJ=$(SRCS:.c=.o)
|
||||||
|
|
||||||
@ -101,6 +101,10 @@ maxpasswd: $(POBJS)
|
|||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(CFLAGS) $< -o $@
|
$(CC) $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
../include/version.h: ../../VERSION
|
||||||
|
echo '#define MAXSCALE_VERSION "'`cat ../../VERSION`'"' > ../include/version.h
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJ) maxscale
|
rm -f $(OBJ) maxscale
|
||||||
- rm *.so
|
- rm *.so
|
||||||
@ -108,7 +112,7 @@ clean:
|
|||||||
tags:
|
tags:
|
||||||
ctags $(SRCS) $(HDRS)
|
ctags $(SRCS) $(HDRS)
|
||||||
|
|
||||||
depend:
|
depend: ../include/version.h
|
||||||
@rm -f depend.mk
|
@rm -f depend.mk
|
||||||
cc -M $(CFLAGS) $(SRCS) > depend.mk
|
cc -M $(CFLAGS) $(SRCS) > depend.mk
|
||||||
|
|
||||||
|
@ -22,10 +22,11 @@
|
|||||||
* @verbatim
|
* @verbatim
|
||||||
* Revision History
|
* Revision History
|
||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 21/06/13 Mark Riddoch Initial implementation
|
* 21/06/13 Mark Riddoch Initial implementation
|
||||||
* 08/07/13 Mark Riddoch Addition on monitor module support
|
* 08/07/13 Mark Riddoch Addition on monitor module support
|
||||||
* 23/07/13 Mark Riddoch Addition on default monitor password
|
* 23/07/13 Mark Riddoch Addition on default monitor password
|
||||||
|
* 06/02/14 Massimiliano Pinto Added support for enable/disable root user in services
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -197,6 +198,12 @@ int error_count = 0;
|
|||||||
config_get_value(obj->parameters, "user");
|
config_get_value(obj->parameters, "user");
|
||||||
char *auth =
|
char *auth =
|
||||||
config_get_value(obj->parameters, "passwd");
|
config_get_value(obj->parameters, "passwd");
|
||||||
|
char *enable_root_user =
|
||||||
|
config_get_value(obj->parameters, "enable_root_user");
|
||||||
|
|
||||||
|
if (enable_root_user)
|
||||||
|
serviceEnableRootUser(obj->element, atoi(enable_root_user));
|
||||||
|
|
||||||
if (!auth)
|
if (!auth)
|
||||||
auth = config_get_value(obj->parameters, "auth");
|
auth = config_get_value(obj->parameters, "auth");
|
||||||
|
|
||||||
@ -333,11 +340,13 @@ int error_count = 0;
|
|||||||
else if (!strcmp(type, "listener"))
|
else if (!strcmp(type, "listener"))
|
||||||
{
|
{
|
||||||
char *service;
|
char *service;
|
||||||
|
char *address;
|
||||||
char *port;
|
char *port;
|
||||||
char *protocol;
|
char *protocol;
|
||||||
|
|
||||||
service = config_get_value(obj->parameters, "service");
|
service = config_get_value(obj->parameters, "service");
|
||||||
port = config_get_value(obj->parameters, "port");
|
port = config_get_value(obj->parameters, "port");
|
||||||
|
address = config_get_value(obj->parameters, "address");
|
||||||
protocol = config_get_value(obj->parameters, "protocol");
|
protocol = config_get_value(obj->parameters, "protocol");
|
||||||
|
|
||||||
if (service && port && protocol)
|
if (service && port && protocol)
|
||||||
@ -349,6 +358,7 @@ int error_count = 0;
|
|||||||
{
|
{
|
||||||
serviceAddProtocol(ptr->element,
|
serviceAddProtocol(ptr->element,
|
||||||
protocol,
|
protocol,
|
||||||
|
address,
|
||||||
atoi(port));
|
atoi(port));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -587,21 +597,31 @@ SERVER *server;
|
|||||||
{
|
{
|
||||||
char *user;
|
char *user;
|
||||||
char *auth;
|
char *auth;
|
||||||
|
char *enable_root_user;
|
||||||
|
|
||||||
|
enable_root_user = config_get_value(obj->parameters, "enable_root_user");
|
||||||
|
|
||||||
user = config_get_value(obj->parameters,
|
user = config_get_value(obj->parameters,
|
||||||
"user");
|
"user");
|
||||||
auth = config_get_value(obj->parameters,
|
auth = config_get_value(obj->parameters,
|
||||||
"passwd");
|
"passwd");
|
||||||
if (user && auth)
|
if (user && auth) {
|
||||||
service_update(service, router,
|
service_update(service, router,
|
||||||
user,
|
user,
|
||||||
auth);
|
auth);
|
||||||
|
if (enable_root_user)
|
||||||
|
serviceEnableRootUser(service, atoi(enable_root_user));
|
||||||
|
}
|
||||||
|
|
||||||
obj->element = service;
|
obj->element = service;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *user;
|
char *user;
|
||||||
char *auth;
|
char *auth;
|
||||||
|
char *enable_root_user;
|
||||||
|
|
||||||
|
enable_root_user = config_get_value(obj->parameters, "enable_root_user");
|
||||||
|
|
||||||
user = config_get_value(obj->parameters,
|
user = config_get_value(obj->parameters,
|
||||||
"user");
|
"user");
|
||||||
@ -615,6 +635,8 @@ SERVER *server;
|
|||||||
serviceSetUser(obj->element,
|
serviceSetUser(obj->element,
|
||||||
user,
|
user,
|
||||||
auth);
|
auth);
|
||||||
|
if (enable_root_user)
|
||||||
|
serviceEnableRootUser(service, atoi(enable_root_user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -739,8 +761,10 @@ SERVER *server;
|
|||||||
char *service;
|
char *service;
|
||||||
char *port;
|
char *port;
|
||||||
char *protocol;
|
char *protocol;
|
||||||
|
char *address;
|
||||||
|
|
||||||
service = config_get_value(obj->parameters, "service");
|
service = config_get_value(obj->parameters, "service");
|
||||||
|
address = config_get_value(obj->parameters, "address");
|
||||||
port = config_get_value(obj->parameters, "port");
|
port = config_get_value(obj->parameters, "port");
|
||||||
protocol = config_get_value(obj->parameters, "protocol");
|
protocol = config_get_value(obj->parameters, "protocol");
|
||||||
|
|
||||||
@ -758,6 +782,7 @@ SERVER *server;
|
|||||||
{
|
{
|
||||||
serviceAddProtocol(ptr->element,
|
serviceAddProtocol(ptr->element,
|
||||||
protocol,
|
protocol,
|
||||||
|
address,
|
||||||
atoi(port));
|
atoi(port));
|
||||||
serviceStartProtocol(ptr->element,
|
serviceStartProtocol(ptr->element,
|
||||||
protocol,
|
protocol,
|
||||||
@ -837,17 +862,19 @@ int i;
|
|||||||
obj = context;
|
obj = context;
|
||||||
while (obj)
|
while (obj)
|
||||||
{
|
{
|
||||||
type = config_get_value(obj->parameters, "type");
|
param_set = NULL;
|
||||||
if (!strcmp(type, "service"))
|
if (obj->parameters &&
|
||||||
param_set = service_params;
|
(type = config_get_value(obj->parameters, "type")))
|
||||||
else if (!strcmp(type, "server"))
|
{
|
||||||
param_set = server_params;
|
if (!strcmp(type, "service"))
|
||||||
else if (!strcmp(type, "listener"))
|
param_set = service_params;
|
||||||
param_set = listener_params;
|
else if (!strcmp(type, "server"))
|
||||||
else if (!strcmp(type, "monitor"))
|
param_set = server_params;
|
||||||
param_set = monitor_params;
|
else if (!strcmp(type, "listener"))
|
||||||
else
|
param_set = listener_params;
|
||||||
param_set = NULL;
|
else if (!strcmp(type, "monitor"))
|
||||||
|
param_set = monitor_params;
|
||||||
|
}
|
||||||
if (param_set != NULL)
|
if (param_set != NULL)
|
||||||
{
|
{
|
||||||
params = obj->parameters;
|
params = obj->parameters;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 24/06/2013 Massimiliano Pinto Initial implementation
|
* 24/06/2013 Massimiliano Pinto Initial implementation
|
||||||
* 08/08/2013 Massimiliano Pinto Fixed bug for invalid memory access in row[1]+1 when row[1] is ""
|
* 08/08/2013 Massimiliano Pinto Fixed bug for invalid memory access in row[1]+1 when row[1] is ""
|
||||||
|
* 06/02/2014 Massimiliano Pinto Mysql user root selected based on configuration flag
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -39,6 +40,9 @@
|
|||||||
#include <log_manager.h>
|
#include <log_manager.h>
|
||||||
#include <secrets.h>
|
#include <secrets.h>
|
||||||
|
|
||||||
|
#define USERS_QUERY_NO_ROOT " WHERE user NOT IN ('root')"
|
||||||
|
#define LOAD_MYSQL_USERS_QUERY "SELECT user, password FROM mysql.user"
|
||||||
|
|
||||||
extern int lm_enabled_logfiles_bitmask;
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
|
|
||||||
static int getUsers(SERVICE *service, struct users *users);
|
static int getUsers(SERVICE *service, struct users *users);
|
||||||
@ -101,6 +105,12 @@ getUsers(SERVICE *service, struct users *users)
|
|||||||
char *dpwd;
|
char *dpwd;
|
||||||
int total_users = 0;
|
int total_users = 0;
|
||||||
SERVER *server;
|
SERVER *server;
|
||||||
|
char *users_query;
|
||||||
|
|
||||||
|
if(service->enable_root)
|
||||||
|
users_query = LOAD_MYSQL_USERS_QUERY;
|
||||||
|
else
|
||||||
|
users_query = LOAD_MYSQL_USERS_QUERY USERS_QUERY_NO_ROOT;
|
||||||
|
|
||||||
serviceGetUser(service, &service_user, &service_passwd);
|
serviceGetUser(service, &service_user, &service_passwd);
|
||||||
/** multi-thread environment requires that thread init succeeds. */
|
/** multi-thread environment requires that thread init succeeds. */
|
||||||
@ -159,7 +169,7 @@ getUsers(SERVICE *service, struct users *users)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mysql_query(con, "SELECT user, password FROM mysql.user")) {
|
if (mysql_query(con, users_query)) {
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Error : Loading users for service %s encountered "
|
"Error : Loading users for service %s encountered "
|
||||||
|
@ -99,7 +99,7 @@ DCB * dcb_alloc(
|
|||||||
{
|
{
|
||||||
DCB *rval;
|
DCB *rval;
|
||||||
|
|
||||||
if ((rval = calloc(1, sizeof(DCB))) == NULL)
|
if ((rval = calloc(1, sizeof(DCB))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -122,6 +122,7 @@ if ((rval = calloc(1, sizeof(DCB))) == NULL)
|
|||||||
memset(&rval->stats, 0, sizeof(DCBSTATS)); // Zero the statistics
|
memset(&rval->stats, 0, sizeof(DCBSTATS)); // Zero the statistics
|
||||||
rval->state = DCB_STATE_ALLOC;
|
rval->state = DCB_STATE_ALLOC;
|
||||||
bitmask_init(&rval->memdata.bitmask);
|
bitmask_init(&rval->memdata.bitmask);
|
||||||
|
rval->next = NULL;
|
||||||
|
|
||||||
spinlock_acquire(&dcbspin);
|
spinlock_acquire(&dcbspin);
|
||||||
if (allDCBs == NULL)
|
if (allDCBs == NULL)
|
||||||
@ -137,6 +138,26 @@ if ((rval = calloc(1, sizeof(DCB))) == NULL)
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free a DCB that has not been associated with a decriptor.
|
||||||
|
*
|
||||||
|
* @param dcb The DCB to free
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
dcb_free(DCB *dcb)
|
||||||
|
{
|
||||||
|
if (dcb->fd == -1)
|
||||||
|
dcb_final_free(dcb);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"Error : Attempt to free a DCB via dcb_fee "
|
||||||
|
"that has been associated with a descriptor.")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the DCB to the end of zombies list.
|
* Add the DCB to the end of zombies list.
|
||||||
*
|
*
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
* 28/06/13 Vilho Raatikka Added necessary headers, example functions and
|
* 28/06/13 Vilho Raatikka Added necessary headers, example functions and
|
||||||
* calls to log manager and to query classifier.
|
* calls to log manager and to query classifier.
|
||||||
* Put example code behind SS_DEBUG macros.
|
* Put example code behind SS_DEBUG macros.
|
||||||
|
* 05/02/14 Mark Riddoch Addition of version string
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -53,6 +54,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#include <monitor.h>
|
#include <monitor.h>
|
||||||
|
#include <version.h>
|
||||||
|
#include <maxscale.h>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -313,7 +316,7 @@ static bool file_write_header(
|
|||||||
*t = time(NULL);
|
*t = time(NULL);
|
||||||
*tm = *localtime(t);
|
*tm = *localtime(t);
|
||||||
|
|
||||||
header_buf1 = "\n\nSkySQL MaxScale\t";
|
header_buf1 = "\n\nSkySQL MaxScale " MAXSCALE_VERSION "\t";
|
||||||
header_buf2 = strdup(asctime(tm));
|
header_buf2 = strdup(asctime(tm));
|
||||||
|
|
||||||
if (header_buf2 == NULL) {
|
if (header_buf2 == NULL) {
|
||||||
@ -865,7 +868,7 @@ static void usage(void)
|
|||||||
*/
|
*/
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = MAXSCALE_SHUTDOWN;
|
||||||
int l;
|
int l;
|
||||||
int i;
|
int i;
|
||||||
int n;
|
int n;
|
||||||
@ -914,7 +917,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char* fprerr = "Failed to register exit functions for MaxScale";
|
char* fprerr = "Failed to register exit functions for MaxScale";
|
||||||
print_log_n_stderr(false, true, NULL, fprerr, 0);
|
print_log_n_stderr(false, true, NULL, fprerr, 0);
|
||||||
rc = 1;
|
rc = MAXSCALE_INTERNALERROR;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -937,7 +940,23 @@ int main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (optarg[0] != '-')
|
if (optarg[0] != '-')
|
||||||
{
|
{
|
||||||
get_expanded_pathname(&home_dir, optarg, NULL);
|
struct stat sb;
|
||||||
|
|
||||||
|
if (stat(optarg, &sb) != -1
|
||||||
|
&& (! S_ISDIR(sb.st_mode)))
|
||||||
|
{
|
||||||
|
char* logerr = "Home directory argument "
|
||||||
|
"identifier \'-c\' was specified but "
|
||||||
|
"the argument didn't specify a valid "
|
||||||
|
"a directory.";
|
||||||
|
print_log_n_stderr(true, true, logerr, logerr, 0);
|
||||||
|
usage();
|
||||||
|
succp = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
get_expanded_pathname(&home_dir, optarg, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (home_dir != NULL)
|
if (home_dir != NULL)
|
||||||
@ -992,7 +1011,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!succp)
|
if (!succp)
|
||||||
{
|
{
|
||||||
rc = 1;
|
rc = MAXSCALE_BADARG;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1024,7 +1043,7 @@ int main(int argc, char **argv)
|
|||||||
eno = errno;
|
eno = errno;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
print_log_n_stderr(true, true, fprerr, fprerr, eno);
|
print_log_n_stderr(true, true, fprerr, fprerr, eno);
|
||||||
rc = 1;
|
rc = MAXSCALE_INTERNALERROR;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
r = sigdelset(&sigset, SIGHUP);
|
r = sigdelset(&sigset, SIGHUP);
|
||||||
@ -1036,7 +1055,7 @@ int main(int argc, char **argv)
|
|||||||
eno = errno;
|
eno = errno;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
print_log_n_stderr(true, true, fprerr, logerr, eno);
|
print_log_n_stderr(true, true, fprerr, logerr, eno);
|
||||||
rc = 1;
|
rc = MAXSCALE_INTERNALERROR;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
r = sigdelset(&sigset, SIGTERM);
|
r = sigdelset(&sigset, SIGTERM);
|
||||||
@ -1048,7 +1067,7 @@ int main(int argc, char **argv)
|
|||||||
eno = errno;
|
eno = errno;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
print_log_n_stderr(true, true, fprerr, logerr, eno);
|
print_log_n_stderr(true, true, fprerr, logerr, eno);
|
||||||
rc = 1;
|
rc = MAXSCALE_INTERNALERROR;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
r = sigprocmask(SIG_SETMASK, &sigset, NULL);
|
r = sigprocmask(SIG_SETMASK, &sigset, NULL);
|
||||||
@ -1059,7 +1078,7 @@ int main(int argc, char **argv)
|
|||||||
eno = errno;
|
eno = errno;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
print_log_n_stderr(true, true, fprerr, logerr, eno);
|
print_log_n_stderr(true, true, fprerr, logerr, eno);
|
||||||
rc = 1;
|
rc = MAXSCALE_INTERNALERROR;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
gw_daemonize();
|
gw_daemonize();
|
||||||
@ -1101,7 +1120,7 @@ int main(int argc, char **argv)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
print_log_n_stderr(true, !daemon_mode, logerr, fprerr, eno);
|
print_log_n_stderr(true, !daemon_mode, logerr, fprerr, eno);
|
||||||
free(logerr);
|
free(logerr);
|
||||||
rc = 1;
|
rc = MAXSCALE_INTERNALERROR;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1112,7 +1131,7 @@ int main(int argc, char **argv)
|
|||||||
char* logerr = "Failed to initialise signal mask for MaxScale. "
|
char* logerr = "Failed to initialise signal mask for MaxScale. "
|
||||||
"Exiting.";
|
"Exiting.";
|
||||||
print_log_n_stderr(true, true, logerr, logerr, eno);
|
print_log_n_stderr(true, true, logerr, logerr, eno);
|
||||||
rc = 1;
|
rc = MAXSCALE_INTERNALERROR;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
l = atexit(libmysqld_done);
|
l = atexit(libmysqld_done);
|
||||||
@ -1123,7 +1142,7 @@ int main(int argc, char **argv)
|
|||||||
char* logerr = "Failed to register exit function libmysql_done "
|
char* logerr = "Failed to register exit function libmysql_done "
|
||||||
"for MaxScale. Exiting.";
|
"for MaxScale. Exiting.";
|
||||||
print_log_n_stderr(true, true, logerr, fprerr, 0);
|
print_log_n_stderr(true, true, logerr, fprerr, 0);
|
||||||
rc = 1;
|
rc = MAXSCALE_INTERNALERROR;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
/*<
|
/*<
|
||||||
@ -1136,7 +1155,7 @@ int main(int argc, char **argv)
|
|||||||
if (!resolve_maxscale_homedir(&home_dir))
|
if (!resolve_maxscale_homedir(&home_dir))
|
||||||
{
|
{
|
||||||
ss_dassert(home_dir == NULL);
|
ss_dassert(home_dir == NULL);
|
||||||
rc = 1;
|
rc = MAXSCALE_HOMELESS;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
sprintf(mysql_home, "%s/mysql", home_dir);
|
sprintf(mysql_home, "%s/mysql", home_dir);
|
||||||
@ -1174,7 +1193,7 @@ int main(int argc, char **argv)
|
|||||||
if (!resolve_maxscale_conf_fname(&cnf_file_path, home_dir, cnf_file_arg))
|
if (!resolve_maxscale_conf_fname(&cnf_file_path, home_dir, cnf_file_arg))
|
||||||
{
|
{
|
||||||
ss_dassert(cnf_file_path == NULL);
|
ss_dassert(cnf_file_path == NULL);
|
||||||
rc = 1;
|
rc = MAXSCALE_BADCONFIG;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1274,7 +1293,7 @@ int main(int argc, char **argv)
|
|||||||
mysql_error(NULL),
|
mysql_error(NULL),
|
||||||
__FILE__,
|
__FILE__,
|
||||||
__LINE__)));
|
__LINE__)));
|
||||||
rc = 1;
|
rc = MAXSCALE_NOLIBRARY;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
libmysqld_started = TRUE;
|
libmysqld_started = TRUE;
|
||||||
@ -1289,12 +1308,13 @@ int main(int argc, char **argv)
|
|||||||
"Error : Failed to load MaxScale configuration file %s. "
|
"Error : Failed to load MaxScale configuration file %s. "
|
||||||
"Exiting.",
|
"Exiting.",
|
||||||
cnf_file_path)));
|
cnf_file_path)));
|
||||||
rc = 1;
|
rc = MAXSCALE_BADCONFIG;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
"SkySQL MaxScale (C) SkySQL Ab 2013")));
|
"SkySQL MaxScale %s (C) SkySQL Ab 2013,2014",
|
||||||
|
MAXSCALE_VERSION)));
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
"MaxScale is running in process %i",
|
"MaxScale is running in process %i",
|
||||||
@ -1310,7 +1330,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char* logerr = "Failed to start any MaxScale services. Exiting.";
|
char* logerr = "Failed to start any MaxScale services. Exiting.";
|
||||||
print_log_n_stderr(true, !daemon_mode, logerr, logerr, 0);
|
print_log_n_stderr(true, !daemon_mode, logerr, logerr, 0);
|
||||||
rc = 1;
|
rc = MAXSCALE_NOSERVICES;
|
||||||
goto return_main;
|
goto return_main;
|
||||||
}
|
}
|
||||||
/*<
|
/*<
|
||||||
@ -1367,7 +1387,7 @@ int main(int argc, char **argv)
|
|||||||
"MaxScale shutdown completed.")));
|
"MaxScale shutdown completed.")));
|
||||||
|
|
||||||
return_main:
|
return_main:
|
||||||
return 0;
|
return rc;
|
||||||
} /*< End of main */
|
} /*< End of main */
|
||||||
|
|
||||||
/*<
|
/*<
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
* 01-07-2013 Massimiliano Pinto Removed session->backends
|
* 01-07-2013 Massimiliano Pinto Removed session->backends
|
||||||
* from gw_read_gwbuff()
|
* from gw_read_gwbuff()
|
||||||
* 25-09-2013 Massimiliano Pinto setipaddress uses getaddrinfo
|
* 25-09-2013 Massimiliano Pinto setipaddress uses getaddrinfo
|
||||||
|
* 06-02-2014 Mark Riddoch Added parse_bindconfig
|
||||||
*
|
*
|
||||||
*@endverbatim
|
*@endverbatim
|
||||||
*/
|
*/
|
||||||
@ -40,9 +41,14 @@
|
|||||||
#include <dcb.h>
|
#include <dcb.h>
|
||||||
#include <session.h>
|
#include <session.h>
|
||||||
|
|
||||||
|
#include <skygw_utils.h>
|
||||||
|
#include <log_manager.h>
|
||||||
|
|
||||||
SPINLOCK tmplock = SPINLOCK_INIT;
|
SPINLOCK tmplock = SPINLOCK_INIT;
|
||||||
|
|
||||||
/**
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
|
|
||||||
|
/*
|
||||||
* Set IP address in socket structure in_addr
|
* Set IP address in socket structure in_addr
|
||||||
*
|
*
|
||||||
* @param a Pointer to a struct in_addr into which the address is written
|
* @param a Pointer to a struct in_addr into which the address is written
|
||||||
@ -184,3 +190,64 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the bind config data. This is passed in a string as address:port.
|
||||||
|
*
|
||||||
|
* The address may be either a . seperated IP address or a hostname to
|
||||||
|
* lookup. The address 0.0.0.0 is the wildcard address for SOCKADR_ANY.
|
||||||
|
* The ':' and port may be omitted, in which case the default port is
|
||||||
|
* used.
|
||||||
|
*
|
||||||
|
* @param config The bind address and port seperated by a ':'
|
||||||
|
* @param def_port The default port to use
|
||||||
|
* @param addr The sockaddr_in in which the data is written
|
||||||
|
* @return 0 on failure
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
parse_bindconfig(char *config, unsigned short def_port, struct sockaddr_in *addr)
|
||||||
|
{
|
||||||
|
char *port, buf[1024];
|
||||||
|
short pnum;
|
||||||
|
struct hostent *hp;
|
||||||
|
|
||||||
|
|
||||||
|
strncpy(buf, config, 1024);
|
||||||
|
port = strrchr(buf, ':');
|
||||||
|
if (port)
|
||||||
|
{
|
||||||
|
*port = 0;
|
||||||
|
port++;
|
||||||
|
pnum = atoi(port);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pnum = def_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(buf, "0.0.0.0"))
|
||||||
|
{
|
||||||
|
addr->sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!inet_aton(buf, &addr->sin_addr))
|
||||||
|
{
|
||||||
|
if ((hp = gethostbyname(buf)) != NULL)
|
||||||
|
{
|
||||||
|
bcopy(hp->h_addr, &(addr->sin_addr.s_addr), hp->h_length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"Error : Failed to lookup host '%s'. ",
|
||||||
|
buf)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addr->sin_family = AF_INET;
|
||||||
|
addr->sin_port = htons(pnum);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 18/06/13 Mark Riddoch Initial implementation
|
* 18/06/13 Mark Riddoch Initial implementation
|
||||||
* 24/06/13 Massimiliano Pinto Added: Loading users from mysql backend in serviceStart
|
* 24/06/13 Massimiliano Pinto Added: Loading users from mysql backend in serviceStart
|
||||||
|
* 06/02/14 Massimiliano Pinto Added: serviceEnableRootUser routine
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -78,6 +79,7 @@ SERVICE *service;
|
|||||||
service->credentials.name = NULL;
|
service->credentials.name = NULL;
|
||||||
service->credentials.authdata = NULL;
|
service->credentials.authdata = NULL;
|
||||||
service->users = users_alloc();
|
service->users = users_alloc();
|
||||||
|
service->enable_root = 0;
|
||||||
service->routerOptions = NULL;
|
service->routerOptions = NULL;
|
||||||
service->databases = NULL;
|
service->databases = NULL;
|
||||||
spinlock_init(&service->spin);
|
spinlock_init(&service->spin);
|
||||||
@ -121,7 +123,7 @@ GWPROTOCOL *funcs;
|
|||||||
if ((funcs =
|
if ((funcs =
|
||||||
(GWPROTOCOL *)load_module(port->protocol, MODULE_PROTOCOL)) == NULL)
|
(GWPROTOCOL *)load_module(port->protocol, MODULE_PROTOCOL)) == NULL)
|
||||||
{
|
{
|
||||||
free(port->listener);
|
dcb_free(port->listener);
|
||||||
port->listener = NULL;
|
port->listener = NULL;
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
@ -133,7 +135,10 @@ GWPROTOCOL *funcs;
|
|||||||
}
|
}
|
||||||
memcpy(&(port->listener->func), funcs, sizeof(GWPROTOCOL));
|
memcpy(&(port->listener->func), funcs, sizeof(GWPROTOCOL));
|
||||||
port->listener->session = NULL;
|
port->listener->session = NULL;
|
||||||
sprintf(config_bind, "0.0.0.0:%d", port->port);
|
if (port->address)
|
||||||
|
sprintf(config_bind, "%s:%d", port->address, port->port);
|
||||||
|
else
|
||||||
|
sprintf(config_bind, "0.0.0.0:%d", port->port);
|
||||||
|
|
||||||
if (port->listener->func.listen(port->listener, config_bind)) {
|
if (port->listener->func.listen(port->listener, config_bind)) {
|
||||||
port->listener->session = session_alloc(service, port->listener);
|
port->listener->session = session_alloc(service, port->listener);
|
||||||
@ -333,11 +338,12 @@ SERVICE *ptr;
|
|||||||
*
|
*
|
||||||
* @param service The service
|
* @param service The service
|
||||||
* @param protocol The name of the protocol module
|
* @param protocol The name of the protocol module
|
||||||
|
* @param address The address to listen with
|
||||||
* @param port The port to listen on
|
* @param port The port to listen on
|
||||||
* @return TRUE if the protocol/port could be added
|
* @return TRUE if the protocol/port could be added
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
serviceAddProtocol(SERVICE *service, char *protocol, unsigned short port)
|
serviceAddProtocol(SERVICE *service, char *protocol, char *address, unsigned short port)
|
||||||
{
|
{
|
||||||
SERV_PROTOCOL *proto;
|
SERV_PROTOCOL *proto;
|
||||||
|
|
||||||
@ -346,6 +352,10 @@ SERV_PROTOCOL *proto;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
proto->protocol = strdup(protocol);
|
proto->protocol = strdup(protocol);
|
||||||
|
if (address)
|
||||||
|
proto->address = strdup(address);
|
||||||
|
else
|
||||||
|
proto->address = NULL;
|
||||||
proto->port = port;
|
proto->port = port;
|
||||||
spinlock_acquire(&service->spin);
|
spinlock_acquire(&service->spin);
|
||||||
proto->next = service->ports;
|
proto->next = service->ports;
|
||||||
@ -356,7 +366,7 @@ SERV_PROTOCOL *proto;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a protocol/port pair si part of the service
|
* Check if a protocol/port pair is part of the service
|
||||||
*
|
*
|
||||||
* @param service The service
|
* @param service The service
|
||||||
* @param protocol The name of the protocol module
|
* @param protocol The name of the protocol module
|
||||||
@ -496,7 +506,7 @@ serviceSetUser(SERVICE *service, char *user, char *auth)
|
|||||||
* @param service The service we are setting the data for
|
* @param service The service we are setting the data for
|
||||||
* @param user The user name to use for connections
|
* @param user The user name to use for connections
|
||||||
* @param auth The authentication data we need, e.g. MySQL SHA1 password
|
* @param auth The authentication data we need, e.g. MySQL SHA1 password
|
||||||
* @return 0 on failure
|
* @return 0 on failure
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
serviceGetUser(SERVICE *service, char **user, char **auth)
|
serviceGetUser(SERVICE *service, char **user, char **auth)
|
||||||
@ -508,6 +518,26 @@ serviceGetUser(SERVICE *service, char **user, char **auth)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable/Disable root user for this service
|
||||||
|
* associated with this service.
|
||||||
|
*
|
||||||
|
* @param service The service we are setting the data for
|
||||||
|
* @param action 1 for root enable, 0 for disable access
|
||||||
|
* @return 0 on failure
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
serviceEnableRootUser(SERVICE *service, int action)
|
||||||
|
{
|
||||||
|
if (action != 0 && action != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
service->enable_root = action;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a named service
|
* Return a named service
|
||||||
*
|
*
|
||||||
|
1
server/include/.gitignore
vendored
Normal file
1
server/include/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
version.h
|
@ -27,8 +27,6 @@
|
|||||||
#define GW_BACKEND_SO_SNDBUF 1024
|
#define GW_BACKEND_SO_SNDBUF 1024
|
||||||
|
|
||||||
#define GW_NOINTR_CALL(A) do { errno = 0; A; } while (errno == EINTR)
|
#define GW_NOINTR_CALL(A) do { errno = 0; A; } while (errno == EINTR)
|
||||||
#define GW_VERSION "0.1.0"
|
|
||||||
#define GW_MYSQL_VERSION "5.5.22-SKYSQL-" GW_VERSION
|
|
||||||
#define GW_MYSQL_LOOP_TIMEOUT 300000000
|
#define GW_MYSQL_LOOP_TIMEOUT 300000000
|
||||||
#define GW_MYSQL_READ 0
|
#define GW_MYSQL_READ 0
|
||||||
#define GW_MYSQL_WRITE 1
|
#define GW_MYSQL_WRITE 1
|
||||||
@ -51,7 +49,6 @@ void gw_daemonize(void);
|
|||||||
int do_read_dcb(DCB *dcb);
|
int do_read_dcb(DCB *dcb);
|
||||||
void MySQLListener(int epfd, char *config_bind);
|
void MySQLListener(int epfd, char *config_bind);
|
||||||
int MySQLAccept(DCB *listener);
|
int MySQLAccept(DCB *listener);
|
||||||
int gw_mysql_do_authentication(DCB *dcb, GWBUF *);
|
|
||||||
char *gw_strend(register const char *s);
|
char *gw_strend(register const char *s);
|
||||||
int do_read_dcb(DCB *dcb);
|
int do_read_dcb(DCB *dcb);
|
||||||
int do_read_10(DCB *dcb, uint8_t *buffer);
|
int do_read_10(DCB *dcb, uint8_t *buffer);
|
||||||
@ -61,3 +58,4 @@ int gw_read_backend_event(DCB *dcb);
|
|||||||
int setnonblocking(int fd);
|
int setnonblocking(int fd);
|
||||||
int gw_write(int fd, const void* buf, size_t nbytes);
|
int gw_write(int fd, const void* buf, size_t nbytes);
|
||||||
int gw_getsockerrno(int fd);
|
int gw_getsockerrno(int fd);
|
||||||
|
int parse_bindconfig(char *, unsigned short, struct sockaddr_in *);
|
||||||
|
43
server/include/maxscale.h
Normal file
43
server/include/maxscale.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#ifndef _MAXSCALE_H
|
||||||
|
#define _MAXSCALE_H
|
||||||
|
/*
|
||||||
|
* This file is distributed as part of the SkySQL Gateway. 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 SkySQL Ab 2014
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file maxscale.h
|
||||||
|
*
|
||||||
|
* Some general definitions for MaxScale
|
||||||
|
*
|
||||||
|
* @verbatim
|
||||||
|
* Revision History
|
||||||
|
*
|
||||||
|
* Date Who Description
|
||||||
|
* 05/02/14 Mark Riddoch Initial implementation
|
||||||
|
*
|
||||||
|
* @endverbatim
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exit status for MaxScale */
|
||||||
|
#define MAXSCALE_SHUTDOWN 0 /* Good shutdown */
|
||||||
|
#define MAXSCALE_BADCONFIG 1 /* Configuration fiel error */
|
||||||
|
#define MAXSCALE_NOLIBRARY 2 /* No embedded library found */
|
||||||
|
#define MAXSCALE_NOSERVICES 3 /* No servics are running */
|
||||||
|
#define MAXSCALE_HOMELESS 4 /* No MaxScale Home */
|
||||||
|
#define MAXSCALE_BADARG 5 /* Bad command line argument */
|
||||||
|
#define MAXSCALE_INTERNALERROR 6 /* Internal error, see error log */
|
||||||
|
#endif
|
@ -31,11 +31,12 @@
|
|||||||
* @verbatim
|
* @verbatim
|
||||||
* Revision History
|
* Revision History
|
||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 14/06/13 Mark Riddoch Initial implementation
|
* 14/06/13 Mark Riddoch Initial implementation
|
||||||
* 18/06/13 Mark Riddoch Addition of statistics and function
|
* 18/06/13 Mark Riddoch Addition of statistics and function
|
||||||
* prototypes
|
* prototypes
|
||||||
* 23/06/13 Mark Riddoch Added service user and users
|
* 23/06/13 Mark Riddoch Added service user and users
|
||||||
|
* 06/02/14 Massimiliano Pinto Added service flag for root user access
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -53,6 +54,7 @@ struct users;
|
|||||||
typedef struct servprotocol {
|
typedef struct servprotocol {
|
||||||
char *protocol; /**< Protocol module to load */
|
char *protocol; /**< Protocol module to load */
|
||||||
unsigned short port; /**< Port to listen on */
|
unsigned short port; /**< Port to listen on */
|
||||||
|
char *address; /**< Address to listen with */
|
||||||
DCB *listener; /**< The DCB for the listener */
|
DCB *listener; /**< The DCB for the listener */
|
||||||
struct servprotocol
|
struct servprotocol
|
||||||
*next; /**< Next service protocol */
|
*next; /**< Next service protocol */
|
||||||
@ -101,6 +103,7 @@ typedef struct service {
|
|||||||
SPINLOCK spin; /**< The service spinlock */
|
SPINLOCK spin; /**< The service spinlock */
|
||||||
SERVICE_STATS stats; /**< The service statistics */
|
SERVICE_STATS stats; /**< The service statistics */
|
||||||
struct users *users; /**< The user data for this service */
|
struct users *users; /**< The user data for this service */
|
||||||
|
int enable_root; /**< Allow root user access */
|
||||||
struct service *next; /**< The next service in the linked list */
|
struct service *next; /**< The next service in the linked list */
|
||||||
} SERVICE;
|
} SERVICE;
|
||||||
|
|
||||||
@ -110,7 +113,7 @@ typedef struct service {
|
|||||||
extern SERVICE *service_alloc(char *, char *);
|
extern SERVICE *service_alloc(char *, char *);
|
||||||
extern int service_free(SERVICE *);
|
extern int service_free(SERVICE *);
|
||||||
extern SERVICE *service_find(char *);
|
extern SERVICE *service_find(char *);
|
||||||
extern int serviceAddProtocol(SERVICE *, char *, unsigned short);
|
extern int serviceAddProtocol(SERVICE *, char *, char *, unsigned short);
|
||||||
extern int serviceHasProtocol(SERVICE *, char *, unsigned short);
|
extern int serviceHasProtocol(SERVICE *, char *, unsigned short);
|
||||||
extern void serviceAddBackend(SERVICE *, SERVER *);
|
extern void serviceAddBackend(SERVICE *, SERVER *);
|
||||||
extern int serviceHasBackend(SERVICE *, SERVER *);
|
extern int serviceHasBackend(SERVICE *, SERVER *);
|
||||||
@ -123,6 +126,7 @@ extern int serviceStop(SERVICE *);
|
|||||||
extern int serviceRestart(SERVICE *);
|
extern int serviceRestart(SERVICE *);
|
||||||
extern int serviceSetUser(SERVICE *, char *, char *);
|
extern int serviceSetUser(SERVICE *, char *, char *);
|
||||||
extern int serviceGetUser(SERVICE *, char **, char **);
|
extern int serviceGetUser(SERVICE *, char **, char **);
|
||||||
|
extern int serviceEnableRootUser(SERVICE *, int );
|
||||||
extern void service_update(SERVICE *, char *, char *, char *);
|
extern void service_update(SERVICE *, char *, char *, char *);
|
||||||
extern void printService(SERVICE *);
|
extern void printService(SERVICE *);
|
||||||
extern void printAllServices();
|
extern void printAllServices();
|
||||||
|
3
server/inih/.gitignore
vendored
Normal file
3
server/inih/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
make.depend
|
@ -49,9 +49,9 @@
|
|||||||
#include <router.h>
|
#include <router.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <users.h>
|
#include <users.h>
|
||||||
|
#include <version.h>
|
||||||
|
|
||||||
#define GW_VERSION "0.1.0"
|
#define GW_MYSQL_VERSION "MaxScale " MAXSCALE_VERSION
|
||||||
#define GW_MYSQL_VERSION "5.5.22-SKYSQL-" GW_VERSION
|
|
||||||
#define GW_MYSQL_LOOP_TIMEOUT 300000000
|
#define GW_MYSQL_LOOP_TIMEOUT 300000000
|
||||||
#define GW_MYSQL_READ 0
|
#define GW_MYSQL_READ 0
|
||||||
#define GW_MYSQL_WRITE 1
|
#define GW_MYSQL_WRITE 1
|
||||||
|
3
server/modules/monitor/.gitignore
vendored
Normal file
3
server/modules/monitor/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
depend.mk
|
3
server/modules/protocol/.gitignore
vendored
Normal file
3
server/modules/protocol/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
depend.mk
|
@ -38,6 +38,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <httpd.h>
|
#include <httpd.h>
|
||||||
|
#include <gw.h>
|
||||||
|
|
||||||
#define ISspace(x) isspace((int)(x))
|
#define ISspace(x) isspace((int)(x))
|
||||||
#define HTTP_SERVER_STRING "Gateway(c) v.1.0.0"
|
#define HTTP_SERVER_STRING "Gateway(c) v.1.0.0"
|
||||||
@ -364,23 +365,12 @@ static int
|
|||||||
httpd_listen(DCB *listener, char *config)
|
httpd_listen(DCB *listener, char *config)
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
char *port;
|
|
||||||
int one = 1;
|
int one = 1;
|
||||||
short pnum;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
memcpy(&listener->func, &MyObject, sizeof(GWPROTOCOL));
|
memcpy(&listener->func, &MyObject, sizeof(GWPROTOCOL));
|
||||||
|
if (!parse_bindconfig(config, 6442, &addr))
|
||||||
port = strrchr(config, ':');
|
return 0;
|
||||||
if (port)
|
|
||||||
port++;
|
|
||||||
else
|
|
||||||
port = "6442";
|
|
||||||
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
pnum = atoi(port);
|
|
||||||
addr.sin_port = htons(pnum);
|
|
||||||
|
|
||||||
if ((listener->fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
if ((listener->fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <skygw_utils.h>
|
#include <skygw_utils.h>
|
||||||
#include <log_manager.h>
|
#include <log_manager.h>
|
||||||
#include <mysql_client_server_protocol.h>
|
#include <mysql_client_server_protocol.h>
|
||||||
|
#include <gw.h>
|
||||||
|
|
||||||
extern int lm_enabled_logfiles_bitmask;
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
|
|
||||||
@ -793,42 +794,13 @@ int gw_MySQLListener(
|
|||||||
{
|
{
|
||||||
int l_so;
|
int l_so;
|
||||||
struct sockaddr_in serv_addr;
|
struct sockaddr_in serv_addr;
|
||||||
char *bind_address_and_port = NULL;
|
|
||||||
char *p;
|
|
||||||
char address[1024] = "";
|
|
||||||
int port = 0;
|
|
||||||
int one = 1;
|
int one = 1;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* this gateway, as default, will bind on port 4404 for localhost only */
|
/* this gateway, as default, will bind on port 4404 for localhost only */
|
||||||
if (config_bind != NULL) {
|
if (!parse_bindconfig(config_bind, 4406, &serv_addr))
|
||||||
bind_address_and_port = config_bind;
|
return 0;
|
||||||
} else {
|
|
||||||
bind_address_and_port = "127.0.0.1:4406";
|
|
||||||
}
|
|
||||||
listen_dcb->fd = -1;
|
listen_dcb->fd = -1;
|
||||||
memset(&serv_addr, 0, sizeof serv_addr);
|
|
||||||
serv_addr.sin_family = AF_INET;
|
|
||||||
p = strchr(bind_address_and_port, ':');
|
|
||||||
|
|
||||||
if (p) {
|
|
||||||
strncpy(address, bind_address_and_port, sizeof(address));
|
|
||||||
address[sizeof(address)-1] = '\0';
|
|
||||||
p = strchr(address, ':');
|
|
||||||
*p = '\0';
|
|
||||||
port = atoi(p+1);
|
|
||||||
setipaddress(&serv_addr.sin_addr, address);
|
|
||||||
|
|
||||||
snprintf(address,
|
|
||||||
(sizeof(address) - 1),
|
|
||||||
"%s",
|
|
||||||
inet_ntoa(serv_addr.sin_addr));
|
|
||||||
} else {
|
|
||||||
port = atoi(bind_address_and_port);
|
|
||||||
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
sprintf(address, "0.0.0.0");
|
|
||||||
}
|
|
||||||
serv_addr.sin_port = htons(port);
|
|
||||||
|
|
||||||
// socket create
|
// socket create
|
||||||
if ((l_so = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
if ((l_so = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||||
@ -852,7 +824,7 @@ int gw_MySQLListener(
|
|||||||
errno,
|
errno,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
fprintf(stderr, "* Can't bind to %s\n\n",
|
fprintf(stderr, "* Can't bind to %s\n\n",
|
||||||
bind_address_and_port);
|
config_bind);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -868,7 +840,7 @@ int gw_MySQLListener(
|
|||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Listening MySQL connections at %s\n",
|
"Listening MySQL connections at %s\n",
|
||||||
bind_address_and_port);
|
config_bind);
|
||||||
} else {
|
} else {
|
||||||
int eno = errno;
|
int eno = errno;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -1101,10 +1101,6 @@ int gw_find_mysql_user_password_sha1(char *username, uint8_t *gateway_password,
|
|||||||
SERVICE *service = NULL;
|
SERVICE *service = NULL;
|
||||||
char *user_password = NULL;
|
char *user_password = NULL;
|
||||||
|
|
||||||
if (strcmp(username , "root") == 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
service = (SERVICE *) ((DCB *)repository)->service;
|
service = (SERVICE *) ((DCB *)repository)->service;
|
||||||
|
|
||||||
user_password = (char *)users_fetch(service->users, username);
|
user_password = (char *)users_fetch(service->users, username);
|
||||||
|
@ -280,8 +280,6 @@ int n_connect = 0;
|
|||||||
socklen_t addrlen = sizeof(struct sockaddr);
|
socklen_t addrlen = sizeof(struct sockaddr);
|
||||||
DCB *client_dcb;
|
DCB *client_dcb;
|
||||||
TELNETD* telnetd_pr = NULL;
|
TELNETD* telnetd_pr = NULL;
|
||||||
dcb_state_t old_state = DCB_STATE_UNDEFINED;
|
|
||||||
bool succp = FALSE;
|
|
||||||
|
|
||||||
so = accept(dcb->fd, (struct sockaddr *)&addr, &addrlen);
|
so = accept(dcb->fd, (struct sockaddr *)&addr, &addrlen);
|
||||||
|
|
||||||
@ -354,23 +352,14 @@ static int
|
|||||||
telnetd_listen(DCB *listener, char *config)
|
telnetd_listen(DCB *listener, char *config)
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
char *port;
|
|
||||||
int one = 1;
|
int one = 1;
|
||||||
short pnum;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
memcpy(&listener->func, &MyObject, sizeof(GWPROTOCOL));
|
memcpy(&listener->func, &MyObject, sizeof(GWPROTOCOL));
|
||||||
|
|
||||||
port = strrchr(config, ':');
|
if (!parse_bindconfig(config, 4442, &addr))
|
||||||
if (port)
|
return 0;
|
||||||
port++;
|
|
||||||
else
|
|
||||||
port = "4442";
|
|
||||||
|
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
pnum = atoi(port);
|
|
||||||
addr.sin_port = htons(pnum);
|
|
||||||
|
|
||||||
if ((listener->fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
if ((listener->fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
{
|
{
|
||||||
|
3
server/modules/routing/.gitignore
vendored
Normal file
3
server/modules/routing/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
depend.mk
|
@ -177,6 +177,8 @@ CLI_SESSION *client;
|
|||||||
|
|
||||||
dcb_printf(session->client, "Welcome the SkySQL MaxScale Debug Interface (%s).\n",
|
dcb_printf(session->client, "Welcome the SkySQL MaxScale Debug Interface (%s).\n",
|
||||||
version_str);
|
version_str);
|
||||||
|
dcb_printf(session->client, "WARNING: This interface is meant for developer usage,\n");
|
||||||
|
dcb_printf(session->client, "passing incorrect addresses to commands can endanger your MaxScale server.\n\n");
|
||||||
dcb_printf(session->client, "Type help for a list of available commands.\n\n");
|
dcb_printf(session->client, "Type help for a list of available commands.\n\n");
|
||||||
|
|
||||||
return (void *)client;
|
return (void *)client;
|
||||||
|
3
server/modules/routing/readwritesplit/.gitignore
vendored
Normal file
3
server/modules/routing/readwritesplit/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.o
|
||||||
|
*.so
|
||||||
|
depend.mk
|
1
utils/.gitignore
vendored
Normal file
1
utils/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.o
|
Reference in New Issue
Block a user