Commit dd724d52 authored by Tres Seaver's avatar Tres Seaver

  - Wire up security policy selection machinery to ZConfig (note that the
    'C' policy is currently borked, but should be fixed very soon).
parent 2a8a5e38
...@@ -40,6 +40,7 @@ def start_zope(cfg): ...@@ -40,6 +40,7 @@ def start_zope(cfg):
# are set up, we flush accumulated messages in StartupHandler's # are set up, we flush accumulated messages in StartupHandler's
# buffers to the real logger. # buffers to the real logger.
starter.setupStartupHandler() starter.setupStartupHandler()
starter.setupSecurityOptions()
# Start ZServer servers before we drop privileges so we can bind to # Start ZServer servers before we drop privileges so we can bind to
# "low" ports: # "low" ports:
starter.setupZServerThreads() starter.setupZServerThreads()
...@@ -98,6 +99,14 @@ class ZopeStarter: ...@@ -98,6 +99,14 @@ class ZopeStarter:
from Signals import Signals from Signals import Signals
Signals.registerZopeSignals() Signals.registerZopeSignals()
def setupSecurityOptions(self):
import AccessControl
AccessControl.setImplementation(
self.cfg.security_policy_implementation)
AccessControl.setDefaultBehaviors(
not self.cfg.skip_ownership_checking,
not self.cfg.skip_authentication_checking)
def setupStartupHandler(self): def setupStartupHandler(self):
# set up our initial logging environment (log everything to stderr # set up our initial logging environment (log everything to stderr
# if we're not in debug mode). # if we're not in debug mode).
......
...@@ -39,14 +39,6 @@ def automatically_quote_dtml_request_data(value): ...@@ -39,14 +39,6 @@ def automatically_quote_dtml_request_data(value):
not value and _setenv('ZOPE_DTML_REQUEST_AUTOQUOTE', '0') not value and _setenv('ZOPE_DTML_REQUEST_AUTOQUOTE', '0')
return value return value
def skip_authentication_checking(value):
value and _setenv('ZSP_AUTHENTICATED_SKIP', '1')
return value
def skip_ownership_checking(value):
value and _setenv('ZSP_OWNEROUS_SKIP', '1')
return value
def maximum_number_of_session_objects(value): def maximum_number_of_session_objects(value):
default = 1000 default = 1000
value not in (None, default) and _setenv('ZSESSION_OBJECT_LIMIT', value) value not in (None, default) and _setenv('ZSESSION_OBJECT_LIMIT', value)
...@@ -97,10 +89,6 @@ def rest_output_encoding(value): ...@@ -97,10 +89,6 @@ def rest_output_encoding(value):
value and _setenv('REST_OUTPUT_ENCODING' , value) value and _setenv('REST_OUTPUT_ENCODING' , value)
return value return value
def maximum_security_manager_stack_size(value):
value is not None and _setenv('Z_MAX_STACK_SIZE', value)
return value
def publisher_profile_file(value): def publisher_profile_file(value):
value is not None and _setenv('PROFILE_PUBLISHER', value) value is not None and _setenv('PROFILE_PUBLISHER', value)
from ZPublisher.Publish import install_profiling from ZPublisher.Publish import install_profiling
...@@ -111,9 +99,6 @@ def http_realm(value): ...@@ -111,9 +99,6 @@ def http_realm(value):
value is not None and _setenv('Z_REALM', value) value is not None and _setenv('Z_REALM', value)
return value return value
def security_policy_implementation(value):
value not in ('C', None) and _setenv('ZOPE_SECURITY_POLICY', value)
def max_listen_sockets(value): def max_listen_sockets(value):
import ZServer import ZServer
ZServer.CONNECTION_LIMIT = value ZServer.CONNECTION_LIMIT = value
......
...@@ -22,6 +22,7 @@ import unittest ...@@ -22,6 +22,7 @@ import unittest
import ZConfig import ZConfig
import Zope.Startup import Zope.Startup
from Zope.Startup import handlers
from Zope.Startup import ZopeStarter from Zope.Startup import ZopeStarter
from App.config import getConfiguration, setConfiguration from App.config import getConfiguration, setConfiguration
...@@ -76,7 +77,7 @@ class ZopeStarterTestCase(unittest.TestCase): ...@@ -76,7 +77,7 @@ class ZopeStarterTestCase(unittest.TestCase):
if why == 17: if why == 17:
# already exists # already exists
pass pass
conf, handler = ZConfig.loadConfigFile(schema, sio) conf, self.handler = ZConfig.loadConfigFile(schema, sio)
self.assertEqual(conf.instancehome, TEMPNAME) self.assertEqual(conf.instancehome, TEMPNAME)
return conf return conf
...@@ -361,9 +362,25 @@ class ZopeStarterTestCase(unittest.TestCase): ...@@ -361,9 +362,25 @@ class ZopeStarterTestCase(unittest.TestCase):
pass pass
setConfiguration(old_config) setConfiguration(old_config)
def testInitializeSecurityOptions(self):
from AccessControl import Implementation
orig = Implementation.getImplementationName()
conf = self.load_config_text("""
instancehome <<INSTANCE_HOME>>
security-policy-implementation python
skip-authentication-checking yes
skip-ownership-checking yes
""")
self.assertEqual(conf.security_policy_implementation, "PYTHON")
starter = ZopeStarter(conf)
try:
starter.setupSecurityOptions()
self.assertEqual(Implementation.getImplementationName(), "PYTHON")
finally:
Implementation.setImplementation(orig)
def test_suite(): def test_suite():
return unittest.makeSuite(ZopeStarterTestCase) return unittest.makeSuite(ZopeStarterTestCase)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(defaultTest="test_suite") unittest.main(defaultTest="test_suite")
...@@ -452,16 +452,6 @@ ...@@ -452,16 +452,6 @@
<metadefault>unset</metadefault> <metadefault>unset</metadefault>
</key> </key>
<key name="maximum-security-manager-stack-size" datatype="integer"
default="100" handler="maximum_security_manager_stack_size">
<description>
This variable allows you to customize the size of the Zope
SecurityManager stack. You shouldn't change this unless you know what
it means.
</description>
<metadefault>100</metadefault>
</key>
<key name="publisher-profile-file" handler="publisher_profile_file"> <key name="publisher-profile-file" handler="publisher_profile_file">
<description> <description>
Causing this directive to point to a file on the filesystem will Causing this directive to point to a file on the filesystem will
...@@ -533,7 +523,7 @@ ...@@ -533,7 +523,7 @@
<key name="security-policy-implementation" <key name="security-policy-implementation"
datatype=".security_policy_implementation" datatype=".security_policy_implementation"
default="C" handler="security_policy_implementation"> default="C">
<description> <description>
The default Zope "security policy" implementation is written in C. The default Zope "security policy" implementation is written in C.
Set this key to "PYTHON" to use the Python implementation Set this key to "PYTHON" to use the Python implementation
...@@ -544,7 +534,7 @@ ...@@ -544,7 +534,7 @@
</key> </key>
<key name="skip-authentication-checking" datatype="boolean" <key name="skip-authentication-checking" datatype="boolean"
default="off" handler="skip_authentication_checking"> default="off">
<description> <description>
Set this directive to 'on' to cause Zope to prevent Zope from Set this directive to 'on' to cause Zope to prevent Zope from
attempting to authenticate users during normal operation. attempting to authenticate users during normal operation.
...@@ -555,7 +545,7 @@ ...@@ -555,7 +545,7 @@
</key> </key>
<key name="skip-ownership-checking" datatype="boolean" <key name="skip-ownership-checking" datatype="boolean"
default="off" handler="skip_ownership_checking"> default="off">
<description> <description>
Set this directive to 'on' to cause Zope to ignore ownership checking Set this directive to 'on' to cause Zope to ignore ownership checking
when attempting to execute "through the web" code. By default, this when attempting to execute "through the web" code. By default, this
......
""" tempstorage package """ """ tempstorage package """
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