43edf8
From b813e9ed8807b14d647035a8f8df0002cebe79dd Mon Sep 17 00:00:00 2001
43edf8
From: Antonio Torres <antorres@redhat.com>
43edf8
Date: Wed, 15 Mar 2023 11:24:06 +0100
43edf8
Subject: [PATCH] ipaserver: deepcopy objectclasses list from IPA config
43edf8
43edf8
We need to deepcopy the list of default objectlasses from IPA config
43edf8
before assigning it to an entry, in order to avoid further modifications of the
43edf8
entry affect the cached IPA config.
43edf8
43edf8
Fixes: https://pagure.io/freeipa/issue/9349
43edf8
Signed-off-by: Antonio Torres <antorres@redhat.com>
43edf8
Reviewed-By: Francisco Trivino <ftrivino@redhat.com>
43edf8
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
43edf8
---
43edf8
 ipaserver/plugins/baseldap.py  | 8 ++++----
43edf8
 ipaserver/plugins/stageuser.py | 4 ++--
43edf8
 2 files changed, 6 insertions(+), 6 deletions(-)
43edf8
43edf8
diff --git a/ipaserver/plugins/baseldap.py b/ipaserver/plugins/baseldap.py
43edf8
index 25449b5aec72cbdbfb57527aa834cc69291398d6..8c041eb26e2c5c905f605f16288f49c4b7a2a274 100644
43edf8
--- a/ipaserver/plugins/baseldap.py
43edf8
+++ b/ipaserver/plugins/baseldap.py
43edf8
@@ -796,9 +796,9 @@ class LDAPObject(Object):
43edf8
         objectclasses = self.object_class
43edf8
         if self.object_class_config:
43edf8
             config = ldap.get_ipa_config()
43edf8
-            objectclasses = config.get(
43edf8
+            objectclasses = deepcopy(config.get(
43edf8
                 self.object_class_config, objectclasses
43edf8
-            )
43edf8
+            ))
43edf8
         objectclasses = objectclasses + self.possible_objectclasses
43edf8
         # Get list of available attributes for this object for use
43edf8
         # in the ACI UI.
43edf8
@@ -1157,9 +1157,9 @@ class LDAPCreate(BaseLDAPCommand, crud.Create):
43edf8
 
43edf8
         if self.obj.object_class_config:
43edf8
             config = ldap.get_ipa_config()
43edf8
-            entry_attrs['objectclass'] = config.get(
43edf8
+            entry_attrs['objectclass'] = deepcopy(config.get(
43edf8
                 self.obj.object_class_config, entry_attrs['objectclass']
43edf8
-            )
43edf8
+            ))
43edf8
 
43edf8
         if self.obj.uuid_attribute:
43edf8
             entry_attrs[self.obj.uuid_attribute] = 'autogenerate'
43edf8
diff --git a/ipaserver/plugins/stageuser.py b/ipaserver/plugins/stageuser.py
43edf8
index 9591a7dda746db64b9c765140d1ef1fb1ecb2ce7..b3e65b76544ca572b822fb3c85e777bb41d21a2d 100644
43edf8
--- a/ipaserver/plugins/stageuser.py
43edf8
+++ b/ipaserver/plugins/stageuser.py
43edf8
@@ -557,9 +557,9 @@ class stageuser_activate(LDAPQuery):
43edf8
 
43edf8
         if self.obj.object_class_config:
43edf8
             config = ldap.get_ipa_config()
43edf8
-            entry_attrs['objectclass'] = config.get(
43edf8
+            entry_attrs['objectclass'] = deepcopy(config.get(
43edf8
                 self.obj.object_class_config, entry_attrs['objectclass']
43edf8
-            )
43edf8
+            ))
43edf8
 
43edf8
         return(entry_attrs)
43edf8
 
43edf8
-- 
43edf8
2.39.2
43edf8