403b09
From 1242b26266b5f1222924dc06479e19d0914a0703 Mon Sep 17 00:00:00 2001
403b09
From: David Kupka <dkupka@redhat.com>
403b09
Date: Wed, 27 Jul 2016 10:54:16 +0200
403b09
Subject: [PATCH] schema: Introduce schema cache format
403b09
403b09
Information about schema cache format is stored in every cache item.
403b09
When schema cache format changes in incompatible way format will be
403b09
increased. When format stored in cache doesn't match currently used
403b09
format the entry in cache is ignored.
403b09
403b09
https://fedorahosted.org/freeipa/ticket/6048
403b09
403b09
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
403b09
---
403b09
 ipaclient/remote_plugins/schema.py | 10 ++++++++++
403b09
 1 file changed, 10 insertions(+)
403b09
403b09
diff --git a/ipaclient/remote_plugins/schema.py b/ipaclient/remote_plugins/schema.py
403b09
index f165736cde6f08d6d22c17070d570da261799e4b..d7c018e3de1cc79ffc086e3576542ce993ebc87a 100644
403b09
--- a/ipaclient/remote_plugins/schema.py
403b09
+++ b/ipaclient/remote_plugins/schema.py
403b09
@@ -23,6 +23,8 @@ from ipapython.dn import DN
403b09
 from ipapython.dnsutil import DNSName
403b09
 from ipapython.ipa_log_manager import log_mgr
403b09
 
403b09
+FORMAT = '0'
403b09
+
403b09
 if six.PY3:
403b09
     unicode = str
403b09
 
403b09
@@ -478,6 +480,14 @@ class Schema(object):
403b09
         return _LockedZipFile(path, mode)
403b09
 
403b09
     def _get_schema_fingerprint(self, schema):
403b09
+        try:
403b09
+            fmt = json.loads(schema.read('format'))
403b09
+        except KeyError:
403b09
+            fmt = '0'
403b09
+
403b09
+        if fmt != FORMAT:
403b09
+            raise RuntimeError('invalid format')
403b09
+
403b09
         schema_info = json.loads(schema.read(self.schema_info_path))
403b09
         return schema_info['fingerprint']
403b09
 
403b09
-- 
403b09
2.7.4
403b09