[Twisted-Python] FTP: A little help?
For no good reason, I've been trying to implement a basic FTP server w/ Twisted 2.2. After a few puzzling exceptions, some custom code, TOSSING the custom code, and more quality time with the source, I've come to the conclusion that I need a nudge in the right direction. Initially, it looks like it should be pretty straightforward (as much as it ever gets in Twisted anyway :), but it's not working. Here's the code: =============== from twisted.protocols.ftp import FTPFactory from twisted.protocols.ftp import FTPRealm from twisted.cred.portal import Portal print "Starting FTP server" p = Portal(FTPRealm('./')) # start up in local dir for giggles f = FTPFactory(p) from twisted.internet import reactor reactor.listenTCP(21, f) reactor.run() print "FTP Server terminated." =============== Simple. This raises no exceptions, and appears to be working until I actually log in. =============== ftp> open localhost Connected to elric. 220 Twisted 2.2.0 FTP Server User (elric:(none)): anonymous 331 Guest login ok, type your email address as password. Password: 530 Sorry, Authentication failed. Login failed. =============== The shell it's running from shows no errors or exceptions. So why did my anonymous login fail? (I'll wait until I solve that before I tackle the issue of actual "real" users) -- "Ladies and gentlemen, there's nothing to worry about ... but please keep your heads down." Best, Jeff
On Fri, 10 Mar 2006 23:36:04 -0500, Jeff Grimmett <grimmtooth@gmail.com> wrote:
For no good reason, I've been trying to implement a basic FTP server w/ Twisted 2.2. After a few puzzling exceptions, some custom code, TOSSING the custom code, and more quality time with the source, I've come to the conclusion that I need a nudge in the right direction.
Initially, it looks like it should be pretty straightforward (as much as it ever gets in Twisted anyway :), but it's not working. Here's the code:
===============
from twisted.protocols.ftp import FTPFactory from twisted.protocols.ftp import FTPRealm from twisted.cred.portal import Portal
print "Starting FTP server"
p = Portal(FTPRealm('./')) # start up in local dir for giggles
Your portal has no credentials checkers, not even one that allows anonymous access. So, no one can log in. Try giving it a twisted.cred.checkers.AllowAnonymousAccess() at least and see if you get any further. Jean-Paul
On 3/11/06, Jean-Paul Calderone <exarkun@divmod.com> wrote:
Your portal has no credentials checkers, not even one that allows anonymous access. So, no one can log in. Try giving it a twisted.cred.checkers.AllowAnonymousAccess() at least and see if you get any further.
Bingo. That also gives me some insight at what I need to do to handle authentication needs (from looking in t.c.checkers). Thanks! Um, is there a place that recipies like this could be posted in general? I know that the tm.com is now essentially a big wiki, but I'm getting lost on it. I figure a mostly working example trumps no example at all :-) -- "Ladies and gentlemen, there's nothing to worry about ... but please keep your heads down." Best, Jeff
On Sat, 11 Mar 2006 14:37:15 -0500, Jeff Grimmett <grimmtooth@gmail.com> wrote:
On 3/11/06, Jean-Paul Calderone <exarkun@divmod.com> wrote:
Your portal has no credentials checkers, not even one that allows anonymous access. So, no one can log in. Try giving it a twisted.cred.checkers.AllowAnonymousAccess() at least and see if you get any further.
Bingo. That also gives me some insight at what I need to do to handle authentication needs (from looking in t.c.checkers). Thanks!
Um, is there a place that recipies like this could be posted in general? I know that the tm.com is now essentially a big wiki, but I'm getting lost on it. I figure a mostly working example trumps no example at all :-)
Twisted/doc/core/examples/ is probably a good place for an example FTP server. If you submit one to the issue tracker, someone will add it to the repository. Jean-Paul
On 3/11/06, Jean-Paul Calderone <exarkun@divmod.com> wrote: Twisted/doc/core/examples/ is probably a good place for an example FTP
server. If you submit one to the issue tracker, someone will add it to the repository.
Will do. I'll work it up to be a little more useful then post it. -- "Ladies and gentlemen, there's nothing to worry about ... but please keep your heads down." Best, Jeff
On 3/11/06, Jean-Paul Calderone <exarkun@divmod.com> wrote: Twisted/doc/core/examples/ is probably a good place for an example FTP
server. If you submit one to the issue tracker, someone will add it to the repository.
I'd love to, but trac seems to be having some problems. I can't enter a new ticket without entering my email address on the account configuration page, but there doesn't seem to be a submit button on it, so I can never add my email address to it. Exceptions all over the place. So.... I've attached my example. If it's not too much trouble? And feel free to hack on my comments. Lord knows I probably misunderstood a few dozen things. -- "Ladies and gentlemen, there's nothing to worry about ... but please keep your heads down." Best, Jeff
participants (2)
-
Jean-Paul Calderone
-
Jeff Grimmett