mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
parent
35ba724de9
commit
d15ccde20f
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user