MXS-1755 Warn about unknown global configuration entries.

MXS_WARNING for unknown entries. Later to become an error (in 2.4).
This commit is contained in:
Niclas Antti
2018-04-26 14:32:05 +03:00
committed by Niclas Antti
parent 39ca403ffa
commit 62a3dd664d
4 changed files with 97 additions and 18 deletions

View File

@ -160,6 +160,22 @@ const char CN_SESSION_TRACK_TRX_STATE[] = "session_track_trx_state";
const char CN_WRITEQ_HIGH_WATER[] = "writeq_high_water";
const char CN_WRITEQ_LOW_WATER[] = "writeq_low_water";
extern const char CN_LOGDIR[] = "logdir";
extern const char CN_LIBDIR[] = "libdir";
extern const char CN_PIDDIR[] = "piddir";
extern const char CN_DATADIR[] = "datadir";
extern const char CN_CACHEDIR[] = "cachedir";
extern const char CN_LANGUAGE[] = "language";
extern const char CN_EXECDIR[] = "execdir";
extern const char CN_CONNECTOR_PLUGINDIR[] = "connector_plugindir";
extern const char CN_PERSISTDIR[] = "persistdir";
extern const char CN_MODULE_CONFIGDIR[] = "module_configdir";
extern const char CN_SYSLOG[] = "syslog";
extern const char CN_MAXLOG[] = "maxlog";
extern const char CN_LOG_AUGMENTATION[] = "log_augmentation";
extern const char CN_LOG_TO_SHM[] = "log_to_shm";
typedef struct duplicate_context
{
HASHTABLE *hash;
@ -299,6 +315,29 @@ const char *server_params[] =
NULL
};
/*
* This is currently only used in handle_global_item() to verify that
* all global configuration item names are valid.
*/
const char *config_pre_parse_global_params[] =
{
CN_LOGDIR,
CN_LIBDIR,
CN_PIDDIR,
CN_DATADIR,
CN_CACHEDIR,
CN_LANGUAGE,
CN_EXECDIR,
CN_CONNECTOR_PLUGINDIR,
CN_PERSISTDIR,
CN_MODULE_CONFIGDIR,
CN_SYSLOG,
CN_MAXLOG,
CN_LOG_AUGMENTATION,
CN_LOG_TO_SHM,
NULL
};
/**
* Initialize the context object used for tracking duplicate sections.
*
@ -1548,6 +1587,8 @@ static struct
static int
handle_global_item(const char *name, const char *value)
{
bool processed = true; // assume 'name' is valid
int i;
if (strcmp(name, CN_THREADS) == 0)
{
@ -1921,10 +1962,12 @@ handle_global_item(const char *name, const char *value)
MXS_WARNING("The 'log_debug' option has no effect in release mode.");
}
#endif
bool found = false;
for (i = 0; lognames[i].name; i++)
{
if (strcasecmp(name, lognames[i].name) == 0)
{
found = true;
if (lognames[i].replacement)
{
MXS_WARNING("In the configuration file the use of '%s' is deprecated, "
@ -1935,7 +1978,24 @@ handle_global_item(const char *name, const char *value)
mxs_log_set_priority_enabled(lognames[i].priority, config_truth_value(value));
}
}
if (!found)
{
for (int i = 0; !found && config_pre_parse_global_params[i]; ++i)
{
found = strcmp(name, config_pre_parse_global_params[i]) == 0;
}
}
processed = found;
}
if (!processed)
{
MXS_WARNING("Config entry '%s' is unknown."
" Please remove it from the configuration file.", name);
}
return 1;
}

View File

@ -2717,7 +2717,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
if (strcmp(name, "logdir") == 0)
if (strcmp(name, CN_LOGDIR) == 0)
{
if (strcmp(get_logdir(), default_logdir) == 0)
{
@ -2731,7 +2731,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "libdir") == 0)
else if (strcmp(name, CN_LIBDIR) == 0)
{
if (strcmp(get_libdir(), default_libdir) == 0)
{
@ -2745,7 +2745,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "piddir") == 0)
else if (strcmp(name, CN_PIDDIR) == 0)
{
if (strcmp(get_piddir(), default_piddir) == 0)
{
@ -2759,7 +2759,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "datadir") == 0)
else if (strcmp(name, CN_DATADIR) == 0)
{
if (!datadir_defined)
{
@ -2776,7 +2776,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "cachedir") == 0)
else if (strcmp(name, CN_CACHEDIR) == 0)
{
if (strcmp(get_cachedir(), default_cachedir) == 0)
{
@ -2790,7 +2790,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "language") == 0)
else if (strcmp(name, CN_LANGUAGE) == 0)
{
if (strcmp(get_langdir(), default_langdir) == 0)
{
@ -2804,7 +2804,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "execdir") == 0)
else if (strcmp(name, CN_EXECDIR) == 0)
{
if (strcmp(get_execdir(), default_execdir) == 0)
{
@ -2818,7 +2818,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "connector_plugindir") == 0)
else if (strcmp(name, CN_CONNECTOR_PLUGINDIR) == 0)
{
if (strcmp(get_connector_plugindir(), default_connector_plugindir) == 0)
{
@ -2832,7 +2832,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "persistdir") == 0)
else if (strcmp(name, CN_PERSISTDIR) == 0)
{
if (strcmp(get_config_persistdir(), default_config_persistdir) == 0)
{
@ -2846,7 +2846,7 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "module_configdir") == 0)
else if (strcmp(name, CN_MODULE_CONFIGDIR) == 0)
{
if (strcmp(get_module_configdir(), default_module_configdir) == 0)
{
@ -2860,25 +2860,25 @@ static int cnf_preparser(void* data, const char* section, const char* name, cons
}
}
}
else if (strcmp(name, "syslog") == 0)
else if (strcmp(name, CN_SYSLOG) == 0)
{
if (!syslog_configured)
{
cnf->syslog = config_truth_value((char*)value);
}
}
else if (strcmp(name, "maxlog") == 0)
else if (strcmp(name, CN_MAXLOG) == 0)
{
if (!maxlog_configured)
{
cnf->maxlog = config_truth_value((char*)value);
}
}
else if (strcmp(name, "log_augmentation") == 0)
else if (strcmp(name, CN_LOG_AUGMENTATION) == 0)
{
set_log_augmentation(value);
}
else if (strcmp(name, "log_to_shm") == 0)
else if (strcmp(name, CN_LOG_TO_SHM) == 0)
{
if (!log_to_shm_configured)
{

View File

@ -45,6 +45,7 @@ extern const char *config_listener_params[];
extern const char *config_monitor_params[];
extern const char *config_filter_params[];
extern const char *config_server_params[];
extern const char *config_pre_parse_global_params[];
/**
* Set the defaults for the global configuration options