mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-25 00:44:42 +00:00
Merge pull request #1037 from t-woerner/fix_allow_repair_missing_krb5.conf_with_DNS_lookup
ipaclient: Fix allow_repair with removed krb5.conf and DNS lookup
This commit is contained in:
@@ -159,11 +159,29 @@ def main():
|
|||||||
ca_crt_exists = os.path.exists(paths.IPA_CA_CRT)
|
ca_crt_exists = os.path.exists(paths.IPA_CA_CRT)
|
||||||
env = {'PATH': SECURE_PATH, 'KRB5CCNAME': paths.IPA_DNS_CCACHE}
|
env = {'PATH': SECURE_PATH, 'KRB5CCNAME': paths.IPA_DNS_CCACHE}
|
||||||
|
|
||||||
# First try: Validate krb5 keytab with system krb5 configuraiton
|
# First try: Validate with temporary test krb5.conf that forces
|
||||||
|
# 1) no DNS lookups and
|
||||||
|
# 2) to load /etc/krb5.conf:
|
||||||
|
#
|
||||||
|
# [libdefaults]
|
||||||
|
# dns_lookup_realm = false
|
||||||
|
# dns_lookup_kdc = false
|
||||||
|
# include /etc/krb5.conf
|
||||||
|
#
|
||||||
try:
|
try:
|
||||||
|
(krb_fd, krb_name) = tempfile.mkstemp()
|
||||||
|
os.close(krb_fd)
|
||||||
|
content = "\n".join([
|
||||||
|
"[libdefaults]",
|
||||||
|
"dns_lookup_realm = false",
|
||||||
|
"dns_lookup_kdc = false",
|
||||||
|
"include /etc/krb5.conf"
|
||||||
|
])
|
||||||
|
with open(krb_name, "w") as outf:
|
||||||
|
outf.write(content)
|
||||||
kinit_keytab(host_principal, paths.KRB5_KEYTAB,
|
kinit_keytab(host_principal, paths.KRB5_KEYTAB,
|
||||||
paths.IPA_DNS_CCACHE,
|
paths.IPA_DNS_CCACHE,
|
||||||
config=paths.KRB5_CONF,
|
config=krb_name,
|
||||||
attempts=kinit_attempts)
|
attempts=kinit_attempts)
|
||||||
krb5_keytab_ok = True
|
krb5_keytab_ok = True
|
||||||
krb5_conf_ok = True
|
krb5_conf_ok = True
|
||||||
@@ -177,6 +195,11 @@ def main():
|
|||||||
pass
|
pass
|
||||||
except GSSError:
|
except GSSError:
|
||||||
pass
|
pass
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
os.remove(krb_name)
|
||||||
|
except OSError:
|
||||||
|
module.fail_json(msg="Could not remove %s" % krb_name)
|
||||||
|
|
||||||
# Second try: Validate krb5 keytab with temporary krb5
|
# Second try: Validate krb5 keytab with temporary krb5
|
||||||
# configuration
|
# configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user