From 5afceb11857f7e4aefbb42eac4e7c09ad12d418c Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 24 Jan 2019 11:29:16 +0200 Subject: [PATCH] MXS-2274 Reserve names starting with `@@` for use by MaxScale Names starting with '@@' can now longer be used in configuration files. Subsequent commits will prevent such names from being used when objects are created dynamically. --- Documentation/Changelog.md | 8 +++ .../MaxScale-2.4.0-Release-Notes.md | 45 ++++++++++++++++ .../Upgrading/Upgrading-To-MaxScale-2.4.md | 24 +++++++++ include/maxscale/config.hh | 16 ++++++ server/core/config.cc | 54 +++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 Documentation/Release-Notes/MaxScale-2.4.0-Release-Notes.md create mode 100644 Documentation/Upgrading/Upgrading-To-MaxScale-2.4.md diff --git a/Documentation/Changelog.md b/Documentation/Changelog.md index 7f95a38e7..e8037428e 100644 --- a/Documentation/Changelog.md +++ b/Documentation/Changelog.md @@ -1,5 +1,13 @@ # Changelog +## MariaDB MaxScale 2.4 + +* Names starting with `@@` are reserved for use by MaxScale. + +For more details, please refer to: + +* [MariaDB MaxScale 2.4.0 Release Notes](Release-Notes/MaxScale-2.4.0-Release-Notes.md) + ## MariaDB MaxScale 2.3 * Runtime Configuration of the Cache diff --git a/Documentation/Release-Notes/MaxScale-2.4.0-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.4.0-Release-Notes.md new file mode 100644 index 000000000..68e094ba0 --- /dev/null +++ b/Documentation/Release-Notes/MaxScale-2.4.0-Release-Notes.md @@ -0,0 +1,45 @@ +# MariaDB MaxScale 2.4.0 Release Notes + +Release 2.4.0 is a Beta release. + +This document describes the changes in release 2.4.0, when compared to +release 2.3. + +For any problems you encounter, please consider submitting a bug +report at [Jira](https://jira.mariadb.org). + +## Changed Features + +### Section and object names + +Section and object names starting with `@@` are now reserved for +use by MaxScale itself. If any such names are encountered in +configuration files, then MaxScale will not start. + +## Dropped Features + +## New Features + +## Bug fixes + +[Here is a list of bugs fixed in MaxScale 2.4.0.](https://jira.mariadb.org/issues/?jql=project%20%3D%20MXS%20AND%20issuetype%20%3D%20Bug%20AND%20status%20%3D%20Closed%20AND%20fixVersion%20%3D%202.4.0) + +## Known Issues and Limitations + +There are some limitations and known issues within this version of MaxScale. +For more information, please refer to the [Limitations](../About/Limitations.md) document. + +## Packaging + +RPM and Debian packages are provided for the Linux distributions supported +by MariaDB Enterprise. + +Packages can be downloaded [here](https://mariadb.com/resources/downloads). + +## Source Code + +The source code of MaxScale is tagged at GitHub with a tag, which is identical +with the version of MaxScale. For instance, the tag of version X.Y.Z of MaxScale +is X.Y.Z. Further, *master* always refers to the latest released non-beta version. + +The source code is available [here](https://github.com/mariadb-corporation/MaxScale). diff --git a/Documentation/Upgrading/Upgrading-To-MaxScale-2.4.md b/Documentation/Upgrading/Upgrading-To-MaxScale-2.4.md new file mode 100644 index 000000000..26d3308ce --- /dev/null +++ b/Documentation/Upgrading/Upgrading-To-MaxScale-2.4.md @@ -0,0 +1,24 @@ +# Upgrading MariaDB MaxScale from 2.3 to 2.4 + +This document describes possible issues when upgrading MariaDB +MaxScale from version 2.3 to 2.4. + +For more information about MariaDB MaxScale 2.4, please refer +to the [ChangeLog](../Changelog.md). + +Before starting the upgrade, we recommend you back up your current +configuration file. + +## Section Names + +Section and object names starting with `@@` are now reserved for +internal use by MaxScale. + +In case such names have been used, they must manually be changed +in all configuration files of MaxScale, before MaxScale 2.4 is started. + +Those files are: + +* The main configuration file; typically `/etc/maxscale.cnf`. +* All nested configuration files; typically `/etc/maxscale.cnf.d/*`. +* All dynamic configuration files; typically `/var/lib/maxscale/maxscale.cnd.d/*`. diff --git a/include/maxscale/config.hh b/include/maxscale/config.hh index 3227c3eca..b25fbc61e 100644 --- a/include/maxscale/config.hh +++ b/include/maxscale/config.hh @@ -601,6 +601,22 @@ bool config_set_writeq_low_water(uint32_t size); bool config_parse_disk_space_threshold(SERVER::DiskSpaceLimits* disk_space_threshold, const char* config_value); +/** + * @brief Check whether section/object name is valid. + * + * @param name The name to be checked. + * @param reason If non-null, will in case the name is not valid contain + * the reason when the function returns. + * + * @return True, if the name is valid, false otherwise. + */ +bool config_is_valid_name(const char* name, std::string* reason = nullptr); + +inline bool config_is_valid_name(const std::string& name, std::string* reason = nullptr) +{ + return config_is_valid_name(name.c_str()); +} + namespace maxscale { diff --git a/server/core/config.cc b/server/core/config.cc index e969026d9..a31c6b6f7 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -751,6 +751,23 @@ static int ini_handler(void* userdata, const char* section, const char* name, co strcpy(fixed_section, section); fix_section_name(fixed_section); + string reason; + if (!config_is_valid_name(fixed_section, &reason)) + { + /* A set that holds all the section names that are invalid. As the configuration file + * is parsed multiple times, we need to do this to prevent the same complaint from + * being logged multiple times. + */ + static std::set warned_invalid_names; + + if (warned_invalid_names.find(reason) == warned_invalid_names.end()) + { + MXS_ERROR("%s", reason.c_str()); + warned_invalid_names.insert(reason); + } + return 0; + } + /* * If we already have some parameters for the object * add the parameters to that object. If not create @@ -5038,3 +5055,40 @@ std::string closest_matching_parameter(const std::string& str, return rval; } + +bool config_is_valid_name(const char* zName, std::string* pReason) +{ + bool is_valid = true; + + for (const char* z = zName; is_valid && *z; z++) + { + if (isspace(*z)) + { + is_valid = false; + + if (pReason) + { + *pReason = "The name '"; + *pReason += zName; + *pReason += "' contains whitespace."; + } + } + } + + if (is_valid) + { + if (strncmp(zName, "@@", 2) == 0) + { + is_valid = false; + + if (pReason) + { + *pReason = "The name '"; + *pReason += zName; + *pReason += "' starts with '@@', which is a prefix reserved for MaxScale."; + } + } + } + + return is_valid; +}