Securing SimpleXMLRPCServer?
John Abel
john.abel at pa.press.net
Tue Jul 9 07:42:31 EDT 2002
I apologise for being a nuisance. I've added the code in, as per
Brian's comments below, but still get an error, when running the client:
Traceback (most recent call last):
File "MDClient.py", line 5, in ?
print ServerConn.GetFiles ( "/test/file" )
File "/usr/local/lib/python2.2/xmlrpclib.py", line 821, in __call__
return self.__send(self.__name, args)
File "/usr/local/lib/python2.2/xmlrpclib.py", line 975, in __request
verbose=self.__verbose
File "/usr/local/lib/python2.2/xmlrpclib.py", line 853, in request
return self.parse_response(h.getfile())
File "/usr/local/lib/python2.2/xmlrpclib.py", line 896, in
parse_response
return u.close()
File "/usr/local/lib/python2.2/xmlrpclib.py", line 571, in close
raise apply(Fault, (), self._stack[0])
xmlrpclib.Fault: <Fault 1: 'exceptions.TypeError:not all arguments
converted'>
Nothing from the over-ridden _dispatch routine is printed out. The only
output is from the the default logging of SimpleXMLRPCServer (as below)
If I run the server script, with the default request handler, then
everything works OK. The client makes a connection, and the server
sends back the requested file. The server outputs the following line.
lestat - - [09/Jul/2002 11:52:01] "POST /RPC2 HTTP/1.0" 200 -
I've even tried running both scripts as root, in case that makes a
difference. I've two different builds of 2.2.1 (initial RH install, and
the AS install) on Red Hat 7.1.
I apologise if it's something simple that I'm missing.
Regards
John
On Mon, 2002-07-08 at 17:39, Brian Quinlan wrote:
> OK, I apologise in advance for appearing dense. I've added the code
> that was supplied by Brian, and the server script appears to run OK.
> However, the client script displays the following error:
>
> Traceback (most recent call last):
[snipped]
> xmlrpclib.Fault: <Fault 1: 'UnknownIP:Client IP Is Not Authorised'>
OK, it looks like the server is rejecting the client's IP address.
> The server script:
>
> import sys, os, SimpleXMLRPCServer, string
>
> class AuthenticatingSimpleXMLRPCRequestHandler
> (SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
> def _dispatch(self,method,params):
> self.UnknownIP = "UnknownIP"
> if not (self.client_address == "144.178.234.189" or
> self.client_address == "localhost" ):
> raise self.UnknownIP, "Client IP Is Not Authorised"
> else:
1. The IP check would be more readable if you wrote it like:
if self.client_address not in ["144.178.234.189", "localhost"]:
....
2. For debugging purposes, try adding the following line:
def _dispatch(self, method, params):
+ print 'client_address: %r' % self.client_address
Then rerun your server and client to see why your server is rejecting
your client's address.
Cheers,
Brian
More information about the Python-list
mailing list