예제 #1
0
 def parseOptions(self, options):
     config = registry.getConfig()
     usage.Options.parseOptions(self, options)
     # check options
     if self.subCommand == const.KEYGEN:
         scripts.KeyGen()
         sys.exit(0)
     elif self.subCommand == const.SHELL:
         scripts.ConnectToShell()
         sys.exit(0)
     elif self.subCommand == const.STOP:
         scripts.StopDaemon()
         sys.exit(0)
예제 #2
0
 def parseOptions(self, options):
     config = registry.getConfig()
     usage.Options.parseOptions(self, options)
     # check options
     if self.subCommand == const.KEYGEN:
         scripts.KeyGen()
         sys.exit(0)
     elif self.subCommand == const.SHELL:
         scripts.ConnectToShell()
         sys.exit(0)
     elif self.subCommand == const.STOP:
         scripts.StopDaemon()
         sys.exit(0)
예제 #3
0
import os

from zope import interface

from twisted.conch import interfaces, manhole_ssh, unix
from twisted.conch.ssh import filetransfer, session
from twisted.python import components

from dreamssh.sdk import registry

from prakasha.app import shell


config = registry.getConfig()


class SFTPEnabledTerminalUser(manhole_ssh.TerminalUser, unix.UnixConchUser):
    """
    """
    def __init__(self, original, avatarId):
        manhole_ssh.TerminalUser.__init__(self, original, avatarId)
        unix.UnixConchUser.__init__(self, avatarId)

    def _runAsUser(self, f, *args, **kw):
        euid = os.geteuid()
        egid = os.getegid()
        groups = os.getgroups()[:16]
        uid, gid = self.getUserGroupId()
        os.setegid(0)
        os.seteuid(0)
        os.setgroups(self.getOtherGroups())
예제 #4
0
import os
from pprint import pprint
import sys

from dreamssh.app.shell import base as baseshell, pythonshell
from dreamssh.sdk import registry

from prakasha.app import api


config = registry.getConfig()


class ShellInterpreter(pythonshell.PythonInterpreter):
    """
    """
    # XXX namespace code needs to be better organized:
    #   * should the CommandAPI be in this module?
    def updateNamespace(self, namespace={}):
        if not self.handler.commandAPI.appOrig:
            self.handler.commandAPI.appOrig = self.handler.namespace.get("app")
        namespace.update({
            "os": os,
            "sys": sys,
            "pprint": pprint,
            "app": self.handler.commandAPI.getAppData,
            "banner": self.handler.commandAPI.banner,
            "info": self.handler.commandAPI.banner,
            "ls": self.handler.commandAPI.ls,
            "clear": self.handler.commandAPI.clear,
            "quit": self.handler.commandAPI.quit,