]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1790] Address review comments (see full log)
authorMukund Sivaraman <muks@isc.org>
Fri, 20 Apr 2012 11:05:59 +0000 (16:35 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 14 May 2012 17:06:57 +0000 (22:36 +0530)
* The filetype parameter is optional, which means it might be missing
  from the dict. Therefore indexing it with zone["filetype"] without
  further check is unsafe. We check for this key now.

* The handling of origin and dots is needlessly complicated. We now
  create Name objects of both and compare them. We also use RRClass
  objects for the zone class. This makes sure the comparison is correct
  one.

src/bin/xfrin/xfrin.py.in
src/bin/xfrin/xfrin_messages.mes

index 7f3959a3f0e036439ee2c9d6c28cb3bc3ac1cade..71da0e951cb508999bb95f540ead6b35152fe7f8 100755 (executable)
@@ -1549,24 +1549,30 @@ class Xfrin:
         if is_default:
             return
         for d in datasources:
-            if "class" in d:
-                dclass = d["class"]
-            else:
-                dclass = "IN"
-            if d["type"].lower() == "memory" and dclass.lower() == zone_class.to_text().lower():
+            try:
+                if "class" in d:
+                    dclass = RRClass(d["class"])
+                else:
+                    dclass = RRClass("IN")
+            except InvalidRRType as err:
+                logger.info(XFRIN_AUTH_CONFIG_ERROR, str(err))
+                continue
+
+            if d["type"].lower() == "memory" and dclass == zone_class:
                 for zone in d["zones"]:
-                    # Remove trailing periods
-                    n1 = zone["origin"]
-                    if n1[-1] == '.':
-                        n1 = n1[:-1]
-                    n2 = zone_name.to_text()
-                    if n2[-1] == '.':
-                        n2 = n2[:-1]
-
-                    if zone["filetype"].lower() == "sqlite3" and n1.lower() == n2.lower():
-                        param = {"origin": n1,
+                    if "filetype" not in zone:
+                        continue
+                    try:
+                        name = Name(zone["origin"])
+                    except (EmptyLabel, TooLongLabel, BadLabelType, BadEscape, TooLongName, IncompleteName):
+                        logger.info(XFRIN_AUTH_CONFIG_ERROR, str(err))
+                        continue
+
+                    if zone["filetype"].lower() == "sqlite3" and name == zone_name:
+                        param = {"origin": zone_name.to_text(),
                                  "class": zone_class.to_text(),
                                  "datasrc": d["type"]}
+
                         logger.debug(DBG_XFRIN_TRACE, XFRIN_AUTH_LOADZONE,
                                      param["origin"], param["class"], param["datasrc"])
 
index 42a313ba1934af62108290f29354881a7f7f7839..388159e3fe9dc013f0cce976fd554782419b0fed 100644 (file)
@@ -121,6 +121,9 @@ likely means that the msgq daemon has quit or was killed.
 There was a problem sending a message to b10-auth. This most likely
 means that the msgq daemon has quit or was killed.
 
+% XFRIN_AUTH_CONFIG_ERROR Error parsing Auth configuration: %1
+There was an error when parsing Auth configuration.
+
 % XFRIN_AUTH_LOADZONE sending Auth loadzone for origin=%1, class=%2, datasrc=%3
 There was a successful zone transfer, and the zone is served by b10-auth
 in the in-memory data source using sqlite3 as a backend. We send the