From d665224a85610cccbe7d291e9ed41d2ce7e5b61c Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Fri, 2 Jun 2017 15:12:09 +0200 Subject: [PATCH] session_storage: Correctly handle string/byte types In session_storage.py, store_data() stores data as the bytes data type but get_data() is returning a string. Have get_data() return bytes as well. https://pagure.io/freeipa/issue/4985 Reviewed-By: Martin Basti --- ipalib/rpc.py | 5 ++++- ipapython/session_storage.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ipalib/rpc.py b/ipalib/rpc.py index e3b8d67d6..224156e73 100644 --- a/ipalib/rpc.py +++ b/ipalib/rpc.py @@ -887,7 +887,10 @@ class RPCClient(Connectible): # (possibly with more than one cookie). try: cookie_string = read_persistent_client_session_data(principal) - except Exception: + cookie_string = cookie_string.decode('utf-8') + except Exception as e: + self.log.debug('Error reading client session data: {err}' + .format(err=e)) return None # Search for the session cookie within the cookie string diff --git a/ipapython/session_storage.py b/ipapython/session_storage.py index 7c302b706..9d2de99f9 100644 --- a/ipapython/session_storage.py +++ b/ipapython/session_storage.py @@ -336,7 +336,7 @@ def get_data(princ_name, key): krb5_cc_end_seq_get(context, ccache, ctypes.byref(cursor)) if got_creds: - data = creds.ticket.data.decode('utf-8') + data = creds.ticket.data krb5_free_cred_contents(context, ctypes.byref(creds)) return data