summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/auth/KeyRing.cc6
-rwxr-xr-xsrc/ceph.in13
-rw-r--r--src/ceph_conf.cc2
-rw-r--r--src/common/config.cc15
-rw-r--r--src/common/config.h4
-rw-r--r--src/global/global_init.cc4
-rw-r--r--src/mon/Monitor.cc2
7 files changed, 31 insertions, 15 deletions
diff --git a/src/auth/KeyRing.cc b/src/auth/KeyRing.cc
index 56655392bae..c41f3008b5f 100644
--- a/src/auth/KeyRing.cc
+++ b/src/auth/KeyRing.cc
@@ -42,11 +42,15 @@ int KeyRing::from_ceph_context(CephContext *cct)
int ret = -ENOENT;
string filename;
- if (ceph_resolve_file_search(conf->keyring, filename)) {
+ ret = ceph_resolve_file_search(conf->keyring, filename);
+ if (ret == 0) {
ret = load(cct, filename);
if (ret < 0)
lderr(cct) << "failed to load " << filename
<< ": " << cpp_strerror(ret) << dendl;
+ } else {
+ lderr(cct) << "error opening keyring: " << cpp_strerror(errno) << dendl;
+ return -errno;
}
if (!conf->key.empty()) {
diff --git a/src/ceph.in b/src/ceph.in
index b5b6f4b0d38..381132bd235 100755
--- a/src/ceph.in
+++ b/src/ceph.in
@@ -543,8 +543,13 @@ def main():
if parsed_args.cluster:
clustername = parsed_args.cluster
- cluster_handle = rados.Rados(name=name, clustername=clustername,
- conf_defaults=conf_defaults, conffile=conffile)
+ try:
+ cluster_handle = rados.Rados(name=name, clustername=clustername,
+ conf_defaults=conf_defaults,
+ conffile=conffile)
+ except Exception as e:
+ print >> sys.stderr, "Error opening cluster: ", str(e)
+ return 1
retargs = cluster_handle.conf_parse_argv(childargs)
#tmp = childargs
@@ -570,8 +575,8 @@ def main():
print >> sys.stderr, 'Cluster connection aborted'
return 1
except Exception as e:
- print >> sys.stderr, 'Error connecting to cluster: {0}'.\
- format(e.__class__.__name__)
+ print >> sys.stderr, 'Error connecting to cluster: {0}({1})'.\
+ format(e.__class__.__name__, str(e))
return 1
if parsed_args.help or parsed_args.help_all:
diff --git a/src/ceph_conf.cc b/src/ceph_conf.cc
index b2286f4e094..24ab2ba8896 100644
--- a/src/ceph_conf.cc
+++ b/src/ceph_conf.cc
@@ -129,7 +129,7 @@ static int lookup(const std::deque<std::string> &sections,
else if (ret == 0) {
if (resolve_search) {
string result;
- if (ceph_resolve_file_search(val, result))
+ if (ceph_resolve_file_search(val, result) >= 0)
puts(result.c_str());
}
else {
diff --git a/src/common/config.cc b/src/common/config.cc
index 5c64f4ec151..79415c74fa1 100644
--- a/src/common/config.cc
+++ b/src/common/config.cc
@@ -96,7 +96,7 @@ struct config_option config_optionsp[] = {
const int NUM_CONFIG_OPTIONS = sizeof(config_optionsp) / sizeof(config_option);
-bool ceph_resolve_file_search(const std::string& filename_list,
+int ceph_resolve_file_search(const std::string& filename_list,
std::string& result)
{
list<string> ls;
@@ -105,15 +105,20 @@ bool ceph_resolve_file_search(const std::string& filename_list,
list<string>::iterator iter;
for (iter = ls.begin(); iter != ls.end(); ++iter) {
int fd = ::open(iter->c_str(), O_RDONLY);
- if (fd < 0)
- continue;
+ if (fd < 0) {
+ if (errno == ENOENT) {
+ continue;
+ } else {
+ return errno;
+ }
+ }
close(fd);
result = *iter;
- return true;
+ return 0;
}
- return false;
+ return ENOENT;
}
md_config_t::md_config_t()
diff --git a/src/common/config.h b/src/common/config.h
index 08ae660b92b..6f34369232c 100644
--- a/src/common/config.h
+++ b/src/common/config.h
@@ -235,8 +235,8 @@ typedef enum {
OPT_ADDR, OPT_U32, OPT_U64, OPT_UUID
} opt_type_t;
-bool ceph_resolve_file_search(const std::string& filename_list,
- std::string& result);
+int ceph_resolve_file_search(const std::string& filename_list,
+ std::string& result);
struct config_option {
const char *name;
diff --git a/src/global/global_init.cc b/src/global/global_init.cc
index e96c317f820..78da8458ab9 100644
--- a/src/global/global_init.cc
+++ b/src/global/global_init.cc
@@ -93,7 +93,9 @@ void global_init(std::vector < const char * > *alt_def_args, std::vector < const
}
}
else if (ret) {
- dout_emergency("global_init: error reading config file.\n");
+ dout_emergency("global_init: error reading config file: ");
+ dout_emergency(cpp_strerror(ret));
+ dout_emergency("\n");
_exit(1);
}
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 9c23a825bd9..edf0af7fd81 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -3594,7 +3594,7 @@ int Monitor::mkfs(bufferlist& osdmapbl)
KeyRing keyring;
string keyring_filename;
- if (!ceph_resolve_file_search(g_conf->keyring, keyring_filename)) {
+ if (ceph_resolve_file_search(g_conf->keyring, keyring_filename) != 0) {
derr << "unable to find a keyring file on " << g_conf->keyring << dendl;
return -ENOENT;
}