]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
auth/KeyRing: always decode keying as plaintext
authorKefu Chai <kchai@redhat.com>
Tue, 1 Jun 2021 14:44:08 +0000 (22:44 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 2 Jun 2021 03:02:28 +0000 (11:02 +0800)
for three reasons:

* we don't encode binary KeyRing since v0.48: the binary encoder for
  KeyRing was dropped in eaea7aa9b28849be612b22ce84971db671319806,
  which was included since v0.48 (argonaut). and we don't encode
  KeyRing in binary manually elsewhere since then.
* we should not use exception in the normal code path. in C++,
  exception is not designed to be efficient or semantically a
  language facility to be part of the normal code path. so, from
  the readability perspective, we should not use exception here.
  as all encoded KeyRings are in plaintext.
* simpler this way.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/auth/KeyRing.cc

index 2ddc0b4ab22bcf8bd0eb238b30598c3c04db04d6..6686fa9f51af418361172bdf491622a68bc9474b 100644 (file)
@@ -201,17 +201,10 @@ void KeyRing::decode_plaintext(bufferlist::const_iterator& bli)
   }
 }
 
-void KeyRing::decode(bufferlist::const_iterator& bl) {
-  __u8 struct_v;
+void KeyRing::decode(bufferlist::const_iterator& bl)
+{
   auto start_pos = bl;
-  try {
-    using ceph::decode;
-    decode(struct_v, bl);
-    decode(keys, bl);
-  } catch (ceph::buffer::error& err) {
-    keys.clear();
-    decode_plaintext(start_pos);
-  }
+  decode_plaintext(start_pos);
 }
 
 int KeyRing::load(CephContext *cct, const std::string &filename)