diff options
author | David Kupka <dkupka@redhat.com> | 2017-01-03 08:57:21 +0100 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2017-01-09 09:13:36 +0100 |
commit | d15ccde20fcc97a597180255ee9f5eb38caa206c (patch) | |
tree | 47569e2f0c59456576f631f3d390eb49d90858c4 /ipaclient | |
parent | 35ba724de90b270773d91596de310291df745df0 (diff) | |
download | freeipa-d15ccde20fcc97a597180255ee9f5eb38caa206c.tar.gz freeipa-d15ccde20fcc97a597180255ee9f5eb38caa206c.tar.xz freeipa-d15ccde20fcc97a597180255ee9f5eb38caa206c.zip |
ipaclient: schema cache: Handle malformed server info data gracefully
As a part of CLI schema cache some data about each previously contacted server
are stored in simple JSON file. The file may get corrupted and became
undecodable for various reasons (parallel access, file system error,
tampering). Since the data are not necessary we should just warn an continue.
https://fedorahosted.org/freeipa/ticket/6578
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaclient')
-rw-r--r-- | ipaclient/remote_plugins/__init__.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ipaclient/remote_plugins/__init__.py b/ipaclient/remote_plugins/__init__.py index 50cfc37dc..da7004d62 100644 --- a/ipaclient/remote_plugins/__init__.py +++ b/ipaclient/remote_plugins/__init__.py @@ -41,8 +41,14 @@ class ServerInfo(collections.MutableMapping): try: with open(self._path, 'r') as sc: self._dict = json.load(sc) - except EnvironmentError as e: - if e.errno != errno.ENOENT: + except Exception as e: + if (isinstance(e, EnvironmentError) and + e.errno == errno.ENOENT): # pylint: disable=no-member + # ignore non-existent file, this happens when the cache was + # erased or the server is contacted for the first time + pass + else: + # warn that the file is unreadable, probably corrupted logger.warning('Failed to read server info: {}'.format(e)) def _write(self): |