MXS-1882: Make [maxscale] sections in sub-configs an error

Defining the [maxscale] section in a configuration file that is not the
root configuration file is now treated as an error instead of silently
ignored.
This commit is contained in:
Markus Mäkelä
2018-05-24 12:23:27 +03:00
parent 3097137a2f
commit a705130708
2 changed files with 14 additions and 2 deletions

View File

@ -123,7 +123,8 @@ form.
### Global Settings ### Global Settings
The global settings, in a section named `[MaxScale]`, allow various parameters The global settings, in a section named `[MaxScale]`, allow various parameters
that affect MariaDB MaxScale as a whole to be tuned. that affect MariaDB MaxScale as a whole to be tuned. This section must be
defined in the root configuration file which by default is `/etc/maxscale.cnf`.
#### `threads` #### `threads`

View File

@ -474,6 +474,8 @@ static bool is_empty_string(const char* str)
return true; return true;
} }
static bool is_root_config_file = true;
/** /**
* Config item handler for the ini file reader * Config item handler for the ini file reader
* *
@ -524,7 +526,15 @@ static int ini_handler(void *userdata, const char *section, const char *name, co
if (strcmp(section, CN_GATEWAY) == 0 || strcasecmp(section, CN_MAXSCALE) == 0) if (strcmp(section, CN_GATEWAY) == 0 || strcasecmp(section, CN_MAXSCALE) == 0)
{ {
return handle_global_item(name, value); if (is_root_config_file)
{
return handle_global_item(name, value);
}
else
{
MXS_ERROR("The [maxscale] section must only be defined in the root configuration file.");
return 0;
}
} }
else if (strlen(section) == 0) else if (strlen(section) == 0)
{ {
@ -842,6 +852,7 @@ config_load_and_process(const char* filename, bool (*process_config)(CONFIG_CONT
if (config_load_single_file(filename, &dcontext, &ccontext)) if (config_load_single_file(filename, &dcontext, &ccontext))
{ {
is_root_config_file = false;
const char DIR_SUFFIX[] = ".d"; const char DIR_SUFFIX[] = ".d";
char dir[strlen(filename) + sizeof(DIR_SUFFIX)]; char dir[strlen(filename) + sizeof(DIR_SUFFIX)];