mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Finished small tweaks to get new ipaserver.xmlrpc() mod_python handler working
This commit is contained in:
committed by
Rob Crittenden
parent
c2b0c80140
commit
3274577cd6
@@ -433,7 +433,6 @@ class Env(object):
|
|||||||
self.script = path.abspath(sys.argv[0])
|
self.script = path.abspath(sys.argv[0])
|
||||||
self.bin = path.dirname(self.script)
|
self.bin = path.dirname(self.script)
|
||||||
self.home = os.environ.get('HOME', None)
|
self.home = os.environ.get('HOME', None)
|
||||||
self.etc = path.join('/', 'etc', 'ipa')
|
|
||||||
self.dot_ipa = self._join('home', '.ipa')
|
self.dot_ipa = self._join('home', '.ipa')
|
||||||
self._merge(**overrides)
|
self._merge(**overrides)
|
||||||
if 'in_tree' not in self:
|
if 'in_tree' not in self:
|
||||||
|
|||||||
@@ -137,12 +137,14 @@ def xml_dumps(params, methodname=None, methodresponse=False, encoding='UTF-8'):
|
|||||||
allow_none=True,
|
allow_none=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def decode_fault(e, encoding='UTF-8'):
|
def decode_fault(e, encoding='UTF-8'):
|
||||||
assert isinstance(e, Fault)
|
assert isinstance(e, Fault)
|
||||||
if type(e.faultString) is str:
|
if type(e.faultString) is str:
|
||||||
return Fault(e.faultCode, e.faultString.decode(encoding))
|
return Fault(e.faultCode, e.faultString.decode(encoding))
|
||||||
return e
|
return e
|
||||||
|
|
||||||
|
|
||||||
def xml_loads(data, encoding='UTF-8'):
|
def xml_loads(data, encoding='UTF-8'):
|
||||||
"""
|
"""
|
||||||
Decode the XML-RPC packet in ``data``, transparently unwrapping its params.
|
Decode the XML-RPC packet in ``data``, transparently unwrapping its params.
|
||||||
|
|||||||
@@ -24,27 +24,51 @@ Package containing server backend.
|
|||||||
from xmlrpclib import dumps, Fault
|
from xmlrpclib import dumps, Fault
|
||||||
from ipalib import api
|
from ipalib import api
|
||||||
|
|
||||||
|
|
||||||
|
# This is a simple way to ensure that ipalib.api is only initialized
|
||||||
|
# when ipaserver is imported from within the Apache process:
|
||||||
try:
|
try:
|
||||||
from mod_python import apache
|
from mod_python import apache
|
||||||
api.bootstrap(context='server', log=None, debug=True)
|
api.bootstrap(context='server', debug=True, log=None)
|
||||||
api.finalize()
|
api.finalize()
|
||||||
|
api.log.info('*** PROCESS START ***')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def xmlrpc(req):
|
def xmlrpc(req):
|
||||||
|
"""
|
||||||
|
mod_python handler for XML-RPC requests.
|
||||||
|
"""
|
||||||
if req.method != 'POST':
|
if req.method != 'POST':
|
||||||
req.allow_methods(['POST'], 1)
|
req.allow_methods(['POST'], 1)
|
||||||
return apache.HTTP_METHOD_NOT_ALLOWED
|
return apache.HTTP_METHOD_NOT_ALLOWED
|
||||||
|
|
||||||
if apache.mpm_query(apache.AP_MPMQ_IS_THREADED):
|
if apache.mpm_query(apache.AP_MPMQ_IS_THREADED):
|
||||||
response = dumps(
|
response = dumps(
|
||||||
Fault(3, 'Apache must use the forked model'), methodresponse=True
|
Fault(3, 'Apache must use the forked model'),
|
||||||
|
methodresponse=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
response = api.Backend.xmlserver.marshaled_dispatch(req.read(), None)
|
req.add_common_vars()
|
||||||
|
response = api.Backend.xmlserver.marshaled_dispatch(
|
||||||
|
req.read(),
|
||||||
|
req.subprocess_env.get('KRB5CCNAME'),
|
||||||
|
)
|
||||||
|
|
||||||
req.content_type = 'text/xml'
|
req.content_type = 'text/xml'
|
||||||
req.set_content_length(len(response))
|
req.set_content_length(len(response))
|
||||||
req.write(response)
|
req.write(response)
|
||||||
return apache.OK
|
return apache.OK
|
||||||
|
|
||||||
|
|
||||||
|
def jsonrpc(req):
|
||||||
|
"""
|
||||||
|
mod_python handler for JSON-RPC requests (place holder).
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def webui(req):
|
||||||
|
"""
|
||||||
|
mod_python handler for web-UI requests (place holder).
|
||||||
|
"""
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
Production XML-RPC server using mod_python.
|
Production XML-RPC server using mod_python.
|
||||||
|
|
||||||
|
This module is depreciated. See the `ipaserver.xmlrpc()` function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -55,20 +55,20 @@ class xmlserver(Executioner):
|
|||||||
super(xmlserver, self).finalize()
|
super(xmlserver, self).finalize()
|
||||||
|
|
||||||
def listMethods(self, *params):
|
def listMethods(self, *params):
|
||||||
return tuple(name.encode('UTF-8') for name in self.Command)
|
return tuple(name.decode('UTF-8') for name in self.Command)
|
||||||
|
|
||||||
def methodSignature(self, *params):
|
def methodSignature(self, *params):
|
||||||
return 'methodSignature not supported'
|
return u'methodSignature not implemented'
|
||||||
|
|
||||||
def methodHelp(self, *params):
|
def methodHelp(self, *params):
|
||||||
return 'methodHelp not supported'
|
return u'methodHelp not implemented'
|
||||||
|
|
||||||
def marshaled_dispatch(self, data, ccache):
|
def marshaled_dispatch(self, data, ccache):
|
||||||
"""
|
"""
|
||||||
Execute the XML-RPC request in contained in ``data``.
|
Execute the XML-RPC request contained in ``data``.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
#self.create_context(ccache=ccache)
|
self.create_context(ccache=ccache)
|
||||||
(params, name) = xml_loads(data)
|
(params, name) = xml_loads(data)
|
||||||
if name in self.__system:
|
if name in self.__system:
|
||||||
response = (self.__system[name](*params),)
|
response = (self.__system[name](*params),)
|
||||||
|
|||||||
@@ -29,18 +29,6 @@ import krbV
|
|||||||
from ipalib import api
|
from ipalib import api
|
||||||
|
|
||||||
|
|
||||||
class Instance(object):
|
|
||||||
"""
|
|
||||||
Just used for `Instance._listMethods()`.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _listMethods(self):
|
|
||||||
"""
|
|
||||||
Provides list of names for ``system.listMethods``.
|
|
||||||
"""
|
|
||||||
return list(api.Command)
|
|
||||||
|
|
||||||
|
|
||||||
class Server(SimpleXMLRPCServer):
|
class Server(SimpleXMLRPCServer):
|
||||||
"""
|
"""
|
||||||
Custom server implementing `Server._marshaled_dispatch()`.
|
Custom server implementing `Server._marshaled_dispatch()`.
|
||||||
@@ -79,8 +67,7 @@ server = Server(('', api.env.lite_xmlrpc_port), **kw)
|
|||||||
|
|
||||||
api.log.info('Logging to file %r', api.env.log)
|
api.log.info('Logging to file %r', api.env.log)
|
||||||
api.log.info('Listening on port %d', api.env.lite_xmlrpc_port)
|
api.log.info('Listening on port %d', api.env.lite_xmlrpc_port)
|
||||||
server.register_introspection_functions()
|
|
||||||
server.register_instance(Instance())
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|||||||
5
setup.py
5
setup.py
@@ -23,11 +23,12 @@
|
|||||||
Python-level packaging using distutils.
|
Python-level packaging using distutils.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from distutils.core import setup
|
from setuptools import setup
|
||||||
|
import ipalib
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='freeipa',
|
name='freeipa',
|
||||||
version='1.99.1',
|
version=ipalib.__version__,
|
||||||
license='GPLv2+',
|
license='GPLv2+',
|
||||||
url='http://freeipa.org/',
|
url='http://freeipa.org/',
|
||||||
packages=[
|
packages=[
|
||||||
|
|||||||
Reference in New Issue
Block a user