commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue common/src/rpc/drivers/pw_xmlrpc/ServerAda...


From: Jan Ischebeck
Subject: gnue common/src/rpc/drivers/pw_xmlrpc/ServerAda...
Date: Sat, 05 Apr 2003 20:28:19 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jan Ischebeck <address@hidden>  03/04/05 20:28:19

Modified files:
        common/src/rpc/drivers/pw_xmlrpc: ServerAdapter.py 
        appserver/src  : geasRpcServer.py geasConfiguration.py 

Log message:
        add "allowed_hosts" directive to gnue.conf section [appserver]
        add optional web frontend

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/rpc/drivers/pw_xmlrpc/ServerAdapter.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/appserver/src/geasRpcServer.py.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/appserver/src/geasConfiguration.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gnue/appserver/src/geasConfiguration.py
diff -c gnue/appserver/src/geasConfiguration.py:1.1 
gnue/appserver/src/geasConfiguration.py:1.2
*** gnue/appserver/src/geasConfiguration.py:1.1 Mon Mar 31 08:39:50 2003
--- gnue/appserver/src/geasConfiguration.py     Sat Apr  5 20:28:19 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasConfiguration.py,v 1.1 2003/03/31 13:39:50 siesel Exp $
  
  from gnue.common.formatting import GTypecast
  
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasConfiguration.py,v 1.2 2003/04/06 01:28:19 siesel Exp $
  
  from gnue.common.formatting import GTypecast
  
***************
*** 46,49 ****
--- 46,65 ----
      'Description': 'Port (if needed) for RPC Interface',
      'Typecast'   : GTypecast.whole,
      'Default'    : '8765' },
+ 
+   { 'Name'       : 'allowed_hosts',
+     'Type'       : 'Setting',
+     'Comment'    : 'Hosts which are allowed to access appserver.',
+     'Description': 'Hosts which are allowed to access appserver.',
+     'Typecast'   : GTypecast.text,
+     'Default'    : '' },
+ 
+   { 'Name'       : 'httpdir',
+     'Type'       : 'Setting',
+     'Comment'    : 'Directory, where files which appserver should serve per'+\
+                    ' http are stored',
+     'Description': 'Directory, where files which appserver should serve per'+\
+                    ' http are stored',
+     'Typecast'   : GTypecast.text,
+     'Default'    : "/this_dir_shouldn't exist." }, # default should be 
overridden
  )
Index: gnue/appserver/src/geasRpcServer.py
diff -c gnue/appserver/src/geasRpcServer.py:1.21 
gnue/appserver/src/geasRpcServer.py:1.22
*** gnue/appserver/src/geasRpcServer.py:1.21    Thu Apr  3 17:53:22 2003
--- gnue/appserver/src/geasRpcServer.py Sat Apr  5 20:28:19 2003
***************
*** 19,25 ****
  #
  # Copyright 2001-2003 Free Software Foundation
  #
! # $Id: geasRpcServer.py,v 1.21 2003/04/03 22:53:22 siesel Exp $
  
  ####
  #  
--- 19,25 ----
  #
  # Copyright 2001-2003 Free Software Foundation
  #
! # $Id: geasRpcServer.py,v 1.22 2003/04/06 01:28:19 siesel Exp $
  
  ####
  #  
***************
*** 112,118 ****
        _('Set the password for the used database.')],
      [ 'selftest',None,'selftest',0,None, None,
        _('Test appservers connection to the backend database, check ')+
!       _('correctness of global settings, etc..')]]
    
    def __init__(self, connections=None):
      GServerApp.__init__(self, connections,'appserver',ConfigOptions)
--- 112,121 ----
        _('Set the password for the used database.')],
      [ 'selftest',None,'selftest',0,None, None,
        _('Test appservers connection to the backend database, check ')+
!       _('correctness of global settings, etc..')],
!     [ 'web-frontend',None,'web-frontend',0,None, None,
!       _('Enable appservers web frontend. Just works for the rpc-type XMLRPC. 
')+
!       _('The webfrontend is at the same port as XMLRPC. ')]]
    
    def __init__(self, connections=None):
      GServerApp.__init__(self, connections,'appserver',ConfigOptions)
***************
*** 146,158 ****
  
        port = gConfig("rpcport")
        print "Exporting our services via xmlrpc (port %s) ..." % port
!       self.setTransports({'xmlrpc':{ 'port': int(port) }})
  
      elif rpctype=="pw_xmlrpc":
  
        port = gConfig("rpcport")
        print "Exporting our services via pw_xmlrpc (port %s) ..." % port
!       self.setTransports({'pw_xmlrpc':{ 'port': int(port) }})
  
      elif rpctype=="sockets":
  
--- 149,171 ----
  
        port = gConfig("rpcport")
        print "Exporting our services via xmlrpc (port %s) ..." % port
!       self.setTransports({'xmlrpc':{ 'port': int(port),
!                                      'allowed_hosts': 
gConfig('allowed_hosts')}})
  
      elif rpctype=="pw_xmlrpc":
  
        port = gConfig("rpcport")
        print "Exporting our services via pw_xmlrpc (port %s) ..." % port
!       
!       params = { 'port': int(port),
!                  'allowed_hosts': gConfig('allowed_hosts')}
! 
!       if self.OPTIONS["web-frontend"]:
!         httpbind={'/':gConfig('httpdir'),
!                   '/status':self.htmlStatus}
!         params.update({'httpbind':httpbind})
! 
!       self.setTransports({'pw_xmlrpc':params})
  
      elif rpctype=="sockets":
  
***************
*** 166,174 ****
        print "The protocol you've set is currently not supported."
        sys.exit(-1)
      
  
    def run(self):
!     
      # Create the various servers
      servers=GComm.bind (GConfig.getInstalledBase('install_prefix')+\
                          '/shared/grpc/GEAS.grpc',
--- 179,194 ----
        print "The protocol you've set is currently not supported."
        sys.exit(-1)
      
+       
+   def htmlStatus(self):
+     out="<HTML><HEAD></HEAD><BODY>"
+     out+="Status: %s Sessions opened</BODY></HTML>" % self.sm._sessNo
+     out+="</BODY></HTML>"
+     return out
+ 
  
    def run(self):
!   
      # Create the various servers
      servers=GComm.bind (GConfig.getInstalledBase('install_prefix')+\
                          '/shared/grpc/GEAS.grpc',
***************
*** 206,220 ****
  
    def requestSessionManager(self):
      #print "SessionManager has started up."
!     sm=geasSessionManager.geasSessionManager()
      loginhandler=testLoginHandler ()
      if self.OPTIONS["username"]:
        loginhandler.setLoginData(self.OPTIONS["username"],
                                  self.OPTIONS["password"])
        
      self.connections.setLoginHandler (loginhandler)
!     sm.setConnections(self.connections)
!     return sm
  
  
  # 
=============================================================================
--- 226,243 ----
  
    def requestSessionManager(self):
      #print "SessionManager has started up."
!     if hasattr(self,"sm"):
!       return self.sm
!     
!     self.sm=geasSessionManager.geasSessionManager()
      loginhandler=testLoginHandler ()
      if self.OPTIONS["username"]:
        loginhandler.setLoginData(self.OPTIONS["username"],
                                  self.OPTIONS["password"])
        
      self.connections.setLoginHandler (loginhandler)
!     self.sm.setConnections(self.connections)
!     return self.sm
  
  
  # 
=============================================================================
Index: gnue/common/src/rpc/drivers/pw_xmlrpc/ServerAdapter.py
diff -c gnue/common/src/rpc/drivers/pw_xmlrpc/ServerAdapter.py:1.10 
gnue/common/src/rpc/drivers/pw_xmlrpc/ServerAdapter.py:1.11
*** gnue/common/src/rpc/drivers/pw_xmlrpc/ServerAdapter.py:1.10 Sat Apr  5 
07:58:23 2003
--- gnue/common/src/rpc/drivers/pw_xmlrpc/ServerAdapter.py      Sat Apr  5 
20:28:19 2003
***************
*** 134,139 ****
--- 134,145 ----
      else:
        self._bindto = '' # bind to all interfaces
  
+     if params.has_key('allowed_hosts'):
+       # TODO: Remove spaces, etc.
+       self._allowed_hosts = string.split(params['allowed_hosts'],',')
+     else:
+       self._allowed_hosts = '' # allow access from all hosts
+ 
      if params.has_key('loglevel'):
        self._loglevel = params['loglevel']
      else:
***************
*** 405,410 ****
--- 411,432 ----
  
  class RequestHandler(BaseHTTPRequestHandler):
  
+   # override basic handle to test allowed host condition
+   #
+   def handle(self):
+     for i in self.server._parent._allowed_hosts:
+       # get ip address of client and compare its first characters with i
+       if self.client_address[0][:len(i)]==i:
+         
+         # continue with normal processing
+         return BaseHTTPRequestHandler.handle(self)
+ 
+     self.requestline="UNKNOWN"
+     self.request_version="UNKNOWN"
+     self.send_error(403, "Access to this server is forbidden!")
+     return
+       
+     
    #
    # Handle the HTTP POST command
    #
***************
*** 462,476 ****
  #
  
  class EnhancedRequestHandler(RequestHandler,SimpleHTTPRequestHandler):
    
    def translate_path(self, path):
      path = posixpath.normpath(urllib.unquote(path))
      words = path.split('/')
      words = filter(None, words)    
!     path = self.server._parent._httpbind
!     ## security check
      if (type(path)!=type("") or (len(path)<4)):
!         return "/dev/null"
      for word in words:
        drive, word = os.path.splitdrive(word)
        head, word = os.path.split(word)
--- 484,522 ----
  #
  
  class EnhancedRequestHandler(RequestHandler,SimpleHTTPRequestHandler):
+ 
+   def send_head(self):
+     # check for handler providing file content in string form
+     try:
+       # TODO: rewrite, add a hook instead of just filtering single pages
+       content=self.server._parent._httpbind[self.path]()
+       self.send_response(200)
+       self.send_header("Content-type", "text/html")
+       self.send_header("Content-Length", str(len(content)))
+       self.end_headers()
+       if self.command=="GET":
+         self.wfile.write(content)
+         self.wfile.flush()
+       return None
+     except:
+       return SimpleHTTPRequestHandler.send_head(self)
+ 
    
    def translate_path(self, path):
      path = posixpath.normpath(urllib.unquote(path))
      words = path.split('/')
      words = filter(None, words)    
!     httpbind = self.server._parent._httpbind
!     
!     try:
!       path=httpbind["/"]
!     except:
!       path=httpbind
! 
!     ## security check      
      if (type(path)!=type("") or (len(path)<4)):
!       return "/dev/null"
!     
      for word in words:
        drive, word = os.path.splitdrive(word)
        head, word = os.path.split(word)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]