Hello,

I have found bug in python-dns and consequently another bug in LOC record parsing in IPA. See commit messages.


My next patch for 'wait_for_dns' functionality (required for bind-dyndb-ldap 4.0) depends on these fixes.

--
Petr^2 Spacek
From ce66964187dce7956ee59f1512874d221cfbd277 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Mon, 17 Feb 2014 14:37:28 +0100
Subject: [PATCH] Fix regular expression for LOC records in DNS.

- Fractional parts of integers are not mandatory.
- Expressions containing only size or only size + horizontal precision
  are allowed.
- N/S/W/E handling was fixed.

See RFC 1876 section 3 for details.
---
 ipalib/plugins/dns.py | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index caaeaf1679113c1378944a1c7a19fc0dfffb0525..e7301a9f78466e9a790d26f03bfab757de501ed6 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -1136,14 +1136,19 @@ class LOCRecord(DNSRecord):
     See RFC 1876 for details""")
 
     def _get_part_values(self, value):
-        regex = re.compile(\
-            r'(?P<d1>\d{1,2}\s+)(?P<m1>\d{1,2}\s+)?(?P<s1>\d{1,2}\.?\d{1,3}?\s+)?'\
-            r'(?P<dir1>[N|S])\s+'\
-            r'(?P<d2>\d{1,3}\s+)(?P<m2>\d{1,2}\s+)?(?P<s2>\d{1,2}\.?\d{1,3}?\s+)?'\
-            r'(?P<dir2>[W|E])\s+'\
-            r'(?P<alt>-?\d{1,8}\.?\d{1,2}?)m?\s*'\
-            r'(?P<siz>\d{1,8}\.?\d{1,2}?)?m?\s*'\
-            r'(?P<hp>\d{1,8}\.?\d{1,2}?)?m?\s*(?P<vp>\d{1,8}\.?\d{1,2}?)?m?\s*$')
+        regex = re.compile(
+            r'(?P<d1>\d{1,2}\s+)'
+            r'(?:(?P<m1>\d{1,2}\s+)'
+            r'(?P<s1>\d{1,2}(?:\.\d{1,3})?\s+)?)?'
+            r'(?P<dir1>[NS])\s+'
+            r'(?P<d2>\d{1,3}\s+)'
+            r'(?:(?P<m2>\d{1,2}\s+)'
+            r'(?P<s2>\d{1,2}(?:\.\d{1,3})?\s+)?)?'
+            r'(?P<dir2>[WE])\s+'
+            r'(?P<alt>-?\d{1,8}(?:\.\d{1,2})?)m?'
+            r'(?:\s+(?P<siz>\d{1,8}(?:\.\d{1,2})?)m?'
+            r'(?:\s+(?P<hp>\d{1,8}(?:\.\d{1,2})?)m?'
+            r'(?:\s+(?P<vp>\d{1,8}(?:\.\d{1,2})?)m?\s*)?)?)?$')
 
         m = regex.match(value)
 
-- 
1.8.5.3

From 19ad0b28cabad86ffd639e5fe51da4eb78d6cd41 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Mon, 17 Feb 2014 15:31:10 +0100
Subject: [PATCH] Modify DNS tests with LOC records to workaround bug in
 python-dns.

Older versions of dnspython have problems with implicit values for
size and h/v precision so our tests use explicit value.
See https://github.com/rthalley/dnspython/issues/47

This change is necessary because we want to test if data visible
over DNS protocol matches data visible over LDAP.
---
 ipatests/test_xmlrpc/test_dns_plugin.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py
index 744dc4dc1b54bab1376efb4ef7e3f7afaa4ebd66..dd434c2f5d0c5ee8ca6311ab768d00483e301def 100644
--- a/ipatests/test_xmlrpc/test_dns_plugin.py
+++ b/ipatests/test_xmlrpc/test_dns_plugin.py
@@ -738,17 +738,17 @@ class test_dns(Declarative):
 
         dict(
             desc='Add LOC record to zone %r using dnsrecord_add' % (zone1),
-            command=('dnsrecord_add', [zone1, u'@'], {'locrecord': u"49 11 42.4 N 16 36 29.6 E 227.64" }),
+            command=('dnsrecord_add', [zone1, u'@'], {'locrecord': u"49 11 42.4 N 16 36 29.6 E 227.64m 10m 10.0m 0.1"}),
             expected={
                 'value': u'@',
                 'summary': None,
                 'result': {
                     'objectclass': objectclasses.dnszone,
                     'dn': zone1_dn,
                     'idnsname': [u'@'],
                     'mxrecord': [u"0 %s" % zone1_ns],
                     'nsrecord': [zone1_ns],
-                    'locrecord': [u"49 11 42.400 N 16 36 29.600 E 227.64"],
+                    'locrecord': [u"49 11 42.400 N 16 36 29.600 E 227.64 10.00 10.00 0.10"],
                 },
             },
         ),
@@ -1193,7 +1193,7 @@ class test_dns(Declarative):
                     'idnszoneactive': [u'TRUE'],
                     'nsrecord': [zone1_ns],
                     'mxrecord': [u'0 ns1.dnszone.test.'],
-                    'locrecord': [u"49 11 42.400 N 16 36 29.600 E 227.64"],
+                    'locrecord': [u"49 11 42.400 N 16 36 29.600 E 227.64 10.00 10.00 0.10"],
                     'idnssoamname': [zone1_ns],
                     'idnssoarname': [zone1_rname],
                     'idnssoaserial': [fuzzy_digits],
@@ -1226,7 +1226,7 @@ class test_dns(Declarative):
                     'idnszoneactive': [u'TRUE'],
                     'nsrecord': [zone1_ns],
                     'mxrecord': [u'0 ns1.dnszone.test.'],
-                    'locrecord': [u"49 11 42.400 N 16 36 29.600 E 227.64"],
+                    'locrecord': [u"49 11 42.400 N 16 36 29.600 E 227.64 10.00 10.00 0.10"],
                     'idnssoamname': [zone1_ns],
                     'idnssoarname': [zone1_rname],
                     'idnssoaserial': [fuzzy_digits],
@@ -1252,7 +1252,7 @@ class test_dns(Declarative):
                     'idnszoneactive': [u'TRUE'],
                     'nsrecord': [zone1_ns],
                     'mxrecord': [u'0 ns1.dnszone.test.'],
-                    'locrecord': [u"49 11 42.400 N 16 36 29.600 E 227.64"],
+                    'locrecord': [u"49 11 42.400 N 16 36 29.600 E 227.64 10.00 10.00 0.10"],
                     'idnssoamname': [zone1_ns],
                     'idnssoarname': [zone1_rname],
                     'idnssoaserial': [u'4294967295'],
-- 
1.8.5.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to