Commit fd0b8d89 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Fix bang propagation as Slave Instance

parent c6fbdfb2
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager, newSecurityManager setSecurityManager, newSecurityManager
from Products import ERP5Security
from Products.ERP5Type.UnrestrictedMethod import super_user
def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None, def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None,
comment=None): comment=None):
...@@ -37,21 +39,19 @@ def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None, ...@@ -37,21 +39,19 @@ def SoftwareInstance_bangAsSelf(self, relative_url=None, reference=None,
raise TypeError('relative_url has to be defined') raise TypeError('relative_url has to be defined')
if reference is None: if reference is None:
raise TypeError('reference has to be defined') raise TypeError('reference has to be defined')
# micro security: can caller access software instance?
software_instance = self.restrictedTraverse(relative_url) software_instance = self.restrictedTraverse(relative_url)
sm = getSecurityManager()
if (software_instance.getPortalType() == "Slave Instance") and \ if (software_instance.getPortalType() == "Slave Instance") and \
(software_instance.getReference() == reference): (software_instance.getReference() == reference):
# XXX There is no account for Slave Instance # XXX There is no account for Slave Instance
user_id = ERP5Security.SUPER_USER with super_user():
else: software_instance.bang(bang_tree=True, comment=comment)
user_id = software_instance.getUserId() return
newSecurityManager(None, self.getPortalObject().acl_users.getUserById( sm = getSecurityManager()
user_id)) user_id = software_instance.getUserId()
newSecurityManager(None, self.getPortalObject().acl_users.getUserById(user_id))
try: try:
software_instance.bang(bang_tree=True, comment=comment) software_instance.bang(bang_tree=True, comment=comment)
finally: finally:
# Restore the original user. # Restore the original user.
setSecurityManager(sm) setSecurityManager(sm)
\ No newline at end of file
...@@ -6,10 +6,22 @@ ...@@ -6,10 +6,22 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SlapOSCloud</string> </value> <value> <string>SlapOSCloud</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>extension.erp5.SlapOSCloud</string> </value> <value> <string>extension.erp5.SlapOSCloud</string> </value>
...@@ -43,13 +55,28 @@ ...@@ -43,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -62,7 +89,7 @@ ...@@ -62,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -71,7 +98,7 @@ ...@@ -71,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
...@@ -52,6 +52,14 @@ ...@@ -52,6 +52,14 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_change</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>Instance_checkConsistency</string> </value> <value> <string>Instance_checkConsistency</string> </value>
......
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