示例#1
0
def createManholeListener():
    sshRealm = TerminalRealm()
    sshRealm.chainedProtocolFactory.protocolFactory = lambda _: Manhole(
        namespace)

    if settings.MANHOLE_PUBLIC_KEY == 'None':
        credChecker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
        credChecker.addUser(settings.MANHOLE_USER.encode('utf-8'),
                            ''.encode('utf-8'))
    else:
        userKeys = {
            settings.MANHOLE_USER.encode('utf-8'):
            settings.MANHOLE_PUBLIC_KEY.encode('utf-8'),
        }
        credChecker = PublicKeyChecker(userKeys)

    sshPortal = portal.Portal(sshRealm)
    sshPortal.registerChecker(credChecker)
    sessionFactory = ConchFactory(sshPortal)

    # set ssh host keys
    if settings.MANHOLE_HOST_KEY_DIR == "":
        raise CarbonConfigException("MANHOLE_HOST_KEY_DIR not defined")
    openSSHFactory = OpenSSHFactory()
    openSSHFactory.dataRoot = settings.MANHOLE_HOST_KEY_DIR
    sessionFactory.publicKeys = openSSHFactory.getPublicKeys()
    sessionFactory.privateKeys = openSSHFactory.getPrivateKeys()

    return sessionFactory
示例#2
0
    def connectionMade(self):
        TerminalProtocol.connectionMade(self)
        self.terminal.eraseDisplay()
        self.terminal.resetPrivateModes([privateModes.CURSOR_MODE])

        self.window = TopWindow(self._draw, self._schedule)
        vbox = VBox()

        self.logWidget = OutputWidget()
        vbox.addChild(self.logWidget)

        logHandler = logging.StreamHandler(OutputLogStream(self.logWidget))
        #make it use the default formatter
        logHandler.setFormatter(logging.Formatter(logging.BASIC_FORMAT))
        logging.getLogger().addHandler(logHandler)

        vbox.addChild(SeperatorWidget())

        #TODO: factory stuff
        self.manhole = Manhole()
        self.manholeView = TerminalProtocolWidget(self.manhole)
        #set the namespace directly so it's mutable
        if self.manholeNamespace is not None:
            self.manhole.interpreter.locals = self.manholeNamespace
        vbox.addChild(self.manholeView)

        self.window.addChild(vbox)
示例#3
0
def createManholeListener():
    sshRealm = TerminalRealm()
    sshRealm.chainedProtocolFactory.protocolFactory = lambda _: Manhole(
        namespace)

    # You can uncomment this if you're lazy and want insecure authentication instead
    # of setting up keys.
    #credChecker = checkers.InMemoryUsernamePasswordDatabaseDontUse(carbon='')
    userKeys = {
        settings.MANHOLE_USER: settings.MANHOLE_PUBLIC_KEY,
    }
    credChecker = PublicKeyChecker(userKeys)

    sshPortal = portal.Portal(sshRealm)
    sshPortal.registerChecker(credChecker)
    sessionFactory = ConchFactory(sshPortal)
    return sessionFactory
示例#4
0
def createManholeListener():
  sshRealm = TerminalRealm()
  sshRealm.chainedProtocolFactory.protocolFactory = lambda _: Manhole(namespace)

  if settings.MANHOLE_PUBLIC_KEY == 'None':
    credChecker = checkers.InMemoryUsernamePasswordDatabaseDontUse()
    credChecker.addUser(settings.MANHOLE_USER, '')
  else:
    userKeys = {
        settings.MANHOLE_USER : settings.MANHOLE_PUBLIC_KEY,
    }
    credChecker = PublicKeyChecker(userKeys)

  sshPortal = portal.Portal(sshRealm)
  sshPortal.registerChecker(credChecker)
  sessionFactory = ConchFactory(sshPortal)
  return sessionFactory
示例#5
0
文件: stdio.py 项目: dkkline/bravo
    def connectionMade(self):
        Manhole.connectionMade(self)

        self.interpreter = BravoInterpreter(self, self.f)
示例#6
0
文件: stdio.py 项目: dkkline/bravo
    def __init__(self, factory, *args, **kwargs):
        Manhole.__init__(self, *args, **kwargs)

        self.f = factory
示例#7
0
 def getManhole(_):
     manhole = Manhole(globals())
     ps1 = 'fluidinfo-api [%d] > ' % servicePort
     ps2 = '... '.rjust(len(ps1))
     manhole.ps = (ps1, ps2)
     return manhole
示例#8
0
    def connectionMade(self):
        Manhole.connectionMade(self)

        self.interpreter = BravoInterpreter(self, self.f)
示例#9
0
    def __init__(self, factory, *args, **kwargs):
        Manhole.__init__(self, *args, **kwargs)

        self.f = factory
示例#10
0
文件: repl.py 项目: froztbyte/monte
 def connectionMade(self):
     Manhole.connectionMade(self)
     self.interpreter = MonteInterpreter(self)
示例#11
0
文件: repl.py 项目: mythmon/monte
 def connectionMade(self):
     Manhole.connectionMade(self)
     self.interpreter = MonteInterpreter(self)