From: Greg Farnum Date: Fri, 26 Mar 2010 22:57:14 +0000 (-0700) Subject: auth: Keyring no longer segfaults if HOME env variable is unset. X-Git-Tag: v0.20~160 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=06393de7aceda4fa0f5d71871abc873e6ee6ab1d;p=ceph.git auth: Keyring no longer segfaults if HOME env variable is unset. Just skip that path, instead. We can't recover what it meant. --- diff --git a/src/auth/KeyRing.cc b/src/auth/KeyRing.cc index a64d238fafd5..481c73763e6d 100644 --- a/src/auth/KeyRing.cc +++ b/src/auth/KeyRing.cc @@ -41,8 +41,12 @@ bool KeyRing::load(const char *filename_list) for (list::iterator p = ls.begin(); p != ls.end(); p++) { // subst in home dir? size_t pos = p->find("~/"); - if (pos != string::npos) - p->replace(pos, 1, getenv("HOME")); + if (pos != string::npos) { + const char *home = getenv("HOME"); + if (home) + p->replace(pos, 1, getenv("HOME")); + else break; //skip, we couldn't correct it + } if (bl.read_file(p->c_str(), true) == 0) { loaded = true;