Blame SOURCES/ansible-freeipa-1.9.2-ipaclient-Defer-krb5-configuration-fix_RHBZ#2189238.patch

e80d55
From 0ec89eb53cf8771b34528ec210b2614370d9b662 Mon Sep 17 00:00:00 2001
e80d55
From: Thomas Woerner <twoerner@redhat.com>
e80d55
Date: Thu, 23 Mar 2023 18:13:08 +0100
e80d55
Subject: [PATCH] ipaclient: ipaclient_setup_nss also needs krb_name parameter
e80d55
e80d55
With the fix to defer creating the final krb5.conf on clients a bug has
e80d55
been introduced with ipaclient_setup_nss: The krb_name parameter that
e80d55
points to the temporary krb5 configuration was not added to the module.
e80d55
e80d55
With a properly configured DNS (like for example IPA DNS) the krb TXT
e80d55
records have been present in the DNS configuration. These have been used
e80d55
automatically as a fallback and broke server affinity for the client.
e80d55
Without the TXT records creating the IPA NSS database failed with
e80d55
 "Cannot find KDC for realm ..".
e80d55
e80d55
The krb_name parameter has been added to ipaclient_setup_nss and is also
e80d55
properly set in tasks/install.yml.
e80d55
---
e80d55
 roles/ipaclient/library/ipaclient_setup_nss.py | 8 ++++++++
e80d55
 roles/ipaclient/tasks/install.yml              | 1 +
e80d55
 2 files changed, 9 insertions(+)
e80d55
e80d55
diff --git a/roles/ipaclient/library/ipaclient_setup_nss.py b/roles/ipaclient/library/ipaclient_setup_nss.py
e80d55
index 74ca9d4..0e8c658 100644
e80d55
--- a/roles/ipaclient/library/ipaclient_setup_nss.py
e80d55
+++ b/roles/ipaclient/library/ipaclient_setup_nss.py
e80d55
@@ -152,6 +152,10 @@ options:
e80d55
       The dist of nss_ldap or nss-pam-ldapd files if sssd is disabled
e80d55
     required: yes
e80d55
     type: dict
e80d55
+  krb_name:
e80d55
+    description: The krb5 config file name
e80d55
+    type: str
e80d55
+    required: yes
e80d55
 author:
e80d55
     - Thomas Woerner (@t-woerner)
e80d55
 '''
e80d55
@@ -167,6 +171,7 @@ EXAMPLES = '''
e80d55
     subject_base: O=EXAMPLE.COM
e80d55
     principal: admin
e80d55
     ca_enabled: yes
e80d55
+    krb_name: /tmp/tmpkrb5.conf
e80d55
 '''
e80d55
 
e80d55
 RETURN = '''
e80d55
@@ -218,6 +223,7 @@ def main():
e80d55
             no_krb5_offline_passwords=dict(required=False, type='bool'),
e80d55
             no_dns_sshfp=dict(required=False, type='bool', default=False),
e80d55
             nosssd_files=dict(required=True, type='dict'),
e80d55
+            krb_name=dict(required=True, type='str'),
e80d55
         ),
e80d55
         supports_check_mode=False,
e80d55
     )
e80d55
@@ -268,6 +274,8 @@ def main():
e80d55
     options.sssd = not options.no_sssd
e80d55
     options.no_ac = False
e80d55
     nosssd_files = module.params.get('nosssd_files')
e80d55
+    krb_name = module.params.get('krb_name')
e80d55
+    os.environ['KRB5_CONFIG'] = krb_name
e80d55
 
e80d55
     # pylint: disable=invalid-name
e80d55
     CCACHE_FILE = paths.IPA_DNS_CCACHE
e80d55
diff --git a/roles/ipaclient/tasks/install.yml b/roles/ipaclient/tasks/install.yml
e80d55
index 662f09a..1dc6fdf 100644
e80d55
--- a/roles/ipaclient/tasks/install.yml
e80d55
+++ b/roles/ipaclient/tasks/install.yml
e80d55
@@ -382,6 +382,7 @@
e80d55
               | default(ipasssd_no_krb5_offline_passwords) }}"
e80d55
         no_dns_sshfp: "{{ ipaclient_no_dns_sshfp }}"
e80d55
         nosssd_files: "{{ result_ipaclient_test.nosssd_files }}"
e80d55
+        krb_name: "{{ result_ipaclient_temp_krb5.krb_name }}"
e80d55
 
e80d55
     - name: Install - Configure SSH and SSHD
e80d55
       ipaclient_setup_ssh:
e80d55
-- 
e80d55
2.39.2
e80d55
e80d55
From 10d072a8c42e6aa91485661d02b31f79bcc89fc0 Mon Sep 17 00:00:00 2001
e80d55
From: Thomas Woerner <twoerner@redhat.com>
e80d55
Date: Fri, 24 Mar 2023 12:40:32 +0100
e80d55
Subject: [PATCH] ipaclient: ipaclient_fix_ca also needs krb_name parameter
e80d55
e80d55
With the fix to defer creating the final krb5.conf on clients a bug has
e80d55
been introduced with ipaclient_fix_ca: The krb_name parameter that
e80d55
points to the temporary krb5 configuration was not added to the module
e80d55
e80d55
Without this the server affinity is broken for allow_repair and additionally
e80d55
ipaclient_fix_ca could fail if krb5 configuration needs to be repraied
e80d55
and also CA needs to be fixed.
e80d55
e80d55
The krb_name parameter has been added to ipaclient_fix_ca and is also
e80d55
properly set in tasks/install.yml.
e80d55
---
e80d55
 roles/ipaclient/library/ipaclient_fix_ca.py | 8 ++++++++
e80d55
 roles/ipaclient/tasks/install.yml           | 1 +
e80d55
 2 files changed, 9 insertions(+)
e80d55
e80d55
diff --git a/roles/ipaclient/library/ipaclient_fix_ca.py b/roles/ipaclient/library/ipaclient_fix_ca.py
e80d55
index 238b316..ede8d56 100644
e80d55
--- a/roles/ipaclient/library/ipaclient_fix_ca.py
e80d55
+++ b/roles/ipaclient/library/ipaclient_fix_ca.py
e80d55
@@ -54,6 +54,10 @@ options:
e80d55
       the host entry will not be changed on the server
e80d55
     type: bool
e80d55
     required: yes
e80d55
+  krb_name:
e80d55
+    description: The krb5 config file name
e80d55
+    type: str
e80d55
+    required: yes
e80d55
 author:
e80d55
     - Thomas Woerner (@t-woerner)
e80d55
 '''
e80d55
@@ -65,6 +69,7 @@ EXAMPLES = '''
e80d55
     realm: EXAMPLE.COM
e80d55
     basedn: dc=example,dc=com
e80d55
     allow_repair: yes
e80d55
+    krb_name: /tmp/tmpkrb5.conf
e80d55
 '''
e80d55
 
e80d55
 RETURN = '''
e80d55
@@ -87,6 +92,7 @@ def main():
e80d55
             realm=dict(required=True, type='str'),
e80d55
             basedn=dict(required=True, type='str'),
e80d55
             allow_repair=dict(required=True, type='bool'),
e80d55
+            krb_name=dict(required=True, type='str'),
e80d55
         ),
e80d55
     )
e80d55
 
e80d55
@@ -98,6 +104,8 @@ def main():
e80d55
     realm = module.params.get('realm')
e80d55
     basedn = module.params.get('basedn')
e80d55
     allow_repair = module.params.get('allow_repair')
e80d55
+    krb_name = module.params.get('krb_name')
e80d55
+    os.environ['KRB5_CONFIG'] = krb_name
e80d55
 
e80d55
     env = {'PATH': SECURE_PATH}
e80d55
     fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
e80d55
diff --git a/roles/ipaclient/tasks/install.yml b/roles/ipaclient/tasks/install.yml
e80d55
index 1dc6fdf..7ff2c39 100644
e80d55
--- a/roles/ipaclient/tasks/install.yml
e80d55
+++ b/roles/ipaclient/tasks/install.yml
e80d55
@@ -346,6 +346,7 @@
e80d55
         realm: "{{ result_ipaclient_test.realm }}"
e80d55
         basedn: "{{ result_ipaclient_test.basedn }}"
e80d55
         allow_repair: "{{ ipaclient_allow_repair }}"
e80d55
+        krb_name: "{{ result_ipaclient_temp_krb5.krb_name }}"
e80d55
       when: not ipaclient_on_master | bool and
e80d55
             result_ipaclient_test_keytab.krb5_keytab_ok and
e80d55
             not result_ipaclient_test_keytab.ca_crt_exists
e80d55
-- 
e80d55
2.39.2
e80d55