Commit c35f1e59 authored by James Brister's avatar James Brister
Browse files

341. [func] Support 'key' clause in named.conf zone masters

                        statement:

                                masters {
                                        10.0.0.1 port 666 key "foo";
                                        10.0.0.2 ;
                                };
parent baf50a72
341. [func] Support 'key' clause in named.conf zone masters
statement:
masters {
10.0.0.1 port 666 key "foo";
10.0.0.2 ;
};
340. [bug] The top-level COPYRIGHT file was missing from
the distribution.
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: named.conf,v 1.41 2000/07/11 19:09:01 brister Exp $ */
/* $Id: named.conf,v 1.42 2000/07/21 21:24:55 brister Exp $ */
/*
* This is a worthless, nonrunnable example of a named.conf file that has
......@@ -232,8 +232,9 @@ zone "slave.demo.zone" {
file "slave.demo.zone";
ixfr-base "slave.demo.zone.ixfr"; // File name for IXFR transaction log file
masters {
1.2.3.4; // where to zone transfer from
1.2.3.4 port 10 key "foo"; // where to zone transfer from
5.6.7.8;
6.7.8.9 key "zippo";
};
transfer-source 10.0.0.53; // fixes multihoming problems
check-names warn;
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confip.c,v 1.27 2000/06/06 15:21:46 tale Exp $ */
/* $Id: confip.c,v 1.28 2000/07/21 21:24:56 brister Exp $ */
#include <config.h>
......@@ -775,6 +775,7 @@ isc_result_t
dns_c_iplist_new(isc_mem_t *mem, int length, dns_c_iplist_t **newlist) {
dns_c_iplist_t *list;
size_t bytes;
int i;
REQUIRE(mem != NULL);
REQUIRE(length > 0);
......@@ -791,9 +792,20 @@ dns_c_iplist_new(isc_mem_t *mem, int length, dns_c_iplist_t **newlist) {
isc_mem_put(mem, list, sizeof *list);
return (ISC_R_NOMEMORY);
}
memset(list->ips, 0x0, bytes);
bytes = sizeof (dns_name_t *) * length;
list->keys = isc_mem_get(mem, bytes);
if (list->keys == NULL) {
isc_mem_put(mem, list->ips, sizeof (isc_sockaddr_t) * length);
isc_mem_put(mem, list, sizeof *list);
return (ISC_R_NOMEMORY);
}
for (i = 0 ; i < length ; i++)
list->keys[i] = NULL;
list->magic = DNS_C_IPLIST_MAGIC;
list->size = length;
list->nextidx = 0;
......@@ -808,6 +820,8 @@ dns_c_iplist_new(isc_mem_t *mem, int length, dns_c_iplist_t **newlist) {
isc_result_t
dns_c_iplist_detach(dns_c_iplist_t **list) {
dns_c_iplist_t *l ;
unsigned int i;
REQUIRE(list != NULL);
REQUIRE(*list != NULL);
......@@ -820,6 +834,16 @@ dns_c_iplist_detach(dns_c_iplist_t **list) {
l->refcount--;
if (l->refcount == 0) {
for (i = 0 ; i < l->size ; i++) {
if (l->keys[i] != NULL) {
dns_name_free(l->keys[i], l->mem);
isc_mem_put(l->mem, l->keys[i],
sizeof (dns_name_t));
l->keys[i] = NULL;
}
}
isc_mem_put(l->mem, l->keys, sizeof (dns_name_t *) * l->size);
isc_mem_put(l->mem, l->ips, sizeof (isc_sockaddr_t) * l->size);
isc_mem_put(l->mem, l, sizeof *l);
}
......@@ -829,6 +853,26 @@ dns_c_iplist_detach(dns_c_iplist_t **list) {
return (ISC_R_SUCCESS);
}
isc_boolean_t
dns_c_iplist_haskeys(dns_c_iplist_t *list)
{
unsigned int i;
if (list->keys == NULL) {
return (ISC_FALSE);
}
for (i = 0 ; i < list->nextidx ; i++) {
if (list->keys[i] != NULL) {
return (ISC_TRUE);
}
}
return (ISC_FALSE);
}
void
dns_c_iplist_attach(dns_c_iplist_t *source, dns_c_iplist_t **target) {
REQUIRE(DNS_C_IPLIST_VALID(source));
......@@ -854,7 +898,22 @@ dns_c_iplist_copy(isc_mem_t *mem, dns_c_iplist_t **dest, dns_c_iplist_t *src) {
for (i = 0 ; i < src->nextidx ; i++) {
newl->ips[i] = src->ips[i];
if (src->keys[i] != NULL) {
newl->keys[i] = isc_mem_get(mem, sizeof (dns_name_t));
if (newl->keys[i] == NULL) {
dns_c_iplist_detach(&newl);
return (ISC_R_NOMEMORY);
} else {
res = dns_name_dup(src->keys[i], mem,
newl->keys[i]);
if (res != ISC_R_SUCCESS) {
dns_c_iplist_detach(&newl);
return (res);
}
}
}
}
newl->nextidx = src->nextidx;
*dest = newl;
......@@ -875,6 +934,14 @@ dns_c_iplist_equal(dns_c_iplist_t *list1, dns_c_iplist_t *list2) {
for (i = 0 ; i < list1->nextidx ; i++) {
if (!isc_sockaddr_equal(&list1->ips[i], &list2->ips[i]))
return (ISC_FALSE);
if ((list1->keys[i] == NULL && list2->keys[i] != NULL) ||
(list1->keys[i] != NULL && list2->keys[i] == NULL))
return (ISC_FALSE);
if (list1->keys[i] != NULL &&
!dns_name_equal(list1->keys[i], list2->keys[i]))
return (ISC_FALSE);
}
return (ISC_TRUE);
......@@ -924,6 +991,11 @@ dns_c_iplist_printfully(FILE *fp, int indent, isc_boolean_t porttoo,
fprintf(fp, " port %d",
isc_sockaddr_getport(&list->ips[i]));
}
if (list->keys[i] != NULL) {
fprintf(fp, " key \"");
dns_name_print(list->keys[i], fp);
fprintf(fp, "\" ");
}
fprintf(fp, ";\n");
}
dns_c_printtabs(fp, indent - 1);
......@@ -939,8 +1011,10 @@ dns_c_iplist_print(FILE *fp, int indent, dns_c_iplist_t *list) {
}
isc_result_t
dns_c_iplist_append(dns_c_iplist_t *list, isc_sockaddr_t newaddr) {
dns_c_iplist_append(dns_c_iplist_t *list, isc_sockaddr_t newaddr,
const char *key) {
isc_uint32_t i;
isc_result_t res;
REQUIRE(DNS_C_IPLIST_VALID(list));
......@@ -956,6 +1030,7 @@ dns_c_iplist_append(dns_c_iplist_t *list, isc_sockaddr_t newaddr) {
if (list->nextidx == list->size) {
isc_sockaddr_t *newlist;
dns_name_t **newkeys;
size_t newbytes;
size_t oldbytes = list->size * sizeof (list->ips[0]);
size_t newsize = list->size + 10;
......@@ -971,15 +1046,46 @@ dns_c_iplist_append(dns_c_iplist_t *list, isc_sockaddr_t newaddr) {
isc_mem_put(list->mem, list->ips, oldbytes);
list->ips = newlist;
oldbytes = list->size * sizeof(list->keys[0]);
newbytes = sizeof (list->ips[0]) * newsize;
newkeys = isc_mem_get(list->mem, newbytes);
if (newkeys == NULL) {
return (ISC_R_NOMEMORY);
}
memcpy(newkeys, list->keys, oldbytes);
for (i = list->size ; i < newsize ; i++)
list->keys[i] = NULL;
isc_mem_put(list->mem, list->keys, oldbytes);
list->keys = newkeys;
i = list->size;
list->size = newsize;
}
list->ips[i] = newaddr;
list->nextidx++;
return (ISC_R_SUCCESS);
res = ISC_R_SUCCESS;
if (key != NULL) {
if (list->keys[i] != NULL) {
dns_name_free(list->keys[i], list->mem);
isc_mem_put(list->mem, list->keys,
sizeof (dns_name_t));
list->keys[i] = NULL;
}
res = dns_c_charptoname(list->mem, key, &list->keys[i]);
}
return (res);
}
isc_result_t
dns_c_iplist_remove(dns_c_iplist_t *list, isc_sockaddr_t newaddr) {
isc_uint32_t i;
......@@ -987,7 +1093,7 @@ dns_c_iplist_remove(dns_c_iplist_t *list, isc_sockaddr_t newaddr) {
REQUIRE(DNS_C_IPLIST_VALID(list));
for (i = 0 ; i < list->nextidx ; i++) {
if (memcmp(&list->ips[0], &newaddr, sizeof newaddr) == 0) {
if (memcmp(&list->ips[i], &newaddr, sizeof newaddr) == 0) {
break;
}
}
......@@ -997,8 +1103,15 @@ dns_c_iplist_remove(dns_c_iplist_t *list, isc_sockaddr_t newaddr) {
}
list->nextidx--;
if (list->keys[i] != NULL) {
dns_name_reset(list->keys[i]);
isc_mem_put(list->mem, list->keys[i], sizeof (dns_name_t));
}
for ( /* nothing */ ; i < list->nextidx ; i++) {
list->ips[i] = list->ips[i + 1];
list->keys[i] = list->keys[i + 1];
}
return (ISC_R_SUCCESS);
......
......@@ -16,7 +16,7 @@
* SOFTWARE.
*/
/* $Id: confparser.y,v 1.102 2000/07/18 13:19:27 brister Exp $ */
/* $Id: confparser.y,v 1.103 2000/07/21 21:24:57 brister Exp $ */
#include <config.h>
......@@ -443,6 +443,7 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult);
%type <text> channel_name
%type <text> domain_name
%type <text> key_value
%type <text> maybe_key
%type <kidlist> control_keys
%type <kidlist> keyid_list
%type <text> ordering_name
......@@ -1646,6 +1647,15 @@ transfer_format: L_ONE_ANSWER
;
maybe_key: /* nothing */
{
$$ = NULL;
}
| L_SEC_KEY any_string
{
$$ = $2;
};
maybe_wild_addr: ip4_address
| ip6_address
| L_STRING
......@@ -1748,7 +1758,7 @@ ip_and_port_element: ip_address maybe_zero_port
};
ip_and_port_list: ip_and_port_element L_EOS
ip_and_port_list: ip_and_port_element maybe_key L_EOS
{
dns_c_iplist_t *list;
......@@ -1759,24 +1769,32 @@ ip_and_port_list: ip_and_port_element L_EOS
YYABORT;
}
tmpres = dns_c_iplist_append(list, $1);
tmpres = dns_c_iplist_append(list, $1, $2);
if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_TRUE,
"failed to append master address");
YYABORT;
}
if ($2 != NULL) {
isc_mem_free(memctx, $2);
}
$$ = list;
}
| ip_and_port_list ip_and_port_element L_EOS
| ip_and_port_list ip_and_port_element maybe_key L_EOS
{
tmpres = dns_c_iplist_append($1, $2);
tmpres = dns_c_iplist_append($1, $2, $3);
if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_TRUE,
"failed to append master address");
YYABORT;
}
if ($3 != NULL) {
isc_mem_free(memctx, $3);
}
$$ = $1;
}
;
......@@ -2113,7 +2131,8 @@ forwarders_in_addr_list: forwarders_in_addr L_EOS
forwarders_in_addr: ip_address
{
tmpres = dns_c_iplist_append(currcfg->options->forwarders, $1);
tmpres = dns_c_iplist_append(currcfg->options->forwarders,
$1, NULL);
if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_FALSE,
"failed to add forwarders "
......@@ -4945,7 +4964,7 @@ in_addr_list: in_addr_elem L_EOS
YYABORT;
}
tmpres = dns_c_iplist_append(list, $1);
tmpres = dns_c_iplist_append(list, $1, NULL);
if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_TRUE,
"failed to append master address");
......@@ -4956,7 +4975,7 @@ in_addr_list: in_addr_elem L_EOS
}
| in_addr_list in_addr_elem L_EOS
{
tmpres = dns_c_iplist_append($1, $2);
tmpres = dns_c_iplist_append($1, $2, NULL);
if (tmpres != ISC_R_SUCCESS) {
parser_error(ISC_TRUE,
"failed to append master address");
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confzone.c,v 1.47 2000/06/05 09:17:09 brister Exp $ */
/* $Id: confzone.c,v 1.48 2000/07/21 21:24:59 brister Exp $ */
#include <config.h>
......@@ -596,7 +596,7 @@ dns_c_zone_validate(dns_c_zone_t *zone)
/*
* Check for allow-update and update-policty together
* Check for allow-update and update-policy together
*/
if (zone->ztype == dns_c_zone_master) {
tmpres = dns_c_zone_getallowupd(zone, &ipmlist);
......@@ -633,6 +633,11 @@ dns_c_zone_validate(dns_c_zone_t *zone)
}
}
/* XXX TODO make sure no 'key' clauses were given on any iplist
except for masters{}; */
return (result);
}
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confip.h,v 1.22 2000/06/23 02:59:04 tale Exp $ */
/* $Id: confip.h,v 1.23 2000/07/21 21:25:00 brister Exp $ */
#ifndef DNS_CONFIP_H
#define DNS_CONFIP_H 1
......@@ -59,6 +59,7 @@
#include <isc/sockaddr.h>
#include <dns/confcommon.h>
#include <dns/name.h>
#define DNS_C_IPLIST_MAGIC 0x49706c73 /* Ipls */
#define DNS_C_IPMDIRECT_MAGIC 0x49506d64 /* IPmd */
......@@ -94,6 +95,7 @@ struct dns_c_iplist {
isc_mem_t *mem;
int refcount;
isc_sockaddr_t *ips;
dns_name_t **keys;
isc_uint32_t size;
isc_uint32_t nextidx;
};
......@@ -225,9 +227,12 @@ isc_result_t dns_c_iplist_detach(dns_c_iplist_t **list);
isc_result_t dns_c_iplist_copy(isc_mem_t *mem, dns_c_iplist_t **dest,
dns_c_iplist_t *src);
isc_boolean_t dns_c_iplist_haskeys(dns_c_iplist_t *list);
void dns_c_iplist_attach(dns_c_iplist_t *source, dns_c_iplist_t **target);
isc_result_t dns_c_iplist_append(dns_c_iplist_t *list, isc_sockaddr_t newaddr);
isc_result_t dns_c_iplist_append(dns_c_iplist_t *list,
isc_sockaddr_t newaddr, const char *key);
isc_result_t dns_c_iplist_remove(dns_c_iplist_t *list, isc_sockaddr_t newaddr);
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confzone.h,v 1.35 2000/06/22 21:55:31 tale Exp $ */
/* $Id: confzone.h,v 1.36 2000/07/21 21:25:01 brister Exp $ */
#ifndef DNS_CONFZONE_H
#define DNS_CONFZONE_H 1
......@@ -79,18 +79,14 @@ typedef struct dns_c_hint_zone dns_c_hintzone_t;
typedef struct dns_c_zone dns_c_zone_t;
typedef struct dns_c_zonelem dns_c_zonelem_t;
#if 0
/* this typedef moved to confcommon.h for confview.h to get at (circular
* include dependencies between view and zone structures.
*/
typedef struct dns_c_zone_list dns_c_zonelist_t;
#endif
struct dns_c_zonelem {
dns_c_zone_t *thezone;
ISC_LINK(dns_c_zonelem_t) next;
};
struct dns_c_zone_list {
isc_int32_t magic;
isc_mem_t *mem;
......@@ -98,6 +94,7 @@ struct dns_c_zone_list {
ISC_LIST(dns_c_zonelem_t) zones;
};
struct dns_c_master_zone {
char *file;
dns_severity_t check_names;
......@@ -223,6 +220,10 @@ struct dns_c_zone {
ISC_LANG_BEGINDECLS
/*
*/
isc_result_t dns_c_zonelist_new(isc_mem_t *mem, dns_c_zonelist_t **zlist);
isc_result_t dns_c_zonelist_delete(dns_c_zonelist_t **zlist);
isc_result_t dns_c_zonelist_checkzones(dns_c_zonelist_t *zlist);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment