2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

support slave zones

This commit is contained in:
Andreas Gustafsson 1999-08-27 18:30:00 +00:00
parent b0a1546de9
commit 0818d0a764
3 changed files with 58 additions and 13 deletions

View File

@ -34,7 +34,9 @@ typedef struct ns_query ns_query_t;
typedef struct ns_dbinfo { typedef struct ns_dbinfo {
char * path; char * path;
char * origin; char * origin;
char * master; /* Dotted quad, or NULL */
isc_boolean_t iscache; isc_boolean_t iscache;
isc_boolean_t isslave;
dns_view_t * view; dns_view_t * view;
dns_db_t * db; dns_db_t * db;
ISC_LINK(struct ns_dbinfo) link; ISC_LINK(struct ns_dbinfo) link;

View File

@ -65,7 +65,7 @@ usage(void) {
static void static void
parse_command_line(int argc, char *argv[]) { parse_command_line(int argc, char *argv[]) {
char *origintext; char *argtext, *mastertext, *origintext;
int ch; int ch;
ns_dbinfo_t *dbi; ns_dbinfo_t *dbi;
@ -77,9 +77,15 @@ parse_command_line(int argc, char *argv[]) {
dbi = isc_mem_get(ns_g_mctx, sizeof *dbi); dbi = isc_mem_get(ns_g_mctx, sizeof *dbi);
if (dbi == NULL) if (dbi == NULL)
early_fatal("creating cache info failed"); early_fatal("creating cache info failed");
dbi->path = optarg; dbi->path = isc_mem_strdup(ns_g_mctx, optarg);
dbi->origin = "."; if (dbi->path == NULL)
early_fatal("out of memory");
dbi->origin = isc_mem_strdup(ns_g_mctx, ".");
if (dbi->origin == NULL)
early_fatal("out of memory");
dbi->master = NULL;
dbi->iscache = ISC_TRUE; dbi->iscache = ISC_TRUE;
dbi->isslave = ISC_FALSE;
dbi->view = NULL; dbi->view = NULL;
dbi->db = NULL; dbi->db = NULL;
ISC_LINK_INIT(dbi, link); ISC_LINK_INIT(dbi, link);
@ -96,19 +102,43 @@ parse_command_line(int argc, char *argv[]) {
break; break;
case 'z': case 'z':
/* XXXRTH temporary syntax */ /* XXXRTH temporary syntax */
origintext = strrchr(optarg, '/');
if (origintext == NULL)
origintext = optarg;
else
origintext++; /* Skip '/'. */
dbi = isc_mem_get(ns_g_mctx, sizeof *dbi); dbi = isc_mem_get(ns_g_mctx, sizeof *dbi);
if (dbi == NULL) if (dbi == NULL)
early_fatal("creating zone info failed"); early_fatal("creating zone info failed");
dbi->path = optarg; argtext = isc_mem_strdup(ns_g_mctx, optarg);
dbi->origin = origintext; if (argtext == NULL)
dbi->iscache = ISC_FALSE; early_fatal("out of memory");
mastertext = strrchr(argtext, '@');
if (mastertext == NULL) {
dbi->master = NULL;
dbi->isslave = ISC_FALSE;
} else {
*mastertext++ = '\0';
dbi->master = isc_mem_strdup(ns_g_mctx,
mastertext);
if (dbi->master == NULL)
early_fatal("out of memory");
RUNTIME_CHECK(dbi->master != NULL);
dbi->isslave = ISC_TRUE;
}
origintext = strrchr(argtext, '/');
if (origintext == NULL)
origintext = argtext;
else
origintext++; /* Skip '/'. */
dbi->path = isc_mem_strdup(ns_g_mctx, argtext);
if (dbi->path == NULL)
early_fatal("out of memory");
dbi->origin = isc_mem_strdup(ns_g_mctx, origintext);
if (dbi->origin == NULL)
early_fatal("out of memory");
dbi->view = NULL; dbi->view = NULL;
dbi->db = NULL; dbi->db = NULL;
dbi->iscache = ISC_FALSE;
isc_mem_free(ns_g_mctx, argtext);
ISC_LINK_INIT(dbi, link); ISC_LINK_INIT(dbi, link);
ISC_LIST_APPEND(ns_g_dbs, dbi, link); ISC_LIST_APPEND(ns_g_dbs, dbi, link);
break; break;

View File

@ -52,6 +52,7 @@
#include <named/types.h> #include <named/types.h>
#include <named/globals.h> #include <named/globals.h>
#include <named/server.h> #include <named/server.h>
#include <named/xfrin.h>
#include "../../isc/util.h" /* XXXRTH */ #include "../../isc/util.h" /* XXXRTH */
@ -102,8 +103,15 @@ load(ns_dbinfo_t *dbi, char *view_name) {
printf("loading %s (%s)\n", dbi->path, dbi->origin); printf("loading %s (%s)\n", dbi->path, dbi->origin);
result = dns_db_load(dbi->db, dbi->path); result = dns_db_load(dbi->db, dbi->path);
if (result != DNS_R_SUCCESS) if (result != DNS_R_SUCCESS) {
goto db_detach; if (dbi->isslave) {
/* Ignore the error, just leave dbi->db == NULL. */
dns_db_detach(&dbi->db);
return (DNS_R_SUCCESS);
} else {
goto db_detach;
}
}
printf("loaded\n"); printf("loaded\n");
printf("journal rollforward\n"); printf("journal rollforward\n");
@ -252,6 +260,10 @@ unload_all(void) {
dns_db_detach(&dbi->db); dns_db_detach(&dbi->db);
dns_view_detach(&dbi->view); dns_view_detach(&dbi->view);
} }
isc_mem_free(ns_g_mctx, dbi->path);
isc_mem_free(ns_g_mctx, dbi->origin);
if (dbi->master != NULL)
isc_mem_free(ns_g_mctx, dbi->master);
ISC_LIST_UNLINK(ns_g_dbs, dbi, link); ISC_LIST_UNLINK(ns_g_dbs, dbi, link);
isc_mem_put(ns_g_mctx, dbi, sizeof *dbi); isc_mem_put(ns_g_mctx, dbi, sizeof *dbi);
} }
@ -280,6 +292,7 @@ load_configuration(void) {
} }
ns_interfacemgr_scan(ns_g_interfacemgr); ns_interfacemgr_scan(ns_g_interfacemgr);
xfrin_test();
} }
static void static void