]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/auth/KeyRing.cc
import 15.2.0 Octopus source
[ceph.git] / ceph / src / auth / KeyRing.cc
index 41e440455c283ecb48dcd1cf1898786541c81196..a2833183633a4c04050b3d76ae9e28dee9003608 100644 (file)
@@ -83,11 +83,6 @@ int KeyRing::from_ceph_context(CephContext *cct)
   return ret;
 }
 
-KeyRing *KeyRing::create_empty()
-{
-  return new KeyRing();
-}
-
 int KeyRing::set_modifier(const char *type,
                          const char *val,
                          EntityName& name,
@@ -165,15 +160,12 @@ void KeyRing::decode_plaintext(bufferlist::const_iterator& bli)
   bufferlist bl;
   bli.copy_all(bl);
   ConfFile cf;
-  std::deque<std::string> parse_errors;
 
-  if (cf.parse_bufferlist(&bl, &parse_errors, NULL) != 0) {
+  if (cf.parse_bufferlist(&bl, nullptr) != 0) {
     throw buffer::malformed_input("cannot parse buffer");
   }
 
-  for (ConfFile::const_section_iter_t s = cf.sections_begin();
-           s != cf.sections_end(); ++s) {
-    string name = s->first;
+  for (auto& [name, section] : cf) {
     if (name == "global")
       continue;
 
@@ -185,17 +177,16 @@ void KeyRing::decode_plaintext(bufferlist::const_iterator& bli)
       throw buffer::malformed_input(oss.str().c_str());
     }
 
-    for (ConfSection::const_line_iter_t l = s->second.lines.begin();
-        l != s->second.lines.end(); ++l) {
-      if (l->key.empty())
+    for (auto& [k, val] : section) {
+      if (k.empty())
         continue;
-      string k(l->key);
-      std::replace(k.begin(), k.end(), '_', ' ');
-      ret = set_modifier(k.c_str(), l->val.c_str(), ename, caps);
+      string key;
+      std::replace_copy(k.begin(), k.end(), back_inserter(key), '_', ' ');
+      ret = set_modifier(key.c_str(), val.c_str(), ename, caps);
       if (ret < 0) {
        ostringstream oss;
-       oss << "error setting modifier for [" << name << "] type=" << k
-           << " val=" << l->val;
+       oss << "error setting modifier for [" << name << "] type=" << key
+           << " val=" << val;
        throw buffer::malformed_input(oss.str().c_str());
       }
     }