Ensure that the system hostname is lower-case.

ticket 1080
This commit is contained in:
Rob Crittenden 2011-03-17 10:22:33 -04:00
parent 861d1bbdca
commit 15e213d025
2 changed files with 11 additions and 5 deletions

View File

@ -681,6 +681,13 @@ def main():
if options.unattended and (options.password is None and options.principal is None and options.prompt_password is False) and not options.on_master:
sys.exit("One of password and principal are required.")
if options.hostname:
hostname = options.hostname
else:
hostname = socket.getfqdn()
if hostname != hostname.lower():
sys.exit('Invalid hostname \'%s\', must be lower-case.' % hostname)
# Create the discovery instance
ds = ipaclient.ipadiscovery.IPADiscovery()
@ -756,6 +763,7 @@ def main():
logging.debug("will use cli_basedn: %s\n", cli_basedn)
subject_base = "O=%s" % ds.getRealmName()
print "Hostname: "+hostname
print "Realm: "+cli_realm
print "DNS Domain: "+cli_domain
print "IPA Server: "+cli_server
@ -876,11 +884,6 @@ def main():
# Add the CA to the default NSS database and trust it
run(["/usr/bin/certutil", "-A", "-d", "/etc/pki/nssdb", "-n", "IPA CA", "-t", "CT,C,C", "-a", "-i", "/etc/ipa/ca.crt"])
if options.hostname:
hostname = options.hostname
else:
hostname = socket.getfqdn()
# If on master assume kerberos is already configured properly.
if not options.on_master:
# Configure krb5.conf

View File

@ -101,6 +101,9 @@ def verify_fqdn(host_name,no_host_dns=False):
if len(host_name.split(".")) < 2 or host_name == "localhost.localdomain":
raise RuntimeError("Invalid hostname '%s', must be fully-qualified." % host_name)
if host_name != host_name.lower():
raise RuntimeError("Invalid hostname '%s', must be lower-case." % host_name)
try:
hostaddr = socket.getaddrinfo(host_name, None)
except: