From: Elias Ohm Date: Fri, 12 Apr 2019 06:10:57 +0000 (+0200) Subject: * use dedicated permissions namespace for scriptframe in filterutility to allow prope... X-Git-Tag: v2.10.5~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8315ea86d79e978b08585f917fa393f89e86ad2f;p=icinga2 * use dedicated permissions namespace for scriptframe in filterutility to allow proper parallel execution * fixes issue https://github.com/Icinga/icinga2/issues/6785 where permission checks get wrong result because permissions checks are done within a shared namespaces without using only unique keys * mitigates issue https://github.com/Icinga/icinga2/issues/6874 where segmentation faults occur because of concurrent access to non threadsafe parts of namespace (a fix for thread safety of namespaces which would be an alternative approach to get rid of these segfaults is out of scope of this fix as 6785 needs to be fixed anyway and this is the straight-forwards) way to fix that * do the same for eventqueue (not certain whether events can be processed in parallel but I expect it is the case) (cherry picked from commit 1e7cd4afc821a0592b535e4270ebb2fdc387a207) --- diff --git a/lib/remote/eventqueue.cpp b/lib/remote/eventqueue.cpp index d72451771..436bd7dbf 100644 --- a/lib/remote/eventqueue.cpp +++ b/lib/remote/eventqueue.cpp @@ -37,7 +37,8 @@ bool EventQueue::CanProcessEvent(const String& type) const void EventQueue::ProcessEvent(const Dictionary::Ptr& event) { - ScriptFrame frame(true); + Namespace::Ptr frameNS = new Namespace(); + ScriptFrame frame(true, frameNS); frame.Sandboxed = true; try { diff --git a/lib/remote/filterutility.cpp b/lib/remote/filterutility.cpp index cf6cb9ed4..8bcebfafb 100644 --- a/lib/remote/filterutility.cpp +++ b/lib/remote/filterutility.cpp @@ -205,7 +205,8 @@ std::vector FilterUtility::GetFilterTargets(const QueryDescription& qd, c Expression *permissionFilter; CheckPermission(user, qd.Permission, &permissionFilter); - ScriptFrame permissionFrame(true); + Namespace::Ptr permissionFrameNS = new Namespace(); + ScriptFrame permissionFrame(true, permissionFrameNS); for (const String& type : qd.Types) { String attr = type;