Commit 54b8ee70 authored by Jérome Perrin's avatar Jérome Perrin

zopewsgi: disable XML-RPC and provide an option to enable

parent 152bbdfb
...@@ -18,6 +18,10 @@ from waitress.server import create_server ...@@ -18,6 +18,10 @@ from waitress.server import create_server
import ZConfig import ZConfig
import Zope2 import Zope2
from Zope2.Startup.run import make_wsgi_app from Zope2.Startup.run import make_wsgi_app
from App.config import getConfiguration
from zope.component import getGlobalSiteManager
import zope.interface
import ZPublisher.interfaces
try: try:
from ZPublisher.WSGIPublisher import _MODULES from ZPublisher.WSGIPublisher import _MODULES
...@@ -86,6 +90,12 @@ class TransLogger(object): ...@@ -86,6 +90,12 @@ class TransLogger(object):
self.logger.info(message) self.logger.info(message)
@zope.interface.implementer(ZPublisher.interfaces.IXmlrpcChecker)
class XMLRPCDisabler:
def __call__(self, request):
return False
def app_wrapper(large_file_threshold, webdav_ports): def app_wrapper(large_file_threshold, webdav_ports):
try: try:
from Products.DeadlockDebugger.dumper import dump_threads, dump_url from Products.DeadlockDebugger.dumper import dump_threads, dump_url
...@@ -186,6 +196,7 @@ def runwsgi(): ...@@ -186,6 +196,7 @@ def runwsgi():
'--with-max-rlimit-nofile', '--with-max-rlimit-nofile',
help='Set soft limit of file descriptors erp5 can open to hard limit', help='Set soft limit of file descriptors erp5 can open to hard limit',
action="store_true") action="store_true")
parser.add_argument('--enable-xml-rpc', help='Enable XML-RPC interface', action='store_true')
args = parser.parse_args() args = parser.parse_args()
if not sys.warnoptions: if not sys.warnoptions:
...@@ -239,6 +250,12 @@ def runwsgi(): ...@@ -239,6 +250,12 @@ def runwsgi():
schema = ZConfig.loadSchema(os.path.join(startup, 'zopeschema.xml')) schema = ZConfig.loadSchema(os.path.join(startup, 'zopeschema.xml'))
conf, _ = ZConfig.loadConfig(schema, args.zope_conf) conf, _ = ZConfig.loadConfig(schema, args.zope_conf)
if not args.enable_xml_rpc:
getGlobalSiteManager().registerUtility(
XMLRPCDisabler(),
ZPublisher.interfaces.IXmlrpcChecker,
)
if conf.debug_mode: if conf.debug_mode:
console_handler = logging.StreamHandler(sys.stderr) console_handler = logging.StreamHandler(sys.stderr)
console_handler.setFormatter(logging.Formatter( console_handler.setFormatter(logging.Formatter(
......
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