Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix intermediate session id preauth tracking #203

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.10.1 - TBD

* Raise the original `BadNetworkName` error if the server doesn't indicate it supports DFS or `FSDriverRequired` was raised trying to lookup the DFS information - https://github.com/jborean93/smbprotocol/issues/196
* Fix pre auth session id tracking if the intermediate token messages return 0 as the session id

## 1.10.0 - 2022-11-07

Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pyspnego
pytest
pytest-cov
pytest-mock
tox
tox
5 changes: 3 additions & 2 deletions src/smbprotocol/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def connect(self):
raise SMBAuthenticationError("Failed to authenticate with server: %s" % str(err.message))

self.connection.preauth_session_table[self.session_id] = self

in_token = self.connection.gss_negotiate_token
if self.auth_protocol != "negotiate":
in_token = None # The GSS Negotiate Token can only be used for Negotiate auth.
Expand Down Expand Up @@ -307,11 +308,11 @@ def connect(self):
# If this is the first time we received the actual session_id, update the preauth table with the server
# assigned id.
session_id = response["session_id"].get_value()
if self.session_id < 0:
if self.session_id < 0 and session_id:
del self.connection.preauth_session_table[self.session_id]
self.connection.preauth_session_table[session_id] = self

self.session_id = session_id
self.session_id = session_id

setup_response = SMB2SessionSetupResponse()
setup_response.unpack(response["data"].get_value())
Expand Down