From 285ae3ab80378b108afdb4224403c0158feaec61 Mon Sep 17 00:00:00 2001 From: James Brister Date: Mon, 25 Oct 1999 09:52:42 +0000 Subject: [PATCH] Minor changes to config file generators. Added a lookup function for server lists. --- lib/dns/config/confacl.c | 3 +- lib/dns/config/confctl.c | 1 + lib/dns/config/confip.c | 2 +- lib/dns/config/conflsn.c | 1 + lib/dns/config/confserv.c | 166 +++++++++++++++++++++++++++++++++++++- lib/dns/config/confview.c | 1 + lib/dns/config/confzone.c | 9 +++ 7 files changed, 180 insertions(+), 3 deletions(-) diff --git a/lib/dns/config/confacl.c b/lib/dns/config/confacl.c index e7559e9cab..52a101611a 100644 --- a/lib/dns/config/confacl.c +++ b/lib/dns/config/confacl.c @@ -275,8 +275,9 @@ dns_c_acl_print(isc_log_t *lctx, } else { fprintf(fp, "{\n"); dns_c_printtabs(lctx, fp, indent); - fprintf(fp, "};"); + fprintf(fp, "}"); } + fprintf(fp, ";\n"); } diff --git a/lib/dns/config/confctl.c b/lib/dns/config/confctl.c index 06b1edf976..8956458942 100644 --- a/lib/dns/config/confctl.c +++ b/lib/dns/config/confctl.c @@ -270,6 +270,7 @@ dns_c_ctrl_print(isc_log_t *lctx, dns_c_printtabs(lctx, fp, indent + 1); fprintf(fp, "allow "); dns_c_ipmatchlist_print(lctx, fp, indent + 2, iml); + fprintf(fp, ";\n"); } else { /* The "#" means force a leading zero */ fprintf(fp, "unix \"%s\" perm %#o owner %d group %d;\n", diff --git a/lib/dns/config/confip.c b/lib/dns/config/confip.c index f4f9f3d055..ef19c0c4a5 100644 --- a/lib/dns/config/confip.c +++ b/lib/dns/config/confip.c @@ -751,7 +751,7 @@ dns_c_ipmatchlist_print(isc_log_t *lctx, } dns_c_printtabs(lctx, fp, indent - 1); - fprintf(fp, "};\n"); + fprintf(fp, "}"); return (ISC_R_SUCCESS); } diff --git a/lib/dns/config/conflsn.c b/lib/dns/config/conflsn.c index 8fd8914df2..5c9bde8595 100644 --- a/lib/dns/config/conflsn.c +++ b/lib/dns/config/conflsn.c @@ -216,6 +216,7 @@ dns_c_lstnon_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_lstnon_t *lo) } dns_c_ipmatchlist_print(lctx, fp, indent + 1, lo->iml); + fprintf(fp, ";\n"); return (ISC_R_SUCCESS); } diff --git a/lib/dns/config/confserv.c b/lib/dns/config/confserv.c index be800ed86e..504004d30d 100644 --- a/lib/dns/config/confserv.c +++ b/lib/dns/config/confserv.c @@ -120,6 +120,44 @@ dns_c_srvlist_print(isc_log_t *lctx, FILE *fp, int indent, } +isc_result_t +dns_c_srvlist_servbyaddr(isc_log_t *lctx, dns_c_srvlist_t *servers, + isc_sockaddr_t addr, dns_c_srv_t **retval) +{ + dns_c_srv_t *server; + isc_result_t res; + + (void) lctx; + + REQUIRE(retval != NULL); + + if (servers == NULL) { + return (ISC_R_NOTFOUND); + } + + server = ISC_LIST_HEAD(servers->elements); + while (server != NULL) { + + if (isc_sockaddr_eqaddr(&addr, &server->address)) { + break; + } + + server = ISC_LIST_NEXT(server, next); + } + + if (server != NULL) { + *retval = server; + res = ISC_R_SUCCESS; + } else { + res = ISC_R_NOTFOUND; + } + + return (res); +} + + + + isc_result_t dns_c_srv_new(isc_log_t *lctx, isc_mem_t *mem, isc_sockaddr_t addr, dns_c_srv_t **server) @@ -143,6 +181,8 @@ dns_c_srv_new(isc_log_t *lctx, isc_mem_t *mem, isc_sockaddr_t addr, serv->transfers = 0; serv->support_ixfr = ISC_FALSE; serv->keys = NULL; + serv->tkeydomain = NULL; + serv->tkeydhkey = NULL; memset(&serv->bitflags, 0x0, sizeof serv->bitflags); @@ -171,6 +211,14 @@ dns_c_srv_delete(isc_log_t *lctx, dns_c_srv_t **server) serv->mem = NULL; dns_c_kidlist_delete(lctx, &serv->keys); + if (serv->tkeydomain != NULL) { + isc_mem_free(mem, serv->tkeydomain); + } + + if (serv->tkeydhkey != NULL) { + isc_mem_free(mem, serv->tkeydhkey); + } + isc_mem_put(mem, serv, sizeof *serv); *server = NULL; @@ -217,6 +265,16 @@ dns_c_srv_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_srv_t *server) if (server->keys != NULL) { dns_c_kidlist_print(lctx, fp, indent + 1, server->keys); } + + if (server->tkeydomain != NULL) { + dns_c_printtabs(lctx, fp, indent + 1); + fprintf(fp, "tkey-domain \"%s\";\n", server->tkeydomain); + } + + if (server->tkeydhkey != NULL) { + dns_c_printtabs(lctx, fp, indent + 1); + fprintf(fp, "tkey-dhkey \"%s\";\n", server->tkeydhkey); + } dns_c_printtabs(lctx, fp, indent); fprintf(fp, "};\n"); @@ -269,7 +327,6 @@ dns_c_srv_setsupportixfr(isc_log_t *lctx, dns_c_srv_t *server, return (ISC_R_SUCCESS); } - isc_result_t dns_c_srv_getsupportixfr(isc_log_t *lctx, dns_c_srv_t *server, isc_boolean_t *retval) @@ -352,3 +409,110 @@ dns_c_srv_gettransferformat(isc_log_t *lctx, dns_c_srv_t *server, return (ISC_R_NOTFOUND); } } + + +isc_result_t +dns_c_srv_settkeydomain(isc_log_t *lctx, dns_c_srv_t *server, + char *newval) +{ + isc_boolean_t existed = ISC_FALSE; + isc_result_t res = ISC_R_SUCCESS; + + (void) lctx; + + REQUIRE(server != NULL); + + if (server->tkeydomain != NULL) { + existed = ISC_TRUE; + isc_mem_free(server->mem, server->tkeydomain); + } + + if (newval != NULL) { + server->tkeydomain = isc_mem_strdup(server->mem, newval); + + if (server->tkeydomain == NULL) { + res = ISC_R_NOMEMORY; + } else if (existed) { + res = ISC_R_EXISTS; + } + } else { + server->tkeydomain = NULL; + if (existed) { + res = ISC_R_EXISTS; + } + } + + return (res); +} + +isc_result_t +dns_c_srv_gettkeydomain(isc_log_t *lctx, dns_c_srv_t *server, + char **retval) +{ + isc_result_t res; + + (void) lctx; + + REQUIRE(server != NULL); + REQUIRE(retval != NULL); + + if (server->tkeydomain != NULL) { + *retval = server->tkeydomain; + res = ISC_R_SUCCESS; + } else { + res = ISC_R_NOTFOUND; + } + + return (res); +} + + + +isc_result_t +dns_c_srv_settkeydhkey(isc_log_t *lctx, dns_c_srv_t *server, char *newval) +{ + isc_boolean_t existed = ISC_FALSE; + isc_result_t res; + + (void) lctx; + + if (server->tkeydhkey != NULL) { + existed = ISC_TRUE; + isc_mem_free(server->mem, server->tkeydhkey); + } + + server->tkeydhkey = isc_mem_strdup(server->mem, newval); + + if (server->tkeydhkey == NULL) { + res = ISC_R_NOMEMORY; + } else if (existed) { + res = ISC_R_EXISTS; + } else { + res = ISC_R_SUCCESS; + } + + return (res); +} + +isc_result_t +dns_c_srv_gettkeydhkey(isc_log_t *lctx, dns_c_srv_t *server, char **retval) +{ + isc_result_t res; + + (void) lctx; + + REQUIRE(server != NULL); + REQUIRE(retval != NULL); + + if (server->tkeydhkey != NULL) { + *retval = server->tkeydhkey; + res = ISC_R_SUCCESS; + } else { + res = ISC_R_NOTFOUND; + } + + return (res); +} + + + diff --git a/lib/dns/config/confview.c b/lib/dns/config/confview.c index 467def2700..299ea75fe7 100644 --- a/lib/dns/config/confview.c +++ b/lib/dns/config/confview.c @@ -259,6 +259,7 @@ dns_c_view_print(isc_log_t *lctx, fprintf(fp, "allow-query "); dns_c_ipmatchlist_print(lctx, fp, indent + 2, view->allowquery); + fprintf(fp, ";\n"); } /* XXXJAB rest of view fields */ diff --git a/lib/dns/config/confzone.c b/lib/dns/config/confzone.c index 9bda7cd2ce..63e15cac10 100644 --- a/lib/dns/config/confzone.c +++ b/lib/dns/config/confzone.c @@ -2509,6 +2509,7 @@ master_zone_print(isc_log_t *lctx, FILE *fp, int indent, fprintf(fp, "allow-update "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, mzone->allow_update); + fprintf(fp, ";\n"); } if (mzone->allow_query != NULL && @@ -2517,6 +2518,7 @@ master_zone_print(isc_log_t *lctx, FILE *fp, int indent, fprintf(fp, "allow-query "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, mzone->allow_query); + fprintf(fp, ";\n"); } if (mzone->allow_transfer != NULL && @@ -2525,6 +2527,7 @@ master_zone_print(isc_log_t *lctx, FILE *fp, int indent, fprintf(fp, "allow-transfer "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, mzone->allow_transfer); + fprintf(fp, ";\n"); } if (DNS_C_CHECKBIT(MZ_DIALUP_BIT, &mzone->setflags)) { @@ -2608,6 +2611,7 @@ slave_zone_print(isc_log_t *lctx, FILE *fp, int indent, fprintf(fp, "allow-update "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, szone->allow_update); + fprintf(fp, ";\n"); } if (szone->allow_query != NULL && @@ -2616,6 +2620,7 @@ slave_zone_print(isc_log_t *lctx, FILE *fp, int indent, fprintf(fp, "allow-query "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, szone->allow_query); + fprintf(fp, ";\n"); } if (szone->allow_transfer != NULL && @@ -2624,6 +2629,7 @@ slave_zone_print(isc_log_t *lctx, FILE *fp, int indent, fprintf(fp, "allow-transfer "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, szone->allow_transfer); + fprintf(fp, ";\n"); } if (DNS_C_CHECKBIT(SZ_TRANSFER_SOURCE_BIT, &szone->setflags)) { @@ -2694,6 +2700,7 @@ stub_zone_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_stubzone_t *szone) fprintf(fp, "allow-update "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, szone->allow_update); + fprintf(fp, ";\n"); } if (szone->allow_query != NULL && @@ -2702,6 +2709,7 @@ stub_zone_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_stubzone_t *szone) fprintf(fp, "allow-query "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, szone->allow_query); + fprintf(fp, ";\n"); } if (szone->allow_transfer != NULL && @@ -2710,6 +2718,7 @@ stub_zone_print(isc_log_t *lctx, FILE *fp, int indent, dns_c_stubzone_t *szone) fprintf(fp, "allow-transfer "); dns_c_ipmatchlist_print(lctx, fp, indent + 1, szone->allow_transfer); + fprintf(fp, ";\n"); } if (DNS_C_CHECKBIT(TZ_TRANSFER_SOURCE_BIT, &szone->setflags)) {