2
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3
# See LICENSE for details.
7
I am the support module for making a manhole server with twistd.
10
from twisted.manhole import service
11
from twisted.spread import pb
12
from twisted.python import usage, util
13
from twisted.cred import portal, checkers
14
from twisted.application import strports
17
class Options(usage.Options):
18
synopsis = "[options]"
20
["user", "u", "admin", "Name of user to allow to log in"],
21
["port", "p", str(pb.portno), "Port to listen on"],
25
["tracebacks", "T", "Allow tracebacks to be sent over the network"],
27
zsh_actions = {"user" : "_users"}
29
def opt_password(self, password):
30
"""Required. '-' will prompt or read a password from stdin.
32
# If standard input is a terminal, I prompt for a password and
33
# confirm it. Otherwise, I use the first line from standard
34
# input, stripping off a trailing newline if there is one.
35
if password in ('', '-'):
36
self['password'] = util.getPassword(confirm=1)
38
self['password'] = password
41
def postOptions(self):
42
if not self.has_key('password'):
43
self.opt_password('-')
45
def makeService(config):
46
port, user, password = config['port'], config['user'], config['password']
48
service.Realm(service.Service(config["tracebacks"], config.get('namespace'))),
49
[checkers.InMemoryUsernamePasswordDatabaseDontUse(**{user: password})]
51
return strports.service(port, pb.PBServerFactory(p, config["tracebacks"]))