def requestAvatarId (self, c, ) : try: u, p = self.getUser(c.username) except KeyError: return defer.fail(error.UnauthorizedLogin(), ) else: if not p : return defer.fail(error.UnauthorizedLogin(), ) return defer.maybeDeferred( lambda : ConfigDatabase.encrypt_password(c.password) == p, ).addCallback(self._cbPasswordMatch, u, )
def run_application () : _options = ServerOptions() _options.parseOptions(skip_reactor=True, ) if _options.get("test") : import doctest doctest.testmod() sys.exit() if not _options.get("verbose") : utils.debug = lambda x : None resource.setrlimit(resource.RLIMIT_NOFILE, (1024, 1024, ), ) _open_key = lambda x : open(os.path.join(_options.get("host-key"), x, ), ) _read_key = lambda x : Key.fromString(data=_open_key(x).read(), ) factory = ssh_factory.SOSFactory() factory.privateKeys = {"ssh-rsa": _read_key("ssh_host_key"), } factory.publicKeys = {"ssh-rsa": _read_key("ssh_host_key.pub"), } _config_db = ConfigDatabase.from_filename(_options.get("config"), _global=_options.get("global"), ) factory.portal = Portal( ssh_factory.SOSRealm(_config_db, verbose=_options.get("verbose"), ), ( ssh_factory.SOSPublicKeyDatabase(_config_db, ), ssh_factory.ConfigDBPassword(_config_db, ), ), ) application = service.Application("source+over+ssh server", ) strports.service( "tcp:%d%s" % ( _options.get("port"), _options.get("interface") and (":interface=%s" % _options.get("interface")) or "", ), factory, ).setServiceParent(application, ) return application