diff options
author | Martin Kosek <mkosek@redhat.com> | 2012-01-06 15:12:41 +0100 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-01-12 09:43:05 +0100 |
commit | 52ea3a6b2958875da6370433d14509bdbd4c4943 (patch) | |
tree | c523383fdba7b9c0bfa72376ece4bdca2b962e0b /ipalib/util.py | |
parent | 91c10419f8a32d070ac4b8fa0378ea48bb82388e (diff) | |
download | freeipa-52ea3a6b2958875da6370433d14509bdbd4c4943.tar.gz freeipa-52ea3a6b2958875da6370433d14509bdbd4c4943.tar.xz freeipa-52ea3a6b2958875da6370433d14509bdbd4c4943.zip |
Refactor dnsrecord processing
Current DNS record processing architecture has many flaws,
including custom execute() methods which does not take advantage
of base LDAP commands or nonstandard and confusing DNS record
option processing.
This patch refactors DNS record processing with the following
improvements:
* Every DNS record has now own Parameter type. Each DNS record
consists from one or more "parts" which are also Parameters.
This architecture will enable much easier implementation of
future per-DNS-type API.
* Validation is now not written as a separate function for
every parameter but is delegated to DNS record parts.
* Normalization is also delegated to DNS record parts.
* Since standard LDAP base commands execute method is now used,
dnsrecord-add and dnsrecord-mod correctly supports --setattr
and --addattr options.
* In order to prevent confusion unsupported DNS record types
are now hidden. They are still present in the plugin so that
old clients receive proper validation error.
The patch also contains several fixes:
* Fix domain-name validation and normalization- allow domain
names that are not fully qualified. For example --cname-rec=bar
is a valid domain-name for bind which will translate it then
as bar.<owning-domain>. This change implies, that fully qualified
domain names must end with '.'.
* Do not let user accidentally remove entire zone with command
"ipa dnsrecord-del @ --del-all".
* Fix --ttl and --class option processing in dnsrecord-add and
dnsrecord-mod.
All API changes are compatible with clients without this patch.
https://fedorahosted.org/freeipa/ticket/2082
Diffstat (limited to 'ipalib/util.py')
-rw-r--r-- | ipalib/util.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ipalib/util.py b/ipalib/util.py index d575329e7..da933a86a 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -257,8 +257,12 @@ def validate_zonemgr(zonemgr): if not all(regex_domain.match(part) for part in domain.split(".")): raise ValueError(_('domain name may only include letters, numbers, and -')) -def validate_hostname(hostname): - """ See RFC 952, 1123""" +def validate_hostname(hostname, check_fqdn=True): + """ See RFC 952, 1123 + + :param hostname Checked value + :param check_fqdn Check if hostname is fully qualified + """ regex_name = re.compile(r'^[a-z0-9]([a-z0-9-]?[a-z0-9])*$', re.IGNORECASE) if len(hostname) > 255: @@ -267,12 +271,12 @@ def validate_hostname(hostname): if hostname.endswith('.'): hostname = hostname[:-1] - if '.' not in hostname: - raise ValueError(_('hostname is not fully qualified')) + if check_fqdn and '.' not in hostname: + raise ValueError(_('not fully qualified')) if not all(regex_name.match(part) for part in hostname.split(".")): - raise ValueError(_('hostname parts may only include letters, numbers, and - ' \ - '(which is not allowed as the last character)')) + raise ValueError(_('only letters, numbers, and - are allowed. ' \ + '- must not be the last name character')) class cachedproperty(object): """ |