mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-28 21:17:54 +00:00
Revert accidental merge of unfinished DLZ work
This commit is contained in:
parent
e214e8728a
commit
632c0f1e91
@ -798,7 +798,6 @@ query_getzonedb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype,
|
||||
|
||||
result = dns_zt_find(client->view->zonetable, name, ztoptions, NULL,
|
||||
&zone);
|
||||
|
||||
if (result == DNS_R_PARTIALMATCH)
|
||||
partial = ISC_TRUE;
|
||||
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH)
|
||||
@ -1029,14 +1028,11 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype,
|
||||
/* See how many labels are in the zone's name. */
|
||||
if (result == ISC_R_SUCCESS && zone != NULL)
|
||||
zonelabels = dns_name_countlabels(dns_zone_getorigin(zone));
|
||||
|
||||
/*
|
||||
* If # zone labels < # name labels, try to find an even better match
|
||||
* Only try if DLZ drivers are loaded for this view
|
||||
* Only try if a DLZ driver is loaded for this view
|
||||
*/
|
||||
if (zonelabels < namelabels &&
|
||||
!ISC_LIST_EMPTY(client->view->dlz_searched))
|
||||
{
|
||||
if (zonelabels < namelabels && client->view->dlzdatabase != NULL) {
|
||||
tresult = dns_dlzfindzone(client->view, name,
|
||||
zonelabels, &tdbp);
|
||||
/* If we successful, we found a better match. */
|
||||
|
@ -1347,7 +1347,7 @@ cache_sharable(dns_view_t *originview, dns_view_t *view,
|
||||
* Callback from DLZ configure when the driver sets up a writeable zone
|
||||
*/
|
||||
static isc_result_t
|
||||
dlzconfigure_callback(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_zone_t *zone) {
|
||||
dlzconfigure_callback(dns_view_t *view, dns_zone_t *zone) {
|
||||
dns_name_t *origin = dns_zone_getorigin(zone);
|
||||
dns_rdataclass_t zclass = view->rdclass;
|
||||
isc_result_t result;
|
||||
@ -1357,7 +1357,8 @@ dlzconfigure_callback(dns_view_t *view, dns_dlzdb_t *dlzdb, dns_zone_t *zone) {
|
||||
return (result);
|
||||
dns_zone_setstats(zone, ns_g_server->zonestats);
|
||||
|
||||
return (ns_zone_configure_writeable_dlz(dlzdb, zone, zclass, origin));
|
||||
return (ns_zone_configure_writeable_dlz(view->dlzdatabase,
|
||||
zone, zclass, origin));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
@ -1568,7 +1569,6 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
|
||||
const cfg_obj_t *forwarders;
|
||||
const cfg_obj_t *alternates;
|
||||
const cfg_obj_t *zonelist;
|
||||
const cfg_obj_t *dlzlist;
|
||||
const cfg_obj_t *dlz;
|
||||
unsigned int dlzargc;
|
||||
char **dlzargv;
|
||||
@ -1759,27 +1759,18 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
|
||||
/*
|
||||
* Create Dynamically Loadable Zone driver.
|
||||
*/
|
||||
dlzlist = NULL;
|
||||
dlz = NULL;
|
||||
if (voptions != NULL)
|
||||
(void)cfg_map_get(voptions, "dlz", &dlzlist);
|
||||
(void)cfg_map_get(voptions, "dlz", &dlz);
|
||||
else
|
||||
(void)cfg_map_get(config, "dlz", &dlzlist);
|
||||
(void)cfg_map_get(config, "dlz", &dlz);
|
||||
|
||||
for (element = cfg_list_first(dlzlist);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
obj = NULL;
|
||||
const cfg_obj_t *dlzopts;
|
||||
|
||||
dlz = cfg_listelt_value(element);
|
||||
dlzopts = cfg_tuple_get(dlz, "options");
|
||||
(void)cfg_map_get(dlzopts, "database", &obj);
|
||||
obj = NULL;
|
||||
if (dlz != NULL) {
|
||||
(void)cfg_map_get(cfg_tuple_get(dlz, "options"),
|
||||
"database", &obj);
|
||||
if (obj != NULL) {
|
||||
dns_dlzdb_t *dlzdb = NULL;
|
||||
const cfg_obj_t *name, *search = NULL;
|
||||
char *s = isc_mem_strdup(mctx, cfg_obj_asstring(obj));
|
||||
|
||||
if (s == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
@ -1791,10 +1782,10 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
name = cfg_tuple_get(dlz, "name");
|
||||
result = dns_dlzcreate(mctx, cfg_obj_asstring(name),
|
||||
obj = cfg_tuple_get(dlz, "name");
|
||||
result = dns_dlzcreate(mctx, cfg_obj_asstring(obj),
|
||||
dlzargv[0], dlzargc, dlzargv,
|
||||
&dlzdb);
|
||||
&view->dlzdatabase);
|
||||
isc_mem_free(mctx, s);
|
||||
isc_mem_put(mctx, dlzargv, dlzargc * sizeof(*dlzargv));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@ -1804,19 +1795,9 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
|
||||
* If the dlz backend supports configuration,
|
||||
* then call its configure method now.
|
||||
*/
|
||||
result = dns_dlzconfigure(view, dlzdb,
|
||||
dlzconfigure_callback);
|
||||
result = dns_dlzconfigure(view, dlzconfigure_callback);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
(void)cfg_map_get(dlzopts, "search", &search);
|
||||
if (search == NULL || cfg_obj_asboolean(search))
|
||||
ISC_LIST_APPEND(view->dlz_searched,
|
||||
dlzdb, link);
|
||||
else
|
||||
ISC_LIST_APPEND(view->dlz_unsearched,
|
||||
dlzdb, link);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3482,8 +3463,7 @@ configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
|
||||
signing = NULL;
|
||||
if ((strcasecmp(ztypestr, "master") == 0 ||
|
||||
strcasecmp(ztypestr, "slave") == 0) &&
|
||||
cfg_map_get(zoptions, "inline-signing", &signing)
|
||||
== ISC_R_SUCCESS &&
|
||||
cfg_map_get(zoptions, "inline-signing", &signing) == ISC_R_SUCCESS &&
|
||||
cfg_obj_asboolean(signing))
|
||||
{
|
||||
dns_zone_getraw(zone, &raw);
|
||||
|
@ -449,9 +449,7 @@ dlopen_dlz_closeversion(const char *zone, isc_boolean_t commit,
|
||||
* Called on startup to configure any writeable zones
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
void *driverarg, void *dbdata)
|
||||
{
|
||||
dlopen_dlz_configure(dns_view_t *view, void *driverarg, void *dbdata) {
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
@ -462,7 +460,7 @@ dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
|
||||
MAYBE_LOCK(cd);
|
||||
cd->in_configure = ISC_TRUE;
|
||||
result = cd->dlz_configure(view, dlzdb, cd->dbdata);
|
||||
result = cd->dlz_configure(view, cd->dbdata);
|
||||
cd->in_configure = ISC_FALSE;
|
||||
MAYBE_UNLOCK(cd);
|
||||
|
||||
|
@ -807,8 +807,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
|
||||
* Normal zone table does not have a match.
|
||||
* Try the DLZ database
|
||||
*/
|
||||
// Temporary: only searching the first DLZ database
|
||||
if (! ISC_LIST_EMPTY(client->view->dlz_searched)) {
|
||||
if (client->view->dlzdatabase != NULL) {
|
||||
result = dns_dlzallowzonexfr(client->view,
|
||||
question_name,
|
||||
&client->peeraddr,
|
||||
|
@ -801,11 +801,10 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
||||
isc_sockaddr_t *addrs;
|
||||
dns_name_t **keynames;
|
||||
isc_uint32_t count;
|
||||
char *cpval;
|
||||
unsigned int dbargc;
|
||||
char **dbargv;
|
||||
static char default_dbtype[] = "rbt";
|
||||
static char dlz_dbtype[] = "dlz";
|
||||
char *cpval = default_dbtype;
|
||||
isc_mem_t *mctx = dns_zone_getmctx(zone);
|
||||
dns_dialuptype_t dialup = dns_dialuptype_no;
|
||||
dns_zonetype_t ztype;
|
||||
@ -868,28 +867,12 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
||||
result = cfg_map_get(zoptions, "database", &obj);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
cpval = isc_mem_strdup(mctx, cfg_obj_asstring(obj));
|
||||
else
|
||||
cpval = default_dbtype;
|
||||
|
||||
if (cpval == NULL)
|
||||
return(ISC_R_NOMEMORY);
|
||||
|
||||
obj = NULL;
|
||||
result = cfg_map_get(zoptions, "dlz", &obj);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
const char *dlzname = cfg_obj_asstring(obj);
|
||||
size_t len;
|
||||
|
||||
if (cpval != default_dbtype) {
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
|
||||
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
||||
"zone '%s': both 'database' and 'dlz' "
|
||||
"specified", zname);
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
len = strlen(dlzname) + 5;
|
||||
cpval = isc_mem_allocate(mctx, len);
|
||||
snprintf(cpval, len, "dlz %s", dlzname);
|
||||
}
|
||||
|
||||
result = strtoargv(mctx, cpval, &dbargc, &dbargv);
|
||||
if (result != ISC_R_SUCCESS && cpval != default_dbtype) {
|
||||
isc_mem_free(mctx, cpval);
|
||||
@ -903,7 +886,7 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
||||
*/
|
||||
result = dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv);
|
||||
isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
|
||||
if (cpval != default_dbtype && cpval != dlz_dbtype)
|
||||
if (cpval != default_dbtype)
|
||||
isc_mem_free(mctx, cpval);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
@ -1,15 +0,0 @@
|
||||
|
||||
dlz one {
|
||||
database "one";
|
||||
};
|
||||
|
||||
dlz two {
|
||||
database "two";
|
||||
search no;
|
||||
};
|
||||
|
||||
zone master {
|
||||
type master;
|
||||
database "none";
|
||||
dlz two;
|
||||
};
|
@ -51,11 +51,5 @@ $CHECKCONF dnssec.3 2>&1 | grep '.*' && ret=1
|
||||
if [ $ret != 0 ]; then echo "I:failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
echo "I: checking named-checkconf DLZ warnings"
|
||||
ret=0
|
||||
$CHECKCONF dlz-bad.conf 2>&1 | grep "'dlz' and 'database'" > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo "I:failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
echo "I:exit status: $status"
|
||||
exit $status
|
||||
|
@ -7,4 +7,3 @@ rm -f ns1/update.txt
|
||||
rm -f */named.memstats
|
||||
rm -f ns1/ddns.key
|
||||
rm -f random.data
|
||||
rm -f dig.out*
|
||||
|
@ -463,7 +463,7 @@ dlz_closeversion(const char *zone, isc_boolean_t commit,
|
||||
* Configure a writeable zone
|
||||
*/
|
||||
isc_result_t
|
||||
dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata) {
|
||||
dlz_configure(dns_view_t *view, void *dbdata) {
|
||||
struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
@ -475,7 +475,7 @@ dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *dbdata) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
result = state->writeable_zone(view, dlzdb, state->zone_name);
|
||||
result = state->writeable_zone(view, state->zone_name);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
state->log(ISC_LOG_ERROR,
|
||||
"dlz_example: failed to configure zone %s",
|
||||
|
@ -70,21 +70,4 @@ done
|
||||
[ "$ret" -eq 0 ] || echo "I:failed"
|
||||
status=`expr $status + $ret`
|
||||
|
||||
echo "I:testing multiple DLZ drivers"
|
||||
test_update testdc1.alternate.nil. A "86400 A 10.53.0.10" "10.53.0.10" || ret=1
|
||||
status=`expr $status + $ret`
|
||||
|
||||
echo "I:testing AXFR from DLZ drivers"
|
||||
$DIG $DIGOPTS +noall +answer axfr example.nil > dig.out.ns1.1
|
||||
n=`cat dig.out.ns1.1 | wc -l`
|
||||
[ "$n" -eq 7 ] || ret=1
|
||||
$DIG $DIGOPTS +noall +answer axfr alternate.nil > dig.out.ns1.2
|
||||
n=`cat dig.out.ns1.2 | wc -l`
|
||||
[ "$n" -eq 5 ] || ret=1
|
||||
status=`expr $status + $ret`
|
||||
|
||||
echo "I:testing unsearched DLZ driver"
|
||||
$DIG $DIGOPTS +noall +answer ns other.nil > dig.out.ns1.3
|
||||
cat dig.out.ns1.3
|
||||
|
||||
exit $status
|
||||
|
@ -466,8 +466,7 @@ dlz_configure(dns_view_t *view, void *dbdata) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
result = state->writeable_zone(view, view->dlzdatabase,
|
||||
state->zone_name);
|
||||
result = state->writeable_zone(view, state->zone_name);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
state->log(ISC_LOG_ERROR,
|
||||
"dlz_example: failed to configure zone %s",
|
||||
|
@ -1280,7 +1280,6 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
|
||||
isc_buffer_t b;
|
||||
isc_boolean_t root = ISC_FALSE;
|
||||
const cfg_listelt_t *element;
|
||||
isc_boolean_t dlz;
|
||||
|
||||
static optionstable options[] = {
|
||||
{ "allow-query", MASTERZONE | SLAVEZONE | STUBZONE | REDIRECTZONE |
|
||||
@ -1702,24 +1701,11 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
|
||||
* require file clauses.
|
||||
*/
|
||||
obj = NULL;
|
||||
dlz = ISC_FALSE;
|
||||
tresult = cfg_map_get(zoptions, "dlz", &obj);
|
||||
if (tresult == ISC_R_SUCCESS)
|
||||
dlz = ISC_TRUE;
|
||||
|
||||
obj = NULL;
|
||||
tresult = cfg_map_get(zoptions, "database", &obj);
|
||||
if (dlz && tresult == ISC_R_SUCCESS) {
|
||||
cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR,
|
||||
"zone '%s': cannot specify both 'dlz' "
|
||||
"and 'database'", znamestr);
|
||||
result = ISC_R_FAILURE;
|
||||
} else if (!dlz &&
|
||||
(tresult == ISC_R_NOTFOUND ||
|
||||
if (tresult == ISC_R_NOTFOUND ||
|
||||
(tresult == ISC_R_SUCCESS &&
|
||||
(strcmp("rbt", cfg_obj_asstring(obj)) == 0 ||
|
||||
strcmp("rbt64", cfg_obj_asstring(obj)) == 0))))
|
||||
{
|
||||
strcmp("rbt64", cfg_obj_asstring(obj)) == 0))) {
|
||||
obj = NULL;
|
||||
tresult = cfg_map_get(zoptions, "file", &obj);
|
||||
if (tresult != ISC_R_SUCCESS &&
|
||||
|
170
lib/dns/dlz.c
170
lib/dns/dlz.c
@ -60,11 +60,10 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <dns/db.h>
|
||||
#include <dns/dlz.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/master.h>
|
||||
#include <dns/dlz.h>
|
||||
#include <dns/ssu.h>
|
||||
#include <dns/zone.h>
|
||||
|
||||
@ -114,41 +113,26 @@ isc_result_t
|
||||
dns_dlzallowzonexfr(dns_view_t *view, dns_name_t *name,
|
||||
isc_sockaddr_t *clientaddr, dns_db_t **dbp)
|
||||
{
|
||||
isc_result_t result = ISC_R_NOTFOUND;
|
||||
isc_result_t result;
|
||||
dns_dlzallowzonexfr_t allowzonexfr;
|
||||
dns_dlzdb_t *dlzdb;
|
||||
dns_dlzdb_t *dlzdatabase;
|
||||
|
||||
/*
|
||||
* Performs checks to make sure data is as we expect it to be.
|
||||
*/
|
||||
REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
|
||||
REQUIRE(name != NULL);
|
||||
REQUIRE(dbp != NULL && *dbp == NULL);
|
||||
|
||||
/*
|
||||
* Find a driver in which the zone exists and transfer is supported
|
||||
*/
|
||||
for (dlzdb = ISC_LIST_HEAD(view->dlz_searched);
|
||||
dlzdb != NULL;
|
||||
dlzdb = ISC_LIST_NEXT(dlzdb, link))
|
||||
{
|
||||
REQUIRE(DNS_DLZ_VALID(dlzdb));
|
||||
|
||||
allowzonexfr = dlzdb->implementation->methods->allowzonexfr;
|
||||
result = (*allowzonexfr)(dlzdb->implementation->driverarg,
|
||||
dlzdb->dbdata, dlzdb->mctx,
|
||||
view->rdclass, name, clientaddr, dbp);
|
||||
|
||||
/*
|
||||
* if ISC_R_NOPERM, we found the right database but
|
||||
* the zone may not transfer.
|
||||
*/
|
||||
if (result == ISC_R_SUCCESS || result == ISC_R_NOPERM)
|
||||
return (result);
|
||||
}
|
||||
/* ask driver if the zone is supported */
|
||||
dlzdatabase = view->dlzdatabase;
|
||||
allowzonexfr = dlzdatabase->implementation->methods->allowzonexfr;
|
||||
result = (*allowzonexfr)(dlzdatabase->implementation->driverarg,
|
||||
dlzdatabase->dbdata, dlzdatabase->mctx,
|
||||
view->rdclass, name, clientaddr, dbp);
|
||||
|
||||
if (result == ISC_R_NOTIMPLEMENTED)
|
||||
result = ISC_R_NOTFOUND;
|
||||
|
||||
return (ISC_R_NOTFOUND);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@ -207,9 +191,6 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername,
|
||||
|
||||
(*dbp)->implementation = impinfo;
|
||||
|
||||
if (dlzname != NULL)
|
||||
(*dbp)->dlzname = isc_mem_strdup(mctx, dlzname);
|
||||
|
||||
/* Create a new database using implementation 'drivername'. */
|
||||
result = ((impinfo->methods->create)(mctx, dlzname, argc, argv,
|
||||
impinfo->driverarg,
|
||||
@ -257,12 +238,9 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* call the drivers destroy method */
|
||||
if ((*dbp) != NULL) {
|
||||
mctx = (*dbp)->mctx;
|
||||
if ((*dbp)->dlzname != NULL)
|
||||
isc_mem_free(mctx, (*dbp)->dlzname);
|
||||
destroy = (*dbp)->implementation->methods->destroy;
|
||||
(*destroy)((*dbp)->implementation->driverarg,(*dbp)->dbdata);
|
||||
/* return memory */
|
||||
@ -275,8 +253,8 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) {
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_dlzfindzone(dns_view_t *view, dns_name_t *name,
|
||||
unsigned int minlabels, dns_db_t **dbp)
|
||||
dns_dlzfindzone(dns_view_t *view, dns_name_t *name, unsigned int minlabels,
|
||||
dns_db_t **dbp)
|
||||
{
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t *zonename;
|
||||
@ -284,13 +262,12 @@ dns_dlzfindzone(dns_view_t *view, dns_name_t *name,
|
||||
unsigned int i;
|
||||
isc_result_t result;
|
||||
dns_dlzfindzone_t findzone;
|
||||
dns_dlzdb_t *dlzdb;
|
||||
dns_db_t *db, *best = NULL;
|
||||
dns_dlzdb_t *dlzdatabase;
|
||||
|
||||
/*
|
||||
* Performs checks to make sure data is as we expect it to be.
|
||||
*/
|
||||
REQUIRE(view != NULL);
|
||||
REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
|
||||
REQUIRE(name != NULL);
|
||||
REQUIRE(dbp != NULL && *dbp == NULL);
|
||||
|
||||
@ -301,53 +278,33 @@ dns_dlzfindzone(dns_view_t *view, dns_name_t *name,
|
||||
/* count the number of labels in the name */
|
||||
namelabels = dns_name_countlabels(name);
|
||||
|
||||
for (dlzdb = ISC_LIST_HEAD(view->dlz_searched);
|
||||
dlzdb != NULL;
|
||||
dlzdb = ISC_LIST_NEXT(dlzdb, link))
|
||||
{
|
||||
REQUIRE(DNS_DLZ_VALID(dlzdb));
|
||||
/*
|
||||
* loop through starting with the longest domain name and
|
||||
* trying shorter names portions of the name until we find a
|
||||
* match, have an error, or are below the 'minlabels'
|
||||
* threshold. minlabels is 0, if the standard database didn't
|
||||
* have a zone name match. Otherwise minlabels is the number
|
||||
* of labels in that name. We need to beat that for a
|
||||
* "better" match for the DLZ database to be authoritative
|
||||
* instead of the standard database.
|
||||
*/
|
||||
for (i = namelabels; i > minlabels && i > 1; i--) {
|
||||
if (i == namelabels) {
|
||||
result = dns_name_copy(name, zonename, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
} else
|
||||
dns_name_split(name, i, NULL, zonename);
|
||||
|
||||
/*
|
||||
* loop through starting with the longest domain name and
|
||||
* trying shorter names portions of the name until we find a
|
||||
* match, have an error, or are below the 'minlabels'
|
||||
* threshold. minlabels is 0, if neither the standard
|
||||
* database nor any previous DLZ database had a zone name
|
||||
* match. Otherwise minlabels is the number of labels
|
||||
* in that name. We need to beat that for a "better"
|
||||
* match for this DLZ database to be authoritative.
|
||||
*/
|
||||
for (i = namelabels; i > minlabels && i > 1; i--) {
|
||||
if (i == namelabels) {
|
||||
result = dns_name_copy(name, zonename, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
} else
|
||||
dns_name_split(name, i, NULL, zonename);
|
||||
|
||||
/* ask SDLZ driver if the zone is supported */
|
||||
db = NULL;
|
||||
findzone = dlzdb->implementation->methods->findzone;
|
||||
result = (*findzone)(dlzdb->implementation->driverarg,
|
||||
dlzdb->dbdata, dlzdb->mctx,
|
||||
view->rdclass, zonename, &db);
|
||||
|
||||
if (result != ISC_R_NOTFOUND) {
|
||||
if (best != NULL)
|
||||
dns_db_detach(&best);
|
||||
dns_db_attach(db, &best);
|
||||
minlabels = i;
|
||||
} else if (db != NULL)
|
||||
dns_db_detach(&db);
|
||||
}
|
||||
/* ask SDLZ driver if the zone is supported */
|
||||
dlzdatabase = view->dlzdatabase;
|
||||
findzone = dlzdatabase->implementation->methods->findzone;
|
||||
result = (*findzone)(dlzdatabase->implementation->driverarg,
|
||||
dlzdatabase->dbdata, dlzdatabase->mctx,
|
||||
view->rdclass, zonename, dbp);
|
||||
if (result != ISC_R_NOTFOUND)
|
||||
return (result);
|
||||
}
|
||||
|
||||
if (best != NULL) {
|
||||
dns_db_attach(best, dbp);
|
||||
dns_db_detach(&best);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
return (ISC_R_NOTFOUND);
|
||||
}
|
||||
|
||||
@ -571,19 +528,20 @@ dns_dlzunregister(dns_dlzimplementation_t **dlzimp) {
|
||||
* specific functionality on the zone
|
||||
*/
|
||||
isc_result_t
|
||||
dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
const char *zone_name)
|
||||
{
|
||||
dns_dlz_writeablezone(dns_view_t *view, const char *zone_name) {
|
||||
dns_zone_t *zone = NULL;
|
||||
dns_zone_t *dupzone = NULL;
|
||||
isc_result_t result;
|
||||
isc_buffer_t buffer;
|
||||
dns_fixedname_t fixorigin;
|
||||
dns_name_t *origin;
|
||||
dns_dlzdb_t *dlzdatabase;
|
||||
|
||||
REQUIRE(DNS_DLZ_VALID(dlzdb));
|
||||
REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
|
||||
|
||||
REQUIRE(dlzdb->configure_callback != NULL);
|
||||
dlzdatabase = view->dlzdatabase;
|
||||
|
||||
REQUIRE(dlzdatabase->configure_callback != NULL);
|
||||
|
||||
isc_buffer_init(&buffer, zone_name, strlen(zone_name));
|
||||
isc_buffer_add(&buffer, strlen(zone_name));
|
||||
@ -614,15 +572,16 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
|
||||
dns_zone_setadded(zone, ISC_TRUE);
|
||||
|
||||
if (dlzdb->ssutable == NULL) {
|
||||
result = dns_ssutable_createdlz(dlzdb->mctx,
|
||||
&dlzdb->ssutable, dlzdb);
|
||||
if (dlzdatabase->ssutable == NULL) {
|
||||
result = dns_ssutable_createdlz(dlzdatabase->mctx,
|
||||
&dlzdatabase->ssutable,
|
||||
view->dlzdatabase);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
}
|
||||
dns_zone_setssutable(zone, dlzdb->ssutable);
|
||||
dns_zone_setssutable(zone, dlzdatabase->ssutable);
|
||||
|
||||
result = dlzdb->configure_callback(view, dlzdb, zone);
|
||||
result = dlzdatabase->configure_callback(view, zone);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
@ -644,31 +603,34 @@ dns_dlz_writeablezone(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
* the backend an opportunity to configure parameters related to DLZ.
|
||||
*/
|
||||
isc_result_t
|
||||
dns_dlzconfigure(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
dlzconfigure_callback_t callback)
|
||||
dns_dlzconfigure(dns_view_t *view, isc_result_t (*callback)(dns_view_t *,
|
||||
dns_zone_t *))
|
||||
{
|
||||
dns_dlzimplementation_t *impl;
|
||||
dns_dlzdb_t *dlzdatabase;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(DNS_DLZ_VALID(dlzdb));
|
||||
REQUIRE(dlzdb->implementation != NULL);
|
||||
REQUIRE(view != NULL);
|
||||
REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
|
||||
REQUIRE(view->dlzdatabase->implementation != NULL);
|
||||
|
||||
impl = dlzdb->implementation;
|
||||
dlzdatabase = view->dlzdatabase;
|
||||
impl = dlzdatabase->implementation;
|
||||
|
||||
if (impl->methods->configure == NULL)
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
dlzdb->configure_callback = callback;
|
||||
dlzdatabase->configure_callback = callback;
|
||||
|
||||
result = impl->methods->configure(impl->driverarg, dlzdb->dbdata,
|
||||
view, dlzdb);
|
||||
result = impl->methods->configure(impl->driverarg,
|
||||
dlzdatabase->dbdata, view);
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
dns_dlz_ssumatch(dns_dlzdb_t *dlzdatabase, dns_name_t *signer,
|
||||
dns_name_t *name, isc_netaddr_t *tcpaddr,
|
||||
dns_rdatatype_t type, const dst_key_t *key)
|
||||
dns_dlz_ssumatch(dns_dlzdb_t *dlzdatabase,
|
||||
dns_name_t *signer, dns_name_t *name, isc_netaddr_t *tcpaddr,
|
||||
dns_rdatatype_t type, const dst_key_t *key)
|
||||
{
|
||||
dns_dlzimplementation_t *impl;
|
||||
isc_boolean_t r;
|
||||
|
@ -169,8 +169,7 @@ typedef isc_result_t
|
||||
|
||||
|
||||
typedef isc_result_t
|
||||
(*dns_dlzconfigure_t)(void *driverarg, void *dbdata,
|
||||
dns_view_t *view, dns_dlzdb_t *dlzdb);
|
||||
(*dns_dlzconfigure_t)(void *driverarg, void *dbdata, dns_view_t *view);
|
||||
/*%<
|
||||
* Method prototype. Drivers implementing the DLZ interface may
|
||||
* optionally supply a configure method. If supplied, this will be
|
||||
@ -210,8 +209,7 @@ struct dns_dlzimplementation {
|
||||
ISC_LINK(dns_dlzimplementation_t) link;
|
||||
};
|
||||
|
||||
typedef isc_result_t (*dlzconfigure_callback_t)(dns_view_t *, dns_dlzdb_t *,
|
||||
dns_zone_t *);
|
||||
typedef isc_result_t (*dlzconfigure_callback_t)(dns_view_t *, dns_zone_t *);
|
||||
|
||||
/*% An instance of a DLZ driver */
|
||||
struct dns_dlzdb {
|
||||
@ -220,8 +218,6 @@ struct dns_dlzdb {
|
||||
dns_dlzimplementation_t *implementation;
|
||||
void *dbdata;
|
||||
dlzconfigure_callback_t configure_callback;
|
||||
char *dlzname;
|
||||
ISC_LINK(dns_dlzdb_t) link;
|
||||
#ifdef BIND9
|
||||
dns_ssutable_t *ssutable;
|
||||
#endif
|
||||
@ -323,7 +319,6 @@ dns_dlzunregister(dns_dlzimplementation_t **dlzimp);
|
||||
|
||||
|
||||
typedef isc_result_t dns_dlz_writeablezone_t(dns_view_t *view,
|
||||
dns_dlzdb_t *dlzdb,
|
||||
const char *zone_name);
|
||||
dns_dlz_writeablezone_t dns_dlz_writeablezone;
|
||||
/*%<
|
||||
@ -333,8 +328,7 @@ dns_dlz_writeablezone_t dns_dlz_writeablezone;
|
||||
|
||||
|
||||
isc_result_t
|
||||
dns_dlzconfigure(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
dlzconfigure_callback_t callback);
|
||||
dns_dlzconfigure(dns_view_t *view, dlzconfigure_callback_t callback);
|
||||
/*%<
|
||||
* call a DLZ drivers configure method, if supplied
|
||||
*/
|
||||
|
@ -115,7 +115,6 @@ typedef void dlz_dlopen_closeversion_t (const char *zone,
|
||||
* want to support dynamic updates
|
||||
*/
|
||||
typedef isc_result_t dlz_dlopen_configure_t (dns_view_t *view,
|
||||
dns_dlzdb_t *dlzdb,
|
||||
void *dbdata);
|
||||
|
||||
/*
|
||||
|
@ -227,9 +227,8 @@ typedef void (*dns_sdlzcloseversion_t)(const char *zone, isc_boolean_t commit,
|
||||
* If the call is successful then *versionp should be set to NULL
|
||||
*/
|
||||
|
||||
typedef isc_result_t (*dns_sdlzconfigure_t)(dns_view_t *view,
|
||||
dns_dlzdb_t *dlzdb,
|
||||
void *driverarg, void *dbdata);
|
||||
typedef isc_result_t (*dns_sdlzconfigure_t)(dns_view_t *view, void *driverarg,
|
||||
void *dbdata);
|
||||
/*%<
|
||||
* Method prototype. Drivers implementing the SDLZ interface may
|
||||
* supply a configure method. When supplied, it will be called
|
||||
|
@ -60,7 +60,6 @@ typedef struct dns_dbtable dns_dbtable_t;
|
||||
typedef void dns_dbversion_t;
|
||||
typedef struct dns_dlzimplementation dns_dlzimplementation_t;
|
||||
typedef struct dns_dlzdb dns_dlzdb_t;
|
||||
typedef ISC_LIST(dns_dlzdb_t) dns_dlzdblist_t;
|
||||
typedef struct dns_sdlzimplementation dns_sdlzimplementation_t;
|
||||
typedef struct dns_decompress dns_decompress_t;
|
||||
typedef struct dns_dispatch dns_dispatch_t;
|
||||
|
@ -87,6 +87,7 @@ struct dns_view {
|
||||
dns_rdataclass_t rdclass;
|
||||
char * name;
|
||||
dns_zt_t * zonetable;
|
||||
dns_dlzdb_t * dlzdatabase;
|
||||
dns_resolver_t * resolver;
|
||||
dns_adb_t * adb;
|
||||
dns_requestmgr_t * requestmgr;
|
||||
@ -161,8 +162,6 @@ struct dns_view {
|
||||
dns_dns64list_t dns64;
|
||||
unsigned int dns64cnt;
|
||||
ISC_LIST(dns_rpz_zone_t) rpz_zones;
|
||||
dns_dlzdblist_t dlz_searched;
|
||||
dns_dlzdblist_t dlz_unsearched;
|
||||
|
||||
/*
|
||||
* Configurable data for server use only,
|
||||
|
@ -1672,8 +1672,7 @@ dns_sdlzfindzone(void *driverarg, void *dbdata, isc_mem_t *mctx,
|
||||
|
||||
|
||||
static isc_result_t
|
||||
dns_sdlzconfigure(void *driverarg, void *dbdata,
|
||||
dns_view_t *view, dns_dlzdb_t *dlzdb)
|
||||
dns_sdlzconfigure(void *driverarg, void *dbdata, dns_view_t *view)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_sdlzimplementation_t *imp;
|
||||
@ -1685,8 +1684,7 @@ dns_sdlzconfigure(void *driverarg, void *dbdata,
|
||||
/* Call SDLZ driver's configure method */
|
||||
if (imp->methods->configure != NULL) {
|
||||
MAYBE_LOCK(imp);
|
||||
result = imp->methods->configure(view, dlzdb,
|
||||
imp->driverarg, dbdata);
|
||||
result = imp->methods->configure(view, imp->driverarg, dbdata);
|
||||
MAYBE_UNLOCK(imp);
|
||||
} else {
|
||||
result = ISC_R_SUCCESS;
|
||||
|
@ -120,8 +120,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
view->acache = NULL;
|
||||
view->cache = NULL;
|
||||
view->cachedb = NULL;
|
||||
ISC_LIST_INIT(view->dlz_searched);
|
||||
ISC_LIST_INIT(view->dlz_unsearched);
|
||||
view->dlzdatabase = NULL;
|
||||
view->hints = NULL;
|
||||
view->resolver = NULL;
|
||||
view->adb = NULL;
|
||||
@ -268,7 +267,6 @@ static inline void
|
||||
destroy(dns_view_t *view) {
|
||||
#ifdef BIND9
|
||||
dns_dns64_t *dns64;
|
||||
dns_dlzdb_t *dlzdb;
|
||||
#endif
|
||||
|
||||
REQUIRE(!ISC_LINK_LINKED(view, link));
|
||||
@ -330,23 +328,9 @@ destroy(dns_view_t *view) {
|
||||
dns_acache_detach(&view->acache);
|
||||
}
|
||||
dns_rpz_view_destroy(view);
|
||||
for (dlzdb = ISC_LIST_HEAD(view->dlz_searched);
|
||||
dlzdb != NULL;
|
||||
dlzdb = ISC_LIST_HEAD(view->dlz_searched)) {
|
||||
ISC_LIST_UNLINK(view->dlz_searched, dlzdb, link);
|
||||
dns_dlzdestroy(&dlzdb);
|
||||
}
|
||||
for (dlzdb = ISC_LIST_HEAD(view->dlz_unsearched);
|
||||
dlzdb != NULL;
|
||||
dlzdb = ISC_LIST_HEAD(view->dlz_unsearched)) {
|
||||
ISC_LIST_UNLINK(view->dlz_unsearched, dlzdb, link);
|
||||
dns_dlzdestroy(&dlzdb);
|
||||
}
|
||||
#else
|
||||
INSIST(view->acache == NULL);
|
||||
INSIST(ISC_LIST_EMPTY(view->rpz_zones));
|
||||
INSIST(ISC_LIST_EMPTY(view->dlz_searched));
|
||||
INSIST(ISC_LIST_EMPTY(view->dlz_unsearched));
|
||||
#endif
|
||||
if (view->requestmgr != NULL)
|
||||
dns_requestmgr_detach(&view->requestmgr);
|
||||
@ -354,6 +338,8 @@ destroy(dns_view_t *view) {
|
||||
isc_task_detach(&view->task);
|
||||
if (view->hints != NULL)
|
||||
dns_db_detach(&view->hints);
|
||||
if (view->dlzdatabase != NULL)
|
||||
dns_dlzdestroy(&view->dlzdatabase);
|
||||
if (view->cachedb != NULL)
|
||||
dns_db_detach(&view->cachedb);
|
||||
if (view->cache != NULL)
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include <dns/callbacks.h>
|
||||
#include <dns/db.h>
|
||||
#include <dns/dbiterator.h>
|
||||
#include <dns/dlz.h>
|
||||
#include <dns/dnssec.h>
|
||||
#include <dns/events.h>
|
||||
#include <dns/journal.h>
|
||||
@ -1617,46 +1616,6 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Zones associated with a DLZ don't need to be loaded either,
|
||||
* but we need to associate the database with the zone object.
|
||||
*/
|
||||
if (strcmp(zone->db_argv[0], "dlz") == 0) {
|
||||
dns_dlzdb_t *dlzdb;
|
||||
dns_db_t *db = NULL;
|
||||
dns_dlzfindzone_t findzone;
|
||||
|
||||
for (dlzdb = ISC_LIST_HEAD(zone->view->dlz_searched);
|
||||
dlzdb != NULL;
|
||||
dlzdb = ISC_LIST_NEXT(dlzdb, link))
|
||||
{
|
||||
INSIST(DNS_DLZ_VALID(dlzdb));
|
||||
if (strcmp(zone->db_argv[1], dlzdb->dlzname) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (dlzdb == NULL) {
|
||||
result = ISC_R_NOTFOUND;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_write);
|
||||
/* ask SDLZ driver if the zone is supported */
|
||||
findzone = dlzdb->implementation->methods->findzone;
|
||||
result = (*findzone)(dlzdb->implementation->driverarg,
|
||||
dlzdb->dbdata, dlzdb->mctx,
|
||||
zone->view->rdclass, &zone->origin, &db);
|
||||
if (result != ISC_R_NOTFOUND) {
|
||||
if (zone->db != NULL)
|
||||
zone_detachdb(zone);
|
||||
zone_attachdb(zone, db);
|
||||
dns_db_detach(&db);
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_write);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((zone->type == dns_zone_slave || zone->type == dns_zone_stub ||
|
||||
(zone->type == dns_zone_redirect && zone->masters != NULL)) &&
|
||||
rbt) {
|
||||
|
@ -130,7 +130,6 @@ static cfg_type_t cfg_type_v4_aaaa;
|
||||
static cfg_clausedef_t
|
||||
dynamically_loadable_zones_clauses[] = {
|
||||
{ "database", &cfg_type_astring, 0 },
|
||||
{ "search", &cfg_type_boolean, 0 },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
@ -870,7 +869,8 @@ static cfg_clausedef_t
|
||||
namedconf_or_view_clauses[] = {
|
||||
{ "key", &cfg_type_key, CFG_CLAUSEFLAG_MULTI },
|
||||
{ "zone", &cfg_type_zone, CFG_CLAUSEFLAG_MULTI },
|
||||
{ "dlz", &cfg_type_dynamically_loadable_zones, CFG_CLAUSEFLAG_MULTI },
|
||||
/* only 1 DLZ per view allowed */
|
||||
{ "dlz", &cfg_type_dynamically_loadable_zones, 0 },
|
||||
{ "server", &cfg_type_server, CFG_CLAUSEFLAG_MULTI },
|
||||
{ "trusted-keys", &cfg_type_dnsseckeys, CFG_CLAUSEFLAG_MULTI },
|
||||
{ "managed-keys", &cfg_type_managedkeys, CFG_CLAUSEFLAG_MULTI },
|
||||
@ -1430,7 +1430,6 @@ zone_only_clauses[] = {
|
||||
CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_OBSOLETE },
|
||||
{ "update-policy", &cfg_type_updatepolicy, 0 },
|
||||
{ "database", &cfg_type_astring, 0 },
|
||||
{ "dlz", &cfg_type_astring, 0 },
|
||||
{ "delegation-only", &cfg_type_boolean, 0 },
|
||||
/*
|
||||
* Note that the format of the check-names option is different between
|
||||
|
Loading…
x
Reference in New Issue
Block a user