MXS-1032: Add configurable connector plugin directory
The connector plugin directory can now be controlled with the `connector_plugindir` argument and configuration option. This should allow the connector to use the system plugins if the versions are binary compatible. Replaced calls to mysql_options to mysql_optionsv as the former is deprecated in Connector-C 3.0 and the latter is supported in Connector-C 2.3.
This commit is contained in:
@ -442,6 +442,17 @@ files.
|
|||||||
execdir=/usr/local/bin/
|
execdir=/usr/local/bin/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `connector_plugindir`
|
||||||
|
|
||||||
|
Location of the MariaDB Connector-C plugin directory. The MariaDB Connector-C
|
||||||
|
used in MaxScale can use this directory to load authentication plugins. The
|
||||||
|
versions of the plugins must be binary compatible with the connector version
|
||||||
|
that MaxScale was built with.
|
||||||
|
|
||||||
|
```
|
||||||
|
connector_plugindir=/usr/lib/plugin/
|
||||||
|
```
|
||||||
|
|
||||||
#### `persistdir`
|
#### `persistdir`
|
||||||
|
|
||||||
Configure the directory where persisted configurations are stored. When a new
|
Configure the directory where persisted configurations are stored. When a new
|
||||||
|
@ -22,6 +22,7 @@ set(DEFAULT_EXEC_SUBPATH "${MAXSCALE_BINDIR}" CACHE PATH "Default executable sub
|
|||||||
set(DEFAULT_CONFIG_SUBPATH "etc" CACHE PATH "Default configuration subpath")
|
set(DEFAULT_CONFIG_SUBPATH "etc" CACHE PATH "Default configuration subpath")
|
||||||
set(DEFAULT_CONFIG_PERSIST_SUBPATH "maxscale.cnf.d" CACHE PATH "Default persisted configuration subpath")
|
set(DEFAULT_CONFIG_PERSIST_SUBPATH "maxscale.cnf.d" CACHE PATH "Default persisted configuration subpath")
|
||||||
set(DEFAULT_MODULE_CONFIG_SUBPATH "${DEFAULT_CONFIG_SUBPATH}/maxscale.modules.d" CACHE PATH "Default configuration subpath")
|
set(DEFAULT_MODULE_CONFIG_SUBPATH "${DEFAULT_CONFIG_SUBPATH}/maxscale.modules.d" CACHE PATH "Default configuration subpath")
|
||||||
|
set(DEFAULT_CONNECTOR_PLUGIN_SUBPATH "lib/plugin" CACHE PATH "Default connector plugin subpath")
|
||||||
|
|
||||||
set(DEFAULT_PIDDIR ${MAXSCALE_VARDIR}/${DEFAULT_PID_SUBPATH} CACHE PATH "Default PID file directory")
|
set(DEFAULT_PIDDIR ${MAXSCALE_VARDIR}/${DEFAULT_PID_SUBPATH} CACHE PATH "Default PID file directory")
|
||||||
set(DEFAULT_LOGDIR ${MAXSCALE_VARDIR}/${DEFAULT_LOG_SUBPATH} CACHE PATH "Default log directory")
|
set(DEFAULT_LOGDIR ${MAXSCALE_VARDIR}/${DEFAULT_LOG_SUBPATH} CACHE PATH "Default log directory")
|
||||||
@ -33,6 +34,7 @@ set(DEFAULT_EXECDIR ${CMAKE_INSTALL_PREFIX}/${DEFAULT_EXEC_SUBPATH} CACHE PATH "
|
|||||||
set(DEFAULT_CONFIGDIR /${DEFAULT_CONFIG_SUBPATH} CACHE PATH "Default configuration directory")
|
set(DEFAULT_CONFIGDIR /${DEFAULT_CONFIG_SUBPATH} CACHE PATH "Default configuration directory")
|
||||||
set(DEFAULT_CONFIG_PERSISTDIR ${DEFAULT_DATADIR}/${DEFAULT_CONFIG_PERSIST_SUBPATH} CACHE PATH "Default persisted configuration directory")
|
set(DEFAULT_CONFIG_PERSISTDIR ${DEFAULT_DATADIR}/${DEFAULT_CONFIG_PERSIST_SUBPATH} CACHE PATH "Default persisted configuration directory")
|
||||||
set(DEFAULT_MODULE_CONFIGDIR /${DEFAULT_MODULE_CONFIG_SUBPATH} CACHE PATH "Default module configuration directory")
|
set(DEFAULT_MODULE_CONFIGDIR /${DEFAULT_MODULE_CONFIG_SUBPATH} CACHE PATH "Default module configuration directory")
|
||||||
|
set(DEFAULT_CONNECTOR_PLUGINDIR ${MAXSCALE_VARDIR}/${DEFAULT_CONNECTOR_PLUGIN_SUBPATH} CACHE PATH "Default connector plugin directory")
|
||||||
|
|
||||||
# Massage TARGET_COMPONENT into a list
|
# Massage TARGET_COMPONENT into a list
|
||||||
if (TARGET_COMPONENT)
|
if (TARGET_COMPONENT)
|
||||||
|
@ -31,6 +31,7 @@ MXS_BEGIN_DECLS
|
|||||||
#define MXS_DEFAULT_CONFIG_SUBPATH "@DEFAULT_CONFIG_SUBPATH@"
|
#define MXS_DEFAULT_CONFIG_SUBPATH "@DEFAULT_CONFIG_SUBPATH@"
|
||||||
#define MXS_DEFAULT_CONFIG_PERSIST_SUBPATH "@DEFAULT_CONFIG_PERSIST_SUBPATH@"
|
#define MXS_DEFAULT_CONFIG_PERSIST_SUBPATH "@DEFAULT_CONFIG_PERSIST_SUBPATH@"
|
||||||
#define MXS_DEFAULT_MODULE_CONFIG_SUBPATH "@DEFAULT_MODULE_CONFIG_SUBPATH@"
|
#define MXS_DEFAULT_MODULE_CONFIG_SUBPATH "@DEFAULT_MODULE_CONFIG_SUBPATH@"
|
||||||
|
#define MXS_DEFAULT_CONNECTOR_PLUGIN_SUBPATH "@DEFAULT_CONNECTOR_PLUGIN_SUBPATH@"
|
||||||
|
|
||||||
/** Default file locations, configured by CMake */
|
/** Default file locations, configured by CMake */
|
||||||
#define MXS_DEFAULT_CONFIGDIR "@DEFAULT_CONFIGDIR@"
|
#define MXS_DEFAULT_CONFIGDIR "@DEFAULT_CONFIGDIR@"
|
||||||
@ -43,6 +44,7 @@ MXS_BEGIN_DECLS
|
|||||||
#define MXS_DEFAULT_EXECDIR "@DEFAULT_EXECDIR@"
|
#define MXS_DEFAULT_EXECDIR "@DEFAULT_EXECDIR@"
|
||||||
#define MXS_DEFAULT_CONFIG_PERSISTDIR "@DEFAULT_CONFIG_PERSISTDIR@"
|
#define MXS_DEFAULT_CONFIG_PERSISTDIR "@DEFAULT_CONFIG_PERSISTDIR@"
|
||||||
#define MXS_DEFAULT_MODULE_CONFIGDIR "@DEFAULT_MODULE_CONFIGDIR@"
|
#define MXS_DEFAULT_MODULE_CONFIGDIR "@DEFAULT_MODULE_CONFIGDIR@"
|
||||||
|
#define MXS_DEFAULT_CONNECTOR_PLUGINDIR "@DEFAULT_CONNECTOR_PLUGINDIR@"
|
||||||
|
|
||||||
static const char* default_cnf_fname = "maxscale.cnf";
|
static const char* default_cnf_fname = "maxscale.cnf";
|
||||||
static const char* default_configdir = MXS_DEFAULT_CONFIGDIR;
|
static const char* default_configdir = MXS_DEFAULT_CONFIGDIR;
|
||||||
@ -59,6 +61,7 @@ static const char* default_langdir = MXS_DEFAULT_LANGDIR;
|
|||||||
static const char* default_execdir = MXS_DEFAULT_EXECDIR;
|
static const char* default_execdir = MXS_DEFAULT_EXECDIR;
|
||||||
static const char* default_config_persistdir = MXS_DEFAULT_CONFIG_PERSISTDIR;
|
static const char* default_config_persistdir = MXS_DEFAULT_CONFIG_PERSISTDIR;
|
||||||
static const char* default_module_configdir = MXS_DEFAULT_MODULE_CONFIGDIR;
|
static const char* default_module_configdir = MXS_DEFAULT_MODULE_CONFIGDIR;
|
||||||
|
static const char* default_connector_plugindir = MXS_DEFAULT_CONNECTOR_PLUGINDIR;
|
||||||
|
|
||||||
static char* configdir = NULL; /*< Where the config file is found e.g. /etc/ */
|
static char* configdir = NULL; /*< Where the config file is found e.g. /etc/ */
|
||||||
static char* config_persistdir = NULL;/*< Persisted configs e.g. /var/lib/maxscale/maxscale.cnf.d/ */
|
static char* config_persistdir = NULL;/*< Persisted configs e.g. /var/lib/maxscale/maxscale.cnf.d/ */
|
||||||
@ -71,6 +74,7 @@ static char* processdatadir = NULL; /*< Process specific data directory */
|
|||||||
static char* langdir = NULL;
|
static char* langdir = NULL;
|
||||||
static char* piddir = NULL;
|
static char* piddir = NULL;
|
||||||
static char* execdir = NULL;
|
static char* execdir = NULL;
|
||||||
|
static char* connector_plugindir = NULL;
|
||||||
|
|
||||||
void set_libdir(char* param);
|
void set_libdir(char* param);
|
||||||
void set_datadir(char* param);
|
void set_datadir(char* param);
|
||||||
@ -83,6 +87,7 @@ void set_logdir(char* param);
|
|||||||
void set_langdir(char* param);
|
void set_langdir(char* param);
|
||||||
void set_piddir(char* param);
|
void set_piddir(char* param);
|
||||||
void set_execdir(char* param);
|
void set_execdir(char* param);
|
||||||
|
void set_connector_plugindir(char* param);
|
||||||
char* get_libdir();
|
char* get_libdir();
|
||||||
char* get_datadir();
|
char* get_datadir();
|
||||||
char* get_process_datadir();
|
char* get_process_datadir();
|
||||||
@ -94,5 +99,6 @@ char* get_piddir();
|
|||||||
char* get_logdir();
|
char* get_logdir();
|
||||||
char* get_langdir();
|
char* get_langdir();
|
||||||
char* get_execdir();
|
char* get_execdir();
|
||||||
|
char* get_connector_plugindir();
|
||||||
|
|
||||||
MXS_END_DECLS
|
MXS_END_DECLS
|
||||||
|
@ -138,6 +138,7 @@ static struct option long_options[] =
|
|||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{"version-full", no_argument, 0, 'V'},
|
{"version-full", no_argument, 0, 'V'},
|
||||||
{"help", no_argument, 0, '?'},
|
{"help", no_argument, 0, '?'},
|
||||||
|
{"connector_plugindir", required_argument, 0, 'H'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
static bool syslog_configured = false;
|
static bool syslog_configured = false;
|
||||||
@ -927,6 +928,8 @@ static void usage(void)
|
|||||||
" -E, --execdir=PATH path to the maxscale and other executable files\n"
|
" -E, --execdir=PATH path to the maxscale and other executable files\n"
|
||||||
" -F, --persistdir=PATH path to persisted configuration directory\n"
|
" -F, --persistdir=PATH path to persisted configuration directory\n"
|
||||||
" -M, --module_configdir=PATH path to module configuration directory\n"
|
" -M, --module_configdir=PATH path to module configuration directory\n"
|
||||||
|
" -H, --connector_plugindir=PATH\n"
|
||||||
|
" path to MariaDB Connector-C plugin directory\n"
|
||||||
" -N, --language=PATH path to errmsg.sys file\n"
|
" -N, --language=PATH path to errmsg.sys file\n"
|
||||||
" -P, --piddir=PATH path to PID file directory\n"
|
" -P, --piddir=PATH path to PID file directory\n"
|
||||||
" -R, --basedir=PATH base path for all other paths\n"
|
" -R, --basedir=PATH base path for all other paths\n"
|
||||||
@ -1332,7 +1335,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "dcf:l:vVs:S:?L:D:C:B:U:A:P:G:N:E:F:M:",
|
while ((opt = getopt_long(argc, argv, "dcf:l:vVs:S:?L:D:C:B:U:A:P:G:N:E:F:M:H:",
|
||||||
long_options, &option_index)) != -1)
|
long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
bool succp = true;
|
bool succp = true;
|
||||||
@ -1496,6 +1499,16 @@ int main(int argc, char **argv)
|
|||||||
succp = false;
|
succp = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'H':
|
||||||
|
if (handle_path_arg(&tmp_path, optarg, NULL, true, false))
|
||||||
|
{
|
||||||
|
set_connector_plugindir(tmp_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
succp = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
if (handle_path_arg(&tmp_path, optarg, NULL, true, true))
|
if (handle_path_arg(&tmp_path, optarg, NULL, true, true))
|
||||||
{
|
{
|
||||||
@ -2532,6 +2545,20 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strcmp(name, "connector_plugindir") == 0)
|
||||||
|
{
|
||||||
|
if (strcmp(get_connector_plugindir(), default_connector_plugindir) == 0)
|
||||||
|
{
|
||||||
|
if (handle_path_arg((char**)&tmp, (char*)value, NULL, true, false))
|
||||||
|
{
|
||||||
|
set_connector_plugindir(tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (strcmp(name, "persistdir") == 0)
|
else if (strcmp(name, "persistdir") == 0)
|
||||||
{
|
{
|
||||||
if (strcmp(get_config_persistdir(), default_config_persistdir) == 0)
|
if (strcmp(get_config_persistdir(), default_config_persistdir) == 0)
|
||||||
|
@ -1181,10 +1181,10 @@ mon_connect_to_db(MXS_MONITOR* mon, MXS_MONITOR_SERVERS *database)
|
|||||||
|
|
||||||
char *dpwd = decrypt_password(passwd);
|
char *dpwd = decrypt_password(passwd);
|
||||||
|
|
||||||
mysql_options(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *) &mon->connect_timeout);
|
mysql_optionsv(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *) &mon->connect_timeout);
|
||||||
mysql_options(database->con, MYSQL_OPT_READ_TIMEOUT, (void *) &mon->read_timeout);
|
mysql_optionsv(database->con, MYSQL_OPT_READ_TIMEOUT, (void *) &mon->read_timeout);
|
||||||
mysql_options(database->con, MYSQL_OPT_WRITE_TIMEOUT, (void *) &mon->write_timeout);
|
mysql_optionsv(database->con, MYSQL_OPT_WRITE_TIMEOUT, (void *) &mon->write_timeout);
|
||||||
|
mysql_optionsv(database->con, MYSQL_PLUGIN_DIR, get_connector_plugindir());
|
||||||
time_t start = time(NULL);
|
time_t start = time(NULL);
|
||||||
bool result = (mxs_mysql_real_connect(database->con, database->server, uname, dpwd) != NULL);
|
bool result = (mxs_mysql_real_connect(database->con, database->server, uname, dpwd) != NULL);
|
||||||
time_t end = time(NULL);
|
time_t end = time(NULL);
|
||||||
|
@ -137,6 +137,17 @@ void set_execdir(char* param)
|
|||||||
execdir = param;
|
execdir = param;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the connector plugin directory.
|
||||||
|
* @param str Path to directory
|
||||||
|
*/
|
||||||
|
void set_connector_plugindir(char* param)
|
||||||
|
{
|
||||||
|
MXS_FREE(connector_plugindir);
|
||||||
|
clean_up_pathname(param);
|
||||||
|
connector_plugindir = param;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the directory with all the modules.
|
* Get the directory with all the modules.
|
||||||
* @return The module directory
|
* @return The module directory
|
||||||
@ -235,3 +246,12 @@ char* get_execdir()
|
|||||||
{
|
{
|
||||||
return execdir ? execdir : (char*) default_execdir;
|
return execdir ? execdir : (char*) default_execdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get connector plugin directory
|
||||||
|
* @return The connector plugin directory
|
||||||
|
*/
|
||||||
|
char* get_connector_plugindir()
|
||||||
|
{
|
||||||
|
return connector_plugindir ? connector_plugindir : (char*) default_connector_plugindir;
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <mysqld_error.h>
|
#include <mysqld_error.h>
|
||||||
#include <maxscale/mysql_utils.h>
|
#include <maxscale/mysql_utils.h>
|
||||||
#include <maxscale/alloc.h>
|
#include <maxscale/alloc.h>
|
||||||
|
#include <maxscale/paths.h>
|
||||||
|
|
||||||
/** Don't include the root user */
|
/** Don't include the root user */
|
||||||
#define USERS_QUERY_NO_ROOT " AND user.user NOT IN ('root')"
|
#define USERS_QUERY_NO_ROOT " AND user.user NOT IN ('root')"
|
||||||
@ -408,22 +409,7 @@ MYSQL *gw_mysql_init()
|
|||||||
|
|
||||||
if (con)
|
if (con)
|
||||||
{
|
{
|
||||||
if (gw_mysql_set_timeouts(con) == 0)
|
if (gw_mysql_set_timeouts(con) != 0)
|
||||||
{
|
|
||||||
// MYSQL_OPT_USE_REMOTE_CONNECTION must be set if the embedded
|
|
||||||
// libary is used. With Connector-C (at least 2.2.1) the call
|
|
||||||
// fails.
|
|
||||||
#if !defined(LIBMARIADB)
|
|
||||||
if (mysql_options(con, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL) != 0)
|
|
||||||
{
|
|
||||||
MXS_ERROR("Failed to set external connection. "
|
|
||||||
"It is needed for backend server connections.");
|
|
||||||
mysql_close(con);
|
|
||||||
con = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to set timeout values for backend connection.");
|
MXS_ERROR("Failed to set timeout values for backend connection.");
|
||||||
mysql_close(con);
|
mysql_close(con);
|
||||||
@ -454,21 +440,21 @@ static int gw_mysql_set_timeouts(MYSQL* handle)
|
|||||||
|
|
||||||
MXS_CONFIG* cnf = config_get_global_options();
|
MXS_CONFIG* cnf = config_get_global_options();
|
||||||
|
|
||||||
if ((rc = mysql_options(handle, MYSQL_OPT_READ_TIMEOUT,
|
if ((rc = mysql_optionsv(handle, MYSQL_OPT_READ_TIMEOUT,
|
||||||
(void *) &cnf->auth_read_timeout)))
|
(void *) &cnf->auth_read_timeout)))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to set read timeout for backend connection.");
|
MXS_ERROR("Failed to set read timeout for backend connection.");
|
||||||
goto retblock;
|
goto retblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = mysql_options(handle, MYSQL_OPT_CONNECT_TIMEOUT,
|
if ((rc = mysql_optionsv(handle, MYSQL_OPT_CONNECT_TIMEOUT,
|
||||||
(void *) &cnf->auth_conn_timeout)))
|
(void *) &cnf->auth_conn_timeout)))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to set connect timeout for backend connection.");
|
MXS_ERROR("Failed to set connect timeout for backend connection.");
|
||||||
goto retblock;
|
goto retblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = mysql_options(handle, MYSQL_OPT_WRITE_TIMEOUT,
|
if ((rc = mysql_optionsv(handle, MYSQL_OPT_WRITE_TIMEOUT,
|
||||||
(void *) &cnf->auth_write_timeout)))
|
(void *) &cnf->auth_write_timeout)))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to set write timeout for backend connection.");
|
MXS_ERROR("Failed to set write timeout for backend connection.");
|
||||||
@ -499,9 +485,10 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MXS_CONFIG* cnf = config_get_global_options();
|
MXS_CONFIG* cnf = config_get_global_options();
|
||||||
mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, &cnf->auth_read_timeout);
|
mysql_optionsv(mysql, MYSQL_OPT_READ_TIMEOUT, &cnf->auth_read_timeout);
|
||||||
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &cnf->auth_conn_timeout);
|
mysql_optionsv(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &cnf->auth_conn_timeout);
|
||||||
mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, &cnf->auth_write_timeout);
|
mysql_optionsv(mysql, MYSQL_OPT_WRITE_TIMEOUT, &cnf->auth_write_timeout);
|
||||||
|
mysql_optionsv(mysql, MYSQL_PLUGIN_DIR, get_connector_plugindir());
|
||||||
|
|
||||||
if (mxs_mysql_real_connect(mysql, server, user, password) == NULL)
|
if (mxs_mysql_real_connect(mysql, server, user, password) == NULL)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user