From: Michael Friedrich Date: Thu, 19 Apr 2018 07:54:29 +0000 (+0200) Subject: Log warning when sysconfig file cannot be read X-Git-Tag: v2.9.0~87^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6f214fa296dcb1121fab04faedc571fe21d0320;p=icinga2 Log warning when sysconfig file cannot be read refs #6215 --- diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index af8a1dda9..34aeddb69 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -155,6 +155,13 @@ static int Main() Application::DeclareZonesDir(Application::GetSysconfDir() + "/icinga2/zones.d"); +#ifndef _WIN32 + if (!Utility::PathExists(Application::GetSysconfigFile())) { + Log(LogWarning, "icinga-app") + << "Sysconfig file '" << Application::GetSysconfigFile() << "' cannot be read. Using default values."; + } +#endif /* _WIN32 */ + String icingaUser = Utility::GetFromSysconfig("ICINGA2_USER"); if (icingaUser.IsEmpty()) icingaUser = ICINGA_USER; @@ -456,6 +463,7 @@ static int Main() std::cout << visibleDesc << std::endl << "Report bugs at " << std::endl + << "Get support: " << std::endl << "Icinga home page: " << std::endl; return EXIT_SUCCESS; } diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index 6869e353d..2d1fb8965 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -1943,6 +1943,9 @@ String Utility::GetFromSysconfig(const String& env) if (sysconf.IsEmpty()) return ""; + if (!Utility::PathExists(sysconf)) + return ""; + String cmdInner = ". " + EscapeShellArg(sysconf) + " 2>&1 >/dev/null;echo \"$" + env + "\""; String cmd = "sh -c " + EscapeShellArg(cmdInner);