X-Git-Url: https://git.proxmox.com/?p=ceph.git;a=blobdiff_plain;f=ceph%2Fsrc%2Fmon%2FConfigKeyService.cc;h=e191f8367c80276d9f7f55c4d8973e269188417a;hp=29ae9d959427aa4c38872fddb33607b44b1c6e24;hb=28e407b858acd3bddc89f68583571f771bb42e46;hpb=dfcb7b53b2e4fcd2a5af0240d4975adc711ab96e diff --git a/ceph/src/mon/ConfigKeyService.cc b/ceph/src/mon/ConfigKeyService.cc index 29ae9d959..e191f8367 100644 --- a/ceph/src/mon/ConfigKeyService.cc +++ b/ceph/src/mon/ConfigKeyService.cc @@ -108,6 +108,17 @@ bool ConfigKeyService::store_has_prefix(const string &prefix) return false; } +static bool is_binary_string(const string& s) +{ + for (auto c : s) { + // \n and \t are escaped in JSON; other control characters are not. + if ((c < 0x20 && c != '\n' && c != '\t') || c >= 0x7f) { + return true; + } + } + return false; +} + void ConfigKeyService::store_dump(stringstream &ss) { KeyValueDB::Iterator iter = @@ -117,7 +128,14 @@ void ConfigKeyService::store_dump(stringstream &ss) f.open_object_section("config-key store"); while (iter->valid()) { - f.dump_string(iter->key().c_str(), iter->value().to_str()); + string s = iter->value().to_str(); + if (is_binary_string(s)) { + ostringstream ss; + ss << "<<< binary blob of length " << s.size() << " >>>"; + f.dump_string(iter->key().c_str(), ss.str()); + } else { + f.dump_string(iter->key().c_str(), s); + } iter->next(); } f.close_section();