Merge branch 'install_dir_change' into develop
Conflicts: CMakeLists.txt Documentation/Tutorials/Administration-Tutorial.md log_manager/CMakeLists.txt server/core/CMakeLists.txt server/core/gateway.c server/core/maxkeys.c server/core/maxpasswd.c server/modules/filter/test/CMakeLists.txt server/modules/routing/CMakeLists.txt
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
if(BUILD_TESTS OR BUILD_TOOLS)
|
||||
add_library(fullcore STATIC adminusers.c atomic.c config.c buffer.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.c modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c externcmd.c)
|
||||
add_library(fullcore STATIC adminusers.c atomic.c config.c buffer.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.c modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c gwdirs.c externcmd.c)
|
||||
if(WITH_JEMALLOC)
|
||||
target_link_libraries(fullcore ${JEMALLOC_LIBRARIES})
|
||||
elseif(WITH_TCMALLOC)
|
||||
@ -12,7 +12,7 @@ add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c
|
||||
gw_utils.c utils.c dcb.c load_utils.c session.c service.c server.c
|
||||
poll.c config.c users.c hashtable.c dbusers.c thread.c gwbitmask.c
|
||||
monitor.c adminusers.c secrets.c filter.c modutil.c hint.c
|
||||
housekeeper.c memlog.c resultset.c externcmd.c)
|
||||
housekeeper.c memlog.c resultset.c gwdirs.c externcmd.c)
|
||||
|
||||
if(WITH_JEMALLOC)
|
||||
target_link_libraries(maxscale ${JEMALLOC_LIBRARIES})
|
||||
@ -21,15 +21,15 @@ elseif(WITH_TCMALLOC)
|
||||
endif()
|
||||
|
||||
target_link_libraries(maxscale ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ${CURL_LIBRARIES} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++)
|
||||
install(TARGETS maxscale DESTINATION bin)
|
||||
install(TARGETS maxscale DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
add_executable(maxkeys maxkeys.c secrets.c utils.c)
|
||||
add_executable(maxkeys maxkeys.c secrets.c utils.c gwdirs.c)
|
||||
target_link_libraries(maxkeys log_manager utils pthread crypt crypto)
|
||||
install(TARGETS maxkeys DESTINATION bin)
|
||||
install(TARGETS maxkeys DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
add_executable(maxpasswd maxpasswd.c secrets.c utils.c)
|
||||
add_executable(maxpasswd maxpasswd.c secrets.c utils.c gwdirs.c)
|
||||
target_link_libraries(maxpasswd log_manager utils pthread crypt crypto)
|
||||
install(TARGETS maxpasswd DESTINATION bin)
|
||||
install(TARGETS maxpasswd DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <adminusers.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -119,12 +120,7 @@ char fname[1024], *home;
|
||||
char uname[80], passwd[80];
|
||||
|
||||
initialise();
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL && strlen(home) < 1024){
|
||||
sprintf(fname, "%s/etc/passwd", home);
|
||||
}
|
||||
else{
|
||||
sprintf(fname, "/usr/local/mariadb-maxscale/etc/passwd");
|
||||
}
|
||||
sprintf(fname, "%s/passwd", get_datadir());
|
||||
if ((fp = fopen(fname, "r")) == NULL)
|
||||
return NULL;
|
||||
if ((rval = users_alloc()) == NULL)
|
||||
@ -155,12 +151,7 @@ FILE *fp;
|
||||
char fname[1024], *home, *cpasswd;
|
||||
|
||||
initialise();
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL && strlen(home) < 1024){
|
||||
sprintf(fname, "%s/etc/passwd", home);
|
||||
}
|
||||
else{
|
||||
sprintf(fname, "/usr/local/mariadb-maxscale/etc/passwd");
|
||||
}
|
||||
sprintf(fname, "%s/passwd", get_datadir());
|
||||
|
||||
if (users == NULL)
|
||||
{
|
||||
@ -253,15 +244,8 @@ char* admin_remove_user(
|
||||
/**
|
||||
* Open passwd file and remove user from the file.
|
||||
*/
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL &&
|
||||
strnlen(home,PATH_MAX) < PATH_MAX &&
|
||||
strnlen(home,PATH_MAX) > 0) {
|
||||
sprintf(fname, "%s/etc/passwd", home);
|
||||
sprintf(fname_tmp, "%s/etc/passwd_tmp", home);
|
||||
} else {
|
||||
sprintf(fname, "/usr/local/mariadb-maxscale/etc/passwd");
|
||||
sprintf(fname_tmp, "/usr/local/mariadb-maxscale/etc/passwd_tmp");
|
||||
}
|
||||
sprintf(fname, "%s/passwd", get_datadir());
|
||||
sprintf(fname_tmp, "%s/passwd_tmp", get_datadir());
|
||||
/**
|
||||
* Rewrite passwd file from memory.
|
||||
*/
|
||||
|
@ -74,6 +74,8 @@
|
||||
|
||||
#include <execinfo.h>
|
||||
|
||||
#include <ini.h>
|
||||
|
||||
/** for procname */
|
||||
#if !defined(_GNU_SOURCE)
|
||||
# define _GNU_SOURCE
|
||||
@ -111,8 +113,6 @@ static char* server_options[] = {
|
||||
|
||||
const int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
|
||||
|
||||
const char* default_cnf_fname = "etc/MaxScale.cnf";
|
||||
|
||||
static char* server_groups[] = {
|
||||
"embedded",
|
||||
"server",
|
||||
@ -125,10 +125,11 @@ static char* server_groups[] = {
|
||||
|
||||
/* The data directory we created for this gateway instance */
|
||||
static char datadir[PATH_MAX+1] = "";
|
||||
|
||||
static bool datadir_defined = false; /*< If the datadir was already set */
|
||||
/* The data directory we created for this gateway instance */
|
||||
static char pidfile[PATH_MAX+1] = "";
|
||||
|
||||
|
||||
/**
|
||||
* exit flag for log flusher.
|
||||
*/
|
||||
@ -150,13 +151,20 @@ static struct option long_options[] = {
|
||||
{"config", required_argument, 0, 'f'},
|
||||
{"nodaemon", no_argument, 0, 'd'},
|
||||
{"log", required_argument, 0, 'l'},
|
||||
{"logdir", required_argument, 0, 'L'},
|
||||
{"datadir", required_argument, 0, 'D'},
|
||||
{"configdir",required_argument, 0, 'C'},
|
||||
{"libdir",required_argument, 0, 'B'},
|
||||
{"cachedir",required_argument, 0, 'A'},
|
||||
{"language",required_argument, 0, 'N'},
|
||||
{"syslog", required_argument, 0, 's'},
|
||||
{"maxscalelog", required_argument, 0, 'S'},
|
||||
{"maxscalelog",required_argument,0,'S'},
|
||||
{"user",required_argument,0,'U'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, '?'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static int cnf_preparser(void* data, const char* section, const char* name, const char* value);
|
||||
static void log_flush_shutdown(void);
|
||||
static void log_flush_cb(void* arg);
|
||||
static int write_pid_file(char *); /* write MaxScale pidfile */
|
||||
@ -168,6 +176,7 @@ static void write_footer(void);
|
||||
static int ntfw_cb(const char*, const struct stat*, int, struct FTW*);
|
||||
static bool file_is_readable(char* absolute_pathname);
|
||||
static bool file_is_writable(char* absolute_pathname);
|
||||
bool handle_path_arg(char** dest, char* path, char* arg, bool rd, bool wr);
|
||||
static void usage(void);
|
||||
static char* get_expanded_pathname(
|
||||
char** abs_path,
|
||||
@ -183,10 +192,9 @@ static bool resolve_maxscale_conf_fname(
|
||||
char** cnf_full_path,
|
||||
char* home_dir,
|
||||
char* cnf_file_arg);
|
||||
static bool resolve_maxscale_homedir(
|
||||
char** p_home_dir);
|
||||
|
||||
static char* check_dir_access(char* dirname);
|
||||
static char* check_dir_access(char* dirname,bool,bool);
|
||||
static int set_user();
|
||||
|
||||
/**
|
||||
* Handler for SIGHUP signal. Reload the configuration for the
|
||||
@ -356,11 +364,10 @@ void datadir_cleanup()
|
||||
{
|
||||
int depth = 1;
|
||||
int flags = FTW_CHDIR|FTW_DEPTH|FTW_MOUNT;
|
||||
int rc;
|
||||
|
||||
if (datadir[0] != 0 && access(datadir, F_OK) == 0)
|
||||
{
|
||||
rc = nftw(datadir, ntfw_cb, depth, flags);
|
||||
nftw(datadir, ntfw_cb, depth, flags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,14 +388,13 @@ static bool file_write_footer(
|
||||
FILE* outfile)
|
||||
{
|
||||
bool succp = false;
|
||||
size_t wbytes1;
|
||||
size_t len1;
|
||||
const char* header_buf1;
|
||||
|
||||
header_buf1 = "------------------------------------------------------"
|
||||
"\n\n";
|
||||
len1 = strlen(header_buf1);
|
||||
wbytes1=fwrite((void*)header_buf1, len1, 1, outfile);
|
||||
fwrite((void*)header_buf1, len1, 1, outfile);
|
||||
|
||||
succp = true;
|
||||
|
||||
@ -399,9 +405,6 @@ static bool file_write_header(
|
||||
FILE* outfile)
|
||||
{
|
||||
bool succp = false;
|
||||
size_t wbytes1;
|
||||
size_t wbytes2;
|
||||
size_t wbytes3;
|
||||
size_t len1;
|
||||
size_t len2;
|
||||
size_t len3;
|
||||
@ -445,9 +448,9 @@ static bool file_write_header(
|
||||
#if defined(LAPTOP_TEST)
|
||||
nanosleep(&ts1, NULL);
|
||||
#else
|
||||
wbytes1=fwrite((void*)header_buf1, len1, 1, outfile);
|
||||
wbytes2=fwrite((void*)header_buf2, len2, 1, outfile);
|
||||
wbytes3=fwrite((void*)header_buf3, len3, 1, outfile);
|
||||
fwrite((void*)header_buf1, len1, 1, outfile);
|
||||
fwrite((void*)header_buf2, len2, 1, outfile);
|
||||
fwrite((void*)header_buf3, len3, 1, outfile);
|
||||
#endif
|
||||
|
||||
succp = true;
|
||||
@ -490,15 +493,9 @@ static bool resolve_maxscale_conf_fname(
|
||||
* directory.
|
||||
* '-f MaxScale.cnf'
|
||||
*/
|
||||
home_etc_dir = (char*)malloc(strlen(home_dir)+strlen("/etc")+1);
|
||||
snprintf(home_etc_dir,
|
||||
strlen(home_dir)+strlen("/etc")+1,
|
||||
"%s/etc",
|
||||
home_dir);
|
||||
*cnf_full_path = get_expanded_pathname(NULL,
|
||||
home_etc_dir,
|
||||
home_dir,
|
||||
cnf_file_arg);
|
||||
free(home_etc_dir);
|
||||
|
||||
if (*cnf_full_path != NULL)
|
||||
{
|
||||
@ -577,149 +574,6 @@ return_succp:
|
||||
return succp;
|
||||
}
|
||||
|
||||
|
||||
static bool resolve_maxscale_homedir(
|
||||
char** p_home_dir)
|
||||
{
|
||||
bool succp = false;
|
||||
char* tmp;
|
||||
char* tmp2;
|
||||
char* log_context = NULL;
|
||||
|
||||
ss_dassert(*p_home_dir == NULL);
|
||||
|
||||
if (*p_home_dir != NULL)
|
||||
{
|
||||
log_context = strdup("Command-line argument");
|
||||
tmp = NULL;
|
||||
goto check_home_dir;
|
||||
}
|
||||
/*<
|
||||
* 1. if home dir wasn't specified by a command-line argument,
|
||||
* read env. variable MAXSCALE_HOME.
|
||||
*/
|
||||
if (getenv("MAXSCALE_HOME") != NULL)
|
||||
{
|
||||
tmp = strndup(getenv("MAXSCALE_HOME"), PATH_MAX);
|
||||
get_expanded_pathname(p_home_dir, tmp, NULL);
|
||||
|
||||
if (*p_home_dir != NULL)
|
||||
{
|
||||
log_context = strdup("MAXSCALE_HOME");
|
||||
goto check_home_dir;
|
||||
}
|
||||
free(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "\n*\n* Warning : MAXSCALE_HOME environment variable "
|
||||
"is not set.\n*\n");
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Warning : MAXSCALE_HOME environment "
|
||||
"variable is not set.")));
|
||||
}
|
||||
/*<
|
||||
* 2. if home dir wasn't specified in MAXSCALE_HOME,
|
||||
* try access /etc/MaxScale/
|
||||
*/
|
||||
tmp = strdup("/etc/MaxScale");
|
||||
get_expanded_pathname(p_home_dir, tmp, NULL);
|
||||
|
||||
if (*p_home_dir != NULL)
|
||||
{
|
||||
log_context = strdup("/etc/MaxScale");
|
||||
goto check_home_dir;
|
||||
}
|
||||
free(tmp);
|
||||
/*<
|
||||
* 3. if /etc/MaxScale/MaxScale.cnf didn't exist or wasn't accessible, home
|
||||
* isn't specified. Thus, try to access $PWD/MaxScale.cnf .
|
||||
*/
|
||||
char *pwd = getenv("PWD");
|
||||
tmp = strndup(pwd ? pwd : "PWD_NOT_SET", PATH_MAX);
|
||||
tmp2 = get_expanded_pathname(p_home_dir, tmp, default_cnf_fname);
|
||||
free(tmp2); /*< full path isn't needed so simply free it */
|
||||
|
||||
if (*p_home_dir != NULL)
|
||||
{
|
||||
log_context = strdup("Current working directory");
|
||||
}
|
||||
|
||||
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 WRITABLE_HOME
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
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 (log_context != NULL)
|
||||
{
|
||||
free(log_context);
|
||||
}
|
||||
|
||||
if (!succp)
|
||||
{
|
||||
char* logstr = "MaxScale was unable to locate home directory "
|
||||
"with read and write permissions. \n*\n* Exiting.";
|
||||
print_log_n_stderr(true, true, logstr, logstr, 0);
|
||||
usage();
|
||||
}
|
||||
return succp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check read and write accessibility to a directory.
|
||||
* @param dirname directory to be checked
|
||||
@ -728,8 +582,9 @@ return_succp:
|
||||
* read or write is not permitted.
|
||||
*/
|
||||
static char* check_dir_access(
|
||||
char* dirname)
|
||||
char* dirname, bool rd, bool wr)
|
||||
{
|
||||
char errbuf[PATH_MAX*2];
|
||||
char* errstr = NULL;
|
||||
|
||||
if (dirname == NULL)
|
||||
@ -737,18 +592,27 @@ static char* check_dir_access(
|
||||
errstr = strdup("Directory argument is NULL");
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
if (!file_is_readable(dirname))
|
||||
|
||||
if(access(dirname,F_OK) != 0)
|
||||
{
|
||||
errstr = strdup("MaxScale doesn't have read permission "
|
||||
"to MAXSCALE_HOME.");
|
||||
sprintf(errbuf,"Can't access '%s'.",dirname);
|
||||
errstr = strdup(errbuf);
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
if (rd && !file_is_readable(dirname))
|
||||
{
|
||||
sprintf(errbuf,"MaxScale doesn't have read permission "
|
||||
"to '%s'.",dirname);
|
||||
errstr = strdup(errbuf);
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
if (!file_is_writable(dirname))
|
||||
if (wr && !file_is_writable(dirname))
|
||||
{
|
||||
errstr = strdup("MaxScale doesn't have write permission "
|
||||
"to MAXSCALE_HOME. Exiting.");
|
||||
sprintf(errbuf,"MaxScale doesn't have write permission "
|
||||
"to '%s'.",dirname);
|
||||
errstr = strdup(errbuf);
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
@ -991,19 +855,27 @@ return_cnf_file_buf:
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"\nUsage : %s [-h] | [-d] [-c <home directory>] [-f <config file name>]\n\n"
|
||||
" -d|--nodaemon enable running in terminal process (default:disabled)\n"
|
||||
" -c|--homedir=... relative|absolute MaxScale home directory\n"
|
||||
" -f|--config=... relative|absolute pathname of MaxScale configuration file\n"
|
||||
" (default: $MAXSCALE_HOME/etc/MaxScale.cnf)\n"
|
||||
" -l|--log=... log to file shared memory or stdout\n"
|
||||
" -lfile, -lshm or -lstdout - defaults to shared memory\n"
|
||||
" -s|--syslog= log messages to syslog."
|
||||
" True or false - defaults to true\n"
|
||||
" -S|--maxscalelog= log messages to MaxScale log."
|
||||
" True or false - defaults to true\n"
|
||||
" -v|--version print version info and exit\n"
|
||||
" -?|--help show this help\n"
|
||||
"\nUsage : %s [OPTION]...\n\n"
|
||||
" -d, --nodaemon enable running in terminal process (default:disabled)\n"
|
||||
" -f, --config=FILE relative|absolute pathname of MaxScale configuration file\n"
|
||||
" (default:/etc/maxscale.cnf)\n"
|
||||
" -l, --log=[file|shm] log to file or shared memory (default: shm)\n"
|
||||
" -L, --logdir=PATH path to log file directory\n"
|
||||
" (default: /var/log/maxscale)\n"
|
||||
" -A, --cachedir=PATH path to cache directory\n"
|
||||
" (default: /var/cache/maxscale)\n"
|
||||
" -B, --libdir=PATH path to module directory\n"
|
||||
" (default: /usr/lib64/maxscale)\n"
|
||||
" -C, --configdir=PATH path to configuration file directory\n"
|
||||
" (default: /etc/)\n"
|
||||
" -D, --datadir=PATH path to data directory, stored embedded mysql tables\n"
|
||||
" (default: /var/cache/maxscale)\n"
|
||||
" -U, --user=USER run MaxScale as another user.\n"
|
||||
" The user ID and group ID of this user are used to run MaxScale.\n"
|
||||
" -s, --syslog=[yes|no] log messages to syslog (default:yes)\n"
|
||||
" -S, --maxscalelog=[yes|no] log messages to MaxScale log (default: yes)\n"
|
||||
" -v, --version print version info and exit\n"
|
||||
" -?, --help show this help\n"
|
||||
, progname);
|
||||
}
|
||||
|
||||
@ -1028,19 +900,13 @@ static void usage(void)
|
||||
* This is not obvious solution because stderr is often directed to somewhere,
|
||||
* but currently this is the case.
|
||||
*
|
||||
* The configuration file is by default \<maxscale home\>/etc/MaxScale.cnf
|
||||
* The configuration file is by default /etc/maxscale.cnf
|
||||
* The name of configuration file and its location can be specified by
|
||||
* command-line argument.
|
||||
*
|
||||
* \<maxscale home\> is resolved in the following order:
|
||||
* 1. from '-c <dir>' command-line argument
|
||||
* 2. from MAXSCALE_HOME environment variable
|
||||
* 3. /etc/ if MaxScale.cnf is found from there
|
||||
* 4. current working directory if MaxScale.cnf is found from there
|
||||
*
|
||||
* \<config filename\> is resolved in the following order:
|
||||
* 1. from '-f \<config filename\>' command-line argument
|
||||
* 2. by using default value "MaxScale.cnf"
|
||||
* 2. by using default value "maxscale.cnf"
|
||||
*
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
@ -1062,9 +928,10 @@ int main(int argc, char **argv)
|
||||
char* cnf_file_path = NULL; /*< conf file, to be freed */
|
||||
char* cnf_file_arg = NULL; /*< conf filename from cmd-line arg */
|
||||
void* log_flush_thr = NULL;
|
||||
char* tmp_path;
|
||||
char* tmp_var;
|
||||
int option_index;
|
||||
int logtofile = 0; /* Use shared memory or file */
|
||||
int logtostdout = 0; /* Use stdout for log output */
|
||||
int syslog_enabled = 1; /** Log to syslog */
|
||||
int maxscalelog_enabled = 1; /** Log with MaxScale */
|
||||
ssize_t log_flush_timeout_ms = 0;
|
||||
@ -1075,11 +942,13 @@ int main(int argc, char **argv)
|
||||
datadir_cleanup,
|
||||
write_footer,
|
||||
NULL};
|
||||
|
||||
|
||||
|
||||
sigemptyset(&sigpipe_mask);
|
||||
sigaddset(&sigpipe_mask, SIGPIPE);
|
||||
|
||||
progname = *argv;
|
||||
|
||||
sprintf(datadir, "%s", default_datadir);
|
||||
#if defined(FAKE_CODE)
|
||||
memset(conn_open, 0, sizeof(bool)*10240);
|
||||
memset(dcb_fake_write_errno, 0, sizeof(unsigned char)*10240);
|
||||
@ -1106,7 +975,8 @@ int main(int argc, char **argv)
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
while ((opt = getopt_long(argc, argv, "dc:f:l:vs:S:?",
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "dc:f:l:vs:S:?L:D:C:B:U:A:",
|
||||
long_options, &option_index)) != -1)
|
||||
{
|
||||
bool succp = true;
|
||||
@ -1116,56 +986,6 @@ int main(int argc, char **argv)
|
||||
/*< Debug mode, maxscale runs in this same process */
|
||||
daemon_mode = false;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
/*<
|
||||
* Create absolute path pointing to MaxScale home
|
||||
* directory. User-provided home directory may be
|
||||
* either absolute or relative. If latter, it is
|
||||
* expanded and stored in home_dir if succeed.
|
||||
*/
|
||||
if (optarg[0] != '-')
|
||||
{
|
||||
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)
|
||||
{
|
||||
/*<
|
||||
* MAXSCALE_HOME is set.
|
||||
* It is used to assist in finding the modules
|
||||
* to be loaded into MaxScale.
|
||||
*/
|
||||
setenv("MAXSCALE_HOME", home_dir, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* logerr = "Home directory argument "
|
||||
"identifier \'-c\' was specified but "
|
||||
"the argument didn't specify \n a valid "
|
||||
"home directory or the argument was "
|
||||
"missing.";
|
||||
print_log_n_stderr(true, true, logerr, logerr, 0);
|
||||
usage();
|
||||
succp = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
/*<
|
||||
@ -1199,8 +1019,6 @@ int main(int argc, char **argv)
|
||||
logtofile = 1;
|
||||
else if (strncasecmp(optarg, "shm", PATH_MAX) == 0)
|
||||
logtofile = 0;
|
||||
else if (strncasecmp(optarg, "stdout", PATH_MAX) == 0)
|
||||
logtostdout = 1;
|
||||
else
|
||||
{
|
||||
char* logerr = "Configuration file argument "
|
||||
@ -1213,6 +1031,43 @@ int main(int argc, char **argv)
|
||||
succp = false;
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
|
||||
if(handle_path_arg(&tmp_path,optarg,NULL,true,false))
|
||||
{
|
||||
logdir = tmp_path;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'N':
|
||||
if(handle_path_arg(&tmp_path,optarg,NULL,true,false))
|
||||
{
|
||||
langdir = tmp_path;
|
||||
}
|
||||
break;
|
||||
case 'D':
|
||||
sprintf(datadir,"%s",optarg);
|
||||
maxscaledatadir = strdup(optarg);
|
||||
datadir_defined = true;
|
||||
break;
|
||||
case 'C':
|
||||
if(handle_path_arg(&tmp_path,optarg,NULL,true,false))
|
||||
{
|
||||
configdir = tmp_path;
|
||||
}
|
||||
break;
|
||||
case 'B':
|
||||
if(handle_path_arg(&tmp_path,optarg,NULL,true,false))
|
||||
{
|
||||
libdir = tmp_path;
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
if(handle_path_arg(&tmp_path,optarg,NULL,true,true))
|
||||
{
|
||||
cachedir = tmp_path;
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
if(strstr(optarg,"="))
|
||||
{
|
||||
@ -1235,6 +1090,12 @@ int main(int argc, char **argv)
|
||||
syslog_enabled = config_truth_value(optarg);
|
||||
}
|
||||
break;
|
||||
case 'U':
|
||||
if(set_user(optarg) != 0)
|
||||
{
|
||||
succp = false;
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
rc = EXIT_SUCCESS;
|
||||
@ -1514,88 +1375,64 @@ int main(int argc, char **argv)
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
/*<
|
||||
* If MaxScale home directory wasn't set by command-line argument.
|
||||
* Next, resolve it from environment variable and further on,
|
||||
* try to use default.
|
||||
/**
|
||||
* Resolve the full pathname for configuration file and check for
|
||||
* read accessibility.
|
||||
*/
|
||||
if (home_dir == NULL)
|
||||
char pathbuf[PATH_MAX+1];
|
||||
snprintf(pathbuf,PATH_MAX,"%s",configdir ? configdir:default_configdir);
|
||||
if(pathbuf[strlen(pathbuf)-1] != '/')
|
||||
strcat(pathbuf,"/");
|
||||
|
||||
if (!resolve_maxscale_conf_fname(&cnf_file_path, pathbuf, cnf_file_arg))
|
||||
{
|
||||
if (!resolve_maxscale_homedir(&home_dir))
|
||||
{
|
||||
ss_dassert(home_dir != NULL);
|
||||
rc = MAXSCALE_HOMELESS;
|
||||
goto return_main;
|
||||
}
|
||||
sprintf(mysql_home, "%s/mysql", home_dir);
|
||||
setenv("MYSQL_HOME", mysql_home, 1);
|
||||
ss_dassert(cnf_file_path == NULL);
|
||||
rc = MAXSCALE_BADCONFIG;
|
||||
goto return_main;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
ini_parse(cnf_file_path,cnf_preparser,NULL);
|
||||
|
||||
if(!datadir_defined)
|
||||
sprintf(datadir,"%s",default_datadir);
|
||||
|
||||
|
||||
/** Use the cache dir for the mysql folder of the embedded library */
|
||||
sprintf(mysql_home, "%s/mysql", cachedir?cachedir:default_cachedir);
|
||||
setenv("MYSQL_HOME", mysql_home, 1);
|
||||
|
||||
|
||||
/**
|
||||
* Init Log Manager for MaxScale.
|
||||
* If $MAXSCALE_HOME is set then write the logs into $MAXSCALE_HOME/log.
|
||||
* The skygw_logmanager_init expects to take arguments as passed to main
|
||||
* and proesses them with getopt, therefore we need to give it a dummy
|
||||
* argv[0]
|
||||
*/
|
||||
{
|
||||
char buf[1024];
|
||||
char *argv[9];
|
||||
char *argv[8];
|
||||
bool succp;
|
||||
/** Set log directory under $MAXSCALE_HOME/log */
|
||||
sprintf(buf, "%s/log", home_dir);
|
||||
|
||||
if(mkdir(buf, 0777) != 0)
|
||||
/** Use default log directory /var/log/maxscale/ */
|
||||
if(logdir == NULL)
|
||||
{
|
||||
if(errno != EEXIST)
|
||||
|
||||
if(access(default_logdir,F_OK) != 0)
|
||||
{
|
||||
if(mkdir(logdir,0555) != 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create log directory: %s\n",
|
||||
buf);
|
||||
goto return_main;
|
||||
fprintf(stderr,
|
||||
"Error: Cannot create log directory: %s\n",
|
||||
default_logdir);
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
logdir = strdup(default_logdir);
|
||||
}
|
||||
|
||||
argv[0] = "MaxScale";
|
||||
argv[1] = "-j";
|
||||
argv[2] = buf;
|
||||
argv[2] = logdir;
|
||||
|
||||
if(!syslog_enabled)
|
||||
{
|
||||
@ -1608,17 +1445,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
logmanager_enable_syslog(syslog_enabled);
|
||||
logmanager_enable_maxscalelog(maxscalelog_enabled);
|
||||
if (logtostdout)
|
||||
{
|
||||
argv[3] = "-s"; /*< store to shared memory */
|
||||
argv[4] = "LOGFILE_DEBUG,LOGFILE_TRACE"; /*< to shm */
|
||||
argv[5] = "-l"; /*< write to syslog */
|
||||
argv[6] = "LOGFILE_MESSAGE,LOGFILE_ERROR"; /*< to syslog */
|
||||
argv[7] = "-o";
|
||||
argv[8] = NULL;
|
||||
succp = skygw_logmanager_init(8, argv);
|
||||
}
|
||||
else if (logtofile)
|
||||
|
||||
if (logtofile)
|
||||
{
|
||||
argv[3] = "-l"; /*< write to syslog */
|
||||
/** Logs that should be syslogged */
|
||||
@ -1643,25 +1471,25 @@ int main(int argc, char **argv)
|
||||
goto return_main;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Resolve the full pathname for configuration file and check for
|
||||
* read accessibility.
|
||||
*/
|
||||
if (!resolve_maxscale_conf_fname(&cnf_file_path, home_dir, cnf_file_arg))
|
||||
{
|
||||
ss_dassert(cnf_file_path == NULL);
|
||||
rc = MAXSCALE_BADCONFIG;
|
||||
goto return_main;
|
||||
}
|
||||
|
||||
/*<
|
||||
|
||||
|
||||
if(cachedir == NULL)
|
||||
cachedir = strdup(default_cachedir);
|
||||
if(langdir == NULL)
|
||||
langdir = strdup(default_langdir);
|
||||
if(libdir == NULL)
|
||||
libdir = strdup(default_libdir);
|
||||
/**
|
||||
* Set a data directory for the mysqld library, we use
|
||||
* a unique directory name to avoid clauses if multiple
|
||||
* instances of the gateway are beign run on the same
|
||||
* machine.
|
||||
*/
|
||||
sprintf(datadir, "%s/data", home_dir);
|
||||
|
||||
if(datadir[strlen(datadir)-1] != '/')
|
||||
strcat(datadir,"/");
|
||||
strcat(datadir,"data");
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
|
||||
if(errno != EEXIST){
|
||||
@ -1671,7 +1499,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(datadir, "%s/data/data%d", home_dir, getpid());
|
||||
sprintf(datadir, "%s/data%d", datadir, getpid());
|
||||
|
||||
if(mkdir(datadir, 0777) != 0){
|
||||
|
||||
@ -1685,31 +1513,41 @@ int main(int argc, char **argv)
|
||||
if (!daemon_mode)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Home directory : %s"
|
||||
"\nConfiguration file : %s"
|
||||
"\nLog directory : %s/log"
|
||||
"\nData directory : %s\n\n",
|
||||
home_dir,
|
||||
"Configuration file : %s\n"
|
||||
"Log directory : %s\n"
|
||||
"Data directory : %s\n"
|
||||
"Module directory : %s\n"
|
||||
"Service cache : %s\n\n",
|
||||
cnf_file_path,
|
||||
home_dir,
|
||||
datadir);
|
||||
logdir,
|
||||
datadir,
|
||||
libdir,
|
||||
cachedir);
|
||||
}
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Home directory : %s",
|
||||
home_dir)));
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Data directory : %s",
|
||||
datadir)));
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Log directory : %s/log",
|
||||
home_dir)));
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Configuration file : %s",
|
||||
cnf_file_path)));
|
||||
|
||||
LOGIF(LM,
|
||||
(skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Configuration file: %s",
|
||||
cnf_file_path)));
|
||||
LOGIF(LM,
|
||||
(skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Log directory: %s/",
|
||||
logdir)));
|
||||
LOGIF(LM,
|
||||
(skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Data directory: %s",
|
||||
datadir)));
|
||||
LOGIF(LM,
|
||||
(skygw_log_write_flush(LOGFILE_MESSAGE,
|
||||
"Module directory: %s",
|
||||
libdir)));
|
||||
LOGIF(LM,
|
||||
(skygw_log_write_flush(LOGFILE_MESSAGE,
|
||||
"Service cache: %s",
|
||||
cachedir)));
|
||||
|
||||
/*< Update the server options */
|
||||
for (i = 0; server_options[i]; i++)
|
||||
@ -1723,8 +1561,8 @@ int main(int argc, char **argv)
|
||||
{
|
||||
snprintf(language_arg,
|
||||
11+PATH_MAX+1,
|
||||
"--language=%s/mysql",
|
||||
home_dir);
|
||||
"--language=%s",
|
||||
langdir);
|
||||
server_options[i] = language_arg;
|
||||
}
|
||||
}
|
||||
@ -1780,10 +1618,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
libmysqld_started = TRUE;
|
||||
|
||||
if(libdir == NULL)
|
||||
libdir = strdup(default_libdir);
|
||||
|
||||
if (!config_load(cnf_file_path))
|
||||
{
|
||||
char* fprerr = "Failed to load MaxScale configuration "
|
||||
"file. Exiting.";
|
||||
"file. Exiting. See the error log for details.";
|
||||
print_log_n_stderr(false, !daemon_mode, fprerr, fprerr, 0);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
@ -1980,7 +1821,7 @@ static int write_pid_file(char *home_dir) {
|
||||
|
||||
int fd = -1;
|
||||
|
||||
snprintf(pidfile, PATH_MAX, "%s/log/maxscale.pid", home_dir);
|
||||
snprintf(pidfile, PATH_MAX, "%smaxscale.pid",default_piddir);
|
||||
|
||||
fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
||||
if (fd == -1) {
|
||||
@ -2015,3 +1856,135 @@ MaxScaleUptime()
|
||||
{
|
||||
return time(0) - MaxScaleStarted;
|
||||
}
|
||||
|
||||
bool handle_path_arg(char** dest, char* path, char* arg, bool rd, bool wr)
|
||||
{
|
||||
char pathbuffer[PATH_MAX+2];
|
||||
char* errstr;
|
||||
bool rval = false;
|
||||
|
||||
if(path == NULL && arg == NULL)
|
||||
return rval;
|
||||
|
||||
if(path)
|
||||
{
|
||||
snprintf(pathbuffer,PATH_MAX,"%s",path);
|
||||
if(pathbuffer[strlen(path) - 1] != '/')
|
||||
{
|
||||
strcat(pathbuffer,"/");
|
||||
}
|
||||
if(arg && strlen(pathbuffer) + strlen(arg) + 1 < PATH_MAX)
|
||||
strcat(pathbuffer,arg);
|
||||
|
||||
if((errstr = check_dir_access(pathbuffer,rd,wr)) == NULL)
|
||||
{
|
||||
*dest = strdup(pathbuffer);
|
||||
rval = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"%s\n",errstr);
|
||||
free(errstr);
|
||||
errstr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-parse the MaxScale.cnf for config, log and module directories.
|
||||
* @param data Parameter passed by inih
|
||||
* @param section Section name
|
||||
* @param name Parameter name
|
||||
* @param value Parameter value
|
||||
* @return 1 in all cases
|
||||
*/
|
||||
static int cnf_preparser(void* data, const char* section, const char* name, const char* value)
|
||||
{
|
||||
|
||||
char pathbuffer[PATH_MAX];
|
||||
char* errstr;
|
||||
|
||||
/** These are read from the configuration file. These will not override
|
||||
* command line parameters but will override default values. */
|
||||
if(strcasecmp(section,"maxscale") == 0)
|
||||
{
|
||||
if(strcmp(name, "logdir") == 0)
|
||||
{
|
||||
if(logdir == NULL)
|
||||
handle_path_arg(&logdir,(char*)value,NULL,true,true);
|
||||
}
|
||||
else if(strcmp(name, "libdir") == 0)
|
||||
{
|
||||
if(libdir == NULL)
|
||||
handle_path_arg(&libdir,(char*)value,NULL,true,false);
|
||||
}
|
||||
else if(strcmp(name, "datadir") == 0)
|
||||
{
|
||||
if(!datadir_defined)
|
||||
{
|
||||
char* tmp;
|
||||
if(handle_path_arg(&tmp,(char*)value,NULL,true,false))
|
||||
{
|
||||
sprintf(datadir,"%s",tmp);
|
||||
maxscaledatadir = strdup(tmp);
|
||||
datadir_defined = true;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strcmp(name, "cachedir") == 0)
|
||||
{
|
||||
if(cachedir == NULL)
|
||||
handle_path_arg((char**)&cachedir,(char*)value,NULL,true,false);
|
||||
}
|
||||
else if(strcmp(name, "language") == 0)
|
||||
{
|
||||
if(langdir == NULL)
|
||||
handle_path_arg((char**)&langdir,(char*)value,NULL,true,false);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int set_user(char* user)
|
||||
{
|
||||
errno = 0;
|
||||
struct passwd *pwname;
|
||||
int rval;
|
||||
|
||||
pwname = getpwnam(user);
|
||||
if(pwname == NULL)
|
||||
{
|
||||
printf("Error: Failed to retrieve user information for '%s': %d %s\n",
|
||||
user,errno,errno == 0 ? "User not found" : strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
rval = setgid(pwname->pw_gid);
|
||||
if(rval != 0)
|
||||
{
|
||||
printf("Error: Failed to change group to '%d': %d %s\n",
|
||||
pwname->pw_gid,errno,strerror(errno));
|
||||
return rval;
|
||||
}
|
||||
|
||||
rval = setuid(pwname->pw_uid);
|
||||
if(rval != 0)
|
||||
{
|
||||
printf("Error: Failed to change user to '%s': %d %s\n",
|
||||
pwname->pw_name,errno,strerror(errno));
|
||||
return rval;
|
||||
}
|
||||
#ifdef SS_DEBUG
|
||||
else
|
||||
{
|
||||
printf("Running MaxScale as: %s %d:%d\n",pwname->pw_name,pwname->pw_uid,pwname->pw_gid);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
29
server/core/gwdirs.c
Normal file
29
server/core/gwdirs.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include <gwdirs.h>
|
||||
|
||||
/**
|
||||
* Get the directory with all the modules.
|
||||
* @return The module directory
|
||||
*/
|
||||
char* get_libdir()
|
||||
{
|
||||
return libdir?libdir:(char*)default_libdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the service cache directory
|
||||
* @return The path to the cache directory
|
||||
*/
|
||||
char* get_cachedir()
|
||||
{
|
||||
return cachedir?cachedir:(char*)default_cachedir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the service cache directory
|
||||
* @return The path to the cache directory
|
||||
*/
|
||||
char* get_datadir()
|
||||
{
|
||||
return maxscaledatadir?maxscaledatadir:(char*)default_datadir;
|
||||
}
|
@ -48,6 +48,8 @@
|
||||
#include <curl/curl.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <gw.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -104,21 +106,10 @@ WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
return realsize;
|
||||
}
|
||||
|
||||
char* get_maxscale_home(void)
|
||||
{
|
||||
char* home = getenv("MAXSCALE_HOME");
|
||||
if (home == NULL)
|
||||
{
|
||||
home = "/usr/local/mariadb-maxscale";
|
||||
}
|
||||
return home;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the dynamic library related to a gateway module. The routine
|
||||
* will look for library files in the current directory,
|
||||
* $MAXSCALE_HOME/modules and /usr/local/mariadb-maxscale/modules.
|
||||
* the configured folder and /usr/lib64/maxscale.
|
||||
*
|
||||
* @param module Name of the module to load
|
||||
* @param type Type of module, used purely for registration
|
||||
@ -142,22 +133,17 @@ MODULE_INFO *mod_info = NULL;
|
||||
*
|
||||
* Search of the shared object.
|
||||
*/
|
||||
snprintf(fname,MAXPATHLEN+1, "./lib%s.so", module);
|
||||
|
||||
|
||||
snprintf(fname, MAXPATHLEN+1,"%s/lib%s.so", get_libdir(), module);
|
||||
|
||||
if (access(fname, F_OK) == -1)
|
||||
{
|
||||
home = get_maxscale_home ();
|
||||
snprintf(fname, MAXPATHLEN+1,"%s/modules/lib%s.so", home, module);
|
||||
|
||||
if (access(fname, F_OK) == -1)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to find library for "
|
||||
"module: %s.",
|
||||
module)));
|
||||
return NULL;
|
||||
}
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to find library for "
|
||||
"module: %s. Module dir: %s",
|
||||
module, get_libdir())));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((dlhandle = dlopen(fname, RTLD_NOW|RTLD_LOCAL)) == NULL)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <secrets.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
#include <gwdirs.h>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int arg_count = 6;
|
||||
@ -52,22 +53,21 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
arg_vector[0] = "logmanager";
|
||||
arg_vector[1] = "-j";
|
||||
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL)
|
||||
if(access("/var/log/maxscale/maxkeys/",F_OK) != 0)
|
||||
{
|
||||
arg_vector[2] = (char*)malloc((strlen(home) + strlen("/log"))*sizeof(char));
|
||||
sprintf(arg_vector[2],"%s/log",home);
|
||||
if(mkdir("/var/log/maxscale/maxkeys/",0777) == -1)
|
||||
{
|
||||
if(errno != EEXIST)
|
||||
{
|
||||
fprintf(stderr,"Error: %d - %s",errno,strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_vector[2] = strdup("/usr/local/mariadb-maxscale/log");
|
||||
}
|
||||
arg_vector[3] = "-o";
|
||||
arg_vector[4] = "-l";
|
||||
arg_vector[5] = "LOGFILE_ERROR";
|
||||
arg_vector[6] = NULL;
|
||||
arg_vector[0] = strdup("logmanager");
|
||||
arg_vector[1] = strdup("-j");
|
||||
arg_vector[2] = strdup("/var/log/maxscale/maxkeys");
|
||||
arg_vector[3] = NULL;
|
||||
skygw_logmanager_init(arg_count,arg_vector);
|
||||
free(arg_vector[2]);
|
||||
free(arg_vector);
|
||||
|
@ -60,18 +60,9 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
arg_vector[0] = "logmanager";
|
||||
arg_vector[1] = "-j";
|
||||
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
arg_vector[2] = (char*)malloc((strlen(home) + strlen("/log"))*sizeof(char));
|
||||
sprintf(arg_vector[2],"%s/log",home);
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_vector[2] = strdup("/usr/local/mariadb-maxscale/log");
|
||||
}
|
||||
arg_vector[0] = strdup("logmanager");
|
||||
arg_vector[1] = strdup("-j");
|
||||
arg_vector[2] = strdup("/var/log/maxscale");
|
||||
|
||||
arg_vector[3] = "-o";
|
||||
arg_vector[4] = "-l";
|
||||
|
@ -841,4 +841,4 @@ int modutil_count_statements(GWBUF* buffer)
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <log_manager.h>
|
||||
#include <ctype.h>
|
||||
#include <mysql_client_server_protocol.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -62,7 +63,7 @@ int i;
|
||||
static MAXKEYS *
|
||||
secrets_readKeys()
|
||||
{
|
||||
char secret_file[255];
|
||||
char secret_file[PATH_MAX+1];
|
||||
char *home;
|
||||
MAXKEYS *keys;
|
||||
struct stat secret_stats;
|
||||
@ -70,12 +71,7 @@ int fd;
|
||||
int len;
|
||||
static int reported = 0;
|
||||
|
||||
home = getenv("MAXSCALE_HOME");
|
||||
|
||||
if (home == NULL) {
|
||||
home = "/usr/local/mariadb-maxscale";
|
||||
}
|
||||
snprintf(secret_file, 255, "%s/etc/.secrets", home);
|
||||
snprintf(secret_file, PATH_MAX, "%s/.secrets", get_datadir());
|
||||
|
||||
/* Try to access secrets file */
|
||||
if (access(secret_file, R_OK) == -1)
|
||||
|
@ -61,6 +61,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <housekeeper.h>
|
||||
#include <resultset.h>
|
||||
#include <gw.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -112,7 +114,7 @@ SERVICE *service;
|
||||
return NULL;
|
||||
if ((service->router = load_module(router, MODULE_ROUTER)) == NULL)
|
||||
{
|
||||
char* home = get_maxscale_home();
|
||||
char* home = get_libdir();
|
||||
char* ldpath = getenv("LD_LIBRARY_PATH");
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
@ -120,12 +122,13 @@ SERVICE *service;
|
||||
"Error : Unable to load %s module \"%s\".\n\t\t\t"
|
||||
" Ensure that lib%s.so exists in one of the "
|
||||
"following directories :\n\t\t\t "
|
||||
"- %s/modules\n\t\t\t - %s",
|
||||
"- %s/modules\n%s%s",
|
||||
MODULE_ROUTER,
|
||||
router,
|
||||
router,
|
||||
home,
|
||||
ldpath)));
|
||||
ldpath?"\t\t\t - ":"",
|
||||
ldpath?ldpath:"")));
|
||||
free(service);
|
||||
return NULL;
|
||||
}
|
||||
@ -229,11 +232,7 @@ GWPROTOCOL *funcs;
|
||||
{
|
||||
/* Try loading authentication data from file cache */
|
||||
char *ptr, path[4097];
|
||||
strcpy(path, "/usr/local/mariadb-maxscale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
strncpy(path, ptr, 4096);
|
||||
}
|
||||
strcpy(path, get_cachedir());
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, service->name, 4096);
|
||||
strncat(path, "/.cache/dbusers", 4096);
|
||||
@ -257,15 +256,11 @@ GWPROTOCOL *funcs;
|
||||
else
|
||||
{
|
||||
/* Save authentication data to file cache */
|
||||
char *ptr, path[4097];
|
||||
char *ptr, path[PATH_MAX + 1];
|
||||
int mkdir_rval = 0;
|
||||
strcpy(path, "/usr/local/mariadb-maxscale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
strncpy(path, ptr, 4096);
|
||||
}
|
||||
strcpy(path, get_cachedir());
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, service->name, 4096);
|
||||
strncat(path, service->name, PATH_MAX);
|
||||
if (access(path, R_OK) == -1)
|
||||
{
|
||||
mkdir_rval = mkdir(path, 0777);
|
||||
@ -280,7 +275,7 @@ GWPROTOCOL *funcs;
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
|
||||
strncat(path, "/.cache", 4096);
|
||||
strncat(path, "/.cache", PATH_MAX);
|
||||
if (access(path, R_OK) == -1)
|
||||
{
|
||||
mkdir_rval = mkdir(path, 0777);
|
||||
@ -294,7 +289,7 @@ GWPROTOCOL *funcs;
|
||||
strerror(errno));
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
strncat(path, "/dbusers", 4096);
|
||||
strncat(path, "/dbusers", PATH_MAX);
|
||||
dbusers_save(service->users, path);
|
||||
}
|
||||
if (loaded == 0)
|
||||
|
@ -44,19 +44,4 @@ add_test(Internal-TestUsers test_users)
|
||||
add_test(Internal-TestAdminUsers test_adminusers)
|
||||
add_test(Internal-TestMemlog testmemlog)
|
||||
add_test(TestFeedback testfeedback)
|
||||
set_tests_properties(Internal-TestMySQLUsers
|
||||
Internal-TestHash
|
||||
Internal-TestHint
|
||||
Internal-TestSpinlock
|
||||
Internal-TestFilter
|
||||
Internal-TestBuffer
|
||||
Internal-TestDCB
|
||||
Internal-TestModutil
|
||||
Internal-TestPoll
|
||||
Internal-TestService
|
||||
Internal-TestServer
|
||||
Internal-TestUsers
|
||||
Internal-TestAdminUsers
|
||||
Internal-TestMemlog
|
||||
TestFeedback PROPERTIES ENVIRONMENT MAXSCALE_HOME=${CMAKE_BINARY_DIR}/)
|
||||
set_tests_properties(TestFeedback PROPERTIES TIMEOUT 30)
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gwdirs.h>
|
||||
#include <adminusers.h>
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
* Test that the username password admin/mariadb is accepted if no users
|
||||
* have been created and that no other users are accepted
|
||||
*
|
||||
* WARNING: $MAXSCALE_HOME/etc/passwd must be removed before this test is run
|
||||
* WARNING: The passwd file must be removed before this test is run
|
||||
*/
|
||||
static int
|
||||
test1()
|
||||
@ -269,9 +269,8 @@ int result = 0;
|
||||
char *home, buf[1024];
|
||||
|
||||
/* Unlink any existing password file before running this test */
|
||||
if ((home = getenv("MAXSCALE_HOME")) == NULL || strlen(home) >= 1024)
|
||||
home = "/usr/local/mariadb-maxscale";
|
||||
sprintf(buf, "%s/etc/passwd", home);
|
||||
|
||||
sprintf(buf, "%s/passwd", default_cachedir);
|
||||
if(!is_valid_posix_path(buf))
|
||||
exit(1);
|
||||
if (strcmp(buf, "/etc/passwd") != 0)
|
||||
|
@ -73,17 +73,8 @@ int main(int argc, char** argv)
|
||||
char* cnf;
|
||||
|
||||
hkinit();
|
||||
home = getenv("MAXSCALE_HOME");
|
||||
|
||||
if(home == NULL)
|
||||
{
|
||||
FAILTEST("MAXSCALE_HOME was not defined.");
|
||||
}
|
||||
printf("Home: %s\n",home);
|
||||
|
||||
cnf = malloc(strlen(home) + strlen("/etc/MaxScale.cnf") + 1);
|
||||
strcpy(cnf,home);
|
||||
strcat(cnf,"/etc/MaxScale.cnf");
|
||||
cnf = strdup("/etc/MaxScale.cnf");
|
||||
|
||||
printf("Config: %s\n",cnf);
|
||||
|
||||
@ -116,4 +107,4 @@ int main(int argc, char** argv)
|
||||
}
|
||||
mysql_library_end();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,25 @@
|
||||
#ifndef _GW_HG
|
||||
#define _GW_HG
|
||||
|
||||
/*
|
||||
* This file is distributed as part of the MariaDB Corporation 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 2013-2014
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@ -16,8 +38,8 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
@ -65,3 +87,5 @@ int gw_write(DCB *dcb, const void *buf, size_t nbytes);
|
||||
int gw_getsockerrno(int fd);
|
||||
int parse_bindconfig(char *, unsigned short, struct sockaddr_in *);
|
||||
int setipaddress(struct in_addr *, char *);
|
||||
char* get_libdir();
|
||||
#endif
|
||||
|
44
server/include/gwdirs.h.in
Normal file
44
server/include/gwdirs.h.in
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef _GW_DIRS_HG
|
||||
#define _GW_DIRS_HG
|
||||
|
||||
/*
|
||||
* This file is distributed as part of the MariaDB Corporation 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 2015
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/** Default file locations, configured by CMake */
|
||||
static const char* default_cnf_fname = "maxscale.cnf";
|
||||
static const char* default_configdir = "/etc/";
|
||||
static const char* default_piddir = "/var/run/maxscale/";
|
||||
static const char* default_logdir = "/var/log/maxscale/";
|
||||
static const char* default_datadir = "/var/lib/maxscale/";
|
||||
static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@";
|
||||
static const char* default_cachedir = "/var/cache/maxscale/";
|
||||
static const char* default_langdir = "@MAXSCALE_VARDIR@/lib/maxscale/";
|
||||
|
||||
static char* configdir = NULL;
|
||||
static char* logdir = NULL;
|
||||
static char* libdir = NULL;
|
||||
static char* cachedir = NULL;
|
||||
static char* maxscaledatadir = NULL;
|
||||
static char* langdir = NULL;
|
||||
|
||||
char* get_libdir();
|
||||
char* get_datadir();
|
||||
char* get_cachedir();
|
||||
#endif
|
@ -68,7 +68,6 @@ extern void unload_all_modules();
|
||||
extern void printModules();
|
||||
extern void dprintAllModules(DCB *);
|
||||
extern RESULTSET *moduleGetList();
|
||||
extern char *get_maxscale_home(void);
|
||||
extern void module_feedback_send(void*);
|
||||
extern void moduleShowFeedbackReport(DCB *dcb);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Example MaxScale.cnf for the Binlog Server.
|
||||
# Example maxscale.cnf for the Binlog Server.
|
||||
#
|
||||
#
|
||||
|
||||
@ -37,14 +37,13 @@ threads=6
|
||||
# The MaxScale Binlog Server Service.
|
||||
#
|
||||
# The name of this service will be used as the directory name
|
||||
# in $MAXSCALE_HOME where the binlogs will be saved.
|
||||
# in the cache directory where the binlogs will be saved.
|
||||
# If this name is changed, it must be changed in the listener
|
||||
# configuration below.
|
||||
[Binlog_Service]
|
||||
|
||||
# type must be service
|
||||
# router must be binlogrouter
|
||||
# (corresponding to the so file in $MAXSCALE_HOME/modules).
|
||||
type=service
|
||||
router=binlogrouter
|
||||
|
@ -3,48 +3,48 @@ if(BUILD_RABBITMQ)
|
||||
include_directories(${RABBITMQ_HEADERS})
|
||||
add_library(mqfilter SHARED mqfilter.c)
|
||||
target_link_libraries(mqfilter query_classifier log_manager utils ${RABBITMQ_LIBRARIES})
|
||||
install(TARGETS mqfilter DESTINATION modules)
|
||||
install(TARGETS mqfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
endif()
|
||||
|
||||
add_library(regexfilter SHARED regexfilter.c)
|
||||
target_link_libraries(regexfilter log_manager utils)
|
||||
install(TARGETS regexfilter DESTINATION modules)
|
||||
install(TARGETS regexfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(testfilter SHARED testfilter.c)
|
||||
target_link_libraries(testfilter log_manager utils)
|
||||
install(TARGETS testfilter DESTINATION modules)
|
||||
install(TARGETS testfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(qlafilter SHARED qlafilter.c)
|
||||
target_link_libraries(qlafilter log_manager utils)
|
||||
install(TARGETS qlafilter DESTINATION modules)
|
||||
install(TARGETS qlafilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(tee SHARED tee.c)
|
||||
target_link_libraries(tee log_manager utils)
|
||||
install(TARGETS tee DESTINATION modules)
|
||||
install(TARGETS tee DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(topfilter SHARED topfilter.c)
|
||||
target_link_libraries(topfilter log_manager utils)
|
||||
install(TARGETS topfilter DESTINATION modules)
|
||||
install(TARGETS topfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(dbfwfilter SHARED dbfwfilter.c)
|
||||
target_link_libraries(dbfwfilter log_manager utils query_classifier)
|
||||
install(TARGETS dbfwfilter DESTINATION modules)
|
||||
install(TARGETS dbfwfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(namedserverfilter SHARED namedserverfilter.c)
|
||||
target_link_libraries(namedserverfilter log_manager utils)
|
||||
install(TARGETS namedserverfilter DESTINATION modules)
|
||||
install(TARGETS namedserverfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
if(BUILD_SLAVELAG)
|
||||
add_library(slavelag SHARED slavelag.c)
|
||||
target_link_libraries(slavelag log_manager utils query_classifier)
|
||||
install(TARGETS slavelag DESTINATION modules)
|
||||
install(TARGETS slavelag DESTINATION ${MAXSCALE_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(BUILD_TOOLS)
|
||||
add_executable(ruleparser dbfwfilter.c)
|
||||
target_compile_definitions(ruleparser PUBLIC "BUILD_RULE_PARSER")
|
||||
target_link_libraries(ruleparser ${EMBEDDED_LIB} log_manager utils query_classifier fullcore)
|
||||
install(TARGETS ruleparser DESTINATION tools)
|
||||
install(TARGETS ruleparser DESTINATION ${MAXSCALE_BINDIR})
|
||||
endif()
|
||||
|
||||
add_subdirectory(hint)
|
||||
|
@ -2214,15 +2214,13 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((home = getenv("MAXSCALE_HOME")) == NULL)
|
||||
home = malloc(sizeof(char)*(PATH_MAX+1));
|
||||
if(getcwd(home,PATH_MAX) == NULL)
|
||||
{
|
||||
home = malloc(sizeof(char)*(PATH_MAX+1));
|
||||
if(getcwd(home,PATH_MAX) == NULL)
|
||||
{
|
||||
free(home);
|
||||
home = NULL;
|
||||
}
|
||||
free(home);
|
||||
home = NULL;
|
||||
}
|
||||
|
||||
printf("Log files written to: %s\n",home?home:"/tpm");
|
||||
|
||||
int argc_ = 2;
|
||||
|
@ -1,4 +1,4 @@
|
||||
add_library(hintfilter SHARED hintfilter.c hintparser.c)
|
||||
set_target_properties(hintfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
|
||||
set_target_properties(hintfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR})
|
||||
target_link_libraries(hintfilter ssl log_manager utils)
|
||||
install(TARGETS hintfilter DESTINATION modules)
|
||||
install(TARGETS hintfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_executable(harness_ui harness_ui.c harness_common.c)
|
||||
add_executable(harness harness_util.c harness_common.c)
|
||||
@ -25,7 +24,3 @@ add_test(TestTeeRecursion ${CMAKE_CURRENT_SOURCE_DIR}/tee_recursion.sh
|
||||
${TEST_PASSWORD}
|
||||
${TEST_HOST}
|
||||
${TEST_PORT})
|
||||
|
||||
set_tests_properties(TestHintfilter TestRegexfilter TestFwfilter1 TestFwfilter2 TestTeeRecursion
|
||||
PROPERTIES
|
||||
ENVIRONMENT MAXSCALE_HOME=${CMAKE_BINARY_DIR}/)
|
||||
|
@ -49,8 +49,8 @@ USER=$3
|
||||
PWD=$4
|
||||
HOST=$5
|
||||
PORT=$6
|
||||
CONF=$BINDIR/etc/MaxScale.cnf
|
||||
OLDCONF=$BINDIR/etc/MaxScale.cnf.old
|
||||
CONF=$BINDIR/etc/maxscale.cnf
|
||||
OLDCONF=$BINDIR/etc/maxscale.cnf.old
|
||||
MAXPID=$BINDIR/log/$(ls -1 $BINDIR/log|grep maxscale)
|
||||
TEST1=$SRCDIR/server/modules/filter/test/tee_recursion1.cnf
|
||||
TEST2=$SRCDIR/server/modules/filter/test/tee_recursion2.cnf
|
||||
|
@ -1,16 +1,16 @@
|
||||
add_library(mysqlmon SHARED mysql_mon.c monitor_common.c)
|
||||
target_link_libraries(mysqlmon log_manager utils)
|
||||
install(TARGETS mysqlmon DESTINATION modules)
|
||||
install(TARGETS mysqlmon DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(galeramon SHARED galeramon.c monitor_common.c)
|
||||
target_link_libraries(galeramon log_manager utils)
|
||||
install(TARGETS galeramon DESTINATION modules)
|
||||
install(TARGETS galeramon DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(ndbclustermon SHARED ndbclustermon.c monitor_common.c)
|
||||
target_link_libraries(ndbclustermon log_manager utils)
|
||||
install(TARGETS ndbclustermon DESTINATION modules)
|
||||
install(TARGETS ndbclustermon DESTINATION ${MAXSCALE_LIBDIR})
|
||||
if(BUILD_MMMON)
|
||||
add_library(mmmon SHARED mmmon.c monitor_common.c)
|
||||
target_link_libraries(mmmon log_manager utils)
|
||||
install(TARGETS mmmon DESTINATION modules)
|
||||
install(TARGETS mmmon DESTINATION ${MAXSCALE_LIBDIR})
|
||||
endif()
|
||||
|
@ -1,27 +1,27 @@
|
||||
add_library(MySQLClient SHARED mysql_client.c mysql_common.c)
|
||||
target_link_libraries(MySQLClient log_manager utils)
|
||||
install(TARGETS MySQLClient DESTINATION modules)
|
||||
install(TARGETS MySQLClient DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(MySQLBackend SHARED mysql_backend.c mysql_common.c)
|
||||
target_link_libraries(MySQLBackend log_manager utils)
|
||||
install(TARGETS MySQLBackend DESTINATION modules)
|
||||
install(TARGETS MySQLBackend DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(telnetd SHARED telnetd.c)
|
||||
target_link_libraries(telnetd log_manager utils)
|
||||
install(TARGETS telnetd DESTINATION modules)
|
||||
install(TARGETS telnetd DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(HTTPD SHARED httpd.c)
|
||||
target_link_libraries(HTTPD log_manager utils)
|
||||
install(TARGETS HTTPD DESTINATION modules)
|
||||
install(TARGETS HTTPD DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_library(testprotocol SHARED testprotocol.c)
|
||||
install(TARGETS testprotocol DESTINATION modules)
|
||||
install(TARGETS testprotocol DESTINATION ${MAXSCALE_LIBDIR})
|
||||
endif()
|
||||
|
||||
add_library(maxscaled SHARED maxscaled.c)
|
||||
target_link_libraries(maxscaled log_manager utils)
|
||||
install(TARGETS maxscaled DESTINATION modules)
|
||||
install(TARGETS maxscaled DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
|
||||
|
||||
|
@ -2,20 +2,20 @@ if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
add_library(testroute SHARED testroute.c)
|
||||
target_link_libraries(testroute log_manager utils)
|
||||
install(TARGETS testroute DESTINATION modules)
|
||||
install(TARGETS testroute DESTINATION ${MAXSCALE_LIBDIR})
|
||||
endif()
|
||||
|
||||
add_library(readconnroute SHARED readconnroute.c)
|
||||
target_link_libraries(readconnroute log_manager utils)
|
||||
install(TARGETS readconnroute DESTINATION modules)
|
||||
install(TARGETS readconnroute DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(debugcli SHARED debugcli.c debugcmd.c)
|
||||
target_link_libraries(debugcli log_manager utils)
|
||||
install(TARGETS debugcli DESTINATION modules)
|
||||
install(TARGETS debugcli DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(cli SHARED cli.c debugcmd.c)
|
||||
target_link_libraries(cli log_manager utils)
|
||||
install(TARGETS cli DESTINATION modules)
|
||||
install(TARGETS cli DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_subdirectory(readwritesplit)
|
||||
add_subdirectory(schemarouter)
|
||||
|
@ -1,4 +1,4 @@
|
||||
add_library(binlogrouter SHARED blr.c blr_master.c blr_cache.c blr_slave.c blr_file.c)
|
||||
set_target_properties(binlogrouter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
|
||||
set_target_properties(binlogrouter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR})
|
||||
target_link_libraries(binlogrouter ssl pthread log_manager)
|
||||
install(TARGETS binlogrouter DESTINATION modules)
|
||||
install(TARGETS binlogrouter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
@ -71,7 +71,7 @@ static void blr_log_header(logfile_id_t file, char *msg, uint8_t *ptr);
|
||||
int
|
||||
blr_file_init(ROUTER_INSTANCE *router)
|
||||
{
|
||||
char *ptr, path[PATH_MAX], filename[PATH_MAX];
|
||||
char *ptr, path[PATH_MAX+1], filename[PATH_MAX+1];
|
||||
int file_found, n = 1;
|
||||
int root_len, i;
|
||||
DIR *dirp;
|
||||
@ -79,12 +79,8 @@ struct dirent *dp;
|
||||
|
||||
if (router->binlogdir == NULL)
|
||||
{
|
||||
strcpy(path, "/usr/local/mariadb-maxscale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
strncpy(path, ptr,PATH_MAX);
|
||||
}
|
||||
strncat(path, "/",PATH_MAX);
|
||||
strcpy(path, get_datadir());
|
||||
strncat(path,"/",PATH_MAX);
|
||||
strncat(path, router->service->name,PATH_MAX);
|
||||
|
||||
if (access(path, R_OK) == -1)
|
||||
@ -660,24 +656,20 @@ struct stat statb;
|
||||
void
|
||||
blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
|
||||
{
|
||||
char path[4097], *ptr;
|
||||
char path[PATH_MAX+1], *ptr;
|
||||
int fd;
|
||||
|
||||
strcpy(path, "/usr/local/mariadb-maxscale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
strncpy(path, ptr, 4096);
|
||||
}
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, router->service->name, 4096);
|
||||
strcpy(path,get_datadir());
|
||||
strncat(path,"/",PATH_MAX);
|
||||
strncat(path, router->service->name, PATH_MAX);
|
||||
|
||||
if (access(path, R_OK) == -1)
|
||||
mkdir(path, 0777);
|
||||
strncat(path, "/.cache", 4096);
|
||||
strncat(path, "/.cache", PATH_MAX);
|
||||
if (access(path, R_OK) == -1)
|
||||
mkdir(path, 0777);
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, response, 4096);
|
||||
strncat(path, response, PATH_MAX);
|
||||
|
||||
if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
|
||||
return;
|
||||
@ -698,19 +690,15 @@ GWBUF *
|
||||
blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
|
||||
{
|
||||
struct stat statb;
|
||||
char path[4097], *ptr;
|
||||
char path[PATH_MAX+1], *ptr;
|
||||
int fd;
|
||||
GWBUF *buf;
|
||||
|
||||
strcpy(path, "/usr/local/mariadb-maxscale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
strncpy(path, ptr, 4096);
|
||||
}
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, router->service->name, 4096);
|
||||
strncat(path, "/.cache/", 4096);
|
||||
strncat(path, response, 4096);
|
||||
strcpy(path, get_datadir());
|
||||
strncat(path, "/", PATH_MAX);
|
||||
strncat(path, router->service->name, PATH_MAX);
|
||||
strncat(path, "/.cache/", PATH_MAX);
|
||||
strncat(path, response, PATH_MAX);
|
||||
|
||||
if ((fd = open(path, O_RDONLY)) == -1)
|
||||
return NULL;
|
||||
|
@ -1,4 +1,4 @@
|
||||
add_library(maxinfo SHARED maxinfo.c maxinfo_parse.c maxinfo_error.c maxinfo_exec.c)
|
||||
set_target_properties(maxinfo PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
|
||||
set_target_properties(maxinfo PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR})
|
||||
target_link_libraries(maxinfo pthread log_manager)
|
||||
install(TARGETS maxinfo DESTINATION modules)
|
||||
install(TARGETS maxinfo DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
@ -1,6 +1,6 @@
|
||||
add_library(readwritesplit SHARED readwritesplit.c)
|
||||
target_link_libraries(readwritesplit ssl pthread log_manager utils query_classifier)
|
||||
install(TARGETS readwritesplit DESTINATION modules)
|
||||
install(TARGETS readwritesplit DESTINATION ${MAXSCALE_LIBDIR})
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
@ -1,10 +1,10 @@
|
||||
add_library(schemarouter SHARED schemarouter.c sharding_common.c)
|
||||
target_link_libraries(schemarouter log_manager utils query_classifier)
|
||||
install(TARGETS schemarouter DESTINATION modules)
|
||||
install(TARGETS schemarouter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(shardrouter SHARED shardrouter.c svcconn.c sharding_common.c)
|
||||
target_link_libraries(shardrouter log_manager utils query_classifier)
|
||||
install(TARGETS shardrouter DESTINATION modules)
|
||||
install(TARGETS shardrouter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
|
@ -1,5 +1,10 @@
|
||||
[maxscale]
|
||||
threads=4
|
||||
libdir=@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@
|
||||
logdir=@CMAKE_INSTALL_PREFIX@/log
|
||||
datadir=@CMAKE_INSTALL_PREFIX@/data
|
||||
cachedir=@CMAKE_INSTALL_PREFIX@/cache
|
||||
language=@CMAKE_INSTALL_PREFIX@/lib/maxscale/
|
||||
|
||||
[feedback]
|
||||
feedback_enable=true
|
Reference in New Issue
Block a user