pgreco / rpms / ipa

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

Blame SOURCES/0119-ipa-kra-install-fix-check_host_keys.patch

483b06
From 85cd84580f45c99b6ab49814ead7eb2f259ca444 Mon Sep 17 00:00:00 2001
483b06
From: Florence Blanc-Renaud <flo@redhat.com>
483b06
Date: Fri, 5 May 2017 17:06:09 +0200
483b06
Subject: [PATCH] ipa-kra-install: fix check_host_keys
483b06
483b06
ipa-kra-install on a replica checks that the keys are available before
483b06
going further to avoid race condition due to replication. The issue is
483b06
that the check_host_keys method expects to find exactly one key for
483b06
cn=env/host but 2 may exist: one below cn=custodia and one below
483b06
cn=dogtag,cn=custodia.
483b06
The fix is to check that at least one key exist (not exactly one key).
483b06
483b06
https://pagure.io/freeipa/issue/6934
483b06
483b06
Reviewed-By: Martin Basti <mbasti@redhat.com>
483b06
---
483b06
 ipaserver/secrets/kem.py | 7 +++----
483b06
 1 file changed, 3 insertions(+), 4 deletions(-)
483b06
483b06
diff --git a/ipaserver/secrets/kem.py b/ipaserver/secrets/kem.py
483b06
index c1991c6b2ae00ed7147b2ec18389e463784b9f98..3363d82fef54c463f498edeb95ddee454b20d31d 100644
483b06
--- a/ipaserver/secrets/kem.py
483b06
+++ b/ipaserver/secrets/kem.py
483b06
@@ -72,7 +72,7 @@ class KEMLdap(iSecLdap):
483b06
                                          'princ': principal})
483b06
         r = conn.search_s(self.keysbase, scope, ldap_filter)
483b06
         if len(r) != 1:
483b06
-            raise ValueError("Incorrect number of results (%d) searching for"
483b06
+            raise ValueError("Incorrect number of results (%d) searching for "
483b06
                              "public key for %s" % (len(r), principal))
483b06
         ipa_public_key = r[0][1]['ipaPublicKey'][0]
483b06
         jwk = self._parse_public_key(ipa_public_key)
483b06
@@ -85,9 +85,8 @@ class KEMLdap(iSecLdap):
483b06
 
483b06
         ldap_filter = self.build_filter(IPA_CHECK_QUERY, {'host': host})
483b06
         r = conn.search_s(self.keysbase, scope, ldap_filter)
483b06
-        if len(r) != 1:
483b06
-            raise ValueError("Incorrect number of results (%d) searching for"
483b06
-                             "public key for %s" % (len(r), host))
483b06
+        if not r:
483b06
+            raise ValueError("No public keys were found for %s" % host)
483b06
         return True
483b06
 
483b06
     def _format_public_key(self, key):
483b06
-- 
483b06
2.12.2
483b06