~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/conch/tap.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- test-case-name: twisted.conch.test.test_tap -*-
 
2
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
"""
 
6
Support module for making SSH servers with twistd.
 
7
"""
 
8
 
 
9
from twisted.conch import checkers, unix
 
10
from twisted.conch.openssh_compat import factory
 
11
from twisted.cred import portal
 
12
from twisted.python import usage
 
13
from twisted.application import strports
 
14
try:
 
15
    from twisted.cred import pamauth
 
16
except ImportError:
 
17
    pamauth = None
 
18
 
 
19
 
 
20
 
 
21
class Options(usage.Options):
 
22
    synopsis = "[-i <interface>] [-p <port>] [-d <dir>] "
 
23
    longdesc = "Makes a Conch SSH server."
 
24
    optParameters = [
 
25
         ["interface", "i", "", "local interface to which we listen"],
 
26
         ["port", "p", "22", "Port on which to listen"],
 
27
         ["data", "d", "/etc", "directory to look for host keys in"],
 
28
         ["moduli", "", None, "directory to look for moduli in "
 
29
                              "(if different from --data)"]
 
30
    ]
 
31
    zsh_actions = {"data" : "_dirs", "moduli" : "_dirs"}
 
32
 
 
33
 
 
34
def makeService(config):
 
35
    t = factory.OpenSSHFactory()
 
36
    t.portal = portal.Portal(unix.UnixSSHRealm())
 
37
    t.portal.registerChecker(checkers.UNIXPasswordDatabase())
 
38
    t.portal.registerChecker(checkers.SSHPublicKeyDatabase())
 
39
    if pamauth is not None:
 
40
        from twisted.cred.checkers import PluggableAuthenticationModulesChecker
 
41
        t.portal.registerChecker(PluggableAuthenticationModulesChecker())
 
42
    t.dataRoot = config['data']
 
43
    t.moduliRoot = config['moduli'] or config['data']
 
44
    port = config['port']
 
45
    if config['interface']:
 
46
        # Add warning here
 
47
        port += ':interface='+config['interface']
 
48
    return strports.service(port, t)