diff options
author | David Kupka <dkupka@redhat.com> | 2016-07-27 10:54:16 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2016-08-03 16:32:39 +0200 |
commit | 86977070e12329be02ef5ebb749c837a8d6d258f (patch) | |
tree | d7b506cbfc5c5ebc15f3948d69101d21acfebf29 /ipaclient | |
parent | 29f7f822aba674ebc4184ecc126854adb4330a89 (diff) | |
download | freeipa-86977070e12329be02ef5ebb749c837a8d6d258f.tar.gz freeipa-86977070e12329be02ef5ebb749c837a8d6d258f.tar.xz freeipa-86977070e12329be02ef5ebb749c837a8d6d258f.zip |
schema: Introduce schema cache format
Information about schema cache format is stored in every cache item.
When schema cache format changes in incompatible way format will be
increased. When format stored in cache doesn't match currently used
format the entry in cache is ignored.
https://fedorahosted.org/freeipa/ticket/6048
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaclient')
-rw-r--r-- | ipaclient/remote_plugins/schema.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ipaclient/remote_plugins/schema.py b/ipaclient/remote_plugins/schema.py index b183fa137..fcff8bf01 100644 --- a/ipaclient/remote_plugins/schema.py +++ b/ipaclient/remote_plugins/schema.py @@ -23,6 +23,8 @@ from ipapython.dn import DN from ipapython.dnsutil import DNSName from ipapython.ipa_log_manager import log_mgr +FORMAT = '0' + if six.PY3: unicode = str @@ -478,6 +480,14 @@ class Schema(object): return _LockedZipFile(path, mode) def _get_schema_fingerprint(self, schema): + try: + fmt = json.loads(schema.read('format')) + except KeyError: + fmt = '0' + + if fmt != FORMAT: + raise RuntimeError('invalid format') + schema_info = json.loads(schema.read(self.schema_info_path)) return schema_info['fingerprint'] |