def run(self):
     from app import APP
     APP.Functions.set_process_name ( "0@TFTPD_FILE" )
     logger = APP.LoggingClient ( name="TFTP_FILE" )
     while True:
         (initiating_packet, client_address) = self.myQueue.get()
         if initiating_packet is None: break
         print "cooking %s" % initiating_packet
         (filename, filesize) = self.oven.prepare (initiating_packet.filename, client_address[0])
         if filesize < 0:
             logger ( "%s, ERROR, %s" % (client_address[0], filename) )
             Protocol.Send_ERROR (client_address, 0, filename)
         else:
             try:
                 self.rfQueue.put ( (client_address, initiating_packet, filename, filesize) )
             except ThreadingQueue.full:
                 logger ( "%s, ERROR, rf queue full" % (client_address[0],) )
                 Protocol.Send_ERROR (client_address, 0, 'rf queue full' )
예제 #2
0
 def finish_request(self, request, client_address):
     data, _ = request
     ipacket = Protocol.Packet ( data )
     if ipacket.opcode == Protocol.Packet.RRQ:
         if not self.handle_RRQ (ipacket, client_address):
             Protocol.Send_ERROR (client_address, 2)
     elif ipacket.opcode == Protocol.Packet.WRQ:
         self.handle_WRQ (ipacket, client_address)
     else:
         self.report_error ( "Message from %s, opcode %s, does not belong to a known session." %
                             (client_address, ipacket.opcode) )
 def handle_RRQ (self, ipacket, client_address):
     for cook in self.cooks:
         (oven,queue,plist) = cook
         if oven.check_access (ipacket.filename, client_address[0]):                    
             try:
                 self.logger ( "RRQ from %s filename=%s" % (client_address[0], ipacket.filename) )
                 queue.put_nowait ( (ipacket, client_address) )
                 return True
             except ThreadingQueue.full:
                 self.logger ( "RRQ from %s FAILED (QUEUE FULL)" % (client_address[0],) )
                 Protocol.Send_ERROR ( client_address, 0, "cook queue full" )
         #else:
         #    print "access denied in oven: ", oven
     return False
예제 #4
0
 def handle_WRQ (self, ipacket, client_address):
     Protocol.Send_ERROR (client_address, 0, "Function not available.")
     return True