pgreco / rpms / ipa

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

Blame SOURCES/0074-renew-agent-revert-to-host-keytab-authentication.patch

483b06
From 37ddd26bc4b2f99dfa27b2ad45219290a2f44ec5 Mon Sep 17 00:00:00 2001
483b06
From: Jan Cholasta <jcholast@redhat.com>
483b06
Date: Fri, 7 Apr 2017 07:46:58 +0200
483b06
Subject: [PATCH] renew agent: revert to host keytab authentication
483b06
483b06
Fixes an issue where the renew agent uses GSSAPI for LDAP connection but
483b06
fails because it is not authenticated.
483b06
483b06
This reverts commit 7462adec13c5b25b6868d2863dc38062c97d0ff7.
483b06
483b06
https://pagure.io/freeipa/issue/6757
483b06
483b06
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
483b06
---
483b06
 install/certmonger/dogtag-ipa-ca-renew-agent-submit | 8 +++++++-
483b06
 1 file changed, 7 insertions(+), 1 deletion(-)
483b06
483b06
diff --git a/install/certmonger/dogtag-ipa-ca-renew-agent-submit b/install/certmonger/dogtag-ipa-ca-renew-agent-submit
483b06
index 5782db703c49d7c2e92c806e24e9925e8e7d710a..3389447a99d9ab9dac159b0d57ca02f60698ce0c 100755
483b06
--- a/install/certmonger/dogtag-ipa-ca-renew-agent-submit
483b06
+++ b/install/certmonger/dogtag-ipa-ca-renew-agent-submit
483b06
@@ -40,6 +40,7 @@ from cryptography.hazmat.backends import default_backend
483b06
 
483b06
 import six
483b06
 
483b06
+from ipalib.install.kinit import kinit_keytab
483b06
 from ipapython import ipautil
483b06
 from ipapython.dn import DN
483b06
 from ipalib import api, errors, x509
483b06
@@ -132,7 +133,7 @@ def ldap_connect():
483b06
     conn = None
483b06
     try:
483b06
         conn = ldap2(api)
483b06
-        conn.connect(autobind=True)
483b06
+        conn.connect(ccache=os.environ['KRB5CCNAME'])
483b06
         yield conn
483b06
     finally:
483b06
         if conn is not None and conn.isconnected():
483b06
@@ -526,6 +527,11 @@ def main():
483b06
     tmpdir = tempfile.mkdtemp(prefix="tmp-")
483b06
     certs.renewal_lock.acquire()
483b06
     try:
483b06
+        principal = str('host/%s@%s' % (api.env.host, api.env.realm))
483b06
+        ccache_filename = os.path.join(tmpdir, 'ccache')
483b06
+        os.environ['KRB5CCNAME'] = ccache_filename
483b06
+        kinit_keytab(principal, paths.KRB5_KEYTAB, ccache_filename)
483b06
+
483b06
         profile = os.environ.get('CERTMONGER_CA_PROFILE')
483b06
         if is_replicated():
483b06
             if profile or is_renewal_master():
483b06
-- 
483b06
2.9.3
483b06