+3433. [bug] dlz_findzone() did not correctly handle
+ ISC_R_NOMORE. [RT #31172]
+
3432. [func] Multiple DLZ databases can now be configured.
DLZ databases are searched in the order configured,
unless set to "search no", in which case a
dlz_findzonedb(void *dbdata, const char *name) {
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+ state->log(ISC_LOG_INFO,
+ "dlz_example: dlz_findzonedb called with name '%s'"
+ "in zone DB '%s'", name, state->zone_name);
+
+ /*
+ * Returning ISC_R_NOTFOUND will cause the query logic to
+ * check the database for parent names, looking for zone cuts.
+ *
+ * Returning ISC_R_NOMORE prevents the query logic from doing
+ * this; it will move onto the next database after a single query.
+ */
+ if (strcasecmp(name, "test.example.com") == 0)
+ return (ISC_R_NOMORE);
+
if (strcasecmp(state->zone_name, name) == 0)
return (ISC_R_SUCCESS);
[ "$ret" -eq 0 ] || echo "I:failed"
status=`expr $status + $ret`
+ret=0
+echo "I:testing unsearched/registered DLZ zone is found"
+$DIG $DIGOPTS +noall +answer ns zone.nil > dig.out.ns1.5
+grep "3600.IN.NS.zone.nil." dig.out.ns1.5 > /dev/null || ret=1
+[ "$ret" -eq 0 ] || echo "I:failed"
+status=`expr $status + $ret`
+
+ret=0
+echo "I:testing correct behavior with findzone returning ISC_R_NOMORE"
+$DIG $DIGOPTS +noall a test.example.com > /dev/null 2>&1 || ret=1
+# we should only find one logged lookup per searched DLZ database
+lines=`grep "dlz_findzonedb.*example\.com.*example.nil" ns1/named.run | wc -l`
+[ $lines -eq 1 ] || ret=1
+lines=`grep "dlz_findzonedb.*example\.com.*alternate.nil" ns1/named.run | wc -l`
+[ $lines -eq 1 ] || ret=1
+[ "$ret" -eq 0 ] || echo "I:failed"
+status=`expr $status + $ret`
+
exit $status
if (result != ISC_R_NOTFOUND) {
if (best != NULL)
dns_db_detach(&best);
- dns_db_attach(db, &best);
- dns_db_detach(&db);
- minlabels = i;
+ if (result == ISC_R_SUCCESS) {
+ INSIST(db != NULL);
+ dns_db_attach(db, &best);
+ dns_db_detach(&db);
+ minlabels = i;
+ } else {
+ if (db != NULL)
+ dns_db_detach(&db);
+ break;
+ }
} else if (db != NULL)
dns_db_detach(&db);
}