[Zope-Checkins] CVS: Zope/ZServer/medusa - ftp_server.py:1.21.2.1
Brian Lloyd
brian@zope.com
Tue, 11 Jun 2002 17:33:10 -0400
Update of /cvs-repository/Zope/ZServer/medusa
In directory cvs.zope.org:/tmp/cvs-serv17257
Modified Files:
Tag: anthony-CallProfiler-branch
ftp_server.py
Log Message:
Added Brad Clements PASV patch.
=== Zope/ZServer/medusa/ftp_server.py 1.21 => 1.21.2.1 ===
self.control_channel = control_channel
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
- # bind to an address on the interface that the
- # control connection is coming from.
- self.bind ((
- self.control_channel.getsockname()[0],
- 0
- ))
+
+ # The environment variable PASV_FTP_PORTRANGE specifies the tcp
+ # port range to use when opening a listening socket. Specified
+ # as [low, high] values separated by a colon.
+ #
+ # Example:
+ # setenv PASV_FTP_PORTRANGE=5000:5010
+ # uses ports 5000 through 5009 inclusive
+ try:
+ port_range = os.environ.get('PASV_FTP_PORTRANGE')
+ if port_range is not None:
+ port_range = map(int, port_range.split(':'))
+ for p in range(port_range[0], port_range[1]):
+ try:
+ self.bind((self.control_channel.getsockname()[0], p))
+ break
+ except:
+ pass
+ else:
+ self.bind((self.control_channel.getsockname()[0], 0))
+ except:
+ self.bind((self.control_channel.getsockname()[0], 0))
+
self.addr = self.getsockname()
self.listen (1)