mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-11 08:41:55 -06:00
KDC autodiscovery may fail when domain is not realm
When ipa-client-install autodiscovers IPA server values it doesn't fill the fixed KDC address to Kerberos configuration file. However, when realm != domain or the autodiscovered values are overridden, installation may fail because it cannot find the KDC. This patch adds a failover to use static KDC address in case when such an issue occurs. https://fedorahosted.org/freeipa/ticket/1100
This commit is contained in:
parent
a7f9814ab7
commit
95b4040f6b
@ -386,7 +386,7 @@ def hardcode_ldap_server(cli_server):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, dnsok, options, filename):
|
def configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, cli_kdc, dnsok, options, filename):
|
||||||
|
|
||||||
krbconf = ipaclient.ipachangeconf.IPAChangeConf("IPA Installer")
|
krbconf = ipaclient.ipachangeconf.IPAChangeConf("IPA Installer")
|
||||||
krbconf.setOptionAssignment(" = ")
|
krbconf.setOptionAssignment(" = ")
|
||||||
@ -399,7 +399,7 @@ def configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, d
|
|||||||
|
|
||||||
#[libdefaults]
|
#[libdefaults]
|
||||||
libopts = [{'name':'default_realm', 'type':'option', 'value':cli_realm}]
|
libopts = [{'name':'default_realm', 'type':'option', 'value':cli_realm}]
|
||||||
if not dnsok or options.force:
|
if not dnsok or not cli_kdc or options.force:
|
||||||
libopts.append({'name':'dns_lookup_realm', 'type':'option', 'value':'false'})
|
libopts.append({'name':'dns_lookup_realm', 'type':'option', 'value':'false'})
|
||||||
libopts.append({'name':'dns_lookup_kdc', 'type':'option', 'value':'false'})
|
libopts.append({'name':'dns_lookup_kdc', 'type':'option', 'value':'false'})
|
||||||
else:
|
else:
|
||||||
@ -413,7 +413,7 @@ def configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, d
|
|||||||
opts.append({'name':'empty', 'type':'empty'})
|
opts.append({'name':'empty', 'type':'empty'})
|
||||||
|
|
||||||
#the following are necessary only if DNS discovery does not work
|
#the following are necessary only if DNS discovery does not work
|
||||||
if not dnsok or options.force:
|
if not dnsok or not cli_kdc or options.force:
|
||||||
#[realms]
|
#[realms]
|
||||||
kropts =[{'name':'kdc', 'type':'option', 'value':cli_server+':88'},
|
kropts =[{'name':'kdc', 'type':'option', 'value':cli_server+':88'},
|
||||||
{'name':'admin_server', 'type':'option', 'value':cli_server+':749'},
|
{'name':'admin_server', 'type':'option', 'value':cli_server+':749'},
|
||||||
@ -716,6 +716,11 @@ def main():
|
|||||||
print >>sys.stderr, "due to network or firewall settings."
|
print >>sys.stderr, "due to network or firewall settings."
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
cli_kdc = ds.getKDCName()
|
||||||
|
if dnsok and not cli_kdc:
|
||||||
|
print >>sys.stderr, "DNS domain '%s' is not configured for automatic KDC address lookup." % ds.getRealmName().lower()
|
||||||
|
print >>sys.stderr, "KDC address will be set to fixed value.\n"
|
||||||
|
|
||||||
if dnsok:
|
if dnsok:
|
||||||
print "Discovery was successful!"
|
print "Discovery was successful!"
|
||||||
elif not options.unattended:
|
elif not options.unattended:
|
||||||
@ -772,7 +777,7 @@ def main():
|
|||||||
try:
|
try:
|
||||||
(krb_fd, krb_name) = tempfile.mkstemp()
|
(krb_fd, krb_name) = tempfile.mkstemp()
|
||||||
os.close(krb_fd)
|
os.close(krb_fd)
|
||||||
if configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, dnsok, options, krb_name):
|
if configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, cli_kdc, dnsok, options, krb_name):
|
||||||
sys.exit("Test kerberos configuration failed")
|
sys.exit("Test kerberos configuration failed")
|
||||||
env['KRB5_CONFIG'] = krb_name
|
env['KRB5_CONFIG'] = krb_name
|
||||||
join_args = ["/usr/sbin/ipa-join", "-s", cli_server]
|
join_args = ["/usr/sbin/ipa-join", "-s", cli_server]
|
||||||
@ -864,7 +869,7 @@ def main():
|
|||||||
if not options.on_master:
|
if not options.on_master:
|
||||||
# Configure krb5.conf
|
# Configure krb5.conf
|
||||||
fstore.backup_file("/etc/krb5.conf")
|
fstore.backup_file("/etc/krb5.conf")
|
||||||
if configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, dnsok, options, "/etc/krb5.conf"):
|
if configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, cli_kdc, dnsok, options, "/etc/krb5.conf"):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
print "Configured /etc/krb5.conf for IPA realm " + cli_realm
|
print "Configured /etc/krb5.conf for IPA realm " + cli_realm
|
||||||
|
@ -68,6 +68,9 @@ class IPADiscovery:
|
|||||||
def getRealmName(self):
|
def getRealmName(self):
|
||||||
return self.realm
|
return self.realm
|
||||||
|
|
||||||
|
def getKDCName(self):
|
||||||
|
return self.kdc
|
||||||
|
|
||||||
def getBaseDN(self):
|
def getBaseDN(self):
|
||||||
return self.basedn
|
return self.basedn
|
||||||
|
|
||||||
@ -139,20 +142,20 @@ class IPADiscovery:
|
|||||||
else:
|
else:
|
||||||
return -2 #no ldap server found
|
return -2 #no ldap server found
|
||||||
|
|
||||||
|
|
||||||
#search for kerberos TODO: move this after ipacheckldap()
|
|
||||||
logging.debug("[ipadnssearchkrb]")
|
|
||||||
krbret = self.ipadnssearchkrb(self.domain)
|
|
||||||
if not krbret:
|
|
||||||
return -3 #no krb server found
|
|
||||||
|
|
||||||
self.realm = krbret[0]
|
|
||||||
|
|
||||||
else: #server forced on us, this means DNS doesn't work :/
|
else: #server forced on us, this means DNS doesn't work :/
|
||||||
|
|
||||||
self.domain = domain
|
self.domain = domain
|
||||||
self.server = server
|
self.server = server
|
||||||
|
|
||||||
|
#search for kerberos
|
||||||
|
logging.debug("[ipadnssearchkrb]")
|
||||||
|
krbret = self.ipadnssearchkrb(self.domain)
|
||||||
|
if not server and not krbret[0]:
|
||||||
|
return -3 # realm for autodiscovery not found
|
||||||
|
|
||||||
|
self.realm = krbret[0]
|
||||||
|
self.kdc = krbret[1]
|
||||||
|
|
||||||
logging.debug("[ipacheckldap]")
|
logging.debug("[ipacheckldap]")
|
||||||
# check ldap now
|
# check ldap now
|
||||||
ldapret = self.ipacheckldap(self.server, self.realm)
|
ldapret = self.ipacheckldap(self.server, self.realm)
|
||||||
@ -303,7 +306,7 @@ class IPADiscovery:
|
|||||||
|
|
||||||
if realm:
|
if realm:
|
||||||
# now fetch server information for the realm
|
# now fetch server information for the realm
|
||||||
qname = "_kerberos._udp." + tdomain
|
qname = "_kerberos._udp." + realm.lower()
|
||||||
# terminate the name
|
# terminate the name
|
||||||
if not qname.endswith("."):
|
if not qname.endswith("."):
|
||||||
qname += "."
|
qname += "."
|
||||||
@ -318,4 +321,7 @@ class IPADiscovery:
|
|||||||
else:
|
else:
|
||||||
kdc = qname
|
kdc = qname
|
||||||
|
|
||||||
|
if not kdc:
|
||||||
|
logging.debug("SRV record for KDC not found! Realm: %s, SRV record: %s" % (realm, qname))
|
||||||
|
|
||||||
return [realm, kdc]
|
return [realm, kdc]
|
||||||
|
Loading…
Reference in New Issue
Block a user