From a7051307088d854a10ff06736058c064d9ee0d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 24 May 2018 12:23:27 +0300 Subject: [PATCH 1/2] 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. --- .../Getting-Started/Configuration-Guide.md | 3 ++- server/core/config.cc | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index 20bbd0113..e90ffb047 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -123,7 +123,8 @@ form. ### Global Settings 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` diff --git a/server/core/config.cc b/server/core/config.cc index 5b9e1d23b..48133db96 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -474,6 +474,8 @@ static bool is_empty_string(const char* str) return true; } +static bool is_root_config_file = true; + /** * 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) { - 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) { @@ -842,6 +852,7 @@ config_load_and_process(const char* filename, bool (*process_config)(CONFIG_CONT if (config_load_single_file(filename, &dcontext, &ccontext)) { + is_root_config_file = false; const char DIR_SUFFIX[] = ".d"; char dir[strlen(filename) + sizeof(DIR_SUFFIX)]; From cd303df35cc2c661ff6667dca218b16967ff6cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 25 May 2018 12:12:35 +0300 Subject: [PATCH 2/2] Revert "Trunate logs instead of removing" This reverts commit 14dc215a787e64fb6457889b647c861f634d68a5. --- maxscale-system-test/testconnections.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 5895013f9..a2d6f908b 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -642,8 +642,8 @@ void TestConnections::init_maxscale(int m) "chmod a+x %s;" "%s" "iptables -F INPUT;" - "truncate -s 0 %s/maxscale.log;" - "truncate -s 0 %s/maxscale1.log;" + "rm -f %s/maxscale.log;" + "rm -f %s/maxscale1.log;" "rm -rf /tmp/core* /dev/shm/* /var/lib/maxscale/maxscale.cnf.d/ /var/lib/maxscale/*;" "%s", maxscales->access_homedir[m],