7e1b55
From be1e3bbfc13aff9a583108376f245b81cc3666fb Mon Sep 17 00:00:00 2001
7e1b55
From: Rob Crittenden <rcritten@redhat.com>
7e1b55
Date: Thu, 9 Sep 2021 15:26:55 -0400
7e1b55
Subject: [PATCH] Don't store entries with a usercertificate in the LDAP cache
7e1b55
7e1b55
usercertificate often has a subclass and both the plain and
7e1b55
subclassed (binary) values are queried. I'm concerned that
7e1b55
they are used more or less interchangably in places so not
7e1b55
caching these entries is the safest path forward for now until
7e1b55
we can dedicate the time to find all usages, determine their
7e1b55
safety and/or perhaps handle this gracefully within the cache
7e1b55
now.
7e1b55
7e1b55
What we see in this bug is that usercertificate;binary holds the
7e1b55
first certificate value but a user-mod is done with
7e1b55
setattr usercertificate=<new_cert>. Since there is no
7e1b55
usercertificate value (remember, it's usercertificate;binary)
7e1b55
a replace is done and 389-ds wipes the existing value as we've
7e1b55
asked it to.
7e1b55
7e1b55
I'm not comfortable with simply treating them the same because
7e1b55
in LDAP they are not.
7e1b55
7e1b55
https://pagure.io/freeipa/issue/8986
7e1b55
7e1b55
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
7e1b55
Reviewed-By: Francois Cami <fcami@redhat.com>
7e1b55
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
7e1b55
---
7e1b55
 ipapython/ipaldap.py | 14 +++++++++++---
7e1b55
 1 file changed, 11 insertions(+), 3 deletions(-)
7e1b55
7e1b55
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
7e1b55
index f94b784d680f33d026e4d56ec8627d4d2ab87931..ced8f1bd66dc8f1f5c206677d2725d1e72b489f9 100644
7e1b55
--- a/ipapython/ipaldap.py
7e1b55
+++ b/ipapython/ipaldap.py
7e1b55
@@ -1821,9 +1821,17 @@ class LDAPCache(LDAPClient):
7e1b55
                         entry=None, exception=None):
7e1b55
         # idnsname - caching prevents delete when mod value to None
7e1b55
         # cospriority - in a Class of Service object, uncacheable
7e1b55
-        # TODO - usercertificate was banned at one point and I don't remember
7e1b55
-        #        why...
7e1b55
-        BANNED_ATTRS = {'idnsname', 'cospriority'}
7e1b55
+        # usercertificate* - caching subtypes is tricky, trade less
7e1b55
+        #                    complexity for performance
7e1b55
+        #
7e1b55
+        # TODO: teach the cache about subtypes
7e1b55
+
7e1b55
+        BANNED_ATTRS = {
7e1b55
+            'idnsname',
7e1b55
+            'cospriority',
7e1b55
+            'usercertificate',
7e1b55
+            'usercertificate;binary'
7e1b55
+        }
7e1b55
         if not self._enable_cache:
7e1b55
             return
7e1b55
 
7e1b55
-- 
7e1b55
2.31.1
7e1b55