]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Fix for #3184 cfuse segv with no keyring
authorSam Lang <sam.lang@inktank.com>
Mon, 24 Sep 2012 16:55:25 +0000 (09:55 -0700)
committerSage Weil <sage@inktank.com>
Wed, 26 Sep 2012 15:24:25 +0000 (08:24 -0700)
Fixes bug #3184 where the ceph-fuse client segfaults if authx is
enabled but no keyring file is present.  This was due to the
client->init() return value not getting checked.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/ceph_fuse.cc
src/client/Client.cc

index d00859404f2a6d1dd9c7d02275b3523f2da554c7..e1b96550b1acd9202bfe9cd3dc4934e56f153cac 100644 (file)
@@ -130,14 +130,22 @@ int main(int argc, const char **argv, const char *envp[]) {
       g_ceph_context->_log->start();
 
     cout << "ceph-fuse[" << getpid() << "]: starting ceph client" << std::endl;
-    messenger->start();
+    int r = messenger->start();
+    if (r < 0) {
+      cerr << "ceph-fuse[" << getpid() << "]: ceph mount failed with " << cpp_strerror(-r) << std::endl;
+      goto out_messenger_start_failed;
+    }
 
     // start client
-    client->init();
+    r = client->init();
+    if (r < 0) {
+      cerr << "ceph-fuse[" << getpid() << "]: ceph mount failed with " << cpp_strerror(-r) << std::endl;
+      goto out_init_failed;
+    }
     
     // start up fuse
     // use my argc, argv (make sure you pass a mount point!)
-    int r = client->mount(g_conf->client_mountpoint.c_str());
+    r = client->mount(g_conf->client_mountpoint.c_str());
     if (r < 0) {
       cerr << "ceph-fuse[" << getpid() << "]: ceph mount failed with " << cpp_strerror(-r) << std::endl;
       goto out_shutdown;
@@ -152,11 +160,12 @@ int main(int argc, const char **argv, const char *envp[]) {
     
   out_shutdown:
     client->shutdown();
-    delete client;
-    
+  out_init_failed:
     // wait for messenger to finish
     messenger->wait();
-
+  out_messenger_start_failed:
+    delete client;
+    
     if (g_conf->daemonize) {
       //cout << "child signalling parent with " << r << std::endl;
       static int foo = 0;
index 00b7bdee567c131b3ade8246a7f50dfe68baf767..b30bb653a1b2e29be5e74903ed913f3a74fa430c 100644 (file)
@@ -268,7 +268,7 @@ void Client::dump_cache()
 
 int Client::init() 
 {
-  Mutex::Locker lock(client_lock);
+  client_lock.Lock();
   assert(!initialized);
 
   timer.init();
@@ -279,8 +279,15 @@ int Client::init()
   messenger->add_dispatcher_head(this);
 
   int r = monclient->init();
-  if (r < 0)
+  if (r < 0) {
+    // need to do cleanup because we're in an intermediate init state
+    timer.shutdown();
+    client_lock.Unlock();
+    objectcacher->stop();
+    monclient->shutdown();
+    messenger->shutdown();
     return r;
+  }
 
   objecter->init();
 
@@ -300,6 +307,7 @@ int Client::init()
   cct->get_perfcounters_collection()->add(logger);
 
   initialized = true;
+  client_lock.Unlock();
   return r;
 }