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