diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-02-18 11:00:36 +0100 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2011-02-22 09:08:11 -0500 |
commit | 6e7815a30e6897967b3c7e50f98f23c8a89c3b03 (patch) | |
tree | 2612749cee46e4ce254bda92d050471e88825fd6 /ipalib/plugins | |
parent | e7ed4035b5bc7bf57d54f5b8dfd789af16671d4b (diff) | |
download | freeipa-6e7815a30e6897967b3c7e50f98f23c8a89c3b03.tar.gz freeipa-6e7815a30e6897967b3c7e50f98f23c8a89c3b03.tar.xz freeipa-6e7815a30e6897967b3c7e50f98f23c8a89c3b03.zip |
Validate NAPTR records
https://fedorahosted.org/freeipa/ticket/840
Diffstat (limited to 'ipalib/plugins')
-rw-r--r-- | ipalib/plugins/dns.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index ed2f955c6..a18940b3a 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -155,12 +155,38 @@ def _validate_mx(ugettext, mx): return None +def _validate_naptr(ugettext, naptr): + "see RFC 2915 " + try: + order, pref, flags, svc, regexp, replacement = naptr.split() + except ValueError: + return u'format must be specified as "order preference flags service regexp replacement"' + + try: + order = int(order) + pref = int(pref) + except ValueError: + return u'order and preference must be integers' + + if order < 0 or order > 65535 or pref < 0 or pref > 65535: + return u'the value of order and preference must be between 0 and 65535' + + flags = flags.replace('"','') + flags = flags.replace('\'','') + if len(flags) != 1: + return u'flag must be a single character (quotation is allowed)' + if flags.upper() not in "SAUP": + return u'flag must be one of "S", "A", "U", or "P"' + + return None + _record_validators = { u'A': _validate_ipaddr, u'AAAA': _validate_ipaddr, u'APL': _validate_ipnet, u'SRV': _validate_srv, u'MX': _validate_mx, + u'NAPTR': _validate_naptr, } def has_cli_options(entry, no_option_msg): |