Exemple #1
0
	def __init__(self, ip, filename):
		threading.Thread.__init__(self)
		assert isfile(filename)

		authorizer = MyAuthorizer()
		authorizer.add_anonymous(filename)
		self._filename = basename(filename)
		self._filesize = os.stat(filename).st_size

		handler = MyFTPHandler
		handler.authorizer = authorizer
		handler.on_file_sent = self.on_file_sent
		handler.abstracted_fs = FileFS
		address = (ip, 21)
		self._url = 'ftp://' + ip + '/' + self._filename

		FTPServer.__init__(self, address, handler)
		self.start()
    def __init__(self,
                 username="******",
                 password="******",
                 ftp_home=None,
                 ftp_port=0,
                 use_TLS=False,
                 certfile=DEFAULT_CERTFILE):
        # Create temp directories for the anonymous and authenticated roots
        self._anon_root = tempfile.mkdtemp(prefix="anon_root_")
        if not ftp_home:
            self.temp_ftp_home = True
            if use_TLS:
                self._ftp_home = tempfile.mkdtemp(prefix="ftp_home_TLS_")
            else:
                self._ftp_home = tempfile.mkdtemp(prefix="ftp_home_")
        else:
            self.temp_ftp_home = False
            self._ftp_home = ftp_home
        self.username = username
        self.password = password
        authorizer = DummyAuthorizer()
        authorizer.add_user(self.username,
                            self.password,
                            self._ftp_home,
                            perm='elradfmwM')
        authorizer.add_anonymous(self._anon_root)

        self._uses_TLS = use_TLS
        self._cert_path = certfile

        if use_TLS:
            handler = TLS_FTPHandler
            handler.certfile = certfile
            validate_cert_file(certfile)
        else:
            handler = FTPHandler

        socket, self._ftp_port = get_socket(ftp_port)

        handler.authorizer = authorizer

        # Create a new pyftpdlib server with the socket and handler we've
        # configured
        FTPServer.__init__(self, socket, handler)
    def __init__(self):
        # Create temp directories for the anonymous and authenticated roots
        self._anon_root = tempfile.mkdtemp()
        self._ftp_home = tempfile.mkdtemp()

        authorizer = DummyAuthorizer()
        authorizer.add_user(self.ftp_user, self.ftp_password, self.ftp_home, perm='elradfmwM')
        authorizer.add_anonymous(self.anon_root)

        handler = FTPHandler
        handler.authorizer = authorizer

        # Create a socket on any free port
        self._ftp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._ftp_socket.bind(('', 0))
        self._ftp_port = self._ftp_socket.getsockname()[1]

        # Create a new pyftpdlib server with the socket and handler we've configured
        FTPServer.__init__(self, self._ftp_socket, handler)
Exemple #4
0
    def __init__(self):
        # Create temp directories for the anonymous and authenticated roots
        self._anon_root = tempfile.mkdtemp()
        self._ftp_home = tempfile.mkdtemp()

        authorizer = DummyAuthorizer()
        authorizer.add_user(self.ftp_user,
                            self.ftp_password,
                            self.ftp_home,
                            perm='elradfmwM')
        authorizer.add_anonymous(self.anon_root)

        handler = FTPHandler
        handler.authorizer = authorizer

        # Create a socket on any free port
        self._ftp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._ftp_socket.bind(('', 0))
        self._ftp_port = self._ftp_socket.getsockname()[1]

        # Create a new pyftpdlib server with the socket and handler we've configured
        FTPServer.__init__(self, self._ftp_socket, handler)
Exemple #5
0
 def __init__(self, *args, **kwargs):
     self.alerting_function = kwargs.pop("alerting_function")
     self.base_dir = kwargs.pop("base_dir")
     FTPServer.__init__(self, *args, **kwargs)