Redirect FTP in Zope

erstellt von Peter Holzer — 16.12.2009 19:20

Since no FTP-Proxy could provide me a directive for a destination folder, i wrote a really small patch.

path.jpg

betabug: ftp is meant for the dumpster of digital technology anyway
hpeter: webdav is already running ... client wants ftp
hpeter: that's why i tried ftp-proxy
betabug: hpeter: state security concerns, ftp is insecure, webdav can be run over https
betabug: only terrorists use ftp
betabug: or worse: if we still use ftp, the terrorists have won!

 

[Fill in Usual Disclaimers] + You don't want to do this on a shared instance since your're patching the ftp-server of your instance!

I found the suspected code in the __init__ method of zope_ftp_channel in ZServer/FTPServer.py.

You only have to change self.path='/' into self.path='/[whatevernameyouwant]' and your entering path for ftp will change to that url. You can still do a CWD and enter any other directory you have the permission to.

from ZServer.medusa.ftp_server import ftp_channel
from ZServer import requestCloseOnExec
from ZServer.FTPServer import zope_ftp_channel 

def patched_ftp__init__ (self, server, conn, addr, module):
    ftp_channel.__init__(self,server,conn,addr)
    requestCloseOnExec(conn)
    self.module=module
    self.userid=''
    self.password=''
    self.path='/plone'
    self.cookies={}

print "patched ftp root for login redirection"

zope_ftp_channel.__init__ = patched_ftp__init__

I'm certain there is a better, nicer,... way of doing this, that's the nature of a patch ;-)

 

Picture by Egan Snow under cc by-sa http://www.flickr.com/photos/egansnow/268912449/

Artikelaktionen