mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 21:47:59 +00:00
support slave zones
This commit is contained in:
parent
b0a1546de9
commit
0818d0a764
@ -34,7 +34,9 @@ typedef struct ns_query ns_query_t;
|
||||
typedef struct ns_dbinfo {
|
||||
char * path;
|
||||
char * origin;
|
||||
char * master; /* Dotted quad, or NULL */
|
||||
isc_boolean_t iscache;
|
||||
isc_boolean_t isslave;
|
||||
dns_view_t * view;
|
||||
dns_db_t * db;
|
||||
ISC_LINK(struct ns_dbinfo) link;
|
||||
|
@ -65,7 +65,7 @@ usage(void) {
|
||||
|
||||
static void
|
||||
parse_command_line(int argc, char *argv[]) {
|
||||
char *origintext;
|
||||
char *argtext, *mastertext, *origintext;
|
||||
int ch;
|
||||
ns_dbinfo_t *dbi;
|
||||
|
||||
@ -77,9 +77,15 @@ parse_command_line(int argc, char *argv[]) {
|
||||
dbi = isc_mem_get(ns_g_mctx, sizeof *dbi);
|
||||
if (dbi == NULL)
|
||||
early_fatal("creating cache info failed");
|
||||
dbi->path = optarg;
|
||||
dbi->origin = ".";
|
||||
dbi->path = isc_mem_strdup(ns_g_mctx, optarg);
|
||||
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->isslave = ISC_FALSE;
|
||||
dbi->view = NULL;
|
||||
dbi->db = NULL;
|
||||
ISC_LINK_INIT(dbi, link);
|
||||
@ -96,19 +102,43 @@ parse_command_line(int argc, char *argv[]) {
|
||||
break;
|
||||
case 'z':
|
||||
/* XXXRTH temporary syntax */
|
||||
origintext = strrchr(optarg, '/');
|
||||
if (origintext == NULL)
|
||||
origintext = optarg;
|
||||
else
|
||||
origintext++; /* Skip '/'. */
|
||||
dbi = isc_mem_get(ns_g_mctx, sizeof *dbi);
|
||||
if (dbi == NULL)
|
||||
early_fatal("creating zone info failed");
|
||||
dbi->path = optarg;
|
||||
dbi->origin = origintext;
|
||||
dbi->iscache = ISC_FALSE;
|
||||
argtext = isc_mem_strdup(ns_g_mctx, optarg);
|
||||
if (argtext == NULL)
|
||||
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->db = NULL;
|
||||
dbi->iscache = ISC_FALSE;
|
||||
isc_mem_free(ns_g_mctx, argtext);
|
||||
ISC_LINK_INIT(dbi, link);
|
||||
ISC_LIST_APPEND(ns_g_dbs, dbi, link);
|
||||
break;
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <named/types.h>
|
||||
#include <named/globals.h>
|
||||
#include <named/server.h>
|
||||
#include <named/xfrin.h>
|
||||
|
||||
#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);
|
||||
result = dns_db_load(dbi->db, dbi->path);
|
||||
|
||||
if (result != DNS_R_SUCCESS)
|
||||
if (result != DNS_R_SUCCESS) {
|
||||
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("journal rollforward\n");
|
||||
@ -252,6 +260,10 @@ unload_all(void) {
|
||||
dns_db_detach(&dbi->db);
|
||||
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_mem_put(ns_g_mctx, dbi, sizeof *dbi);
|
||||
}
|
||||
@ -280,6 +292,7 @@ load_configuration(void) {
|
||||
}
|
||||
|
||||
ns_interfacemgr_scan(ns_g_interfacemgr);
|
||||
xfrin_test();
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
x
Reference in New Issue
Block a user