]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: don't migrate config values that look like data
authorJohn Spray <john.spray@redhat.com>
Mon, 16 Apr 2018 09:39:03 +0000 (05:39 -0400)
committerJohn Spray <john.spray@redhat.com>
Mon, 23 Apr 2018 11:29:46 +0000 (07:29 -0400)
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 <john.spray@redhat.com>
src/mgr/PyModuleRegistry.cc

index f66f0a2feb9db54533dbd818b2150ebb8fce12d3..940d65f60541fcbdb6bf4ce3b3a2a8716417d263 100644 (file)
@@ -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;