Skip to content

Commit

Permalink
Merge pull request #30117 from smithfarm/wip-41438-mimic
Browse files Browse the repository at this point in the history
mimic: rbd-mirror: ignore errors relating to parsing the cluster config file

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
yuriw committed Oct 8, 2019
2 parents 40c14f5 + 6287126 commit 0f54652
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/global/global_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,30 @@ global_init(const std::map<std::string,std::string> *defaults,
gid_t gid = 0;
std::string uid_string;
std::string gid_string;
std::string home_directory;
if (g_conf->setuser.length()) {
char buf[4096];
struct passwd pa;
struct passwd *p = 0;

uid = atoi(g_conf->setuser.c_str());
if (!uid) {
char buf[4096];
struct passwd pa;
struct passwd *p = 0;
if (uid) {
getpwuid_r(uid, &pa, buf, sizeof(buf), &p);
} else {
getpwnam_r(g_conf->setuser.c_str(), &pa, buf, sizeof(buf), &p);
if (!p) {
if (!p) {
cerr << "unable to look up user '" << g_conf->setuser << "'"
<< std::endl;
exit(1);
}
uid = p->pw_uid;
gid = p->pw_gid;
uid_string = g_conf->setuser;

uid = p->pw_uid;
gid = p->pw_gid;
uid_string = g_conf->setuser;
}

if (p && p->pw_dir != nullptr) {
home_directory = std::string(p->pw_dir);
}
}
if (g_conf->setgroup.length() > 0) {
Expand Down Expand Up @@ -293,6 +302,10 @@ global_init(const std::map<std::string,std::string> *defaults,
<< std::endl;
exit(1);
}
if (setenv("HOME", home_directory.c_str(), 1) != 0) {
cerr << "warning: unable to set HOME to " << home_directory << ": "
<< cpp_strerror(errno) << std::endl;
}
priv_ss << "set uid:gid to " << uid << ":" << gid << " (" << uid_string << ":" << gid_string << ")";
} else {
priv_ss << "deferred set uid:gid to " << uid << ":" << gid << " (" << uid_string << ":" << gid_string << ")";
Expand Down

0 comments on commit 0f54652

Please sign in to comment.