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