From e6f214fa296dcb1121fab04faedc571fe21d0320 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 19 Apr 2018 09:54:29 +0200 Subject: [PATCH] Log warning when sysconfig file cannot be read refs #6215 --- icinga-app/icinga.cpp | 8 ++++++++ lib/base/utility.cpp | 3 +++ 2 files changed, 11 insertions(+) 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); -- 2.40.0