Fix infinite loop when user/group for -u/-g are invalid.

Fixes #6008
This commit is contained in:
Gunnar Beutner 2014-04-13 23:35:42 +02:00
parent c4893ad1a0
commit 25b598300f
1 changed files with 19 additions and 20 deletions

View File

@ -229,7 +229,7 @@ int main(int argc, char **argv)
#ifndef _WIN32 #ifndef _WIN32
("user,u", po::value<std::string>(), "user to run Icinga as") ("user,u", po::value<std::string>(), "user to run Icinga as")
("group,g", po::value<std::string>(), "group to run Icinga as") ("group,g", po::value<std::string>(), "group to run Icinga as")
#endif #endif /* _WIN32 */
; ;
try { try {
@ -243,6 +243,24 @@ int main(int argc, char **argv)
po::notify(g_AppParams); po::notify(g_AppParams);
if (g_AppParams.count("define")) {
BOOST_FOREACH(const String& define, g_AppParams["define"].as<std::vector<std::string> >()) {
String key, value;
size_t pos = define.FindFirstOf('=');
if (pos != String::NPos) {
key = define.SubStr(0, pos);
value = define.SubStr(pos + 1);
} else {
key = define;
value = "1";
}
ScriptVariable::Set(key, value);
}
}
Application::DeclareStatePath(Application::GetLocalStateDir() + "/lib/icinga2/icinga2.state");
Application::DeclarePidPath(Application::GetLocalStateDir() + "/run/icinga2/icinga2.pid");
#ifndef _WIN32 #ifndef _WIN32
if (g_AppParams.count("group")) { if (g_AppParams.count("group")) {
String group = g_AppParams["group"].as<std::string>(); String group = g_AppParams["group"].as<std::string>();
@ -325,25 +343,6 @@ int main(int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if (g_AppParams.count("define")) {
BOOST_FOREACH(const String& define, g_AppParams["define"].as<std::vector<std::string> >()) {
String key, value;
size_t pos = define.FindFirstOf('=');
if (pos != String::NPos) {
key = define.SubStr(0, pos);
value = define.SubStr(pos + 1);
}
else {
key = define;
value = "1";
}
ScriptVariable::Set(key, value);
}
}
Application::DeclareStatePath(Application::GetLocalStateDir() + "/lib/icinga2/icinga2.state");
Application::DeclarePidPath(Application::GetLocalStateDir() + "/run/icinga2/icinga2.pid");
ScriptVariable::Set("UseVfork", true, false, true); ScriptVariable::Set("UseVfork", true, false, true);
Application::MakeVariablesConstant(); Application::MakeVariablesConstant();