]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
auth/KeyRing: remove KeyRing::create_empty()
authorKefu Chai <kchai@redhat.com>
Thu, 13 Jun 2019 14:38:02 +0000 (22:38 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 14 Jun 2019 07:19:30 +0000 (15:19 +0800)
it never fails unless out of memory. and it would be simpler to just
allocate it on stack.

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

index 7f207d8fa538ed229e31ec7daa7012bcb78be58e..c436df52b5646e3d00fffa106b91c5ff8386e557 100644 (file)
@@ -82,11 +82,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,
index 551ff7acc96d3a9dc9a909909806141c36e518e9..d5fe7fabbd4916389d3ab73a820c9471094d75a9 100644 (file)
@@ -29,9 +29,6 @@ public:
    * We will use the configuration stored inside the context. */
   int from_ceph_context(CephContext *cct);
 
-  /* Create an empty KeyRing */
-  static KeyRing *create_empty();
-
   std::map<EntityName, EntityAuth>& get_keys() { return keys; }  // yuck
 
   int load(CephContext *cct, const std::string &filename);
index 4ce211fa90fa9d4800f7558e8a89c66c6193871c..145f404f42352240fdbebd3c1917c41c0906f314 100644 (file)
@@ -321,25 +321,21 @@ int main(int argc, const char **argv)
 
   if (mkkey) {
     common_init_finish(g_ceph_context);
-    KeyRing *keyring = KeyRing::create_empty();
-    if (!keyring) {
-      derr << "Unable to get a Ceph keyring." << dendl;
-      forker.exit(1);
-    }
+    KeyRing keyring;
 
     EntityName ename{g_conf()->name};
     EntityAuth eauth;
 
     std::string keyring_path = g_conf().get_val<std::string>("keyring");
-    int ret = keyring->load(g_ceph_context, keyring_path);
+    int ret = keyring.load(g_ceph_context, keyring_path);
     if (ret == 0 &&
-       keyring->get_auth(ename, eauth)) {
+       keyring.get_auth(ename, eauth)) {
       derr << "already have key in keyring " << keyring_path << dendl;
     } else {
       eauth.key.create(g_ceph_context, CEPH_CRYPTO_AES);
-      keyring->add(ename, eauth);
+      keyring.add(ename, eauth);
       bufferlist bl;
-      keyring->encode_plaintext(bl);
+      keyring.encode_plaintext(bl);
       int r = bl.write_file(keyring_path.c_str(), 0600);
       if (r)
        derr << TEXT_RED << " ** ERROR: writing new keyring to "