xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2125: sessions.2.patch

File sessions.2.patch, 7.6 KB (added by brief, 19 months ago)
  • src/xpra/server/auth/sqlauthbase.py

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/xpra/server/auth/sqlauthbase.py b/src/xpra/server/auth/sqlauthbase.py
    a b  
    3131        return tuple(str(x[0]) for x in data)
    3232
    3333    def get_sessions(self):
    34         cursor = self.db_cursor(self.sessions_query, (self.username, self.password_used or ""))
     34        cursor = self.db_cursor(self.sessions_query_by_username, (self.username, ))
     35        datas = cursor.fetchall()
     36        return self.parse_session_datas(datas)
     37
     38    def get_session_by_token(self, token):
     39        cursor = self.db_cursor(self.sessions_get_by_token, (token, ))
    3540        data = cursor.fetchone()
    3641        if not data:
    3742            return None
    3843        return self.parse_session_data(data)
    3944
     45    def parse_session_datas(self, datas):
     46        sessions = []
     47        for data in datas:
     48            parsed_data = self.parse_session_data(data)
     49           
     50            if parsed_data is None:
     51                return None
     52           
     53            sessions.append(parsed_data)
     54           
     55        return sessions
     56
    4057    def parse_session_data(self, data):
    4158        try:
    4259            uid = data[0]
     
    129146        a = auth_class(username, self.uri)
    130147        passwords = a.get_passwords()
    131148        assert passwords
    132         log("authenticate: got %i passwords", len(passwords))
     149        assert len(passwords) in 1
    133150        assert password in passwords
    134151        a.password_used = password
    135         sessions = a.get_sessions()
    136         assert sessions, "no sessions found"
    137         log("sql authentication success, found sessions: %s", sessions)
     152        print("success, found password")
     153        #sessions = a.get_sessions()
     154        #assert sessions, "no sessions found"
     155        #log("sql authentication success, found sessions: %s", sessions)
    138156
    139157    def get_authenticator_class(self):
    140158        raise NotImplementedError()
  • src/xpra/server/proxy/proxy_server.py

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/xpra/server/proxy/proxy_server.py b/src/xpra/server/proxy/proxy_server.py
    a b  
    335335            try:
    336336                auth_sessions = authenticator.get_sessions()
    337337                authlog("proxy_auth %s.get_sessions()=%s", authenticator, auth_sessions)
    338                 if auth_sessions:
     338                if len(auth_sessions) > 0:
    339339                    sessions = auth_sessions
    340340                    break
    341341            except Exception as e:
     
    344344                authlog.error(" %s", e)
    345345                disconnect(AUTHENTICATION_ERROR, "cannot access sessions")
    346346                return
    347         authlog("proxy_auth(%s, {..}, %s) found sessions: %s", client_proto, auth_caps, sessions)
    348         if sessions is None:
     347       
     348        if len(sessions) == 1:
     349            session_selected = sessions[0]
     350        elif len(sessions) > 1:
     351            # TODO selection session
     352            # sessionId = ???
     353            session_selected = sessions[0]
     354        else:
    349355            disconnect(SESSION_NOT_FOUND, "no sessions found")
    350356            return
    351357        self.proxy_session(client_proto, c, auth_caps, sessions)
     
    662668                if auth_sessions:
    663669                    sessions = auth_sessions
    664670                    break
    665             if sessions:
    666                 uid, gid = sessions[:2]
     671
     672            sessions_info = []
     673            for session in sessions:
     674               
     675                uid, gid = session[:2]
    667676                if not POSIX or (uid==getuid() and gid==getgid()):
    668677                    self.reap()
    669678                    i = 0
     
    683692                            iinfo.update(proxy_instance.get_info())
    684693                        instances_info[i] = iinfo
    685694                        i += 1
    686                     info["instances"] = instances_info
    687                     info["proxies"] = len(instances)
     695                       
     696                    sessions_info.append({"instances": instances_info, "proxies": len(instances)})
     697
     698            info["sessions"] = sessions_info
     699           
    688700        return info
  • src/xpra/server/auth/sys_auth_base.py

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/xpra/server/auth/sys_auth_base.py b/src/xpra/server/auth/sys_auth_base.py
    a b  
    208208            displays = []
    209209        v = uid, gid, displays, {}, {}
    210210        log("%s.get_sessions()=%s", self, v)
    211         return v
     211        return [v]
    212212
    213213
    214214class SysAuthenticator(SysAuthenticatorBase):
  • src/unittests/unit/server/auth_test.py

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/unittests/unit/server/auth_test.py b/src/unittests/unit/server/auth_test.py
    a b  
    235235                        assert self.capsauth(a, verify, client_salt), "%s failed" % a.authenticate
    236236                        if display_count>0:
    237237                            sessions = a.get_sessions()
    238                             assert len(sessions)>=3
    239                             displays = sessions[2]
     238                            assert len(sessions) == 1
     239                            session = sessions[0]
     240                            assert len(session)>=3
     241                            displays = session[2]
    240242                            assert len(displays)==display_count, "expected %i displays but got %i : %s" % (
    241                                 display_count, len(sessions), sessions)
     243                                display_count, len(session), session)
    242244                        assert not self.capsauth(a, verify, client_salt), "authenticated twice!"
    243245                        passwords = a.get_passwords()
    244246                        assert len(passwords)==1, "expected just one password in file, got %i" % len(passwords)
  • src/xpra/server/auth/multifile_auth.py

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/xpra/server/auth/multifile_auth.py b/src/xpra/server/auth/multifile_auth.py
    a b  
    103103        if not verify_digest(self.digest, fpassword, salt, challenge_response):
    104104            log.warn("Warning: %s challenge for '%s' does not match", self.digest, self.username)
    105105            return False
    106         self.sessions = uid, gid, displays, env_options, session_options
     106        self.sessions = [(uid, gid, displays, env_options, session_options)]
    107107        return True
    108108
    109109    def get_sessions(self):