From abe3f8a9590d1bdc5cf8222538d26ccdc976ea48 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 3 Jan 2018 10:19:24 +0100 Subject: [PATCH] Build fix for Debian wheezy --- icinga-app/icinga.cpp | 2 +- lib/base/function.cpp | 2 +- lib/base/scriptframe.cpp | 2 +- lib/base/scriptframe.hpp | 4 ++-- lib/cli/consolecommand.cpp | 10 +++++----- lib/cli/daemonutility.cpp | 2 +- lib/config/configfragment.hpp | 2 +- lib/config/configitem.cpp | 4 ++-- lib/icinga/dependency-apply.cpp | 2 +- lib/icinga/hostgroup.cpp | 2 +- lib/icinga/notification-apply.cpp | 2 +- lib/icinga/scheduleddowntime-apply.cpp | 2 +- lib/icinga/service-apply.cpp | 2 +- lib/icinga/servicegroup.cpp | 2 +- lib/icinga/usergroup.cpp | 2 +- lib/remote/configobjectutility.cpp | 2 +- lib/remote/consolehandler.cpp | 4 ++-- lib/remote/eventqueue.cpp | 2 +- lib/remote/filterutility.cpp | 4 ++-- test/config-ops.cpp | 6 +++--- 20 files changed, 30 insertions(+), 30 deletions(-) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 0a25e691e..69d796be0 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -180,7 +180,7 @@ static int Main(void) try { expression = ConfigCompiler::CompileFile(initconfig); - ScriptFrame frame; + ScriptFrame frame(true); expression->Evaluate(frame); } catch (const std::exception& ex) { Log(LogCritical, "config", DiagnosticInformation(ex)); diff --git a/lib/base/function.cpp b/lib/base/function.cpp index 3c3d690f8..d79e78725 100644 --- a/lib/base/function.cpp +++ b/lib/base/function.cpp @@ -44,7 +44,7 @@ Value Function::Invoke(const std::vector& arguments) Value Function::InvokeThis(const Value& otherThis, const std::vector& arguments) { - ScriptFrame frame(otherThis, false); + ScriptFrame frame(false, otherThis); return m_Callback(arguments); } diff --git a/lib/base/scriptframe.cpp b/lib/base/scriptframe.cpp index da6c29a06..7d4367926 100644 --- a/lib/base/scriptframe.cpp +++ b/lib/base/scriptframe.cpp @@ -46,7 +46,7 @@ ScriptFrame::ScriptFrame(bool allocLocals) InitializeFrame(); } -ScriptFrame::ScriptFrame(const Value& self, bool allocLocals) +ScriptFrame::ScriptFrame(bool allocLocals, const Value& self) : Locals(allocLocals ? new Dictionary() : nullptr), Self(self), Sandboxed(false), Depth(0) { InitializeFrame(); diff --git a/lib/base/scriptframe.hpp b/lib/base/scriptframe.hpp index 8de9360cf..41f68f31e 100644 --- a/lib/base/scriptframe.hpp +++ b/lib/base/scriptframe.hpp @@ -36,8 +36,8 @@ struct I2_BASE_API ScriptFrame bool Sandboxed; int Depth; - ScriptFrame(bool allocLocals = true); - ScriptFrame(const Value& self, bool allocLocals = true); + ScriptFrame(bool allocLocals); + ScriptFrame(bool allocLocals, const Value& self); ~ScriptFrame(void); void IncreaseStackDepth(void); diff --git a/lib/cli/consolecommand.cpp b/lib/cli/consolecommand.cpp index 0a00c469c..e5664eef8 100644 --- a/lib/cli/consolecommand.cpp +++ b/lib/cli/consolecommand.cpp @@ -50,7 +50,7 @@ INITIALIZE_ONCE(&ConsoleCommand::StaticInitialize); extern "C" void dbg_spawn_console(void) { - ScriptFrame frame; + ScriptFrame frame(true); ConsoleCommand::RunScriptConsole(frame); } @@ -71,7 +71,7 @@ extern "C" void dbg_eval(const char *text) std::unique_ptr expr; try { - ScriptFrame frame; + ScriptFrame frame(true); expr = ConfigCompiler::CompileText("", text); Value result = Serialize(expr->Evaluate(frame), 0); dbg_inspect_value(result); @@ -85,7 +85,7 @@ extern "C" void dbg_eval_with_value(const Value& value, const char *text) std::unique_ptr expr; try { - ScriptFrame frame; + ScriptFrame frame(true); frame.Locals = new Dictionary(); frame.Locals->Set("arg", value); expr = ConfigCompiler::CompileText("", text); @@ -101,7 +101,7 @@ extern "C" void dbg_eval_with_object(Object *object, const char *text) std::unique_ptr expr; try { - ScriptFrame frame; + ScriptFrame frame(true); frame.Locals = new Dictionary(); frame.Locals->Set("arg", object); expr = ConfigCompiler::CompileText("", text); @@ -227,7 +227,7 @@ int ConsoleCommand::Run(const po::variables_map& vm, const std::vectorEvaluate(frame); } catch (const std::exception& ex) { Log(LogCritical, "config", DiagnosticInformation(ex)); diff --git a/lib/config/configfragment.hpp b/lib/config/configfragment.hpp index 59fb9a585..bd3c5939b 100644 --- a/lib/config/configfragment.hpp +++ b/lib/config/configfragment.hpp @@ -31,7 +31,7 @@ std::unique_ptr expression = icinga::ConfigCompiler::CompileText(name, fragment); \ VERIFY(expression); \ try { \ - icinga::ScriptFrame frame; \ + icinga::ScriptFrame frame(true); \ expression->Evaluate(frame); \ } catch (const std::exception& ex) { \ std::cerr << icinga::DiagnosticInformation(ex) << std::endl; \ diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 525f81df5..0d501ef6f 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -196,7 +196,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard) DebugHint debugHints; - ScriptFrame frame(dobj); + ScriptFrame frame(true, dobj); if (m_Scope) m_Scope->CopyTo(frame.Locals); try { @@ -584,7 +584,7 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vectorEvaluate(frame); } catch (const std::exception& ex) { Log(LogCritical, "config", DiagnosticInformation(ex)); diff --git a/lib/icinga/dependency-apply.cpp b/lib/icinga/dependency-apply.cpp index 2871b6058..72d2aa915 100644 --- a/lib/icinga/dependency-apply.cpp +++ b/lib/icinga/dependency-apply.cpp @@ -91,7 +91,7 @@ bool Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyR Service::Ptr service; tie(host, service) = GetHostService(checkable); - ScriptFrame frame; + ScriptFrame frame(true); if (rule.GetScope()) rule.GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/hostgroup.cpp b/lib/icinga/hostgroup.cpp index d729d29e7..1d386396f 100644 --- a/lib/icinga/hostgroup.cpp +++ b/lib/icinga/hostgroup.cpp @@ -41,7 +41,7 @@ bool HostGroup::EvaluateObjectRule(const Host::Ptr& host, const ConfigItem::Ptr& CONTEXT("Evaluating rule for group '" + group_name + "'"); - ScriptFrame frame; + ScriptFrame frame(true); if (group->GetScope()) group->GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/notification-apply.cpp b/lib/icinga/notification-apply.cpp index 06bae342d..9573315a4 100644 --- a/lib/icinga/notification-apply.cpp +++ b/lib/icinga/notification-apply.cpp @@ -90,7 +90,7 @@ bool Notification::EvaluateApplyRule(const Checkable::Ptr& checkable, const Appl Service::Ptr service; tie(host, service) = GetHostService(checkable); - ScriptFrame frame; + ScriptFrame frame(true); if (rule.GetScope()) rule.GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/scheduleddowntime-apply.cpp b/lib/icinga/scheduleddowntime-apply.cpp index de2a682ff..2c2ec4a14 100644 --- a/lib/icinga/scheduleddowntime-apply.cpp +++ b/lib/icinga/scheduleddowntime-apply.cpp @@ -89,7 +89,7 @@ bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const Service::Ptr service; tie(host, service) = GetHostService(checkable); - ScriptFrame frame; + ScriptFrame frame(true); if (rule.GetScope()) rule.GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/service-apply.cpp b/lib/icinga/service-apply.cpp index f16c13f22..d9a01c980 100644 --- a/lib/icinga/service-apply.cpp +++ b/lib/icinga/service-apply.cpp @@ -80,7 +80,7 @@ bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule) msgbuf << "Evaluating 'apply' rule (" << di << ")"; CONTEXT(msgbuf.str()); - ScriptFrame frame; + ScriptFrame frame(true); if (rule.GetScope()) rule.GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/servicegroup.cpp b/lib/icinga/servicegroup.cpp index 2b5363625..5b2b43aac 100644 --- a/lib/icinga/servicegroup.cpp +++ b/lib/icinga/servicegroup.cpp @@ -43,7 +43,7 @@ bool ServiceGroup::EvaluateObjectRule(const Service::Ptr& service, const ConfigI Host::Ptr host = service->GetHost(); - ScriptFrame frame; + ScriptFrame frame(true); if (group->GetScope()) group->GetScope()->CopyTo(frame.Locals); frame.Locals->Set("host", host); diff --git a/lib/icinga/usergroup.cpp b/lib/icinga/usergroup.cpp index ab1923d66..e1740e35a 100644 --- a/lib/icinga/usergroup.cpp +++ b/lib/icinga/usergroup.cpp @@ -41,7 +41,7 @@ bool UserGroup::EvaluateObjectRule(const User::Ptr& user, const ConfigItem::Ptr& CONTEXT("Evaluating rule for group '" + group_name + "'"); - ScriptFrame frame; + ScriptFrame frame(true); if (group->GetScope()) group->GetScope()->CopyTo(frame.Locals); frame.Locals->Set("user", user); diff --git a/lib/remote/configobjectutility.cpp b/lib/remote/configobjectutility.cpp index 181c0152b..5207e515b 100644 --- a/lib/remote/configobjectutility.cpp +++ b/lib/remote/configobjectutility.cpp @@ -129,7 +129,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full try { ActivationScope ascope; - ScriptFrame frame; + ScriptFrame frame(true); expr->Evaluate(frame); expr.reset(); diff --git a/lib/remote/consolehandler.cpp b/lib/remote/consolehandler.cpp index 72e544a2f..1f32bb725 100644 --- a/lib/remote/consolehandler.cpp +++ b/lib/remote/consolehandler.cpp @@ -129,7 +129,7 @@ bool ConsoleHandler::ExecuteScriptHelper(HttpRequest& request, HttpResponse& res try { expr = ConfigCompiler::CompileText(fileName, command); - ScriptFrame frame; + ScriptFrame frame(true); frame.Locals = lsf.Locals; frame.Self = lsf.Locals; frame.Sandboxed = sandboxed; @@ -190,7 +190,7 @@ bool ConsoleHandler::AutocompleteScriptHelper(HttpRequest& request, HttpResponse Array::Ptr results = new Array(); Dictionary::Ptr resultInfo = new Dictionary(); - ScriptFrame frame; + ScriptFrame frame(true); frame.Locals = lsf.Locals; frame.Self = lsf.Locals; frame.Sandboxed = sandboxed; diff --git a/lib/remote/eventqueue.cpp b/lib/remote/eventqueue.cpp index 591e0222a..105a448d7 100644 --- a/lib/remote/eventqueue.cpp +++ b/lib/remote/eventqueue.cpp @@ -37,7 +37,7 @@ bool EventQueue::CanProcessEvent(const String& type) const void EventQueue::ProcessEvent(const Dictionary::Ptr& event) { - ScriptFrame frame; + ScriptFrame frame(true); frame.Sandboxed = true; try { diff --git a/lib/remote/filterutility.cpp b/lib/remote/filterutility.cpp index e864482f2..826e5e827 100644 --- a/lib/remote/filterutility.cpp +++ b/lib/remote/filterutility.cpp @@ -197,7 +197,7 @@ std::vector FilterUtility::GetFilterTargets(const QueryDescription& qd, c Expression *permissionFilter; CheckPermission(user, qd.Permission, &permissionFilter); - ScriptFrame permissionFrame; + ScriptFrame permissionFrame(true); for (const String& type : qd.Types) { String attr = type; @@ -247,7 +247,7 @@ std::vector FilterUtility::GetFilterTargets(const QueryDescription& qd, c if (qd.Types.find(type) == qd.Types.end()) BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type specified for this query.")); - ScriptFrame frame; + ScriptFrame frame(true); frame.Sandboxed = true; Dictionary::Ptr uvars = new Dictionary(); diff --git a/test/config-ops.cpp b/test/config-ops.cpp index 9ec91ff88..ac7817d37 100644 --- a/test/config-ops.cpp +++ b/test/config-ops.cpp @@ -27,7 +27,7 @@ BOOST_AUTO_TEST_SUITE(config_ops) BOOST_AUTO_TEST_CASE(simple) { - ScriptFrame frame; + ScriptFrame frame(true); std::unique_ptr expr; Dictionary::Ptr dict; @@ -168,7 +168,7 @@ BOOST_AUTO_TEST_CASE(simple) BOOST_AUTO_TEST_CASE(advanced) { - ScriptFrame frame; + ScriptFrame frame(true); std::unique_ptr expr; Function::Ptr func; @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(advanced) BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError); Object::Ptr self = new Object(); - ScriptFrame frame2(self); + ScriptFrame frame2(true, self); expr = ConfigCompiler::CompileText("", "this"); BOOST_CHECK(expr->Evaluate(frame2).GetValue() == Value(self));