From 0818d0a7646cde4ecee39e69cbe711d4b6727ea3 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Fri, 27 Aug 1999 18:30:00 +0000 Subject: [PATCH] support slave zones --- bin/named/include/named/types.h | 2 ++ bin/named/main.c | 52 ++++++++++++++++++++++++++------- bin/named/server.c | 17 +++++++++-- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/bin/named/include/named/types.h b/bin/named/include/named/types.h index cae631c524..a31f54d0f5 100644 --- a/bin/named/include/named/types.h +++ b/bin/named/include/named/types.h @@ -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; diff --git a/bin/named/main.c b/bin/named/main.c index 31da605f4f..8061d73ea8 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -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; diff --git a/bin/named/server.c b/bin/named/server.c index 7947538cb0..cf6c1a69bd 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -52,6 +52,7 @@ #include #include #include +#include #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) - goto db_detach; + 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