mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
Allow master zones to not have a 'file' option, to support non-rbt
databases. Zones with a nonpersistent database and no 'file' option will get an error logged at load time.
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: zoneconf.c,v 1.70 2000/11/18 00:57:23 gson Exp $ */
|
/* $Id: zoneconf.c,v 1.71 2000/11/18 02:54:22 gson Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -207,11 +207,9 @@ dns_zone_configure(dns_c_ctx_t *cctx, dns_c_view_t *cview,
|
|||||||
isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
|
isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
|
||||||
|
|
||||||
result = dns_c_zone_getfile(czone, &filename);
|
result = dns_c_zone_getfile(czone, &filename);
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
RETERR(dns_zone_setfile(zone, filename));
|
filename = NULL;
|
||||||
else if (czone->ztype != dns_c_zone_slave &&
|
RETERR(dns_zone_setfile(zone, filename));
|
||||||
czone->ztype != dns_c_zone_stub)
|
|
||||||
return (result);
|
|
||||||
|
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
result = dns_c_zone_getchecknames(czone, &severity);
|
result = dns_c_zone_getchecknames(czone, &severity);
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: zone.h,v 1.90 2000/11/18 00:57:22 gson Exp $ */
|
/* $Id: zone.h,v 1.91 2000/11/18 02:54:19 gson Exp $ */
|
||||||
|
|
||||||
#ifndef DNS_ZONE_H
|
#ifndef DNS_ZONE_H
|
||||||
#define DNS_ZONE_H 1
|
#define DNS_ZONE_H 1
|
||||||
@@ -186,14 +186,14 @@ isc_result_t
|
|||||||
dns_zone_setfile(dns_zone_t *zone, const char *file);
|
dns_zone_setfile(dns_zone_t *zone, const char *file);
|
||||||
/*
|
/*
|
||||||
* Sets the name of the master file from which the zone
|
* Sets the name of the master file from which the zone
|
||||||
* loads its database.
|
* loads its database to 'file'. For zones that have
|
||||||
|
* no associated master file, 'file' will be NULL.
|
||||||
*
|
*
|
||||||
* For zones with persistent databases, the file name
|
* For zones with persistent databases, the file name
|
||||||
* is ignored.
|
* setting is ignored.
|
||||||
*
|
*
|
||||||
* Require:
|
* Require:
|
||||||
* 'zone' to be a valid zone.
|
* 'zone' to be a valid zone.
|
||||||
* 'file' to be non-NULL.
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* ISC_R_NOMEMORY
|
* ISC_R_NOMEMORY
|
||||||
@@ -843,11 +843,11 @@ dns_zone_setjournal(dns_zone_t *zone, const char *journal);
|
|||||||
/*
|
/*
|
||||||
* Sets the filename used for journaling updates / IXFR transfers.
|
* Sets the filename used for journaling updates / IXFR transfers.
|
||||||
* The default journal name is set by dns_zone_setfile() to be
|
* The default journal name is set by dns_zone_setfile() to be
|
||||||
* "file.jnl".
|
* "file.jnl". If 'journal' is NULL, the zone will have no
|
||||||
|
* journal name.
|
||||||
*
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
* 'zone' to be a valid zone.
|
* 'zone' to be a valid zone.
|
||||||
* 'journal' to be non-NULL.
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* ISC_R_SUCCESS
|
* ISC_R_SUCCESS
|
||||||
@@ -858,7 +858,7 @@ char *
|
|||||||
dns_zone_getjournal(dns_zone_t *zone);
|
dns_zone_getjournal(dns_zone_t *zone);
|
||||||
/*
|
/*
|
||||||
* Returns the journal name associated with this zone.
|
* Returns the journal name associated with this zone.
|
||||||
* If not journal has been set this will be NULL.
|
* If no journal has been set this will be NULL.
|
||||||
*
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
* 'zone' to be valid initialised zone.
|
* 'zone' to be valid initialised zone.
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: zone.c,v 1.254 2000/11/18 00:57:20 gson Exp $ */
|
/* $Id: zone.c,v 1.255 2000/11/18 02:54:18 gson Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -759,22 +759,37 @@ dns_zone_setorigin(dns_zone_t *zone, dns_name_t *origin) {
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static isc_result_t
|
||||||
|
dns_zone_setstring(dns_zone_t *zone, char **field, const char *value) {
|
||||||
|
char *copy;
|
||||||
|
if (value != NULL) {
|
||||||
|
copy = isc_mem_strdup(zone->mctx, value);
|
||||||
|
if (copy == NULL)
|
||||||
|
return (ISC_R_NOMEMORY);
|
||||||
|
} else {
|
||||||
|
copy = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*field != NULL)
|
||||||
|
isc_mem_free(zone->mctx, *field);
|
||||||
|
|
||||||
|
*field = copy;
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_zone_setfile(dns_zone_t *zone, const char *file) {
|
dns_zone_setfile(dns_zone_t *zone, const char *file) {
|
||||||
isc_result_t result = ISC_R_SUCCESS;
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
|
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
REQUIRE(file != NULL);
|
|
||||||
|
|
||||||
LOCK(&zone->lock);
|
LOCK(&zone->lock);
|
||||||
if (zone->masterfile != NULL)
|
result = dns_zone_setstring(zone, &zone->masterfile, file);
|
||||||
isc_mem_free(zone->mctx, zone->masterfile);
|
if (result == ISC_R_SUCCESS)
|
||||||
zone->masterfile = isc_mem_strdup(zone->mctx, file);
|
|
||||||
if (zone->masterfile == NULL)
|
|
||||||
result = ISC_R_NOMEMORY;
|
|
||||||
else
|
|
||||||
result = default_journal(zone);
|
result = default_journal(zone);
|
||||||
UNLOCK(&zone->lock);
|
UNLOCK(&zone->lock);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,20 +802,26 @@ dns_zone_getfile(dns_zone_t *zone) {
|
|||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
default_journal(dns_zone_t *zone) {
|
default_journal(dns_zone_t *zone) {
|
||||||
int len;
|
isc_result_t result;
|
||||||
|
char *journal;
|
||||||
|
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
REQUIRE(zone->masterfile != NULL);
|
|
||||||
|
|
||||||
if (zone->journal != NULL)
|
if (zone->masterfile != NULL) {
|
||||||
isc_mem_free(zone->mctx, zone->journal);
|
/* Calculate string length including '\0'. */
|
||||||
len = strlen(zone->masterfile) + sizeof ".jnl"; /* includes '\0' */
|
int len = strlen(zone->masterfile) + sizeof ".jnl";
|
||||||
zone->journal = isc_mem_allocate(zone->mctx, len);
|
journal = isc_mem_allocate(zone->mctx, len);
|
||||||
if (zone->journal == NULL)
|
if (journal == NULL)
|
||||||
return (ISC_R_NOMEMORY);
|
return (ISC_R_NOMEMORY);
|
||||||
strcpy(zone->journal, zone->masterfile);
|
strcpy(journal, zone->masterfile);
|
||||||
strcat(zone->journal, ".jnl");
|
strcat(journal, ".jnl");
|
||||||
return (ISC_R_SUCCESS);
|
} else {
|
||||||
|
journal = NULL;
|
||||||
|
}
|
||||||
|
result = dns_zone_setstring(zone, &zone->journal, journal);
|
||||||
|
if (journal != NULL)
|
||||||
|
isc_mem_free(zone->mctx, journal);
|
||||||
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
@@ -808,15 +829,11 @@ dns_zone_setjournal(dns_zone_t *zone, const char *journal) {
|
|||||||
isc_result_t result = ISC_R_SUCCESS;
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
|
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
REQUIRE(journal != NULL);
|
|
||||||
|
|
||||||
LOCK(&zone->lock);
|
LOCK(&zone->lock);
|
||||||
if (zone->journal != NULL)
|
result = dns_zone_setstring(zone, &zone->journal, journal);
|
||||||
isc_mem_free(zone->mctx, zone->journal);
|
|
||||||
zone->journal = isc_mem_strdup(zone->mctx, journal);
|
|
||||||
if (zone->journal == NULL)
|
|
||||||
result = ISC_R_NOMEMORY;
|
|
||||||
UNLOCK(&zone->lock);
|
UNLOCK(&zone->lock);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -842,10 +859,14 @@ dns_zone_load(dns_zone_t *zone) {
|
|||||||
|
|
||||||
INSIST(zone->type != dns_zone_none);
|
INSIST(zone->type != dns_zone_none);
|
||||||
|
|
||||||
if (zone->masterfile == NULL) {
|
if (zone->db != NULL && zone->masterfile == NULL) {
|
||||||
/*
|
/*
|
||||||
* The zone has no master file (maybe it is the built-in
|
* The zone has no master file configured, but it already
|
||||||
* version.bind. CH zone). Do nothing.
|
* has a database. It could be the built-in
|
||||||
|
* version.bind. CH zone, a zone with a persistent
|
||||||
|
* database being reloaded, or maybe a zone that
|
||||||
|
* used to have a master file but whose configuration
|
||||||
|
* was changed so that it no longer has one. Do nothing.
|
||||||
*/
|
*/
|
||||||
result = ISC_R_SUCCESS;
|
result = ISC_R_SUCCESS;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -858,13 +879,14 @@ dns_zone_load(dns_zone_t *zone) {
|
|||||||
* than the last time the zone was loaded. If the zone has not
|
* than the last time the zone was loaded. If the zone has not
|
||||||
* been loaded yet, zone->loadtime will be the epoch.
|
* been loaded yet, zone->loadtime will be the epoch.
|
||||||
*/
|
*/
|
||||||
if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_HASINCLUDE)) {
|
if (zone->masterfile != NULL &&
|
||||||
|
! DNS_ZONE_FLAG(zone, DNS_ZONEFLG_HASINCLUDE)) {
|
||||||
result = isc_file_getmodtime(zone->masterfile, &filetime);
|
result = isc_file_getmodtime(zone->masterfile, &filetime);
|
||||||
if (result == ISC_R_SUCCESS &&
|
if (result == ISC_R_SUCCESS &&
|
||||||
!isc_time_isepoch(&zone->loadtime) &&
|
!isc_time_isepoch(&zone->loadtime) &&
|
||||||
isc_time_compare(&filetime, &zone->loadtime) < 0) {
|
isc_time_compare(&filetime, &zone->loadtime) < 0) {
|
||||||
zone_log(zone, me, ISC_LOG_DEBUG(1),
|
zone_log(zone, me, ISC_LOG_DEBUG(1),
|
||||||
"skipping: database file older"
|
"skipping: master file older"
|
||||||
" than last load");
|
" than last load");
|
||||||
result = ISC_R_SUCCESS;
|
result = ISC_R_SUCCESS;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -895,8 +917,16 @@ dns_zone_load(dns_zone_t *zone) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dns_db_ispersistent(db))
|
if (! dns_db_ispersistent(db)) {
|
||||||
result = zone_startload(db, zone, loadtime);
|
if (zone->masterfile != NULL) {
|
||||||
|
result = zone_startload(db, zone, loadtime);
|
||||||
|
} else {
|
||||||
|
if (zone->type == dns_zone_master) {
|
||||||
|
zone_log(zone, me, ISC_LOG_ERROR,
|
||||||
|
"no master file configured");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result == DNS_R_CONTINUE) {
|
if (result == DNS_R_CONTINUE) {
|
||||||
zone->flags |= DNS_ZONEFLG_LOADING;
|
zone->flags |= DNS_ZONEFLG_LOADING;
|
||||||
@@ -1015,7 +1045,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
|
|||||||
zone->type == dns_zone_stub) {
|
zone->type == dns_zone_stub) {
|
||||||
if (result == ISC_R_FILENOTFOUND)
|
if (result == ISC_R_FILENOTFOUND)
|
||||||
zone_log(zone, me, ISC_LOG_INFO,
|
zone_log(zone, me, ISC_LOG_INFO,
|
||||||
"no database file");
|
"no master file");
|
||||||
else
|
else
|
||||||
zone_log(zone, me, ISC_LOG_ERROR,
|
zone_log(zone, me, ISC_LOG_ERROR,
|
||||||
"loading master file %s: %s",
|
"loading master file %s: %s",
|
||||||
|
Reference in New Issue
Block a user