Commit 5e4421ea authored by Ayush Tiwari's avatar Ayush Tiwari

ActivityTool: Use UnrestrictedMethod instead of ad-hoc user for process_timer

This is required cause while running  _activeSense for portal_alarm, we switch
user to nobody so as to use system user, but at the same time in proces_timer
in ActivityTool, we use the user of portal_catalog to invoke the activities.

https://lab.nexedi.com/nexedi/erp5/blob/master/product/ERP5/Document/Alarm.py#L164

The problem comes when someone runs an alarm which create a new portal_catalog,
which might not be having the required permission to invoke all the activites.
So, its better to use unrestrictedMethod or maybe, super_user here.
parent 3370a6fe
Pipeline #1828 skipped
......@@ -54,6 +54,7 @@ from zExceptions import ExceptionFormatter
from BTrees.OIBTree import OIBTree
from Zope2 import app
from Products.ERP5Type.UnrestrictedMethod import PrivilegedUser
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from zope.site.hooks import setSite
import transaction
from App.config import getConfiguration
......@@ -993,6 +994,7 @@ class ActivityTool (Folder, UniqueObject):
LOG('CMFActivity', INFO, "Shutdown: Activities finished.")
security.declareProtected(CMFCorePermissions.ManagePortal, 'process_timer')
@UnrestrictedMethod
def process_timer(self, tick, interval, prev="", next=""):
"""
Call distribute() if we are the Distributing Node and call tic()
......@@ -1011,11 +1013,6 @@ class ActivityTool (Folder, UniqueObject):
self.setupCurrentSkin(self.REQUEST)
old_sm = getSecurityManager()
try:
# get owner of portal_catalog, so normally we should be able to
# have the permission to invoke all activities
user = self.portal_catalog.getWrappedOwner()
newSecurityManager(self.REQUEST, user)
currentNode = self.getCurrentNode()
self.registerNode(currentNode)
processing_node_list = self.getNodeList(role=ROLE_PROCESSING)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment