Skip to content

Always wait for completion during SASL/GSSAPI authentication #1248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 10, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions kafka/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,9 @@ def _try_authenticate_gssapi(self, future):
# establishes a security context, or it needs further token exchange.
# The gssapi will be able to identify the needed next step.
# The connection is closed on failure.
response = self._sock.recv(2000)
header = self._sock.recv(4)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Socket can return less than 4 bytes

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, yes it can.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be easier to address this issue in #1249

token_size = struct.unpack('>i', header)
received_token = self._sock.recv(token_size)
self._sock.setblocking(False)

except ConnectionError as e:
Expand All @@ -542,13 +544,6 @@ def _try_authenticate_gssapi(self, future):
self.close(error=error)
return future.failure(error)

# pass the received token back to gssapi, strip the first 4 bytes
# dpkp note: what are the first four bytes here?
# it seems likely that this is the encoded message size
# which we should receive and parse first, then use to parse
# the remainder of the token
received_token = response[4:]

except Exception as e:
return future.failure(e)

Expand Down