/usr/share/pyshared/twisted/plugins/tftp_plugin.py is in python-txtftp 0.1~bzr38-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | '''
@author: shylent
'''
from tftp.backend import FilesystemSynchronousBackend
from tftp.protocol import TFTP
from twisted.application import internet
from twisted.application.service import IServiceMaker
from twisted.plugin import IPlugin
from twisted.python import usage
from twisted.python.filepath import FilePath
from zope.interface import implements
def to_path(str_path):
return FilePath(str_path)
class TFTPOptions(usage.Options):
optFlags = [
['enable-reading', 'r', 'Lets the clients read from this server.'],
['enable-writing', 'w', 'Lets the clients write to this server.'],
['verbose', 'v', 'Make this server noisy.']
]
optParameters = [
['port', 'p', 1069, 'Port number to listen on.', int],
['root-directory', 'd', None, 'Root directory for this server.', to_path]
]
def postOptions(self):
if self['root-directory'] is None:
raise usage.UsageError("You must provide a root directory for the server")
class TFTPServiceCreator(object):
implements(IServiceMaker, IPlugin)
tapname = "tftp"
description = "A TFTP Server"
options = TFTPOptions
def makeService(self, options):
backend = FilesystemSynchronousBackend(options["root-directory"],
can_read=options['enable-reading'],
can_write=options['enable-writing'])
return internet.UDPServer(options['port'], TFTP(backend))
serviceMaker = TFTPServiceCreator()
|