r46950 - fix up some things
hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org
| Newsgroups | gmane.comp.python.twisted.commits |
|---|---|
| Message-ID | <[email protected]> |
Author: hawkowl
Date: Tue Mar 8 09:23:26 2016
New Revision: 46950
Modified:
branches/manhole-hardcodedkey-8229/twisted/conch/manhole_ssh.py
branches/manhole-hardcodedkey-8229/twisted/conch/manhole_tap.py
branches/manhole-hardcodedkey-8229/twisted/conch/ssh/keys.py
Log:
fix up some things
Modified: branches/manhole-hardcodedkey-8229/twisted/conch/manhole_ssh.py
==============================================================================
--- branches/manhole-hardcodedkey-8229/twisted/conch/manhole_ssh.py (original)
+++ branches/manhole-hardcodedkey-8229/twisted/conch/manhole_ssh.py Tue Mar 8 09:23:26 2016
@@ -16,6 +16,7 @@
from twisted.conch.insults import insults
+
class _Glue:
"""A feeble class for making one attribute look like another.
@@ -28,6 +29,8 @@
def __getattr__(self, name):
raise AttributeError(self.name, "has no attribute", name)
+
+
class TerminalSessionTransport:
def __init__(self, proto, chainedProtocol, avatar, width, height):
self.proto = proto
@@ -79,12 +82,16 @@
def closed(self):
pass
+
+
class TerminalUser(avatar.ConchUser, components.Adapter):
def __init__(self, original, avatarId):
components.Adapter.__init__(self, original)
avatar.ConchUser.__init__(self)
self.channelLookup['session'] = session.SSHSession
+
+
class TerminalRealm:
userFactory = TerminalUser
sessionFactory = TerminalSession
@@ -117,6 +124,8 @@
lambda: None)
raise NotImplementedError()
+
+
class ConchFactory(factory.SSHFactory):
publicKeys = {}
privateKeys = {}
Modified: branches/manhole-hardcodedkey-8229/twisted/conch/manhole_tap.py
==============================================================================
--- branches/manhole-hardcodedkey-8229/twisted/conch/manhole_tap.py (original)
+++ branches/manhole-hardcodedkey-8229/twisted/conch/manhole_tap.py Tue Mar 8 09:23:26 2016
@@ -18,6 +18,8 @@
from twisted.conch.insults import insults
from twisted.conch.ssh import keys
+
+
class makeTelnetProtocol:
def __init__(self, portal):
self.portal = portal
@@ -27,6 +29,8 @@
args = (self.portal,)
return telnet.TelnetTransport(auth, *args)
+
+
class chainedProtocolFactory:
def __init__(self, namespace):
self.namespace = namespace
@@ -50,6 +54,8 @@
lambda: None)
raise NotImplementedError()
+
+
class Options(usage.Options):
optParameters = [
["telnetPort", "t", None, "strports description of the address on which to listen for telnet connections"],
@@ -68,6 +74,8 @@
if self['telnetPort'] is None and self['sshPort'] is None:
raise usage.UsageError("At least one of --telnetPort and --sshPort must be specified")
+
+
def makeService(options):
"""
Create a manhole server service.
@@ -122,7 +130,9 @@
sshPortal = portal.Portal(sshRealm, [checker])
sshFactory = manhole_ssh.ConchFactory(sshPortal)
- sshKey = keys._generateSavedRSAKey()
+ sshKey = keys._generateSavedRSAKey(options['sshKeyDir'],
+ options['sshKeyName'],
+ int(options['sshKeySize']))
sshFactory.publicKeys["ssh-rsa"] = sshKey
sshFactory.privateKeys["ssh-rsa"] = sshKey
Modified: branches/manhole-hardcodedkey-8229/twisted/conch/ssh/keys.py
==============================================================================
--- branches/manhole-hardcodedkey-8229/twisted/conch/ssh/keys.py (original)
+++ branches/manhole-hardcodedkey-8229/twisted/conch/ssh/keys.py Tue Mar 8 09:23:26 2016
@@ -1230,10 +1230,13 @@
-def _generateSavedRSAKey(directory=None, filename="server.pem", keySize=4096):
+def _generateSavedRSAKey(directory=None, filename=None, keySize=4096):
"""
This function generates a persistent server key
"""
+ if filename is None:
+ filename = "server.pem"
+
if directory is None:
from appdirs import user_data_dir
directory = user_data_dir("Twisted", "Conch")