Fix variable scope for object rules

This commit is contained in:
Gunnar Beutner 2014-11-06 19:26:44 +01:00
parent 83e6fb3083
commit f69f7d61f2
4 changed files with 4 additions and 4 deletions

View File

@ -65,10 +65,7 @@ void ObjectRule::AddRule(const String& sourceType, const String& name,
bool ObjectRule::EvaluateFilter(const Dictionary::Ptr& scope) const
{
scope->Set("__parent", m_Scope);
bool result = m_Filter->Evaluate(scope);
scope->Remove("__parent");
return result;
return m_Filter->Evaluate(scope);
}
void ObjectRule::EvaluateRules(bool clear)

View File

@ -46,6 +46,7 @@ bool HostGroup::EvaluateObjectRuleOne(const Host::Ptr& host, const ObjectRule& r
CONTEXT(msgbuf.str());
Dictionary::Ptr locals = make_shared<Dictionary>();
locals->Set("__parent", rule.GetScope());
locals->Set("host", host);
if (!rule.EvaluateFilter(locals))

View File

@ -48,6 +48,7 @@ bool ServiceGroup::EvaluateObjectRuleOne(const Service::Ptr& service, const Obje
Host::Ptr host = service->GetHost();
Dictionary::Ptr locals = make_shared<Dictionary>();
locals->Set("__parent", rule.GetScope());
locals->Set("host", host);
locals->Set("service", service);

View File

@ -46,6 +46,7 @@ bool UserGroup::EvaluateObjectRuleOne(const User::Ptr& user, const ObjectRule& r
CONTEXT(msgbuf.str());
Dictionary::Ptr locals = make_shared<Dictionary>();
locals->Set("__parent", rule.GetScope());
locals->Set("user", user);
if (!rule.EvaluateFilter(locals))