From 77e782e2cb5413cde9501568155cce9283ff7b7d Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 28 Jan 2009 18:16:04 -0700 Subject: Fixed bug I introduced in KerbTransport; started work on lite-xmlrpc.py to add client address to context --- ipalib/rpc.py | 4 ++-- lite-xmlrpc.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ipalib/rpc.py b/ipalib/rpc.py index 3d837b5f1..5a1f9e1ed 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -198,7 +198,7 @@ class KerbTransport(SafeTransport): else: raise e - extra_headers += [ + extra_headers = [ ('Authorization', 'negotiate %s' % kerberos.authGSSClientResponse(vc)) ] @@ -240,7 +240,7 @@ class xmlclient(Connectible): raise ValueError( '%s.forward(): %r not in api.Command' % (self.name, name) ) - self.info('Forwarding %r to %r', name, self.env.xmlrpc_uri) + self.info('Forwarding %r to server %r', name, self.env.xmlrpc_uri) command = getattr(self.conn, name) params = args + (kw,) try: diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index d755dfa3f..55babf9ef 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -24,7 +24,7 @@ In-tree XML-RPC server using SimpleXMLRPCServer. """ import sys -from SimpleXMLRPCServer import SimpleXMLRPCServer +from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler import krbV from ipalib import api @@ -54,14 +54,25 @@ class Server(SimpleXMLRPCServer): ccache=krbV.default_context().default_ccache().name return api.Backend.xmlserver.marshaled_dispatch(data, ccache) except Exception, e: - api.log.exception('Error caught by lite-xmlrpc.py...') + api.log.exception('lite-xmlrpc: caught error in _marshaled_dispatch()') raise e +class RequestHandler(SimpleXMLRPCRequestHandler): + + def do_POST(self): + try: + client = '%r %r' % self.client_address + except Exception, e: + api.log.exception('lite-xmlrpc: caught error in do_POST()') + raise e + return SimpleXMLRPCRequestHandler.do_POST(self) + + api.bootstrap_with_global_options(context='server') api.finalize() -kw = dict(logRequests=False) +kw = dict(requestHandler=RequestHandler, logRequests=False) if sys.version_info[:2] != (2, 4): kw.update(dict(encoding='UTF-8', allow_none=True)) server = Server(('', api.env.lite_xmlrpc_port), **kw) -- cgit