From d19024ef2041393dcd9300e6fa0c4eeaf26f572e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 3 Feb 2021 19:19:15 +0100 Subject: [PATCH] imapserver: GSSAPI: make sure reply is all bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code mixed string and bytes leading to: ERROR: Exceptions occurred during the run! ERROR: While attempting to sync account 'honk.sigxcpu.org' sequence item 1: expected str instance, int found Traceback: File "/usr/share/offlineimap3/offlineimap/accounts.py", line 298, in syncrunner self.__sync() File "/usr/share/offlineimap3/offlineimap/accounts.py", line 374, in __sync remoterepos.getfolders() File "/usr/share/offlineimap3/offlineimap/repository/IMAP.py", line 648, in getfolders imapobj = self.imapserver.acquireconnection() File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 592, in acquireconnection self.__authn_helper(imapobj) File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 449, in __authn_helper if func(imapobj): File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 362, in __authn_gssapi imapobj.authenticate('GSSAPI', self.__gsshandler) File "/usr/lib/python3/dist-packages/imaplib2.py", line 691, in authenticate typ, dat = self._simple_command('AUTHENTICATE', mechanism.upper()) File "/usr/lib/python3/dist-packages/imaplib2.py", line 1684, in _simple_command return self._command_complete(self._command(name, *args), kw) File "/usr/lib/python3/dist-packages/imaplib2.py", line 1404, in _command literal = literator(data, rqb) File "/usr/lib/python3/dist-packages/imaplib2.py", line 2247, in process ret = self.mech(self.decode(data)) File "/usr/share/offlineimap3/offlineimap/imapserver.py", line 318, in __gsshandler reply = ''.join(reply) Closes: #46 Signed-off-by: Guido Günther --- offlineimap/imapserver.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index 3970541..bd377f7 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -310,12 +310,8 @@ class IMAPServer: # This is a behavior we got from pykerberos. First byte is one, # first four bytes are preserved (pykerberos calls this a length). # Any additional bytes are username. - reply = [] - reply[0:4] = response.message[0:4] - reply[0] = '\x01' - if self.username: - reply[5:] = self.username - reply = ''.join(reply) + reply = b'\x01' + response.message[1:4] + reply += bytes(self.username, 'utf-8') response = self.gss_vc.wrap(reply, response.encrypted) return response.message if response.message else ""