4udak / pyftpdlib

Automatically exported from code.google.com/p/pyftpdlib
Other
1 stars 1 forks source link

EPSV with ipv4 does not work #230

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. start basic_ftpd.py with ipv4/ipv6 enabled
2. use own client and epsv ftp mode

[2012-Dec-16 14:38:01] 127.0.0.1:51556 ==> 220 pyftpdlib 0.7.0 based ftpd ready.
[2012-Dec-16 14:38:01] 127.0.0.1:51556 <== USER anonymous
[2012-Dec-16 14:38:01] 127.0.0.1:51556 ==> 331 Username ok, send password.
[2012-Dec-16 14:38:01] 127.0.0.1:51556 <== PASS ******
[2012-Dec-16 14:38:01] 127.0.0.1:51556 ==> 230 Login successful.
[2012-Dec-16 14:38:01] 127.0.0.1:51556 <== TYPE A
[2012-Dec-16 14:38:01] 127.0.0.1:51556 ==> 200 Type set to: ASCII.
[2012-Dec-16 14:38:01] 127.0.0.1:51556 <== EPSV

[anonymous]@127.0.0.1:51556 unhandled exception in instance 
<pyftpdlib.ftpserver.FTPHandler object at 0x131fb0>
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 83, in read
    obj.handle_read_event()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 444, in handle_read_event
    self.handle_read()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asynchat.py", line 158, in handle_read
    self.found_terminator()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyftpdlib-0.7.0-py2.7.egg/pyftpdlib/ftpserver.py", line 2286, in found_terminator
    self.process_command(cmd, arg, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyftpdlib-0.7.0-py2.7.egg/pyftpdlib/ftpserver.py", line 2295, in process_command
    method(*args, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyftpdlib-0.7.0-py2.7.egg/pyftpdlib/ftpserver.py", line 2807, in ftp_EPSV
    self._make_epasv(extmode=True)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyftpdlib-0.7.0-py2.7.egg/pyftpdlib/ftpserver.py", line 2709, in _make_epasv
    self._dtp_acceptor = self.passive_dtp(self, extmode)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyftpdlib-0.7.0-py2.7.egg/pyftpdlib/ftpserver.py", line 709, in __init__
    self.bind((local_ip, port))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 341, in bind
    return self.socket.bind(addr)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 49] Can't assign requested address

uname -a
Darwin claus-kleins-macbook-pro.local 9.8.0 Darwin Kernel Version 9.8.0: Wed 
Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 i386 
MacBookPro5,1 Darwin

Original issue reported on code.google.com by claus.kl...@googlemail.com on 17 Dec 2012 at 4:37

GoogleCodeExporter commented 9 years ago
with this patch, it works fine

Original comment by claus.kl...@googlemail.com on 17 Dec 2012 at 4:39

Attachments:

GoogleCodeExporter commented 9 years ago
You should try this with development version which AFAICT shouldn't have this 
problem.

Original comment by g.rodola on 18 Dec 2012 at 11:27

GoogleCodeExporter commented 9 years ago
# XXX test_epsv_v4 (__main__.TestIPv6MixedEnvironment) ... Exception in thread 
Thread-131:
    def test_epsv_v4(self):
        mlstline = lambda cmd: self.client.voidcmd(cmd).split('\n')[1]
        self.client = self.client_class()
        self.client.connect('127.0.0.1', self.server.port)
        self.client.sock.settimeout(2)
        self.client.login(USER, PASSWD)
        host, port = ftplib.parse229(self.client.sendcmd('EPSV'),
                     self.client.sock.getpeername())
        self.assertEqual('127.0.0.1', host)
        # test connection
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(2)
        s.connect((host, port))
        self.assertTrue(mlstline('mlst /').endswith('/'))
        s.close()

# I add this test to show the error

Original comment by claus.kl...@googlemail.com on 19 Dec 2012 at 7:53

GoogleCodeExporter commented 9 years ago
with development version it works better:
test_eprt_v4 (__main__.TestIPv6MixedEnvironment) ... ERROR
test_epsv_v4 (__main__.TestIPv6MixedEnvironment) ... ok
test_pasv_v4 (__main__.TestIPv6MixedEnvironment) ... ok
test_port_v4 (__main__.TestIPv6MixedEnvironment) ... ok

======================================================================
ERROR: test_oob_abor (__main__.TestFtpAbort)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_ftpd.py", line 2007, in test_oob_abor
    self.assertEqual(self.client.getresp()[:3], '225')
  File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/ftplib.py", line 220, in getresp
    raise error_perm(resp)
ftplib.error_perm: 500 Command "\xef\xbf\xbdOR" not understood.

======================================================================
ERROR: test_eprt_v4 (__main__.TestIPv6MixedEnvironment)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_ftpd.py", line 2964, in test_eprt_v4
    self.client.sendcmd('eprt |1|%s|%s|' % (ip, port))
  File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/ftplib.py", line 245, in sendcmd
    return self.getresp()
  File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/ftplib.py", line 220, in getresp
    raise error_perm(resp)
ftplib.error_perm: 522 Network protocol not supported (use 2).

----------------------------------------------------------------------
Ran 146 tests in 4.374s

FAILED (errors=2)

Original comment by claus.kl...@googlemail.com on 19 Dec 2012 at 7:59

GoogleCodeExporter commented 9 years ago
What's the status on this if you try latest r1145?

Original comment by g.rodola on 5 Jan 2013 at 6:10