mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
Merge pull request #5939 from Icinga/fix/build-fix-wheezy
Build fix for Debian wheezy
This commit is contained in:
commit
0e6f4b1966
@ -180,7 +180,7 @@ static int Main(void)
|
|||||||
try {
|
try {
|
||||||
expression = ConfigCompiler::CompileFile(initconfig);
|
expression = ConfigCompiler::CompileFile(initconfig);
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
expression->Evaluate(frame);
|
expression->Evaluate(frame);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogCritical, "config", DiagnosticInformation(ex));
|
Log(LogCritical, "config", DiagnosticInformation(ex));
|
||||||
|
@ -44,7 +44,7 @@ Value Function::Invoke(const std::vector<Value>& arguments)
|
|||||||
|
|
||||||
Value Function::InvokeThis(const Value& otherThis, const std::vector<Value>& arguments)
|
Value Function::InvokeThis(const Value& otherThis, const std::vector<Value>& arguments)
|
||||||
{
|
{
|
||||||
ScriptFrame frame(otherThis, false);
|
ScriptFrame frame(false, otherThis);
|
||||||
return m_Callback(arguments);
|
return m_Callback(arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ ScriptFrame::ScriptFrame(bool allocLocals)
|
|||||||
InitializeFrame();
|
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)
|
: Locals(allocLocals ? new Dictionary() : nullptr), Self(self), Sandboxed(false), Depth(0)
|
||||||
{
|
{
|
||||||
InitializeFrame();
|
InitializeFrame();
|
||||||
|
@ -36,8 +36,8 @@ struct ScriptFrame
|
|||||||
bool Sandboxed;
|
bool Sandboxed;
|
||||||
int Depth;
|
int Depth;
|
||||||
|
|
||||||
ScriptFrame(bool allocLocals = true);
|
ScriptFrame(bool allocLocals);
|
||||||
ScriptFrame(const Value& self, bool allocLocals = true);
|
ScriptFrame(bool allocLocals, const Value& self);
|
||||||
~ScriptFrame(void);
|
~ScriptFrame(void);
|
||||||
|
|
||||||
void IncreaseStackDepth(void);
|
void IncreaseStackDepth(void);
|
||||||
|
@ -50,7 +50,7 @@ INITIALIZE_ONCE(&ConsoleCommand::StaticInitialize);
|
|||||||
|
|
||||||
extern "C" void dbg_spawn_console(void)
|
extern "C" void dbg_spawn_console(void)
|
||||||
{
|
{
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
ConsoleCommand::RunScriptConsole(frame);
|
ConsoleCommand::RunScriptConsole(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ extern "C" void dbg_eval(const char *text)
|
|||||||
std::unique_ptr<Expression> expr;
|
std::unique_ptr<Expression> expr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
expr = ConfigCompiler::CompileText("<dbg>", text);
|
expr = ConfigCompiler::CompileText("<dbg>", text);
|
||||||
Value result = Serialize(expr->Evaluate(frame), 0);
|
Value result = Serialize(expr->Evaluate(frame), 0);
|
||||||
dbg_inspect_value(result);
|
dbg_inspect_value(result);
|
||||||
@ -85,7 +85,7 @@ extern "C" void dbg_eval_with_value(const Value& value, const char *text)
|
|||||||
std::unique_ptr<Expression> expr;
|
std::unique_ptr<Expression> expr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
frame.Locals = new Dictionary();
|
frame.Locals = new Dictionary();
|
||||||
frame.Locals->Set("arg", value);
|
frame.Locals->Set("arg", value);
|
||||||
expr = ConfigCompiler::CompileText("<dbg>", text);
|
expr = ConfigCompiler::CompileText("<dbg>", text);
|
||||||
@ -101,7 +101,7 @@ extern "C" void dbg_eval_with_object(Object *object, const char *text)
|
|||||||
std::unique_ptr<Expression> expr;
|
std::unique_ptr<Expression> expr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
frame.Locals = new Dictionary();
|
frame.Locals = new Dictionary();
|
||||||
frame.Locals->Set("arg", object);
|
frame.Locals->Set("arg", object);
|
||||||
expr = ConfigCompiler::CompileText("<dbg>", text);
|
expr = ConfigCompiler::CompileText("<dbg>", text);
|
||||||
@ -227,7 +227,7 @@ int ConsoleCommand::Run(const po::variables_map& vm, const std::vector<std::stri
|
|||||||
#endif /* HAVE_EDITLINE */
|
#endif /* HAVE_EDITLINE */
|
||||||
|
|
||||||
String addr, session;
|
String addr, session;
|
||||||
ScriptFrame scriptFrame;
|
ScriptFrame scriptFrame(true);
|
||||||
|
|
||||||
session = Utility::NewUniqueID();
|
session = Utility::NewUniqueID();
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ static bool ExecuteExpression(Expression *expression)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
expression->Evaluate(frame);
|
expression->Evaluate(frame);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogCritical, "config", DiagnosticInformation(ex));
|
Log(LogCritical, "config", DiagnosticInformation(ex));
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
std::unique_ptr<icinga::Expression> expression = icinga::ConfigCompiler::CompileText(name, fragment); \
|
std::unique_ptr<icinga::Expression> expression = icinga::ConfigCompiler::CompileText(name, fragment); \
|
||||||
VERIFY(expression); \
|
VERIFY(expression); \
|
||||||
try { \
|
try { \
|
||||||
icinga::ScriptFrame frame; \
|
icinga::ScriptFrame frame(true); \
|
||||||
expression->Evaluate(frame); \
|
expression->Evaluate(frame); \
|
||||||
} catch (const std::exception& ex) { \
|
} catch (const std::exception& ex) { \
|
||||||
std::cerr << icinga::DiagnosticInformation(ex) << std::endl; \
|
std::cerr << icinga::DiagnosticInformation(ex) << std::endl; \
|
||||||
|
@ -196,7 +196,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
|
|||||||
|
|
||||||
DebugHint debugHints;
|
DebugHint debugHints;
|
||||||
|
|
||||||
ScriptFrame frame(dobj);
|
ScriptFrame frame(true, dobj);
|
||||||
if (m_Scope)
|
if (m_Scope)
|
||||||
m_Scope->CopyTo(frame.Locals);
|
m_Scope->CopyTo(frame.Locals);
|
||||||
try {
|
try {
|
||||||
@ -584,7 +584,7 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
|
|||||||
|
|
||||||
if (expression) {
|
if (expression) {
|
||||||
try {
|
try {
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
expression->Evaluate(frame);
|
expression->Evaluate(frame);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogCritical, "config", DiagnosticInformation(ex));
|
Log(LogCritical, "config", DiagnosticInformation(ex));
|
||||||
|
@ -91,7 +91,7 @@ bool Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyR
|
|||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(checkable);
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
if (rule.GetScope())
|
if (rule.GetScope())
|
||||||
rule.GetScope()->CopyTo(frame.Locals);
|
rule.GetScope()->CopyTo(frame.Locals);
|
||||||
frame.Locals->Set("host", host);
|
frame.Locals->Set("host", host);
|
||||||
|
@ -41,7 +41,7 @@ bool HostGroup::EvaluateObjectRule(const Host::Ptr& host, const ConfigItem::Ptr&
|
|||||||
|
|
||||||
CONTEXT("Evaluating rule for group '" + group_name + "'");
|
CONTEXT("Evaluating rule for group '" + group_name + "'");
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
if (group->GetScope())
|
if (group->GetScope())
|
||||||
group->GetScope()->CopyTo(frame.Locals);
|
group->GetScope()->CopyTo(frame.Locals);
|
||||||
frame.Locals->Set("host", host);
|
frame.Locals->Set("host", host);
|
||||||
|
@ -90,7 +90,7 @@ bool Notification::EvaluateApplyRule(const Checkable::Ptr& checkable, const Appl
|
|||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(checkable);
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
if (rule.GetScope())
|
if (rule.GetScope())
|
||||||
rule.GetScope()->CopyTo(frame.Locals);
|
rule.GetScope()->CopyTo(frame.Locals);
|
||||||
frame.Locals->Set("host", host);
|
frame.Locals->Set("host", host);
|
||||||
|
@ -89,7 +89,7 @@ bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const
|
|||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(checkable);
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
if (rule.GetScope())
|
if (rule.GetScope())
|
||||||
rule.GetScope()->CopyTo(frame.Locals);
|
rule.GetScope()->CopyTo(frame.Locals);
|
||||||
frame.Locals->Set("host", host);
|
frame.Locals->Set("host", host);
|
||||||
|
@ -80,7 +80,7 @@ bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule)
|
|||||||
msgbuf << "Evaluating 'apply' rule (" << di << ")";
|
msgbuf << "Evaluating 'apply' rule (" << di << ")";
|
||||||
CONTEXT(msgbuf.str());
|
CONTEXT(msgbuf.str());
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
if (rule.GetScope())
|
if (rule.GetScope())
|
||||||
rule.GetScope()->CopyTo(frame.Locals);
|
rule.GetScope()->CopyTo(frame.Locals);
|
||||||
frame.Locals->Set("host", host);
|
frame.Locals->Set("host", host);
|
||||||
|
@ -43,7 +43,7 @@ bool ServiceGroup::EvaluateObjectRule(const Service::Ptr& service, const ConfigI
|
|||||||
|
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
if (group->GetScope())
|
if (group->GetScope())
|
||||||
group->GetScope()->CopyTo(frame.Locals);
|
group->GetScope()->CopyTo(frame.Locals);
|
||||||
frame.Locals->Set("host", host);
|
frame.Locals->Set("host", host);
|
||||||
|
@ -41,7 +41,7 @@ bool UserGroup::EvaluateObjectRule(const User::Ptr& user, const ConfigItem::Ptr&
|
|||||||
|
|
||||||
CONTEXT("Evaluating rule for group '" + group_name + "'");
|
CONTEXT("Evaluating rule for group '" + group_name + "'");
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
if (group->GetScope())
|
if (group->GetScope())
|
||||||
group->GetScope()->CopyTo(frame.Locals);
|
group->GetScope()->CopyTo(frame.Locals);
|
||||||
frame.Locals->Set("user", user);
|
frame.Locals->Set("user", user);
|
||||||
|
@ -129,7 +129,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||||||
try {
|
try {
|
||||||
ActivationScope ascope;
|
ActivationScope ascope;
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
expr->Evaluate(frame);
|
expr->Evaluate(frame);
|
||||||
expr.reset();
|
expr.reset();
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ bool ConsoleHandler::ExecuteScriptHelper(HttpRequest& request, HttpResponse& res
|
|||||||
try {
|
try {
|
||||||
expr = ConfigCompiler::CompileText(fileName, command);
|
expr = ConfigCompiler::CompileText(fileName, command);
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
frame.Locals = lsf.Locals;
|
frame.Locals = lsf.Locals;
|
||||||
frame.Self = lsf.Locals;
|
frame.Self = lsf.Locals;
|
||||||
frame.Sandboxed = sandboxed;
|
frame.Sandboxed = sandboxed;
|
||||||
@ -190,7 +190,7 @@ bool ConsoleHandler::AutocompleteScriptHelper(HttpRequest& request, HttpResponse
|
|||||||
Array::Ptr results = new Array();
|
Array::Ptr results = new Array();
|
||||||
Dictionary::Ptr resultInfo = new Dictionary();
|
Dictionary::Ptr resultInfo = new Dictionary();
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
frame.Locals = lsf.Locals;
|
frame.Locals = lsf.Locals;
|
||||||
frame.Self = lsf.Locals;
|
frame.Self = lsf.Locals;
|
||||||
frame.Sandboxed = sandboxed;
|
frame.Sandboxed = sandboxed;
|
||||||
|
@ -37,7 +37,7 @@ bool EventQueue::CanProcessEvent(const String& type) const
|
|||||||
|
|
||||||
void EventQueue::ProcessEvent(const Dictionary::Ptr& event)
|
void EventQueue::ProcessEvent(const Dictionary::Ptr& event)
|
||||||
{
|
{
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
frame.Sandboxed = true;
|
frame.Sandboxed = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -197,7 +197,7 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
|
|||||||
Expression *permissionFilter;
|
Expression *permissionFilter;
|
||||||
CheckPermission(user, qd.Permission, &permissionFilter);
|
CheckPermission(user, qd.Permission, &permissionFilter);
|
||||||
|
|
||||||
ScriptFrame permissionFrame;
|
ScriptFrame permissionFrame(true);
|
||||||
|
|
||||||
for (const String& type : qd.Types) {
|
for (const String& type : qd.Types) {
|
||||||
String attr = type;
|
String attr = type;
|
||||||
@ -247,7 +247,7 @@ std::vector<Value> FilterUtility::GetFilterTargets(const QueryDescription& qd, c
|
|||||||
if (qd.Types.find(type) == qd.Types.end())
|
if (qd.Types.find(type) == qd.Types.end())
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type specified for this query."));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type specified for this query."));
|
||||||
|
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
frame.Sandboxed = true;
|
frame.Sandboxed = true;
|
||||||
Dictionary::Ptr uvars = new Dictionary();
|
Dictionary::Ptr uvars = new Dictionary();
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ BOOST_AUTO_TEST_SUITE(config_ops)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(simple)
|
BOOST_AUTO_TEST_CASE(simple)
|
||||||
{
|
{
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
std::unique_ptr<Expression> expr;
|
std::unique_ptr<Expression> expr;
|
||||||
Dictionary::Ptr dict;
|
Dictionary::Ptr dict;
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ BOOST_AUTO_TEST_CASE(simple)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(advanced)
|
BOOST_AUTO_TEST_CASE(advanced)
|
||||||
{
|
{
|
||||||
ScriptFrame frame;
|
ScriptFrame frame(true);
|
||||||
std::unique_ptr<Expression> expr;
|
std::unique_ptr<Expression> expr;
|
||||||
Function::Ptr func;
|
Function::Ptr func;
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(advanced)
|
|||||||
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
BOOST_CHECK_THROW(expr->Evaluate(frame).GetValue(), ScriptError);
|
||||||
|
|
||||||
Object::Ptr self = new Object();
|
Object::Ptr self = new Object();
|
||||||
ScriptFrame frame2(self);
|
ScriptFrame frame2(true, self);
|
||||||
expr = ConfigCompiler::CompileText("<test>", "this");
|
expr = ConfigCompiler::CompileText("<test>", "this");
|
||||||
BOOST_CHECK(expr->Evaluate(frame2).GetValue() == Value(self));
|
BOOST_CHECK(expr->Evaluate(frame2).GetValue() == Value(self));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user