diff options
author | Rob Crittenden <rcritten@redhat.com> | 2010-07-22 14:16:22 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2010-08-06 15:31:57 -0400 |
commit | d885339f1cbf208b06c1eb26c49c60d11d62f1c3 (patch) | |
tree | 73411396f22a74ed0381fe33c71abf47c3f3adb6 /ipalib/util.py | |
parent | 830910d1f30de22c037f43d7bcba33bd877a5581 (diff) | |
download | freeipa-d885339f1cbf208b06c1eb26c49c60d11d62f1c3.tar.gz freeipa-d885339f1cbf208b06c1eb26c49c60d11d62f1c3.tar.xz freeipa-d885339f1cbf208b06c1eb26c49c60d11d62f1c3.zip |
Require that hosts be resolvable in DNS. Use --force to ignore warnings.
This also requires a resolvable hostname on services as well. I want
people to think long and hard about adding things that aren't resolvable.
The cert plugin can automatically create services on the user's behalf when
issuing a cert. It will always set the force flag to True.
We use a lot of made-up host names in the test system, all of which require
the force flag now.
ticket #25
Diffstat (limited to 'ipalib/util.py')
-rw-r--r-- | ipalib/util.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ipalib/util.py b/ipalib/util.py index 76be9a6d7..570d66e00 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -28,6 +28,7 @@ import time import krbV import socket from ipalib import errors +from ipapython import dnsclient def get_current_principal(): @@ -113,3 +114,18 @@ def realm_to_suffix(realm_name): s = realm_name.split(".") terms = ["dc=" + x.lower() for x in s] return ",".join(terms) + +def validate_host_dns(log, fqdn): + """ + See if the hostname has a DNS A record. + """ + rs = dnsclient.query(fqdn + '.', dnsclient.DNS_C_IN, dnsclient.DNS_T_A) + if len(rs) == 0: + log.debug( + 'IPA: DNS A record lookup failed for %s' % fqdn + ) + raise errors.DNSNotARecordError() + else: + log.debug( + 'IPA: found %d records for %s' % (len(rs), fqdn) + ) |