summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-02-15 10:40:27 +0100
committerRob Crittenden <rcritten@redhat.com>2011-02-16 09:56:29 -0500
commita9dc175bc547996646c213661ca42906ffef83ab (patch)
tree8f04c8451f253da99be9717b577f85989c31fcba /ipalib
parentc4206d646242728ed03d6e9edb92a1eae55a44e1 (diff)
downloadfreeipa-a9dc175bc547996646c213661ca42906ffef83ab.tar.gz
freeipa-a9dc175bc547996646c213661ca42906ffef83ab.tar.xz
freeipa-a9dc175bc547996646c213661ca42906ffef83ab.zip
Validate MX records
https://fedorahosted.org/freeipa/ticket/967
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/dns.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index 1437011e..1bdb4bfd 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -30,6 +30,9 @@ EXAMPLES:
Add second nameserver for example.com:
ipa dnsrecord-add example.com @ --ns-rec nameserver2.example.com
+ Add a mail server for example.com:
+ ipa dnsrecord-add example.com @ --mx-rec="10 mail2"
+
Delete previously added nameserver from example.com:
ipa dnsrecord-del example.com @ --ns-rec nameserver2.example.com
@@ -136,11 +139,28 @@ def _validate_srv(ugettext, srv):
return None
+def _validate_mx(ugettext, mx):
+ try:
+ prio, host = mx.split()
+ except ValueError:
+ return u'format must be specified as "priority mailserver"'
+
+ try:
+ prio = int(prio)
+ except ValueError:
+ return u'the value of priority must be integer'
+
+ if prio < 0 or prio > 65535:
+ return u'the value of priority must be between 0 and 65535'
+
+ return None
+
_record_validators = {
u'A': _validate_ipaddr,
u'AAAA': _validate_ipaddr,
u'APL': _validate_ipnet,
u'SRV': _validate_srv,
+ u'MX': _validate_mx,
}
def has_cli_options(entry, no_option_msg):