bool side_effect_free, bool deprecated);
};
+/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
#define REGISTER_FUNCTION(ns, name, callback, args) \
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
Function::Ptr sf = new icinga::Function(#ns "#" #name, callback, String(args).Split(":"), false); \
using namespace icinga;
+/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
INITIALIZE_ONCE_WITH_PRIORITY([]() {
Type::Ptr type = new ObjectType();
type->SetPrototype(Object::GetPrototype());
ObjectFactory m_Factory;
};
+/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
#define REGISTER_BUILTIN_TYPE(type, prototype) \
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
icinga::Type::Ptr t = new PrimitiveType(#type, "None"); \
static auto l_InternalNSBehavior = new ConstNamespaceBehavior();
+/* Ensure that this gets called with highest priority
+ * and wins against other static initializers in lib/icinga, etc.
+ * LTO-enabled builds will cause trouble otherwise, see GH #6575.
+ */
INITIALIZE_ONCE_WITH_PRIORITY([]() {
Namespace::Ptr globalNS = ScriptGlobal::GetGlobals();
Namespace::Ptr internalNS = new Namespace(l_InternalNSBehavior);
globalNS->SetAttribute("Internal", std::make_shared<ConstEmbeddedNamespaceValue>(internalNS));
-}, 50);
+}, 1000);
INITIALIZE_ONCE_WITH_PRIORITY([]() {
l_InternalNSBehavior->Freeze();
Type::Ptr Type::TypeInstance;
+/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
INITIALIZE_ONCE_WITH_PRIORITY([]() {
Type::Ptr type = new TypeType();
type->SetPrototype(TypeType::GetPrototype());
{
};
+/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
#define REGISTER_TYPE(type) \
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
icinga::Type::Ptr t = new TypeImpl<type>(); \
#include "base/utility.hpp"
#include "base/logger.hpp"
#include "base/application.hpp"
+#include "base/scriptglobal.hpp"
#include "config/configcompiler.hpp"
#include "config/configcompilercontext.hpp"
#include "config/configitembuilder.hpp"
-
using namespace icinga;
static bool ExecuteExpression(Expression *expression)
return false;
Namespace::Ptr systemNS = ScriptGlobal::Get("System");
+ VERIFY(systemNS);
+
+ /* This is initialized inside the IcingaApplication class. */
Value vAppType;
VERIFY(systemNS->Get("ApplicationType", &vAppType));
#include "base/exception.hpp"
#include "base/application.hpp"
+/* Ensure that the priority is lower than the basic namespace initialization in scriptframe.cpp. */
#define REGISTER_CONFIG_FRAGMENT(name, fragment) \
INITIALIZE_ONCE_WITH_PRIORITY([]() { \
std::unique_ptr<icinga::Expression> expression = icinga::ConfigCompiler::CompileText(name, fragment); \
static Timer::Ptr l_RetentionTimer;
REGISTER_TYPE(IcingaApplication);
+/* Ensure that the priority is lower than the basic System namespace initialization in scriptframe.cpp. */
INITIALIZE_ONCE_WITH_PRIORITY(&IcingaApplication::StaticInitialize, 50);
void IcingaApplication::StaticInitialize()
ScriptGlobal::Set("NodeName", node_name);
- ScriptGlobal::Set("System.ApplicationType", "IcingaApplication", true);
+ Namespace::Ptr systemNS = ScriptGlobal::Get("System");
+ /* Ensure that the System namespace is already initialized. Otherwise this is a programming error. */
+ VERIFY(systemNS);
- ScriptGlobal::Set("System.ApplicationVersion", Application::GetAppVersion(), true);
+ systemNS->Set("ApplicationType", "IcingaApplication", true);
+ systemNS->Set("ApplicationVersion", Application::GetAppVersion(), true);
Namespace::Ptr globalNS = ScriptGlobal::GetGlobals();
+ VERIFY(globalNS);
auto icingaNSBehavior = new ConstNamespaceBehavior();
icingaNSBehavior->Freeze();