Fix ipa-replica-prepare always warning the user about not using the system hostname.

ticket 1717
This commit is contained in:
Jan Cholasta 2011-09-26 11:34:16 +02:00 committed by Martin Kosek
parent 09dc3562f2
commit f4089adf77
2 changed files with 16 additions and 6 deletions

View File

@ -246,7 +246,7 @@ def main():
options.setup_pkinit = False
try:
installutils.verify_fqdn(replica_fqdn)
installutils.verify_fqdn(replica_fqdn, system_name_check=False)
except RuntimeError, e:
msg = str(e)
if msg.startswith('Unable to resolve host name'):

View File

@ -117,7 +117,16 @@ def verify_dns_records(host_name, responses, resaddr, family):
raise RuntimeError("The DNS forward record %s does not match the reverse address %s" % (rec.dns_name, rev.rdata.ptrdname))
def verify_fqdn(host_name,no_host_dns=False):
def verify_fqdn(host_name, no_host_dns=False, system_name_check=True):
"""
Verify that the given host name is fully-qualified.
Raises `RuntimeError` if the host name is not fully-qualified.
:param host_name: The host name to verify.
:param no_host_dns: If true, skip DNS resolution of the host name.
:param system_name_check: If true, check if the host name matches the system host name.
"""
if len(host_name.split(".")) < 2 or host_name == "localhost.localdomain":
raise RuntimeError("Invalid hostname '%s', must be fully-qualified." % host_name)
@ -127,10 +136,11 @@ def verify_fqdn(host_name,no_host_dns=False):
if ipautil.valid_ip(host_name):
raise RuntimeError("IP address not allowed as a hostname")
system_host_name = socket.gethostname()
if not (host_name + '.').startswith(system_host_name + '.'):
print "Warning: The host name '%s' does not match the system host name '%s'." % (host_name, system_host_name)
print " Some services may not work properly."
if system_name_check:
system_host_name = socket.gethostname()
if not (host_name + '.').startswith(system_host_name + '.'):
print "Warning: The host name '%s' does not match the system host name '%s'." % (host_name, system_host_name)
print " Some services may not work properly."
if no_host_dns:
print "Warning: skipping DNS resolution of host", host_name