Exemplo n.º 1
0
 def cmd_pass(self, line):
     'specify password'
     if len(line) < 2:
         pw = ''
     else:
         pw = line[1]
     self.password = pw
     i = self.userid.find('@')
     if i == -1:
         if self.server.limiter.check_limit(self):
             self.respond('230 Login successful.')
             self.authorized = 1
             self.anonymous = 1
             self.log_info('Successful login.')
         else:
             self.respond('421 User limit reached. Closing connection.')
             self.close_when_done()
     else:
         path = self.userid[i + 1:]
         self.userid = self.userid[:i]
         self.anonymous = None
         response = make_response(self, self.pass_completion,
                                  self._join_paths('/', path))
         request = FTPRequest(path, 'PASS', self, response)
         handle(self.module, request, response)
Exemplo n.º 2
0
 def cmd_pass(self, line):
     'specify password'
     if len(line) < 2:
         pw = ''
     else:
         pw = line[1]
     self.password=pw
     i=self.userid.find('@')
     if i ==-1:
         if self.server.limiter.check_limit(self):
             self.respond ('230 Login successful.')
             self.authorized = 1
             self.anonymous = 1
             self.log_info ('Successful login.')
         else:
             self.respond('421 User limit reached. Closing connection.')
             self.close_when_done()
     else:
         path=self.userid[i+1:]
         self.userid=self.userid[:i]
         self.anonymous=None
         response=make_response(self, self.pass_completion,
                 self._join_paths('/',path))
         request=FTPRequest(path,'PASS',self,response)
         handle(self.module,request,response)
Exemplo n.º 3
0
 def send_response(self):
     # create an output pipe by passing request to ZPublisher,
     # and requesting a callback of self.log with the module
     # name and PATH_INFO as an argument.
     self.done = 1
     response = PCGIResponse(stdout=PCGIPipe(self), stderr=StringIO())
     request = HTTPRequest(self.data, self.env, response)
     handle(self.server.module, request, response)
Exemplo n.º 4
0
 def send_response(self):
     # create an output pipe by passing request to ZPublisher,
     # and requesting a callback of self.log with the module
     # name and PATH_INFO as an argument.
     self.done=1
     response=PCGIResponse(stdout=PCGIPipe(self), stderr=StringIO())
     request=HTTPRequest(self.data, self.env, response)
     handle(self.server.module, request, response)
Exemplo n.º 5
0
 def cmd_size(self, line):
     'return size of file'
     if len (line) != 2:
         self.command.not_understood (' '.join(line))
         return
     response=make_response(self, self.size_completion)
     request=FTPRequest(line[1],'SIZE',self,response)
     handle(self.module,request,response)
Exemplo n.º 6
0
 def cmd_mdtm(self, line):
     'show last modification time of file'
     if len(line) != 2:
         self.command.not_understood(' '.join(line))
         return
     response = make_response(self, self.mdtm_completion)
     request = FTPRequest(line[1], 'MDTM', self, response)
     handle(self.module, request, response)
Exemplo n.º 7
0
 def work(self):
     "try to handle a request"
     if not self.working:
         if self.queue and not self.no_more_requests:
             self.working=1
             try: module_name, request, response=self.queue.pop(0)
             except: return
             handle(module_name, request, response)
Exemplo n.º 8
0
 def cmd_mkd(self, line):
     if len(line) != 2:
         self.command.not_understood(' '.join(line))
         return
     path, id = os.path.split(line[1])
     response = make_response(self, self.mkd_completion)
     request = FTPRequest(path, ('MKD', id), self, response)
     handle(self.module, request, response)
Exemplo n.º 9
0
 def cmd_mkd(self, line):
     if len (line) != 2:
         self.command.not_understood (' '.join (line))
         return
     path,id=os.path.split(line[1])
     response=make_response(self, self.mkd_completion)
     request=FTPRequest(path,('MKD',id),self,response)
     handle(self.module,request,response)
Exemplo n.º 10
0
 def cmd_size(self, line):
     'return size of file'
     if len(line) != 2:
         self.command.not_understood(' '.join(line))
         return
     response = make_response(self, self.size_completion)
     request = FTPRequest(line[1], 'SIZE', self, response)
     handle(self.module, request, response)
Exemplo n.º 11
0
 def cmd_mdtm(self, line):
     'show last modification time of file'
     if len (line) != 2:
         self.command.not_understood (' '.join(line))
         return
     response=make_response(self, self.mdtm_completion)
     request=FTPRequest(line[1],'MDTM',self,response)
     handle(self.module,request,response)
Exemplo n.º 12
0
 def cmd_rnto (self, line):
     if len (line) != 2:
         self.command_not_understood (' '.join(line))
         return
     pathf,idf=os.path.split(self.fromfile)
     patht,idt=os.path.split(line[1])
     response=make_response(self, self.rnto_completion)
     request=FTPRequest(pathf,('RNTO',idf,idt),self,response)
     handle(self.module,request,response)
Exemplo n.º 13
0
 def listdir(self, path, long=0):
     response = make_response(self, self.listdir_completion, long)
     request = FTPRequest(path,
                          'LST',
                          self,
                          response,
                          globbing=self.globbing,
                          recursive=self.recursive)
     handle(self.module, request, response)
Exemplo n.º 14
0
 def cmd_rnto(self, line):
     if len(line) != 2:
         self.command_not_understood(' '.join(line))
         return
     pathf, idf = os.path.split(self.fromfile)
     patht, idt = os.path.split(line[1])
     response = make_response(self, self.rnto_completion)
     request = FTPRequest(pathf, ('RNTO', idf, idt), self, response)
     handle(self.module, request, response)
Exemplo n.º 15
0
 def cmd_rmd(self, line):
     # XXX should object be checked to see if it's folderish
     #     before we allow it to be RMD'd?
     if len(line) != 2:
         self.command.not_understood(' '.join(line))
         return
     path, id = os.path.split(line[1])
     response = make_response(self, self.rmd_completion)
     request = FTPRequest(path, ('RMD', id), self, response)
     handle(self.module, request, response)
Exemplo n.º 16
0
 def cmd_rnfr(self, line):
     'rename from'
     if len(line) != 2:
         self.command_not_understood(' '.join(line))
     else:
         self.fromfile = line[1]
         pathf, idf = os.path.split(self.fromfile)
         response = make_response(self, self.rnfr_completion)
         request = FTPRequest(pathf, ('RNFR', idf), self, response)
         handle(self.module, request, response)
Exemplo n.º 17
0
 def stor_callback(self, path, data, size):
     'callback to do the STOR, after we have the input'
     response = make_response(self, self.stor_completion)
     request = FTPRequest(path,
                          'STOR',
                          self,
                          response,
                          stdin=data,
                          size=size)
     handle(self.module, request, response)
Exemplo n.º 18
0
 def send_response(self):
     """
     Create output pipes, request, and response objects.  Give them
     to ZPublisher for processing.
     """
     response = FCGIResponse(stdout = FCGIPipe(self, FCGI_STDOUT),
                             stderr = StringIO())
     response.setChannel(self)
     request  = HTTPRequest(self.stdin, self.env, response)
     handle(self.server.module, request, response)
Exemplo n.º 19
0
 def send_response(self):
     """
     Create output pipes, request, and response objects.  Give them
     to ZPublisher for processing.
     """
     response = FCGIResponse(stdout = FCGIPipe(self, FCGI_STDOUT),
                             stderr = StringIO())
     response.setChannel(self)
     request  = HTTPRequest(self.stdin, self.env, response)
     handle(self.server.module, request, response)
Exemplo n.º 20
0
 def cmd_rnfr (self, line):
     'rename from'
     if len (line) != 2:
         self.command_not_understood (' '.join(line))
     else:
         self.fromfile = line[1]
         pathf,idf=os.path.split(self.fromfile)
         response=make_response(self, self.rnfr_completion)
         request=FTPRequest(pathf,('RNFR',idf),self,response)
         handle(self.module,request,response)
Exemplo n.º 21
0
 def cmd_rmd(self, line):
     # XXX should object be checked to see if it's folderish
     #     before we allow it to be RMD'd?
     if len (line) != 2:
         self.command.not_understood (' '.join (line))
         return
     path,id=os.path.split(line[1])
     response=make_response(self, self.rmd_completion)
     request=FTPRequest(path,('RMD',id),self,response)
     handle(self.module,request,response)
Exemplo n.º 22
0
 def cmd_retr(self, line):
     if len(line) < 2:
         self.command_not_understood(' '.join(line))
         return
     response = make_response(self, self.retr_completion, line[1])
     self._response_producers = response.stdout._producers
     request = FTPRequest(line[1], 'RETR', self, response)
     # Support download restarts if possible.
     if self.restart_position > 0:
         request.environ['HTTP_RANGE'] = 'bytes=%d-' % self.restart_position
     handle(self.module, request, response)
Exemplo n.º 23
0
 def cmd_retr(self,line):
     if len(line) < 2:
         self.command_not_understood (' '.join(line))
         return
     response=make_response(self, self.retr_completion, line[1])
     self._response_producers = response.stdout._producers
     request=FTPRequest(line[1],'RETR',self,response)
     # Support download restarts if possible.
     if self.restart_position > 0:
         request.environ['HTTP_RANGE'] = 'bytes=%d-' % self.restart_position
     handle(self.module,request,response)
Exemplo n.º 24
0
 def cmd_cwd(self, line):
     'change working directory'
     response = make_response(self, self.cwd_completion,
                              self._join_paths(self.path, line[1]))
     request = FTPRequest(line[1], 'CWD', self, response)
     handle(self.module, request, response)
Exemplo n.º 25
0
 def listdir (self, path, long=0):
     response = make_response(self, self.listdir_completion, long)
     request = FTPRequest(path, 'LST', self, response,
                          globbing=self.globbing,
                          recursive=self.recursive)
     handle(self.module, request, response)
Exemplo n.º 26
0
 def stor_callback(self, path, data, size):
     'callback to do the STOR, after we have the input'
     response = make_response(self, self.stor_completion)
     request = FTPRequest(path, 'STOR', self, response,
                          stdin=data, size=size)
     handle(self.module, request, response)
Exemplo n.º 27
0
 def cmd_cwd (self, line):
     'change working directory'
     response=make_response(self, self.cwd_completion,
                            self._join_paths(self.path,line[1]))
     request=FTPRequest(line[1],'CWD',self,response)
     handle(self.module,request,response)