From: John Spray Date: Mon, 16 Apr 2018 09:39:03 +0000 (-0400) Subject: mgr: don't migrate config values that look like data X-Git-Tag: v13.1.0~143^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1d830df90169f7220b5ffe65e249cbdc38b512cc;p=ceph-ci.git 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 --- diff --git a/src/mgr/PyModuleRegistry.cc b/src/mgr/PyModuleRegistry.cc index f66f0a2feb9..940d65f6054 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;