Skip to content

Commit d15ccde

Browse files
David KupkaJan Cholasta
authored andcommitted
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>
1 parent 35ba724 commit d15ccde

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

ipaclient/remote_plugins/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ def _read(self):
4141
try:
4242
with open(self._path, 'r') as sc:
4343
self._dict = json.load(sc)
44-
except EnvironmentError as e:
45-
if e.errno != errno.ENOENT:
44+
except Exception as e:
45+
if (isinstance(e, EnvironmentError) and
46+
e.errno == errno.ENOENT): # pylint: disable=no-member
47+
# ignore non-existent file, this happens when the cache was
48+
# erased or the server is contacted for the first time
49+
pass
50+
else:
51+
# warn that the file is unreadable, probably corrupted
4652
logger.warning('Failed to read server info: {}'.format(e))
4753

4854
def _write(self):

0 commit comments

Comments
 (0)