Changed relevant files to use get_cachedir() instead of using the now deprecated MAXSCALE_HOME.
This commit is contained in:
parent
1cc6ced505
commit
9e0a2bfc12
@ -38,7 +38,7 @@ _RETVAL_STATUS_OK=0
|
||||
_RETVAL_STATUS_NOT_RUNNING=3
|
||||
|
||||
# Sanity checks.
|
||||
[ -x $MAXSCALE_HOME/bin/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
[ -x @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
@ -51,7 +51,7 @@ RETVAL=0
|
||||
|
||||
start() {
|
||||
echo -n $"Starting MaxScale: "
|
||||
my_check=`status -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale`
|
||||
my_check=`status -p $MAXSCALE_PIDFILE @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale`
|
||||
CHECK_RET=$?
|
||||
[ $CHECK_RET -eq 0 ] && echo -n " found $my_check" && success && CHECK_RET=0
|
||||
|
||||
@ -62,7 +62,7 @@ start() {
|
||||
|
||||
if [ $CHECK_RET -ne 0 ]; then
|
||||
sleep 2
|
||||
my_check=`status -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale`
|
||||
my_check=`status -p $MAXSCALE_PIDFILE @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale`
|
||||
CHECK_RET=$?
|
||||
[ $CHECK_RET -eq 0 ] && echo -n $my_check && success || failure
|
||||
fi
|
||||
|
@ -38,7 +38,7 @@ _RETVAL_STATUS_OK=0
|
||||
_RETVAL_STATUS_NOT_RUNNING=3
|
||||
|
||||
# Sanity checks.
|
||||
[ -x $MAXSCALE_HOME/bin/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
[ -x @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
|
||||
#################################
|
||||
# stop/start/status related vars
|
||||
|
@ -23,11 +23,11 @@ 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 ${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 ${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 ${MAXSCALE_BINDIR})
|
||||
|
||||
|
@ -191,8 +191,6 @@ 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,bool,bool);
|
||||
|
||||
@ -575,149 +573,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
|
||||
@ -1042,19 +897,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)
|
||||
@ -1131,56 +980,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':
|
||||
/*<
|
||||
@ -1589,7 +1388,6 @@ int main(int argc, char **argv)
|
||||
sprintf(datadir,"%s",default_datadir);
|
||||
/**
|
||||
* 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]
|
||||
|
@ -49,6 +49,7 @@
|
||||
#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;
|
||||
@ -108,7 +109,7 @@ WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
/**
|
||||
* 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
|
||||
|
@ -62,16 +62,7 @@ main(int argc, char **argv)
|
||||
|
||||
arg_vector[0] = strdup("logmanager");
|
||||
arg_vector[1] = strdup("-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[2] = strdup("/var/log/maxscale");
|
||||
|
||||
arg_vector[3] = NULL;
|
||||
skygw_logmanager_init(arg_count,arg_vector);
|
||||
|
@ -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_cachedir());
|
||||
|
||||
/* Try to access secrets file */
|
||||
if (access(secret_file, R_OK) == -1)
|
||||
|
@ -232,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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -39,5 +39,5 @@ static char* cachedir = NULL;
|
||||
static char* langdir = NULL;
|
||||
|
||||
char* get_libdir();
|
||||
|
||||
char* get_cachedir();
|
||||
#endif
|
||||
|
@ -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
|
||||
|
||||
|
@ -2133,15 +2133,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_ = 11;
|
||||
|
@ -1,10 +1,3 @@
|
||||
aux_source_directory(${CMAKE_SOURCE_DIR}/server/core CORE_ALL)
|
||||
foreach(VAR ${CORE_ALL})
|
||||
if(NOT( (${VAR} MATCHES "max[a-z_]*.c") OR (${VAR} MATCHES "gateway.c")))
|
||||
list(APPEND CORE ${VAR})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
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 ${CORE})
|
||||
@ -32,6 +25,3 @@ add_test(TestTeeRecursion ${CMAKE_CURRENT_SOURCE_DIR}/tee_recursion.sh
|
||||
${TEST_HOST}
|
||||
${TEST_PORT})
|
||||
|
||||
set_tests_properties(TestHintfilter TestRegexfilter TestFwfilter1 TestFwfilter2 TestTeeRecursion
|
||||
PROPERTIES
|
||||
ENVIRONMENT MAXSCALE_HOME=${CMAKE_BINARY_DIR}/)
|
||||
|
Loading…
x
Reference in New Issue
Block a user