def CreateCrestSession(self, userID, charID, details, sessionID, clientID): sessionInit = {'userid': userID, 'userType': 13, 'role': service.ROLE_PLAYER, 'languageID': 'EN', 'maxSessionTime': None, 'inDetention': None} if charID: sess = self.GetCharacterSession(charID) elif userID: sess = self.GetUserSession(userID) else: raise RuntimeError("CreateCrestSession can't create session without identifiers") if sess: raise RuntimeError('CreateCrestSession asked to create an existing session. This is not supported') s = base.CreateSession(sessionID, const.session.SESSION_TYPE_CREST, role=details.pop('role')) sm.GetService('machoNet').RegisterSessionWithTransport(s, clientID) changes = {k:v for k, v in details.iteritems()} sessionInit['role'] |= s.role if charID: initVals = self.session.ConnectToSolServerService('sessionMgr').GetInitialValuesFromCharID(charID) sessionInit.update(initVals) sessionInit.update({'charid': charID}) s.LogSessionHistory('Character/User authenticated implicitely via direct call to sessionMgr') s.SetAttributes(sessionInit) s.LogSessionHistory('Applying initial session attribute directly via direct call to sessionMgr') s.SetAttributes(changes) return s
def CreateSession(username, password): session = base.CreateSession() session.esps = ESPSession(None, session.sid) session.esps.contents['username'] = username session.esps.contents['password'] = password return session
def _AssociateWithSession(self, packet=None, forceNodeID=None): if forceNodeID is not None: nodeID = forceNodeID serviceSession = True elif macho.mode == 'client': nodeID = 0 serviceSession = False elif not packet.command % 2: if packet.source.addressType == const.ADDRESS_TYPE_CLIENT: nodeID = packet.source.clientID serviceSession = False else: nodeID = packet.source.nodeID serviceSession = True elif packet.destination.addressType == const.ADDRESS_TYPE_CLIENT: nodeID = packet.destination.clientID serviceSession = False else: nodeID = packet.destination.nodeID serviceSession = True sess = self.sessions.get(nodeID, None) if not sess: sess = self.contextSessions.get(nodeID, None) if not sess: if macho.mode == 'client': sess = session elif serviceSession: sess = base.GetServiceSession('remote:%d' % nodeID, True) elif not packet.command % 2: if not isinstance(packet, macho.SessionInitialStateNotification): log.LogTraceback( 'Packet received before initial session notification. Packet/tasklet reordering?' ) raise SessionUnavailable( 'Unable to load session for request') sess = base.CreateSession(packet.sid, packet.sessionType) else: raise UnMachoDestination( 'Failed session association: cmd = %s, mode = %s' % (packet.command, macho.mode)) sess.__dict__['clientID'] = nodeID if sess.contextOnly: self.contextSessions[nodeID] = sess else: self.sessions[nodeID] = sess if serviceSession: role = sess.__dict__['role'] | ROLE_SERVICE | ROLE_REMOTESERVICE sess.SetAttributes({'role': role}) sess.LogSessionHistory( 'machoNet associated remote service session with clientID/nodeID %s' % nodeID) else: sess.__dict__['rwlock'] = uthread.RWLock( ('sessions', sess.sid)) packetUserID = None if packet is None else packet.userID if packetUserID is not None: sess.SetAttributes({'userid': packetUserID}) sess.LogSessionHistory( 'machoNet associated session with clientID %s and userID %s' % (nodeID, packetUserID)) sess.lastRemoteCall = blue.os.GetWallclockTime() return (nodeID, sess)
def GetSession(parent, request, response, sessionsBySID, sessionsByFlatkaka): parent.LogInfo('GetSession') if request.cookie.has_key('flatkaka'): flatkaka = request.cookie['flatkaka'] if sessionsByFlatkaka.has_key(flatkaka): sess = sessionsByFlatkaka[flatkaka] if macho.mode == 'client': return sess uspa = request.Authorization() if uspa != None: u = sess.esps.contents['username'] p = sess.esps.contents['password'] if uspa[0] != u or uspa[1] != p: parent.LogWarn("User %s is trying to hijack %s's session, with sessID=%d" % (uspa[0], u, sess.sid)) else: parent.LogInfo('cookie information verified') return sess sess = None success = False if macho.mode == 'client': sess = base.CreateSession(None, const.session.SESSION_TYPE_ESP, None) sess.esps = ESPSession(parent, sess.sid) success = True else: usernameAndPassword = request.Authorization() reason = 'Access denied' statusCode = '401 Unauthorized' if usernameAndPassword != None: parent.LogInfo('GetSession uap<>n') username = usernameAndPassword[0] password = usernameAndPassword[1] for s in sessionsBySID.itervalues(): if hasattr(s, 'esps') and s.esps.contents['username'] == username: if s.userid and s.esps.contents['password'] == password: return s break if macho.mode == 'server' and ('authentication' not in sm.services or sm.services['authentication'].state != service.SERVICE_RUNNING): blue.pyos.synchro.SleepWallclock(3000) raise UserError('AutClusterStarting') try: if sm.services['http'].session.ConnectToProxyServerService('machoNet').CheckACL(request.ep.address, espCheck=True): blue.pyos.synchro.SleepWallclock(3000) raise UserError('AutClusterStarting') except UnMachoDestination: blue.pyos.synchro.SleepWallclock(3000) raise UserError('AutClusterStarting') sessionID = base.GetNewSid() sess = base.CreateSession(sessionID, const.session.SESSION_TYPE_ESP) sess.esps = ESPSession(parent, sess.sid) auth = base.GetServiceSession('httpService').ConnectToAnyService('authentication') try: try: sessstuff, _ = auth.Login(sessionID, username, password, None, const.userConnectTypeServerPages, request.ep.address) sessstuff['role'] |= sess.role except UserError as e: if e.msg != 'CharacterInDifferentRegion': raise sys.exc_clear() for each in base.FindSessions('userid', [sessstuff['userid']]): each.LogSessionHistory('Usurped by user %s via HTTP using local authentication' % username) base.CloseSession(each) sess.LogSessionHistory('Authenticating user %s via HTTP using local authentication' % username) sess.SetAttributes(sessstuff) sess.LogSessionHistory('Authenticated user %s via HTTP using local authentication' % username) success = True except UnMachoDestination: reason = 'The proxy server was unable to connect to any Sol Server Node to handle your authentication request.' statusCode = '500 No Sol Server available' sys.exc_clear() except UserError as e: if e.msg != 'LoginAuthFailed': raise sys.exc_clear() if not success: sess.LogSessionHistory('Session closed due to local authentication failure') base.CloseSession(sess) parent.LogInfo('GetSession done auth %s' % success) if success: sessID = sess.sid while sessionsBySID.has_key(sessID): parent.LogWarn('Session %d already exits, adding 1 to it' % sessID) sessID += 1 sessionsBySID[sessID] = sess sessionsByFlatkaka[sess.esps.GetFlatkaka()] = sess parent.OnSessionBegin(sessID) session = sess session.cacheList = [] session.requestCount = 0 session.esps.contents['timeoutTimer'] = None if macho.mode != 'client': session.esps.contents['username'] = username session.esps.contents['password'] = password return session else: response.Clear() response.status = statusCode response.Write(reason) response.authenticate = 1 response.Flush() return
def Startup(appCacheDirs, userCacheDirs, builtinSetupHook, servicesToRun, preUIStartArgProcessHook, StartupUIServiceName, startInline=[], serviceManagerClass='ServiceManager'): global Done args = blue.pyos.GetArg()[1:] autoexec_common.LogStarting('Client') bootWatchdog.SetPercentage(10) additionalScriptDirs = [] fullDevToolsPath = os.path.join( blue.paths.ResolvePath(u'root:/devtools/script')) if not blue.pyos.packaged and '/compile' not in args and '/nodevtools' not in args and os.path.exists( fullDevToolsPath): additionalScriptDirs.extend(['script:/../../devtools/script/']) log.general.Log('Loading devtools locally from %s' % fullDevToolsPath, log.LGINFO) else: log.general.Log('Additional tools will be loaded from the server', log.LGINFO) servicesToRun += ('devToolsClient', ) if '/black' in args: blue.resMan.substituteBlackForRed = True if '/jessica' in args and '/localizationMonitor' in args: servicesToRun += ('localizationMonitor', ) if not blue.pyos.packaged and '/jessica' in args: if '/carbon' in blue.paths.ResolvePath(u'bin:/'): jessicaToolPath = '../tools/' else: jessicaToolPath = '../../carbon/tools/' additionalScriptDirs.extend([ 'script:/../' + jessicaToolPath + '/jessica/script/', 'script:/../../../carbon/backend/script/', 'script:/../../backend/script/' ]) useExtensions = '/noJessicaExtensions' not in args if useExtensions: additionalScriptDirs.extend([ 'script:/../' + jessicaToolPath + 'jessicaExtensions/script/', 'script:/../../tools/jessicaExtensions/script/' ]) bootWatchdog.SetPercentage(20) import nasty nasty.Startup(additionalScriptDirs) localization.LoadLanguageData() errorMsg = { 'resetsettings': [ localization.GetByLabel('ErrorDialog/CantClearSettings'), localization.GetByLabel('ErrorDialog/CantClearSettingsHeader'), localization.GetByLabel('ErrorDialog/CantClearSettings') ], 'clearcache': [ localization.GetByLabel('ErrorDialog/CantClearCache'), localization.GetByLabel('ErrorDialog/CantClearCacheHeader'), localization.GetByLabel('ErrorDialog/CantClearCache') ] } if not getattr(prefs, 'disableLogInMemory', 0): blue.logInMemory.capacity = 1024 blue.logInMemory.Start() bootWatchdog.SetPercentage(30) for clearType, clearPath in [ ('resetsettings', blue.paths.ResolvePath(u'settings:/')), ('clearcache', blue.paths.ResolvePath(u'cache:/')) ]: if getattr(prefs, clearType, 0): if clearType == 'resetsettings': prefs.DeleteValue(clearType) if os.path.exists(clearPath): i = 0 while 1: newDir = clearPath[:-1] + '_backup%s' % i if not os.path.isdir(newDir): try: os.makedirs(newDir) except: blue.win32.MessageBox(errorMsg[clearType][0], errorMsg[clearType][1], 272) bluepy.Terminate(errorMsg[clearType][2]) return False break i += 1 for filename in os.listdir(clearPath): if filename != 'Settings': try: os.rename( clearPath + filename, '%s_backup%s/%s' % (clearPath[:-1], i, filename)) except: blue.win32.MessageBox(errorMsg[clearType][0], errorMsg[clearType][1], 272) bluepy.Terminate(errorMsg[clearType][2]) return False prefs.DeleteValue(clearType) mydocs = blue.win32.SHGetFolderPath(blue.win32.CSIDL_PERSONAL) paths = [blue.paths.ResolvePath(u'cache:/')] for dir in appCacheDirs: paths.append(blue.paths.ResolvePath(u'cache:/') + dir) for dir in userCacheDirs: paths.append(mydocs + dir) for path in paths: try: os.makedirs(path) except OSError as e: sys.exc_clear() import __builtin__ import base session = base.CreateSession(None, const.session.SESSION_TYPE_GAME) __builtin__.session = session __builtin__.charsession = session base.EnableCallTimers(2) builtinSetupHook() autoexec_common.LogStarted('Client') bootWatchdog.SetPercentage(40) import numerical bluepy.frameClock = numerical.FrameClock() blue.os.frameClock = bluepy.frameClock import service smClass = getattr(service, serviceManagerClass) srvMng = smClass(startInline=['DB2', 'machoNet'] + startInline) bootWatchdog.SetPercentage(50) if hasattr(prefs, 'http') and prefs.http: log.general.Log('Running http', log.LGINFO) srvMng.Run(('http', )) srvMng.Run(servicesToRun) title = '[%s] %s %s %s.%s pid=%s' % (boot.region.upper(), boot.codename, boot.role, boot.version, boot.build, blue.os.pid) blue.os.SetAppTitle(title) Done = True try: blue.EnableBreakpad(prefs.GetValue('breakpadUpload', 1) == 1) except RuntimeError: pass bmRuns = prefs.GetValue('bmnextrun', 0) if '/benchmark' in args or bmRuns >= 1: import benchmark1 prefs.SetValue('bmnextrun', bmRuns - 1) benchmark1.Run() if preUIStartArgProcessHook is not None: preUIStartArgProcessHook(args) if '/skiprun' not in args: if '/webtools' in args: ix = args.index('/webtools') + 1 pr = args[ix] pr = pr.split(',') srvMng.StartService('webtools').SetVars(pr) srvMng.GetService(StartupUIServiceName).StartupUI(0)
def Startup(appCacheDirs, userCacheDirs, servicesToRun): blue.os.sleeptime = 0 _InitializeRemoteFileCacheIfNeeded() _PrepareRenderer() args = blue.pyos.GetArg()[1:] if '/thinclient' in args: import thinclients, thinclients.clientsetup if thinclients.HEADLESS in args: thinclients.clientsetup.patch_all() elif thinclients.HEADED in args: thinclients.clientsetup.enable_live_updates() thinclients.clientsetup.install_commands() else: raise RuntimeError('Bad params.') autoexec_common.LogStarting('Client') bootWatchdog.SetPercentage(10) if '/black' in args: blue.resMan.substituteBlackForRed = True if '/jessica' in args and '/localizationMonitor' in args: servicesToRun += ('localizationMonitor',) bootWatchdog.SetPercentage(20) builtinmangler.SmashNastyspaceBuiltinConflicts() whitelist.InitWhitelist() import localization localization.LoadLanguageData() errorMsg = {'resetsettings': [localization.GetByLabel('UI/ErrorDialog/CantClearSettings'), localization.GetByLabel('UI/ErrorDialog/CantClearSettingsHeader'), localization.GetByLabel('UI/ErrorDialog/CantClearSettings')], 'clearcache': [localization.GetByLabel('UI/ErrorDialog/CantClearCache'), localization.GetByLabel('UI/ErrorDialog/CantClearCacheHeader'), localization.GetByLabel('UI/ErrorDialog/CantClearCache')]} if not getattr(prefs, 'disableLogInMemory', 0): blue.logInMemory.capacity = 1024 blue.logInMemory.Start() bootWatchdog.SetPercentage(30) for clearType, clearPath in [('resetsettings', blue.paths.ResolvePath(u'settings:/')), ('clearcache', blue.paths.ResolvePath(u'cache:/'))]: if getattr(prefs, clearType, 0): if clearType == 'resetsettings': prefs.DeleteValue(clearType) if os.path.exists(clearPath): i = 0 while 1: newDir = clearPath[:-1] + '_backup%s' % i if not os.path.isdir(newDir): try: os.makedirs(newDir) except: blue.win32.MessageBox(errorMsg[clearType][0], errorMsg[clearType][1], 272) bluepy.Terminate(errorMsg[clearType][2]) return False break i += 1 for filename in os.listdir(clearPath): if filename != 'Settings': try: os.rename(clearPath + filename, '%s_backup%s/%s' % (clearPath[:-1], i, filename)) except: blue.win32.MessageBox(errorMsg[clearType][0], errorMsg[clearType][1], 272) bluepy.Terminate(errorMsg[clearType][2]) return False prefs.DeleteValue(clearType) mydocs = blue.win32.SHGetFolderPath(blue.win32.CSIDL_PERSONAL) paths = [blue.paths.ResolvePath(u'cache:/')] for dir in appCacheDirs: paths.append(blue.paths.ResolvePath(u'cache:/') + dir) for dir in userCacheDirs: paths.append(mydocs + dir) for path in paths: try: os.makedirs(path) except OSError as e: sys.exc_clear() import base import const session = base.CreateSession(None, const.session.SESSION_TYPE_GAME) __builtin__.session = session __builtin__.charsession = session base.EnableCallTimers(2) _InitializeEveBuiltin() autoexec_common.LogStarted('Client') bootWatchdog.SetPercentage(40) bluepy.frameClock = numerical.FrameClock() blue.os.frameClock = bluepy.frameClock import service srvMng = service.ServiceManager(startInline=INLINE_SERVICES) bootWatchdog.SetPercentage(50) if hasattr(prefs, 'http') and prefs.http: logmodule.general.Log('Running http', logmodule.LGINFO) srvMng.Run(('http',)) srvMng.Run(servicesToRun) title = '[%s] %s %s %s.%s pid=%s' % (boot.region.upper(), boot.codename, boot.role, boot.version, boot.build, blue.os.pid) blue.os.SetAppTitle(title) try: blue.EnableBreakpad(prefs.GetValue('breakpadUpload', 1) == 1) except RuntimeError: pass blue.os.frameTimeTimeout = prefs.GetValue('frameTimeTimeout', 30000) if '/skiprun' not in args: if '/webtools' in args: ix = args.index('/webtools') + 1 pr = args[ix] pr = pr.split(',') srvMng.StartService('webtools').SetVars(pr) srvMng.GetService('gameui').StartupUI(0)
def Startup(servicesToRun, builtinSetupHook, startInline=[], serviceManagerClass='ServiceManager'): global Done args = blue.pyos.GetArg()[1:] autoexec_common.LogStarting('ThinClient') additionalScriptDirs = [ 'script:/../../../client/script/', 'script:/../../../../carbon/client/script/', 'script:/../../../../carbon/tools/thinClient/script/', 'script:/../../../devtools/script/' ] for argument in args: if argument.startswith('/cache='): cachepath = argument[len('/cache='):] blue.paths.SetSearchPath('cache:', cachepath + os.sep) log.general.Log( 'Cache directory set to: ' + blue.paths.ResolvePath(u'cache:/'), log.LGNOTICE) elif argument.startswith('/randomcache'): import tempfile cachepath = tempfile.mkdtemp() blue.paths.SetSearchPath('cache:', u'%s' % cachepath + os.sep) log.general.Log( 'Cache directory set to: ' + blue.paths.ResolvePath(u'cache:/'), log.LGNOTICE) if '/automaton' in args: additionalScriptDirs.extend([ 'script:/../../../../carbon/backend/script/', 'script:/../../../backend/script/' ]) if not blue.pyos.packaged and '/jessica' in args: additionalScriptDirs.extend([ 'script:/../../../../carbon/tools/jessica/script/', 'script:/../../../../carbon/backend/script/', 'script:/../../../backend/script/' ]) useExtensions = '/noJessicaExtensions' not in args if useExtensions: additionalScriptDirs.extend([ 'script:/../../../../carbon/tools/jessicaExtensions/script/', 'script:/../../../tools/jessicaExtensions/script/', 'script:/../tools/jessicaExtensions/script/' ]) import nasty nasty.Startup(additionalScriptDirs) errorMsg = { 'resetsettings': [ 'The application is unable to clear the settings. If you are running other instances of Eve Online, please exit them. If the problem persists you should restart your system.', 'Cannot clear settings!', 'Cannot clear settings' ], 'clearcache': [ 'The application is unable to clear the cache. If you are running other instances of Eve Online, please exit them. If the problem persists you should restart your system.', 'Cannot clear cache!', 'Cannot clear cache' ] } for clearType, clearPath in [ ('resetsettings', blue.paths.ResolvePath(u'settings:/')), ('clearcache', blue.paths.ResolvePath(u'cache:/')) ]: if getattr(prefs, clearType, 0): if clearType == 'resetsettings': prefs.DeleteValue(clearType) if os.path.exists(clearPath): i = 0 while 1: newDir = clearPath[:-1] + '_backup%s' % i if not os.path.isdir(newDir): try: os.makedirs(newDir) except: blue.win32.MessageBox(errorMsg[clearType][0], errorMsg[clearType][1], 272) bluepy.Terminate(errorMsg[clearType][2]) return False break i += 1 for filename in os.listdir(clearPath): if filename != 'Settings': try: os.rename( clearPath + filename, '%s_backup%s/%s' % (clearPath[:-1], i, filename)) except: blue.win32.MessageBox(errorMsg[clearType][0], errorMsg[clearType][1], 272) bluepy.Terminate(errorMsg[clearType][2]) return False prefs.DeleteValue(clearType) mydocs = blue.win32.SHGetFolderPath(blue.win32.CSIDL_PERSONAL) paths = [blue.paths.ResolvePath(u'cache:/')] for path in paths: try: os.makedirs(path) except OSError as e: sys.exc_clear() import __builtin__, base session = base.CreateSession(None, const.session.SESSION_TYPE_GAME) __builtin__.session = session __builtin__.charsession = session builtinSetupHook() autoexec_common.LogStarted('ThinClient') import numerical bluepy.frameClock = numerical.FrameClock() blue.os.frameClock = bluepy.frameClock import service smClass = getattr(service, serviceManagerClass) srvMng = smClass(startInline=['DB2', 'machoNet'] + startInline) if hasattr(prefs, 'http') and prefs.http: print 'http' srvMng.Run(('http', )) srvMng.Run(servicesToRun) title = '[%s] %s %s %s.%s pid=%s' % (boot.region.upper(), boot.codename, boot.role, boot.version, boot.build, blue.os.pid) blue.os.SetAppTitle(title) Done = True if bluepy.IsRunningStartupTest(): bluepy.TerminateStartupTest() def f(*args, **kwargs): return 'Malkovich' localization.GetByMessageID = f localization.GetByLabel = f localization.GetImportantByMessageID = f localization.GetImportantByLabel = f localization._GetRawByMessageID = f localization.FormatImportantString = f