[Zope] specify passive ports for ftp

ra@burningman.com ra@burningman.com
Fri, 08 Feb 2002 13:32:43 -0800


Brad Clements wrote:

> On 7 Feb 2002 at 23:37, ra@burningman.com wrote:
> 
> 
>>Actually, I'd be interested in even hearing ways to solve this problem that
>>DO involve modifying the source code... I dug into the FTPServer.py code a
>>while back to try to tackle this very problem and didn't see where the
>>ports were being specified.  Unfortunately, other matters became a bit more
>>pressing.  I'd be willing to hack up a way to set the passive ftp ports if
>>someone would orient me a bit...
>>
> 
> I changed the code in one of my servers to specify the pasv port range.. Now I can't 
> remember which instance I changed, or where it was in the code.
> 
> It wasn't hard, if that's any help.
> 
> You need to change ZServer/medusa/ftp_server.py
> 
> class passive_acceptor (asyncore.dispatcher):
>         ready = None
> 
>         def __init__ (self, control_channel):
>                 # connect_fun (conn, addr)
>                 asyncore.dispatcher.__init__ (self)
>                 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
>                         ))
>                 self.addr = self.getsockname()
>                 self.listen (1)
> 
> 
> As I recall, I put a range loop to try the self.bind over a range of non-privilaged ports. I 
> use a range in case a port is in use.

Awesome, thanks!  I'll dig in over the next few days and will post a 
brief note to the list after I've got it working.  Anyone interested in 
the patch (against 2.4.2, which I'm currently running) can contact me 
off-list at that point.

-r