has an error. This head object is there to show the snapset that was used in
determining errors.
+
+* The config-key interface can store arbitrary binary blobs but JSON
+ can only express printable strings. If binary blobs are present,
+ the 'ceph config-key dump' command will show them as something like
+ ``<<< binary blob of length N >>>``.
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, const string& prefix)
{
KeyValueDB::Iterator iter =
iter->key().find(prefix) != 0) {
break;
}
- 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();