diff --git a/CHANGELOG.md b/CHANGELOG.md index 1779cefee095bee149b2253a7ac16472a242ec78..21504c62935b2b938214f4b4ddb540d0da38f311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.6.2 - TBD + +* Fix up cached credential logic when setting `domain_controller` in the initial config singleton + ## 1.6.1 - 2021-07-29 * Remove `print()` statement that was used during testing diff --git a/setup.py b/setup.py index f00d1330b75a532b4e557e1390c59e545e039029..c3caa8136903f1ea17fcd915e873f42147ba561b 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ with open(abs_path('README.md'), mode='rb') as fd: setup( name='smbprotocol', - version='1.6.1', + version='1.6.2', packages=['smbclient', 'smbprotocol'], install_requires=[ 'cryptography>=2.0', diff --git a/smbclient/_pool.py b/smbclient/_pool.py index 162fc65ade798850095930af9cbf2997ea93fdf8..7593d5edd1d96e3412e2202e190ca84b0a291566 100644 --- a/smbclient/_pool.py +++ b/smbclient/_pool.py @@ -54,14 +54,25 @@ class _ConfigSingleton(type): def __call__(cls, *args, **kwargs): if cls not in cls.__instances: - cls.__instances[cls] = super(_ConfigSingleton, cls).__call__(*args, **kwargs) + config = super(_ConfigSingleton, cls).__call__(*args, **kwargs) + cls.__instances[cls] = config + + # Needs to be done after the config instance is in the singleton dict due to setting this value will kick + # off an IPC connection which then gets and instance of this config to see what the default creds are. + # The property will not run the DFS request if the passed in value matches what is already there. Set + # to None initially to ensure it detects a changed value. + # https://github.com/jborean93/smbprotocol/issues/109 + dc_value = config.domain_controller + config.domain_controller = None + config.domain_controller = dc_value else: # Allow users to initialise and set multiple config options like ConfigType(key=value) even when the object # has been initialized already. - cls.__instances[cls].set(**kwargs) + config = cls.__instances[cls] + config.set(**kwargs) - return cls.__instances[cls] + return config class ClientConfig(object, metaclass=_ConfigSingleton): @@ -95,13 +106,10 @@ class ClientConfig(object, metaclass=_ConfigSingleton): self.skip_dfs = skip_dfs self.auth_protocol = auth_protocol self.require_secure_negotiate = require_secure_negotiate - self._domain_controller = None # type: Optional[str] + self._domain_controller = domain_controller # type: Optional[str] self._domain_cache = [] # type: List[DomainEntry] self._referral_cache = [] # type: List[ReferralEntry] - # This relies on other attributes so set this last - self.domain_controller = domain_controller - @property def domain_controller(self): return self._domain_controller