pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0236-Checks-if-replica-s4u2proxy.ldif-should-be-applied.patch

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