summaryrefslogtreecommitdiff
path: root/usr.sbin/nsd/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/nsd/options.c')
-rw-r--r--usr.sbin/nsd/options.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/usr.sbin/nsd/options.c b/usr.sbin/nsd/options.c
index 5064eca94f8..3fb67ffdd34 100644
--- a/usr.sbin/nsd/options.c
+++ b/usr.sbin/nsd/options.c
@@ -15,6 +15,7 @@
#include "tsig.h"
#include "difffile.h"
#include "rrl.h"
+#include "bitset.h"
#include "configyyrename.h"
#include "configparser.h"
@@ -57,6 +58,7 @@ nsd_options_create(region_type* region)
opt->verbosity = 0;
opt->hide_version = 0;
opt->hide_identity = 0;
+ opt->drop_updates = 0;
opt->do_ip4 = 1;
opt->do_ip6 = 1;
opt->database = DBFILE;
@@ -70,6 +72,8 @@ nsd_options_create(region_type* region)
opt->confine_to_zone = 0;
opt->refuse_any = 1;
opt->server_count = 1;
+ opt->cpu_affinity = NULL;
+ opt->service_cpu_affinity = NULL;
opt->tcp_count = 100;
opt->tcp_reject_overflow = 0;
opt->tcp_query_count = 0;
@@ -346,6 +350,7 @@ parse_zone_list_file(struct nsd_options* opt)
add foo.bar.nl slave
add rutabaga.uk config
*/
+ char hdr[64];
char buf[1024];
/* create empty data structures */
@@ -364,15 +369,16 @@ parse_zone_list_file(struct nsd_options* opt)
return 0;
}
/* read header */
- buf[strlen(ZONELIST_HEADER)] = 0;
- if(fread(buf, 1, strlen(ZONELIST_HEADER), opt->zonelist) !=
- strlen(ZONELIST_HEADER) || strncmp(buf, ZONELIST_HEADER,
+ hdr[strlen(ZONELIST_HEADER)] = 0;
+ if(fread(hdr, 1, strlen(ZONELIST_HEADER), opt->zonelist) !=
+ strlen(ZONELIST_HEADER) || strncmp(hdr, ZONELIST_HEADER,
strlen(ZONELIST_HEADER)) != 0) {
log_msg(LOG_ERR, "zone list %s contains bad header\n", opt->zonelistfile);
fclose(opt->zonelist);
opt->zonelist = NULL;
return 0;
}
+ buf[sizeof(buf)-1]=0;
/* read entries in file */
while(fgets(buf, sizeof(buf), opt->zonelist)) {
@@ -1414,7 +1420,7 @@ acl_addr_matches_ipv6host(struct acl_options* acl, struct sockaddr_storage* addr
return 0;
break;
case acl_range_minmax:
- if(!acl_addr_match_range((uint32_t*)&acl->addr.addr6, (uint32_t*)&addr->sin6_addr,
+ if(!acl_addr_match_range_v6((uint32_t*)&acl->addr.addr6, (uint32_t*)&addr->sin6_addr,
(uint32_t*)&acl->range_mask.addr6, sizeof(struct in6_addr)))
return 0;
break;
@@ -1442,7 +1448,7 @@ acl_addr_matches_ipv4host(struct acl_options* acl, struct sockaddr_in* addr, uns
return 0;
break;
case acl_range_minmax:
- if(!acl_addr_match_range((uint32_t*)&acl->addr.addr, (uint32_t*)&addr->sin_addr,
+ if(!acl_addr_match_range_v4((uint32_t*)&acl->addr.addr, (uint32_t*)&addr->sin_addr,
(uint32_t*)&acl->range_mask.addr, sizeof(struct in_addr)))
return 0;
break;
@@ -1522,7 +1528,23 @@ acl_addr_match_mask(uint32_t* a, uint32_t* b, uint32_t* mask, size_t sz)
}
int
-acl_addr_match_range(uint32_t* minval, uint32_t* x, uint32_t* maxval, size_t sz)
+acl_addr_match_range_v4(uint32_t* minval, uint32_t* x, uint32_t* maxval, size_t sz)
+{
+ assert(sz == 4); (void)sz;
+ /* check treats x as one huge number */
+
+ /* if outside bounds, we are done */
+ if(*minval > *x)
+ return 0;
+ if(*maxval < *x)
+ return 0;
+
+ return 1;
+}
+
+#ifdef INET6
+int
+acl_addr_match_range_v6(uint32_t* minval, uint32_t* x, uint32_t* maxval, size_t sz)
{
size_t i;
uint8_t checkmin = 1, checkmax = 1;
@@ -1550,6 +1572,7 @@ acl_addr_match_range(uint32_t* minval, uint32_t* x, uint32_t* maxval, size_t sz)
}
return 1;
}
+#endif /* INET6 */
int
acl_key_matches(struct acl_options* acl, struct query* q)