c58629
From 17fab4982fcb8b8af6c20130907dd3d4bad7f699 Mon Sep 17 00:00:00 2001
c58629
From: Felipe Barreto <fbarreto@redhat.com>
c58629
Date: Fri, 13 Oct 2017 09:19:43 +0200
c58629
Subject: [PATCH] Checks if replica-s4u2proxy.ldif should be applied
c58629
c58629
Before applying replica-s3u2proxy.ldif, we check
c58629
if the values are already there. The values can be
c58629
there if a replica installation was done in the past
c58629
and some info was left behind. Also, the code checks
c58629
the values independently.
c58629
c58629
https://pagure.io/freeipa/issue/7174
c58629
c58629
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
c58629
---
c58629
 ipaserver/install/dsinstance.py | 19 ++++++++++++++++++-
c58629
 1 file changed, 18 insertions(+), 1 deletion(-)
c58629
c58629
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
c58629
index 7a88612997a3fa96cf394852401fb01e5e4501d5..923f483340a26a614001701ce6c235dd73501501 100644
c58629
--- a/ipaserver/install/dsinstance.py
c58629
+++ b/ipaserver/install/dsinstance.py
c58629
@@ -954,7 +954,24 @@ class DsInstance(service.Service):
c58629
         self._ldap_mod("replica-prevent-time-skew.ldif", self.sub_dict)
c58629
 
c58629
     def __setup_s4u2proxy(self):
c58629
-        self._ldap_mod("replica-s4u2proxy.ldif", self.sub_dict)
c58629
+
c58629
+        def __add_principal(last_cn, principal, self):
c58629
+            dn = DN(('cn', last_cn), ('cn', 's4u2proxy'),
c58629
+                    ('cn', 'etc'), self.suffix)
c58629
+
c58629
+            value = '{principal}/{fqdn}@{realm}'.format(fqdn=self.fqdn,
c58629
+                                                        realm=self.realm,
c58629
+                                                        principal=principal)
c58629
+
c58629
+            entry = api.Backend.ldap2.get_entry(dn, ['memberPrincipal'])
c58629
+            try:
c58629
+                entry['memberPrincipal'].append(value)
c58629
+                api.Backend.ldap2.update_entry(entry)
c58629
+            except errors.EmptyModlist:
c58629
+                pass
c58629
+
c58629
+        __add_principal('ipa-http-delegation', 'HTTP', self)
c58629
+        __add_principal('ipa-ldap-delegation-targets', 'ldap', self)
c58629
 
c58629
     def __create_indices(self):
c58629
         self._ldap_mod("indices.ldif")
c58629
-- 
c58629
2.9.5
c58629