From 25b598300f14824641513e7d8d1c7b51371f0f74 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 13 Apr 2014 23:35:42 +0200 Subject: [PATCH] Fix infinite loop when user/group for -u/-g are invalid. Fixes #6008 --- icinga-app/icinga.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index cd784bdc5..d04f8a4fc 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -229,7 +229,7 @@ int main(int argc, char **argv) #ifndef _WIN32 ("user,u", po::value(), "user to run Icinga as") ("group,g", po::value(), "group to run Icinga as") -#endif +#endif /* _WIN32 */ ; try { @@ -243,6 +243,24 @@ int main(int argc, char **argv) po::notify(g_AppParams); + if (g_AppParams.count("define")) { + BOOST_FOREACH(const String& define, g_AppParams["define"].as >()) { + 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 if (g_AppParams.count("group")) { String group = g_AppParams["group"].as(); @@ -325,25 +343,6 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } - if (g_AppParams.count("define")) { - BOOST_FOREACH(const String& define, g_AppParams["define"].as >()) { - 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); Application::MakeVariablesConstant();