| 160 | } |
| 161 | |
| 162 | void KeyRing::decode(bufferlist::const_iterator& bli) |
| 163 | { |
| 164 | int ret; |
| 165 | bufferlist bl; |
| 166 | bli.copy_all(bl); |
| 167 | ConfFile cf; |
| 168 | |
| 169 | if (cf.parse_bufferlist(&bl, nullptr) != 0) { |
| 170 | throw ceph::buffer::malformed_input("cannot parse buffer"); |
| 171 | } |
| 172 | |
| 173 | for (auto& [name, section] : cf) { |
| 174 | if (name == "global") |
| 175 | continue; |
| 176 | |
| 177 | EntityName ename; |
| 178 | map<string, bufferlist> caps; |
| 179 | if (!ename.from_str(name)) { |
| 180 | ostringstream oss; |
| 181 | oss << "bad entity name in keyring: " << name; |
| 182 | throw ceph::buffer::malformed_input(oss.str().c_str()); |
| 183 | } |
| 184 | |
| 185 | for (auto& [k, val] : section) { |
| 186 | if (k.empty()) |
| 187 | continue; |
| 188 | string key; |
| 189 | std::replace_copy(k.begin(), k.end(), back_inserter(key), '_', ' '); |
| 190 | ret = set_modifier(key.c_str(), val.c_str(), ename, caps); |
| 191 | if (ret < 0) { |
| 192 | ostringstream oss; |
| 193 | oss << "error setting modifier for [" << name << "] type=" << key |
| 194 | << " val=" << val; |
| 195 | throw ceph::buffer::malformed_input(oss.str().c_str()); |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | int KeyRing::load(CephContext *cct, const std::string &filename) |
| 202 | { |
nothing calls this directly
no test coverage detected