"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "options.c" between
nsd-4.3.5.tar.gz and nsd-4.3.6.tar.gz

About: NSD is an authoritative only, high performance, simple name server daemon.

options.c  (nsd-4.3.5):options.c  (nsd-4.3.6)
skipping to change at line 14 skipping to change at line 14
* Copyright (c) 2001-2006, NLnet Labs. All rights reserved. * Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
* *
* See LICENSE for the license. * See LICENSE for the license.
* *
*/ */
#include "config.h" #include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_IFADDRS_H
#include <ifaddrs.h>
#endif
#include "options.h" #include "options.h"
#include "query.h" #include "query.h"
#include "tsig.h" #include "tsig.h"
#include "difffile.h" #include "difffile.h"
#include "rrl.h" #include "rrl.h"
#include "bitset.h" #include "bitset.h"
#include "configyyrename.h"
#include "configparser.h" #include "configparser.h"
config_parser_state_type* cfg_parser = 0; config_parser_state_type* cfg_parser = 0;
extern FILE* c_in, *c_out; extern FILE* c_in, *c_out;
int c_parse(void); int c_parse(void);
int c_lex(void); int c_lex(void);
int c_wrap(void); int c_wrap(void);
int c_lex_destroy(void); int c_lex_destroy(void);
extern char* c_text; extern char* c_text;
static int static int
skipping to change at line 261 skipping to change at line 263
} }
for(acl=pat->provide_xfr; acl; acl=acl->next) for(acl=pat->provide_xfr; acl; acl=acl->next)
{ {
if(acl->nokey || acl->blocked) if(acl->nokey || acl->blocked)
continue; continue;
acl->key_options = key_options_find(opt, acl->key_name); acl->key_options = key_options_find(opt, acl->key_name);
if(!acl->key_options) if(!acl->key_options)
c_error("key %s in pattern %s could not be found" , c_error("key %s in pattern %s could not be found" ,
acl->key_name, pat->pname); acl->key_name, pat->pname);
} }
for(acl=pat->allow_query; acl; acl=acl->next)
{
if(acl->nokey || acl->blocked)
continue;
acl->key_options = key_options_find(opt, acl->key_name);
if(!acl->key_options)
c_error("key %s in pattern %s could not be found"
,
acl->key_name, pat->pname);
}
} }
if(cfg_parser->errors > 0) if(cfg_parser->errors > 0)
{ {
if(err) { if(err) {
char m[MAXSYSLOGMSGLEN]; char m[MAXSYSLOGMSGLEN];
snprintf(m, sizeof(m), "read %s failed: %d errors in " snprintf(m, sizeof(m), "read %s failed: %d errors in "
"configuration file\n", file, "configuration file\n", file,
cfg_parser->errors); cfg_parser->errors);
err(err_arg, m); err(err_arg, m);
skipping to change at line 830 skipping to change at line 841
struct pattern_options)); struct pattern_options));
p->node = *RBTREE_NULL; p->node = *RBTREE_NULL;
p->pname = 0; p->pname = 0;
p->zonefile = 0; p->zonefile = 0;
p->zonestats = 0; p->zonestats = 0;
p->allow_notify = 0; p->allow_notify = 0;
p->request_xfr = 0; p->request_xfr = 0;
p->size_limit_xfr = 0; p->size_limit_xfr = 0;
p->notify = 0; p->notify = 0;
p->provide_xfr = 0; p->provide_xfr = 0;
p->allow_query = 0;
p->outgoing_interface = 0; p->outgoing_interface = 0;
p->notify_retry = 5; p->notify_retry = 5;
p->notify_retry_is_default = 1; p->notify_retry_is_default = 1;
p->allow_axfr_fallback = 1; p->allow_axfr_fallback = 1;
p->allow_axfr_fallback_is_default = 1; p->allow_axfr_fallback_is_default = 1;
p->implicit = 0; p->implicit = 0;
p->xfrd_flags = 0; p->xfrd_flags = 0;
p->max_refresh_time = 2419200; /* 4 weeks */ p->max_refresh_time = 2419200; /* 4 weeks */
p->max_refresh_time_is_default = 1; p->max_refresh_time_is_default = 1;
p->min_refresh_time = 0; p->min_refresh_time = 0;
skipping to change at line 899 skipping to change at line 911
if(p->zonefile) if(p->zonefile)
region_recycle(opt->region, (void*)p->zonefile, region_recycle(opt->region, (void*)p->zonefile,
strlen(p->zonefile)+1); strlen(p->zonefile)+1);
if(p->zonestats) if(p->zonestats)
region_recycle(opt->region, (void*)p->zonestats, region_recycle(opt->region, (void*)p->zonestats,
strlen(p->zonestats)+1); strlen(p->zonestats)+1);
acl_list_delete(opt->region, p->allow_notify); acl_list_delete(opt->region, p->allow_notify);
acl_list_delete(opt->region, p->request_xfr); acl_list_delete(opt->region, p->request_xfr);
acl_list_delete(opt->region, p->notify); acl_list_delete(opt->region, p->notify);
acl_list_delete(opt->region, p->provide_xfr); acl_list_delete(opt->region, p->provide_xfr);
acl_list_delete(opt->region, p->allow_query);
acl_list_delete(opt->region, p->outgoing_interface); acl_list_delete(opt->region, p->outgoing_interface);
region_recycle(opt->region, p, sizeof(struct pattern_options)); region_recycle(opt->region, p, sizeof(struct pattern_options));
} }
static struct acl_options* static struct acl_options*
copy_acl(region_type* region, struct acl_options* a) copy_acl(region_type* region, struct acl_options* a)
{ {
struct acl_options* b; struct acl_options* b;
if(!a) return NULL; if(!a) return NULL;
skipping to change at line 999 skipping to change at line 1012
struct pattern_options* orig = pattern_options_find(opt, p->pname); struct pattern_options* orig = pattern_options_find(opt, p->pname);
if(!orig) { if(!orig) {
/* needs to be copied to opt region */ /* needs to be copied to opt region */
orig = pattern_options_create(opt->region); orig = pattern_options_create(opt->region);
orig->pname = region_strdup(opt->region, p->pname); orig->pname = region_strdup(opt->region, p->pname);
copy_pat_fixed(opt->region, orig, p); copy_pat_fixed(opt->region, orig, p);
orig->allow_notify = copy_acl_list(opt, p->allow_notify); orig->allow_notify = copy_acl_list(opt, p->allow_notify);
orig->request_xfr = copy_acl_list(opt, p->request_xfr); orig->request_xfr = copy_acl_list(opt, p->request_xfr);
orig->notify = copy_acl_list(opt, p->notify); orig->notify = copy_acl_list(opt, p->notify);
orig->provide_xfr = copy_acl_list(opt, p->provide_xfr); orig->provide_xfr = copy_acl_list(opt, p->provide_xfr);
orig->allow_query = copy_acl_list(opt, p->allow_query);
orig->outgoing_interface = copy_acl_list(opt, orig->outgoing_interface = copy_acl_list(opt,
p->outgoing_interface); p->outgoing_interface);
nsd_options_insert_pattern(opt, orig); nsd_options_insert_pattern(opt, orig);
} else { } else {
/* modify in place so pointers stay valid (and copy /* modify in place so pointers stay valid (and copy
into region). Do not touch unchanged acls. */ into region). Do not touch unchanged acls. */
if(orig->zonefile) if(orig->zonefile)
region_recycle(opt->region, (char*)orig->zonefile, region_recycle(opt->region, (char*)orig->zonefile,
strlen(orig->zonefile)+1); strlen(orig->zonefile)+1);
if(orig->zonestats) if(orig->zonestats)
region_recycle(opt->region, (char*)orig->zonestats, region_recycle(opt->region, (char*)orig->zonestats,
strlen(orig->zonestats)+1); strlen(orig->zonestats)+1);
copy_pat_fixed(opt->region, orig, p); copy_pat_fixed(opt->region, orig, p);
copy_changed_acl(opt, &orig->allow_notify, p->allow_notify); copy_changed_acl(opt, &orig->allow_notify, p->allow_notify);
copy_changed_acl(opt, &orig->request_xfr, p->request_xfr); copy_changed_acl(opt, &orig->request_xfr, p->request_xfr);
copy_changed_acl(opt, &orig->notify, p->notify); copy_changed_acl(opt, &orig->notify, p->notify);
copy_changed_acl(opt, &orig->provide_xfr, p->provide_xfr); copy_changed_acl(opt, &orig->provide_xfr, p->provide_xfr);
copy_changed_acl(opt, &orig->allow_query, p->allow_query);
copy_changed_acl(opt, &orig->outgoing_interface, copy_changed_acl(opt, &orig->outgoing_interface,
p->outgoing_interface); p->outgoing_interface);
} }
} }
struct pattern_options* struct pattern_options*
pattern_options_find(struct nsd_options* opt, const char* name) pattern_options_find(struct nsd_options* opt, const char* name)
{ {
return (struct pattern_options*)rbtree_search(opt->patterns, name); return (struct pattern_options*)rbtree_search(opt->patterns, name);
} }
skipping to change at line 1052 skipping to change at line 1067
if(!booleq(p->allow_axfr_fallback_is_default, if(!booleq(p->allow_axfr_fallback_is_default,
q->allow_axfr_fallback_is_default)) return 0; q->allow_axfr_fallback_is_default)) return 0;
if(p->notify_retry != q->notify_retry) return 0; if(p->notify_retry != q->notify_retry) return 0;
if(!booleq(p->notify_retry_is_default, if(!booleq(p->notify_retry_is_default,
q->notify_retry_is_default)) return 0; q->notify_retry_is_default)) return 0;
if(!booleq(p->implicit, q->implicit)) return 0; if(!booleq(p->implicit, q->implicit)) return 0;
if(!acl_list_equal(p->allow_notify, q->allow_notify)) return 0; if(!acl_list_equal(p->allow_notify, q->allow_notify)) return 0;
if(!acl_list_equal(p->request_xfr, q->request_xfr)) return 0; if(!acl_list_equal(p->request_xfr, q->request_xfr)) return 0;
if(!acl_list_equal(p->notify, q->notify)) return 0; if(!acl_list_equal(p->notify, q->notify)) return 0;
if(!acl_list_equal(p->provide_xfr, q->provide_xfr)) return 0; if(!acl_list_equal(p->provide_xfr, q->provide_xfr)) return 0;
if(!acl_list_equal(p->allow_query, q->allow_query)) return 0;
if(!acl_list_equal(p->outgoing_interface, q->outgoing_interface)) if(!acl_list_equal(p->outgoing_interface, q->outgoing_interface))
return 0; return 0;
if(p->max_refresh_time != q->max_refresh_time) return 0; if(p->max_refresh_time != q->max_refresh_time) return 0;
if(!booleq(p->max_refresh_time_is_default, if(!booleq(p->max_refresh_time_is_default,
q->max_refresh_time_is_default)) return 0; q->max_refresh_time_is_default)) return 0;
if(p->min_refresh_time != q->min_refresh_time) return 0; if(p->min_refresh_time != q->min_refresh_time) return 0;
if(!booleq(p->min_refresh_time_is_default, if(!booleq(p->min_refresh_time_is_default,
q->min_refresh_time_is_default)) return 0; q->min_refresh_time_is_default)) return 0;
if(p->max_retry_time != q->max_retry_time) return 0; if(p->max_retry_time != q->max_retry_time) return 0;
if(!booleq(p->max_retry_time_is_default, if(!booleq(p->max_retry_time_is_default,
skipping to change at line 1224 skipping to change at line 1240
marshal_u8(b, p->allow_axfr_fallback); marshal_u8(b, p->allow_axfr_fallback);
marshal_u8(b, p->allow_axfr_fallback_is_default); marshal_u8(b, p->allow_axfr_fallback_is_default);
marshal_u8(b, p->notify_retry); marshal_u8(b, p->notify_retry);
marshal_u8(b, p->notify_retry_is_default); marshal_u8(b, p->notify_retry_is_default);
marshal_u8(b, p->implicit); marshal_u8(b, p->implicit);
marshal_u64(b, p->size_limit_xfr); marshal_u64(b, p->size_limit_xfr);
marshal_acl_list(b, p->allow_notify); marshal_acl_list(b, p->allow_notify);
marshal_acl_list(b, p->request_xfr); marshal_acl_list(b, p->request_xfr);
marshal_acl_list(b, p->notify); marshal_acl_list(b, p->notify);
marshal_acl_list(b, p->provide_xfr); marshal_acl_list(b, p->provide_xfr);
marshal_acl_list(b, p->allow_query);
marshal_acl_list(b, p->outgoing_interface); marshal_acl_list(b, p->outgoing_interface);
marshal_u32(b, p->max_refresh_time); marshal_u32(b, p->max_refresh_time);
marshal_u8(b, p->max_refresh_time_is_default); marshal_u8(b, p->max_refresh_time_is_default);
marshal_u32(b, p->min_refresh_time); marshal_u32(b, p->min_refresh_time);
marshal_u8(b, p->min_refresh_time_is_default); marshal_u8(b, p->min_refresh_time_is_default);
marshal_u32(b, p->max_retry_time); marshal_u32(b, p->max_retry_time);
marshal_u8(b, p->max_retry_time_is_default); marshal_u8(b, p->max_retry_time_is_default);
marshal_u32(b, p->min_retry_time); marshal_u32(b, p->min_retry_time);
marshal_u8(b, p->min_retry_time_is_default); marshal_u8(b, p->min_retry_time_is_default);
marshal_u32(b, p->min_expire_time); marshal_u32(b, p->min_expire_time);
skipping to change at line 1258 skipping to change at line 1275
p->allow_axfr_fallback = unmarshal_u8(b); p->allow_axfr_fallback = unmarshal_u8(b);
p->allow_axfr_fallback_is_default = unmarshal_u8(b); p->allow_axfr_fallback_is_default = unmarshal_u8(b);
p->notify_retry = unmarshal_u8(b); p->notify_retry = unmarshal_u8(b);
p->notify_retry_is_default = unmarshal_u8(b); p->notify_retry_is_default = unmarshal_u8(b);
p->implicit = unmarshal_u8(b); p->implicit = unmarshal_u8(b);
p->size_limit_xfr = unmarshal_u64(b); p->size_limit_xfr = unmarshal_u64(b);
p->allow_notify = unmarshal_acl_list(r, b); p->allow_notify = unmarshal_acl_list(r, b);
p->request_xfr = unmarshal_acl_list(r, b); p->request_xfr = unmarshal_acl_list(r, b);
p->notify = unmarshal_acl_list(r, b); p->notify = unmarshal_acl_list(r, b);
p->provide_xfr = unmarshal_acl_list(r, b); p->provide_xfr = unmarshal_acl_list(r, b);
p->allow_query = unmarshal_acl_list(r, b);
p->outgoing_interface = unmarshal_acl_list(r, b); p->outgoing_interface = unmarshal_acl_list(r, b);
p->max_refresh_time = unmarshal_u32(b); p->max_refresh_time = unmarshal_u32(b);
p->max_refresh_time_is_default = unmarshal_u8(b); p->max_refresh_time_is_default = unmarshal_u8(b);
p->min_refresh_time = unmarshal_u32(b); p->min_refresh_time = unmarshal_u32(b);
p->min_refresh_time_is_default = unmarshal_u8(b); p->min_refresh_time_is_default = unmarshal_u8(b);
p->max_retry_time = unmarshal_u32(b); p->max_retry_time = unmarshal_u32(b);
p->max_retry_time_is_default = unmarshal_u8(b); p->max_retry_time_is_default = unmarshal_u8(b);
p->min_retry_time = unmarshal_u32(b); p->min_retry_time = unmarshal_u32(b);
p->min_retry_time_is_default = unmarshal_u8(b); p->min_retry_time_is_default = unmarshal_u8(b);
p->min_expire_time = unmarshal_u32(b); p->min_expire_time = unmarshal_u32(b);
skipping to change at line 2052 skipping to change at line 2070
} }
dest->size_limit_xfr = pat->size_limit_xfr; dest->size_limit_xfr = pat->size_limit_xfr;
#ifdef RATELIMIT #ifdef RATELIMIT
dest->rrl_whitelist |= pat->rrl_whitelist; dest->rrl_whitelist |= pat->rrl_whitelist;
#endif #endif
/* append acl items */ /* append acl items */
copy_and_append_acls(&dest->allow_notify, pat->allow_notify); copy_and_append_acls(&dest->allow_notify, pat->allow_notify);
copy_and_append_acls(&dest->request_xfr, pat->request_xfr); copy_and_append_acls(&dest->request_xfr, pat->request_xfr);
copy_and_append_acls(&dest->notify, pat->notify); copy_and_append_acls(&dest->notify, pat->notify);
copy_and_append_acls(&dest->provide_xfr, pat->provide_xfr); copy_and_append_acls(&dest->provide_xfr, pat->provide_xfr);
copy_and_append_acls(&dest->allow_query, pat->allow_query);
copy_and_append_acls(&dest->outgoing_interface, pat->outgoing_interface); copy_and_append_acls(&dest->outgoing_interface, pat->outgoing_interface);
if(pat->multi_master_check) if(pat->multi_master_check)
dest->multi_master_check = pat->multi_master_check; dest->multi_master_check = pat->multi_master_check;
} }
void void
nsd_options_destroy(struct nsd_options* opt) nsd_options_destroy(struct nsd_options* opt)
{ {
region_destroy(opt->region); region_destroy(opt->region);
#ifdef MEMCLEAN /* OS collects memory pages */ #ifdef MEMCLEAN /* OS collects memory pages */
skipping to change at line 2106 skipping to change at line 2125
* named pipe without certificates. */ * named pipe without certificates. */
int int
options_remote_is_address(struct nsd_options* cfg) options_remote_is_address(struct nsd_options* cfg)
{ {
if(!cfg->control_enable) return 0; if(!cfg->control_enable) return 0;
if(!cfg->control_interface) return 1; if(!cfg->control_interface) return 1;
if(!cfg->control_interface->address) return 1; if(!cfg->control_interface->address) return 1;
if(cfg->control_interface->address[0] == 0) return 1; if(cfg->control_interface->address[0] == 0) return 1;
return (cfg->control_interface->address[0] != '/'); return (cfg->control_interface->address[0] != '/');
} }
#ifdef HAVE_GETIFADDRS
static void
resolve_ifa_name(struct ifaddrs *ifas, const char *search_ifa, char ***ip_addres
ses, size_t *ip_addresses_size)
{
struct ifaddrs *ifa;
size_t last_ip_addresses_size = *ip_addresses_size;
for(ifa = ifas; ifa != NULL; ifa = ifa->ifa_next) {
sa_family_t family;
const char* atsign;
#ifdef INET6 /* | address ip | % | ifa name | @ | port | nul */
char addr_buf[INET6_ADDRSTRLEN + 1 + IF_NAMESIZE + 1 + 16 + 1];
#else
char addr_buf[INET_ADDRSTRLEN + 1 + 16 + 1];
#endif
if((atsign=strrchr(search_ifa, '@')) != NULL) {
if(strlen(ifa->ifa_name) != (size_t)(atsign-search_ifa)
|| strncmp(ifa->ifa_name, search_ifa,
atsign-search_ifa) != 0)
continue;
} else {
if(strcmp(ifa->ifa_name, search_ifa) != 0)
continue;
atsign = "";
}
if(ifa->ifa_addr == NULL)
continue;
family = ifa->ifa_addr->sa_family;
if(family == AF_INET) {
char a4[INET_ADDRSTRLEN + 1];
struct sockaddr_in *in4 = (struct sockaddr_in *)
ifa->ifa_addr;
if(!inet_ntop(family, &in4->sin_addr, a4, sizeof(a4)))
error("inet_ntop");
snprintf(addr_buf, sizeof(addr_buf), "%s%s",
a4, atsign);
}
#ifdef INET6
else if(family == AF_INET6) {
struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)
ifa->ifa_addr;
char a6[INET6_ADDRSTRLEN + 1];
char if_index_name[IF_NAMESIZE + 1];
if_index_name[0] = 0;
if(!inet_ntop(family, &in6->sin6_addr, a6, sizeof(a6)))
error("inet_ntop");
if_indextoname(in6->sin6_scope_id,
(char *)if_index_name);
if (strlen(if_index_name) != 0) {
snprintf(addr_buf, sizeof(addr_buf),
"%s%%%s%s", a6, if_index_name, atsign);
} else {
snprintf(addr_buf, sizeof(addr_buf), "%s%s",
a6, atsign);
}
}
#endif
else {
continue;
}
VERBOSITY(4, (LOG_INFO, "interface %s has address %s",
search_ifa, addr_buf));
*ip_addresses = xrealloc(*ip_addresses, sizeof(char *) * (*ip_add
resses_size + 1));
(*ip_addresses)[*ip_addresses_size] = xstrdup(addr_buf);
(*ip_addresses_size)++;
}
if (*ip_addresses_size == last_ip_addresses_size) {
*ip_addresses = xrealloc(*ip_addresses, sizeof(char *) * (*ip_add
resses_size + 1));
(*ip_addresses)[*ip_addresses_size] = xstrdup(search_ifa);
(*ip_addresses_size)++;
}
}
static void
resolve_interface_names_for_ref(struct ip_address_option** ip_addresses_ref,
struct ifaddrs *addrs, region_type* region)
{
struct ip_address_option *ip_addr;
struct ip_address_option *last = NULL;
struct ip_address_option *first = NULL;
/* replace the list of ip_adresses with a new list where the
* interface names are replaced with their ip-address strings
* from getifaddrs. An interface can have several addresses. */
for(ip_addr = *ip_addresses_ref; ip_addr; ip_addr = ip_addr->next) {
char **ip_addresses = NULL;
size_t ip_addresses_size = 0, i;
resolve_ifa_name(addrs, ip_addr->address, &ip_addresses,
&ip_addresses_size);
for (i = 0; i < ip_addresses_size; i++) {
struct ip_address_option *current;
/* this copies the range_option, dev, and fib from
* the original ip_address option to the new ones
* with the addresses spelled out by resolve_ifa_name*/
current = region_alloc_init(region, ip_addr,
sizeof(*ip_addr));
current->address = region_strdup(region,
ip_addresses[i]);
current->next = NULL;
free(ip_addresses[i]);
if(first == NULL) {
first = current;
} else {
last->next = current;
}
last = current;
}
free(ip_addresses);
}
*ip_addresses_ref = first;
}
#endif /* HAVE_GETIFADDRS */
void
resolve_interface_names(struct nsd_options* options)
{
#ifdef HAVE_GETIFADDRS
struct ifaddrs *addrs;
if(getifaddrs(&addrs) == -1)
error("failed to list interfaces");
resolve_interface_names_for_ref(&options->ip_addresses,
addrs, options->region);
resolve_interface_names_for_ref(&options->control_interface,
addrs, options->region);
freeifaddrs(addrs);
#else
(void)options;
#endif /* HAVE_GETIFADDRS */
}
 End of changes. 12 change blocks. 
1 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)