Ignore:
Timestamp:
08/06/06 12:51:22 (14 years ago)
Author:
spascoe
Message:

There are various changes here.

The server now calls python for authorisation. This is untested, although the test suite passes. More flesh on delivery.server and it's now used in the
test suite. The server now logs python exceptions to syslog from within C code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/lib/python/delivery/server.py

    r1133 r1141  
    77import bbftpd 
    88 
    9 def start(authHandler): 
     9def start(authHandler, args): 
    1010    """Start the bbftp server. 
    1111 
    1212    The server performs a fork() during initialisation, the child process remains in 
    1313    the server's main loop and the parent returns from this function.  The server process 
    14     calls authHandler() on each connection to do authentication/authorisation. 
     14    calls authHandler.authorise() on each connection to do authentication/authorisation. 
    1515 
    1616    @note: because the server process forks, authHandler will not see any changes to the python 
    1717        interpreter following the call to start(). 
    1818 
     19    @param authHandler: an instance of AuthHandler. 
     20    @param args: a list of command line arguments. 
    1921    @return: the PID of the server process. 
    2022    """ 
    2123     
    22     bbftpd.run(authHandler) 
     24    return bbftpd.run(authHandler, args) 
    2325 
    2426 
     
    3032    """ 
    3133     
    32     def __call__(self): 
    33         """Entry point called by the server to do authorisation. 
    34  
    35         This function simply calls the authorise() method.  See authorise() for details. 
    36         """ 
    37         return self.authorise() 
    38  
    3934    def send(self, buffer): 
    4035        """Send a message to the client. 
     
    7065class AuthzHandler(object): 
    7166    """Abstract base class for implementing authorisation. 
     67 
     68    @ivar username the client's username 
    7269    """ 
    7370 
     
    9289        raise NotImplementedError 
    9390 
    94     def authzSend(self, path): 
    95         """Authorise a send request. 
     91    def authzStore(self, path): 
     92        """Authorise a store request. 
    9693 
    9794        @param path: the destination file. 
     
    9996        """ 
    10097 
     98        raise NotImplementedError 
     99     
     100    def _raiseNoUsername(self): 
     101        raise ValueError, "No username has been set" 
     102    username = property(_raiseNoUsername) 
    101103 
    102  
     104#-------------------------------------------------------------------------------------------------------------- 
    103105 
    104106class BasicClientAuthHandler(AuthHandler): 
     
    124126        return msg 
    125127 
     128 
     129 
     130class LiberalAuthzHandler(AuthzHandler): 
     131    """Allow everything. 
     132    """ 
     133 
     134    username = None 
     135 
     136    def __init__(self, username): 
     137        self.username = username 
     138 
     139    def authzControl(self, m, t, p): 
     140        return 0; 
     141 
     142    def authzRetr(self, p): 
     143        return 0; 
     144 
     145    def authzStore(self, p): 
     146        return 0; 
     147     
Note: See TracChangeset for help on using the changeset viewer.