From 1d830df90169f7220b5ffe65e249cbdc38b512cc Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 16 Apr 2018 05:39:03 -0400 Subject: [PATCH] mgr: don't migrate config values that look like data A quickie heuristic, but sufficient to avoid picking up e.g. SSL certs and trying to cram them into config values. Signed-off-by: John Spray --- src/mgr/PyModuleRegistry.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/mgr/PyModuleRegistry.cc b/src/mgr/PyModuleRegistry.cc index f66f0a2feb9db..940d65f60541f 100644 --- a/src/mgr/PyModuleRegistry.cc +++ b/src/mgr/PyModuleRegistry.cc @@ -410,6 +410,29 @@ void PyModuleRegistry::upgrade_config( auto last_slash = i.first.rfind('/'); const std::string module_name = i.first.substr(4, i.first.substr(4).find('/')); const std::string key = i.first.substr(last_slash + 1); + + const auto &value = i.second; + + // Heuristic to skip things that look more like stores + // than configs. + bool is_config = true; + for (const auto &c : value) { + if (c == '\n' || c == '\r' || c < 0x20) { + is_config = false; + break; + } + } + + if (value.size() > 256) { + is_config = false; + } + + if (!is_config) { + dout(1) << "Not migrating config module:key " + << module_name << " : " << key << dendl; + continue; + } + module_config.set_config(monc, module_name, key, i.second); dout(4) << "Rewrote configuration module:key " << module_name << ":" << key << dendl; -- 2.39.5