2
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3
# See LICENSE for details.
7
I am the support module for making a ftp server with twistd.
10
from twisted.protocols import ftp
11
from twisted.python import usage
12
from twisted.application import internet
13
from twisted.cred import error, portal, checkers, credentials
18
class Options(usage.Options):
19
synopsis = """[options].
20
WARNING: This FTP server is probably INSECURE do not use it.
23
["port", "p", "2121", "set the port number"],
24
["root", "r", "/usr/local/ftp", "define the root of the ftp-site."],
25
["userAnonymous", "", "anonymous", "Name of the anonymous user."],
26
["password-file", "", None, "username:password-style credentials database"],
32
def makeService(config):
35
r = ftp.FTPRealm(config['root'])
37
p.registerChecker(checkers.AllowAnonymousAccess(), credentials.IAnonymous)
39
if config['password-file'] is not None:
40
p.registerChecker(checkers.FilePasswordDB(config['password-file'], cache=True))
42
f.tld = config['root']
43
f.userAnonymous = config['userAnonymous']
48
portno = int(config['port'])
51
return internet.TCPServer(portno, f)