From: Mukund Sivaraman Date: Fri, 20 Apr 2012 11:05:59 +0000 (+0530) Subject: [1790] Address review comments (see full log) X-Git-Tag: trac2351_base~226^2~138 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab86972df562a452de633cb13403f0ed8eb00510;p=thirdparty%2Fkea.git [1790] Address review comments (see full log) * 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. --- diff --git a/src/bin/xfrin/xfrin.py.in b/src/bin/xfrin/xfrin.py.in index 7f3959a3f0..71da0e951c 100755 --- a/src/bin/xfrin/xfrin.py.in +++ b/src/bin/xfrin/xfrin.py.in @@ -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"]) diff --git a/src/bin/xfrin/xfrin_messages.mes b/src/bin/xfrin/xfrin_messages.mes index 42a313ba19..388159e3fe 100644 --- a/src/bin/xfrin/xfrin_messages.mes +++ b/src/bin/xfrin/xfrin_messages.mes @@ -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