From dfd310368267df848f2b65cc536b4ffcb039d353 Mon Sep 17 00:00:00 2001 From: Sam Lang Date: Mon, 24 Sep 2012 09:55:25 -0700 Subject: [PATCH] client: Fix for #3184 cfuse segv with no keyring 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 (cherry picked from commit 47983df4cbd31f299eef896b4612d3837bd7c7bd) --- src/ceph_fuse.cc | 21 +++++++++++++++------ src/client/Client.cc | 12 ++++++++++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc index d76963a788010..b218dd29201c9 100644 --- a/src/ceph_fuse.cc +++ b/src/ceph_fuse.cc @@ -125,14 +125,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; @@ -147,11 +155,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; diff --git a/src/client/Client.cc b/src/client/Client.cc index baa5dfadde514..3af00f52134c6 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -272,7 +272,7 @@ void Client::dump_cache() int Client::init() { - Mutex::Locker lock(client_lock); + client_lock.Lock(); assert(!initialized); timer.init(); @@ -283,8 +283,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(); @@ -303,6 +310,7 @@ int Client::init() cct->get_perfcounters_collection()->add(logger); initialized = true; + client_lock.Unlock(); return r; } -- 2.39.5