mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-19 08:33:44 -04:00
Use clang-format to reformat the source files
This commit is contained in:
parent
4c3b063ef8
commit
f50b1e0685
966 changed files with 75914 additions and 74245 deletions
|
|
@ -9,23 +9,21 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Winsock2.h>
|
||||
#endif
|
||||
|
||||
#include "check-tool.h"
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/log.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/netdb.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/netdb.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/region.h>
|
||||
#include <isc/stdio.h>
|
||||
|
|
@ -52,6 +50,8 @@
|
|||
|
||||
#include <ns/log.h>
|
||||
|
||||
#include "check-tool.h"
|
||||
|
||||
#ifndef CHECK_SIBLING
|
||||
#define CHECK_SIBLING 1
|
||||
#endif
|
||||
|
|
@ -60,11 +60,11 @@
|
|||
#define CHECK_LOCAL 1
|
||||
#endif
|
||||
|
||||
#define CHECK(r) \
|
||||
do { \
|
||||
result = (r); \
|
||||
#define CHECK(r) \
|
||||
do { \
|
||||
result = (r); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto cleanup; \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
#define ERR_IS_CNAME 1
|
||||
|
|
@ -78,9 +78,9 @@
|
|||
|
||||
static const char *dbtype[] = { "rbt" };
|
||||
|
||||
int debug = 0;
|
||||
int debug = 0;
|
||||
const char *journal = NULL;
|
||||
bool nomerge = true;
|
||||
bool nomerge = true;
|
||||
#if CHECK_LOCAL
|
||||
bool docheckmx = true;
|
||||
bool dochecksrv = true;
|
||||
|
|
@ -90,40 +90,37 @@ bool docheckmx = false;
|
|||
bool dochecksrv = false;
|
||||
bool docheckns = false;
|
||||
#endif
|
||||
dns_zoneopt_t zone_options = DNS_ZONEOPT_CHECKNS |
|
||||
DNS_ZONEOPT_CHECKMX |
|
||||
DNS_ZONEOPT_MANYERRORS |
|
||||
DNS_ZONEOPT_CHECKNAMES |
|
||||
dns_zoneopt_t zone_options = DNS_ZONEOPT_CHECKNS | DNS_ZONEOPT_CHECKMX |
|
||||
DNS_ZONEOPT_MANYERRORS | DNS_ZONEOPT_CHECKNAMES |
|
||||
DNS_ZONEOPT_CHECKINTEGRITY |
|
||||
#if CHECK_SIBLING
|
||||
DNS_ZONEOPT_CHECKSIBLING |
|
||||
#endif
|
||||
DNS_ZONEOPT_CHECKWILDCARD |
|
||||
DNS_ZONEOPT_WARNMXCNAME |
|
||||
DNS_ZONEOPT_WARNSRVCNAME;
|
||||
DNS_ZONEOPT_WARNMXCNAME | DNS_ZONEOPT_WARNSRVCNAME;
|
||||
|
||||
/*
|
||||
* This needs to match the list in bin/named/log.c.
|
||||
*/
|
||||
static isc_logcategory_t categories[] = {
|
||||
{ "", 0 },
|
||||
{ "unmatched", 0 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
static isc_logcategory_t categories[] = { { "", 0 },
|
||||
{ "unmatched", 0 },
|
||||
{ NULL, 0 } };
|
||||
|
||||
static isc_symtab_t *symtab = NULL;
|
||||
static isc_mem_t *sym_mctx;
|
||||
static isc_mem_t * sym_mctx;
|
||||
|
||||
static void
|
||||
freekey(char *key, unsigned int type, isc_symvalue_t value, void *userarg) {
|
||||
freekey(char *key, unsigned int type, isc_symvalue_t value, void *userarg)
|
||||
{
|
||||
UNUSED(type);
|
||||
UNUSED(value);
|
||||
isc_mem_free(userarg, key);
|
||||
}
|
||||
|
||||
static void
|
||||
add(char *key, int value) {
|
||||
isc_result_t result;
|
||||
add(char *key, int value)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_symvalue_t symvalue;
|
||||
|
||||
if (sym_mctx == NULL) {
|
||||
|
|
@ -147,7 +144,8 @@ add(char *key, int value) {
|
|||
}
|
||||
|
||||
static bool
|
||||
logged(char *key, int value) {
|
||||
logged(char *key, int value)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
if (symtab == NULL)
|
||||
|
|
@ -164,16 +162,16 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
dns_rdataset_t *a, dns_rdataset_t *aaaa)
|
||||
{
|
||||
dns_rdataset_t *rdataset;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
struct addrinfo hints, *ai, *cur;
|
||||
char namebuf[DNS_NAME_FORMATSIZE + 1];
|
||||
char ownerbuf[DNS_NAME_FORMATSIZE];
|
||||
char namebuf[DNS_NAME_FORMATSIZE + 1];
|
||||
char ownerbuf[DNS_NAME_FORMATSIZE];
|
||||
char addrbuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:123.123.123.123")];
|
||||
bool answer = true;
|
||||
bool match;
|
||||
const char *type;
|
||||
void *ptr = NULL;
|
||||
int result;
|
||||
void * ptr = NULL;
|
||||
int result;
|
||||
|
||||
REQUIRE(a == NULL || !dns_rdataset_isassociated(a) ||
|
||||
a->type == dns_rdatatype_a);
|
||||
|
|
@ -216,8 +214,7 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
dns_zone_log(zone, ISC_LOG_ERROR,
|
||||
"%s/NS '%s' (out of zone) "
|
||||
"is a CNAME '%s' (illegal)",
|
||||
ownerbuf, namebuf,
|
||||
cur->ai_canonname);
|
||||
ownerbuf, namebuf, cur->ai_canonname);
|
||||
/* XXX950 make fatal for 9.5.0 */
|
||||
/* answer = false; */
|
||||
add(namebuf, ERR_IS_CNAME);
|
||||
|
|
@ -240,8 +237,8 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
default:
|
||||
if (!logged(namebuf, ERR_LOOKUP_FAILURE)) {
|
||||
dns_zone_log(zone, ISC_LOG_WARNING,
|
||||
"getaddrinfo(%s) failed: %s",
|
||||
namebuf, gai_strerror(result));
|
||||
"getaddrinfo(%s) failed: %s", namebuf,
|
||||
gai_strerror(result));
|
||||
add(namebuf, ERR_LOOKUP_FAILURE);
|
||||
}
|
||||
return (true);
|
||||
|
|
@ -266,11 +263,12 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
}
|
||||
}
|
||||
if (!match && !logged(namebuf, ERR_EXTRA_A)) {
|
||||
dns_zone_log(zone, ISC_LOG_ERROR, "%s/NS '%s' "
|
||||
dns_zone_log(zone, ISC_LOG_ERROR,
|
||||
"%s/NS '%s' "
|
||||
"extra GLUE A record (%s)",
|
||||
ownerbuf, namebuf,
|
||||
inet_ntop(AF_INET, rdata.data,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
inet_ntop(AF_INET, rdata.data, addrbuf,
|
||||
sizeof(addrbuf)));
|
||||
add(namebuf, ERR_EXTRA_A);
|
||||
/* XXX950 make fatal for 9.5.0 */
|
||||
/* answer = false; */
|
||||
|
|
@ -279,7 +277,7 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
result = dns_rdataset_next(a);
|
||||
}
|
||||
|
||||
checkaaaa:
|
||||
checkaaaa:
|
||||
if (!dns_rdataset_isassociated(aaaa))
|
||||
goto checkmissing;
|
||||
result = dns_rdataset_first(aaaa);
|
||||
|
|
@ -289,18 +287,20 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
for (cur = ai; cur != NULL; cur = cur->ai_next) {
|
||||
if (cur->ai_family != AF_INET6)
|
||||
continue;
|
||||
ptr = &((struct sockaddr_in6 *)(cur->ai_addr))->sin6_addr;
|
||||
ptr = &((struct sockaddr_in6 *)(cur->ai_addr))
|
||||
->sin6_addr;
|
||||
if (memcmp(ptr, rdata.data, rdata.length) == 0) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!match && !logged(namebuf, ERR_EXTRA_AAAA)) {
|
||||
dns_zone_log(zone, ISC_LOG_ERROR, "%s/NS '%s' "
|
||||
dns_zone_log(zone, ISC_LOG_ERROR,
|
||||
"%s/NS '%s' "
|
||||
"extra GLUE AAAA record (%s)",
|
||||
ownerbuf, namebuf,
|
||||
inet_ntop(AF_INET6, rdata.data,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
inet_ntop(AF_INET6, rdata.data, addrbuf,
|
||||
sizeof(addrbuf)));
|
||||
add(namebuf, ERR_EXTRA_AAAA);
|
||||
/* XXX950 make fatal for 9.5.0. */
|
||||
/* answer = false; */
|
||||
|
|
@ -309,7 +309,7 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
result = dns_rdataset_next(aaaa);
|
||||
}
|
||||
|
||||
checkmissing:
|
||||
checkmissing:
|
||||
/*
|
||||
* Check that all addresses appear in the glue.
|
||||
*/
|
||||
|
|
@ -319,16 +319,18 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
switch (cur->ai_family) {
|
||||
case AF_INET:
|
||||
rdataset = a;
|
||||
ptr = &((struct sockaddr_in *)(cur->ai_addr))->sin_addr;
|
||||
ptr = &((struct sockaddr_in *)(cur->ai_addr))
|
||||
->sin_addr;
|
||||
type = "A";
|
||||
break;
|
||||
case AF_INET6:
|
||||
rdataset = aaaa;
|
||||
ptr = &((struct sockaddr_in6 *)(cur->ai_addr))->sin6_addr;
|
||||
ptr = &((struct sockaddr_in6 *)(cur->ai_addr))
|
||||
->sin6_addr;
|
||||
type = "AAAA";
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
match = false;
|
||||
if (dns_rdataset_isassociated(rdataset))
|
||||
|
|
@ -343,11 +345,13 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
result = dns_rdataset_next(rdataset);
|
||||
}
|
||||
if (!match) {
|
||||
dns_zone_log(zone, ISC_LOG_ERROR, "%s/NS '%s' "
|
||||
dns_zone_log(zone, ISC_LOG_ERROR,
|
||||
"%s/NS '%s' "
|
||||
"missing GLUE %s record (%s)",
|
||||
ownerbuf, namebuf, type,
|
||||
inet_ntop(cur->ai_family, ptr,
|
||||
addrbuf, sizeof(addrbuf)));
|
||||
addrbuf,
|
||||
sizeof(addrbuf)));
|
||||
/* XXX950 make fatal for 9.5.0. */
|
||||
/* answer = false; */
|
||||
missing_glue = true;
|
||||
|
|
@ -361,13 +365,14 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
|
|||
}
|
||||
|
||||
static bool
|
||||
checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
||||
checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner)
|
||||
{
|
||||
struct addrinfo hints, *ai, *cur;
|
||||
char namebuf[DNS_NAME_FORMATSIZE + 1];
|
||||
char ownerbuf[DNS_NAME_FORMATSIZE];
|
||||
int result;
|
||||
int level = ISC_LOG_ERROR;
|
||||
bool answer = true;
|
||||
char namebuf[DNS_NAME_FORMATSIZE + 1];
|
||||
char ownerbuf[DNS_NAME_FORMATSIZE];
|
||||
int result;
|
||||
int level = ISC_LOG_ERROR;
|
||||
bool answer = true;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
|
|
@ -434,8 +439,8 @@ checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
|||
default:
|
||||
if (!logged(namebuf, ERR_LOOKUP_FAILURE)) {
|
||||
dns_zone_log(zone, ISC_LOG_WARNING,
|
||||
"getaddrinfo(%s) failed: %s",
|
||||
namebuf, gai_strerror(result));
|
||||
"getaddrinfo(%s) failed: %s", namebuf,
|
||||
gai_strerror(result));
|
||||
add(namebuf, ERR_LOOKUP_FAILURE);
|
||||
}
|
||||
return (true);
|
||||
|
|
@ -443,13 +448,14 @@ checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
|||
}
|
||||
|
||||
static bool
|
||||
checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
||||
checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner)
|
||||
{
|
||||
struct addrinfo hints, *ai, *cur;
|
||||
char namebuf[DNS_NAME_FORMATSIZE + 1];
|
||||
char ownerbuf[DNS_NAME_FORMATSIZE];
|
||||
int result;
|
||||
int level = ISC_LOG_ERROR;
|
||||
bool answer = true;
|
||||
char namebuf[DNS_NAME_FORMATSIZE + 1];
|
||||
char ownerbuf[DNS_NAME_FORMATSIZE];
|
||||
int result;
|
||||
int level = ISC_LOG_ERROR;
|
||||
bool answer = true;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
|
|
@ -484,7 +490,8 @@ checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
|||
level = ISC_LOG_WARNING;
|
||||
if ((zone_options & DNS_ZONEOPT_IGNORESRVCNAME) == 0) {
|
||||
if (!logged(namebuf, ERR_IS_SRVCNAME)) {
|
||||
dns_zone_log(zone, level, "%s/SRV '%s'"
|
||||
dns_zone_log(zone, level,
|
||||
"%s/SRV '%s'"
|
||||
" (out of zone) is a "
|
||||
"CNAME '%s' (illegal)",
|
||||
ownerbuf, namebuf,
|
||||
|
|
@ -515,8 +522,8 @@ checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
|||
default:
|
||||
if (!logged(namebuf, ERR_LOOKUP_FAILURE)) {
|
||||
dns_zone_log(zone, ISC_LOG_WARNING,
|
||||
"getaddrinfo(%s) failed: %s",
|
||||
namebuf, gai_strerror(result));
|
||||
"getaddrinfo(%s) failed: %s", namebuf,
|
||||
gai_strerror(result));
|
||||
add(namebuf, ERR_LOOKUP_FAILURE);
|
||||
}
|
||||
return (true);
|
||||
|
|
@ -524,10 +531,11 @@ checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
|
||||
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp)
|
||||
{
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
isc_log_t *log = NULL;
|
||||
isc_logconfig_t * logconfig = NULL;
|
||||
isc_log_t * log = NULL;
|
||||
|
||||
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
|
||||
isc_log_registercategories(log, categories);
|
||||
|
|
@ -542,11 +550,10 @@ setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
|
|||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
RUNTIME_CHECK(isc_log_createchannel(logconfig, "stderr",
|
||||
ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination, 0) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr",
|
||||
NULL, NULL) == ISC_R_SUCCESS);
|
||||
ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
|
||||
&destination, 0) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
*logp = log;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
@ -554,16 +561,17 @@ setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
|
|||
|
||||
/*% scan the zone for oversize TTLs */
|
||||
static isc_result_t
|
||||
check_ttls(dns_zone_t *zone, dns_ttl_t maxttl) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
dns_dbversion_t *version = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
dns_dbiterator_t *dbiter = NULL;
|
||||
check_ttls(dns_zone_t *zone, dns_ttl_t maxttl)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_db_t * db = NULL;
|
||||
dns_dbversion_t * version = NULL;
|
||||
dns_dbnode_t * node = NULL;
|
||||
dns_dbiterator_t * dbiter = NULL;
|
||||
dns_rdatasetiter_t *rdsiter = NULL;
|
||||
dns_rdataset_t rdataset;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t *name;
|
||||
dns_rdataset_t rdataset;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t * name;
|
||||
name = dns_fixedname_initname(&fname);
|
||||
dns_rdataset_init(&rdataset);
|
||||
|
||||
|
|
@ -573,8 +581,7 @@ check_ttls(dns_zone_t *zone, dns_ttl_t maxttl) {
|
|||
CHECK(dns_db_newversion(db, &version));
|
||||
CHECK(dns_db_createiterator(db, 0, &dbiter));
|
||||
|
||||
for (result = dns_dbiterator_first(dbiter);
|
||||
result == ISC_R_SUCCESS;
|
||||
for (result = dns_dbiterator_first(dbiter); result == ISC_R_SUCCESS;
|
||||
result = dns_dbiterator_next(dbiter)) {
|
||||
result = dns_dbiterator_current(dbiter, &node, name);
|
||||
if (result == DNS_R_NEWORIGIN)
|
||||
|
|
@ -587,8 +594,8 @@ check_ttls(dns_zone_t *zone, dns_ttl_t maxttl) {
|
|||
result = dns_rdatasetiter_next(rdsiter)) {
|
||||
dns_rdatasetiter_current(rdsiter, &rdataset);
|
||||
if (rdataset.ttl > maxttl) {
|
||||
char nbuf[DNS_NAME_FORMATSIZE];
|
||||
char tbuf[255];
|
||||
char nbuf[DNS_NAME_FORMATSIZE];
|
||||
char tbuf[255];
|
||||
isc_buffer_t b;
|
||||
isc_region_t r;
|
||||
|
||||
|
|
@ -618,7 +625,7 @@ check_ttls(dns_zone_t *zone, dns_ttl_t maxttl) {
|
|||
if (result == ISC_R_NOMORE)
|
||||
result = ISC_R_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (node != NULL)
|
||||
dns_db_detachnode(db, &node);
|
||||
if (rdsiter != NULL)
|
||||
|
|
@ -639,13 +646,13 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
|||
dns_masterformat_t fileformat, const char *classname,
|
||||
dns_ttl_t maxttl, dns_zone_t **zonep)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
dns_rdataclass_t rdclass;
|
||||
isc_textregion_t region;
|
||||
isc_buffer_t buffer;
|
||||
dns_fixedname_t fixorigin;
|
||||
dns_name_t *origin;
|
||||
dns_zone_t *zone = NULL;
|
||||
isc_buffer_t buffer;
|
||||
dns_fixedname_t fixorigin;
|
||||
dns_name_t * origin;
|
||||
dns_zone_t * zone = NULL;
|
||||
|
||||
REQUIRE(zonep == NULL || *zonep == NULL);
|
||||
|
||||
|
|
@ -662,7 +669,7 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
|||
origin = dns_fixedname_initname(&fixorigin);
|
||||
CHECK(dns_name_fromtext(origin, &buffer, dns_rootname, 0, NULL));
|
||||
CHECK(dns_zone_setorigin(zone, origin));
|
||||
dns_zone_setdbtype(zone, 1, (const char * const *) dbtype);
|
||||
dns_zone_setdbtype(zone, 1, (const char *const *)dbtype);
|
||||
CHECK(dns_zone_setfile(zone, filename, fileformat,
|
||||
&dns_master_style_default));
|
||||
if (journal != NULL)
|
||||
|
|
@ -700,7 +707,7 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
|||
zone = NULL;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (zone != NULL)
|
||||
dns_zone_detach(&zone);
|
||||
return (result);
|
||||
|
|
@ -713,15 +720,15 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
|
|||
const uint32_t rawversion)
|
||||
{
|
||||
isc_result_t result;
|
||||
FILE *output = stdout;
|
||||
const char *flags;
|
||||
FILE * output = stdout;
|
||||
const char * flags;
|
||||
|
||||
flags = (fileformat == dns_masterformat_text) ? "w" : "wb";
|
||||
|
||||
if (debug) {
|
||||
if (filename != NULL && strcmp(filename, "-") != 0)
|
||||
fprintf(stderr, "dumping \"%s\" to \"%s\"\n",
|
||||
zonename, filename);
|
||||
fprintf(stderr, "dumping \"%s\" to \"%s\"\n", zonename,
|
||||
filename);
|
||||
else
|
||||
fprintf(stderr, "dumping \"%s\"\n", zonename);
|
||||
}
|
||||
|
|
@ -730,8 +737,10 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
|
|||
result = isc_stdio_open(filename, flags, &output);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "could not open output "
|
||||
"file \"%s\" for writing\n", filename);
|
||||
fprintf(stderr,
|
||||
"could not open output "
|
||||
"file \"%s\" for writing\n",
|
||||
filename);
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -746,14 +755,15 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
|
|||
|
||||
#ifdef _WIN32
|
||||
void
|
||||
InitSockets(void) {
|
||||
WORD wVersionRequested;
|
||||
InitSockets(void)
|
||||
{
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
int err;
|
||||
|
||||
wVersionRequested = MAKEWORD(2, 0);
|
||||
|
||||
err = WSAStartup( wVersionRequested, &wsaData );
|
||||
err = WSAStartup(wVersionRequested, &wsaData);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup() failed: %d\n", err);
|
||||
exit(1);
|
||||
|
|
@ -761,7 +771,8 @@ InitSockets(void) {
|
|||
}
|
||||
|
||||
void
|
||||
DestroySockets(void) {
|
||||
DestroySockets(void)
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CHECK_TOOL_H
|
||||
#define CHECK_TOOL_H
|
||||
|
||||
|
|
@ -42,16 +41,18 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
|
|||
const uint32_t rawversion);
|
||||
|
||||
#ifdef _WIN32
|
||||
void InitSockets(void);
|
||||
void DestroySockets(void);
|
||||
void
|
||||
InitSockets(void);
|
||||
void
|
||||
DestroySockets(void);
|
||||
#endif
|
||||
|
||||
extern int debug;
|
||||
extern const char *journal;
|
||||
extern bool nomerge;
|
||||
extern bool docheckmx;
|
||||
extern bool docheckns;
|
||||
extern bool dochecksrv;
|
||||
extern int debug;
|
||||
extern const char * journal;
|
||||
extern bool nomerge;
|
||||
extern bool docheckmx;
|
||||
extern bool docheckns;
|
||||
extern bool dochecksrv;
|
||||
extern dns_zoneopt_t zone_options;
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
|
|
|||
|
|
@ -9,13 +9,12 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/dir.h>
|
||||
|
|
@ -27,11 +26,6 @@
|
|||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <isccfg/namedconf.h>
|
||||
#include <isccfg/grammar.h>
|
||||
|
||||
#include <bind9/check.h>
|
||||
|
||||
#include <dns/db.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/log.h>
|
||||
|
|
@ -41,19 +35,24 @@
|
|||
#include <dns/rootns.h>
|
||||
#include <dns/zone.h>
|
||||
|
||||
#include <isccfg/grammar.h>
|
||||
#include <isccfg/namedconf.h>
|
||||
|
||||
#include "check-tool.h"
|
||||
|
||||
#include <bind9/check.h>
|
||||
|
||||
static const char *program = "named-checkconf";
|
||||
|
||||
static bool loadplugins = true;
|
||||
|
||||
isc_log_t *logc = NULL;
|
||||
|
||||
#define CHECK(r)\
|
||||
do { \
|
||||
result = (r); \
|
||||
#define CHECK(r) \
|
||||
do { \
|
||||
result = (r); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto cleanup; \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
/*% usage */
|
||||
|
|
@ -61,17 +60,21 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
fprintf(stderr, "usage: %s [-chijlvz] [-p [-x]] [-t directory] "
|
||||
"[named.conf]\n", program);
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-chijlvz] [-p [-x]] [-t directory] "
|
||||
"[named.conf]\n",
|
||||
program);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*% directory callback */
|
||||
static isc_result_t
|
||||
directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) {
|
||||
directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char *directory;
|
||||
const char * directory;
|
||||
|
||||
REQUIRE(strcasecmp("directory", clausename) == 0);
|
||||
|
||||
|
|
@ -85,8 +88,8 @@ directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) {
|
|||
result = isc_dir_chdir(directory);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
cfg_obj_log(obj, logc, ISC_LOG_ERROR,
|
||||
"change directory to '%s' failed: %s\n",
|
||||
directory, isc_result_totext(result));
|
||||
"change directory to '%s' failed: %s\n", directory,
|
||||
isc_result_totext(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +97,8 @@ directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) {
|
|||
}
|
||||
|
||||
static bool
|
||||
get_maps(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj) {
|
||||
get_maps(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj)
|
||||
{
|
||||
int i;
|
||||
for (i = 0;; i++) {
|
||||
if (maps[i] == NULL)
|
||||
|
|
@ -105,13 +109,14 @@ get_maps(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj) {
|
|||
}
|
||||
|
||||
static bool
|
||||
get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
|
||||
get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj)
|
||||
{
|
||||
const cfg_listelt_t *element;
|
||||
const cfg_obj_t *checknames;
|
||||
const cfg_obj_t *type;
|
||||
const cfg_obj_t *value;
|
||||
isc_result_t result;
|
||||
int i;
|
||||
const cfg_obj_t * checknames;
|
||||
const cfg_obj_t * type;
|
||||
const cfg_obj_t * value;
|
||||
isc_result_t result;
|
||||
int i;
|
||||
|
||||
for (i = 0;; i++) {
|
||||
if (maps[i] == NULL)
|
||||
|
|
@ -124,16 +129,14 @@ get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
|
|||
*obj = checknames;
|
||||
return (true);
|
||||
}
|
||||
for (element = cfg_list_first(checknames);
|
||||
element != NULL;
|
||||
for (element = cfg_list_first(checknames); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
value = cfg_listelt_value(element);
|
||||
type = cfg_tuple_get(value, "type");
|
||||
if ((strcasecmp(cfg_obj_asstring(type),
|
||||
"primary") != 0) &&
|
||||
(strcasecmp(cfg_obj_asstring(type),
|
||||
"master") != 0))
|
||||
{
|
||||
if ((strcasecmp(cfg_obj_asstring(type), "primary") !=
|
||||
0) &&
|
||||
(strcasecmp(cfg_obj_asstring(type), "master") !=
|
||||
0)) {
|
||||
continue;
|
||||
}
|
||||
*obj = cfg_tuple_get(value, "mode");
|
||||
|
|
@ -143,9 +146,10 @@ get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_db_t * db = NULL;
|
||||
dns_rdataclass_t rdclass;
|
||||
isc_textregion_t r;
|
||||
|
||||
|
|
@ -168,28 +172,28 @@ configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
|
|||
|
||||
/*% configure the zone */
|
||||
static isc_result_t
|
||||
configure_zone(const char *vclass, const char *view,
|
||||
const cfg_obj_t *zconfig, const cfg_obj_t *vconfig,
|
||||
const cfg_obj_t *config, isc_mem_t *mctx, bool list)
|
||||
configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
|
||||
const cfg_obj_t *vconfig, const cfg_obj_t *config,
|
||||
isc_mem_t *mctx, bool list)
|
||||
{
|
||||
int i = 0;
|
||||
isc_result_t result;
|
||||
const char *zclass;
|
||||
const char *zname;
|
||||
const char *zfile = NULL;
|
||||
const cfg_obj_t *maps[4];
|
||||
const cfg_obj_t *mastersobj = NULL;
|
||||
const cfg_obj_t *inviewobj = NULL;
|
||||
const cfg_obj_t *zoptions = NULL;
|
||||
const cfg_obj_t *classobj = NULL;
|
||||
const cfg_obj_t *typeobj = NULL;
|
||||
const cfg_obj_t *fileobj = NULL;
|
||||
const cfg_obj_t *dlzobj = NULL;
|
||||
const cfg_obj_t *dbobj = NULL;
|
||||
const cfg_obj_t *obj = NULL;
|
||||
const cfg_obj_t *fmtobj = NULL;
|
||||
int i = 0;
|
||||
isc_result_t result;
|
||||
const char * zclass;
|
||||
const char * zname;
|
||||
const char * zfile = NULL;
|
||||
const cfg_obj_t * maps[4];
|
||||
const cfg_obj_t * mastersobj = NULL;
|
||||
const cfg_obj_t * inviewobj = NULL;
|
||||
const cfg_obj_t * zoptions = NULL;
|
||||
const cfg_obj_t * classobj = NULL;
|
||||
const cfg_obj_t * typeobj = NULL;
|
||||
const cfg_obj_t * fileobj = NULL;
|
||||
const cfg_obj_t * dlzobj = NULL;
|
||||
const cfg_obj_t * dbobj = NULL;
|
||||
const cfg_obj_t * obj = NULL;
|
||||
const cfg_obj_t * fmtobj = NULL;
|
||||
dns_masterformat_t masterformat;
|
||||
dns_ttl_t maxttl = 0;
|
||||
dns_ttl_t maxttl = 0;
|
||||
|
||||
zone_options = DNS_ZONEOPT_CHECKNS | DNS_ZONEOPT_MANYERRORS;
|
||||
|
||||
|
|
@ -233,8 +237,7 @@ configure_zone(const char *vclass, const char *view,
|
|||
* Skip checks when using an alternate data source.
|
||||
*/
|
||||
cfg_map_get(zoptions, "database", &dbobj);
|
||||
if (dbobj != NULL &&
|
||||
strcmp("rbt", cfg_obj_asstring(dbobj)) != 0 &&
|
||||
if (dbobj != NULL && strcmp("rbt", cfg_obj_asstring(dbobj)) != 0 &&
|
||||
strcmp("rbt64", cfg_obj_asstring(dbobj)) != 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
|
|
@ -255,8 +258,7 @@ configure_zone(const char *vclass, const char *view,
|
|||
return (configure_hint(zfile, zclass, mctx));
|
||||
} else if ((strcasecmp(cfg_obj_asstring(typeobj), "primary") != 0) &&
|
||||
(strcasecmp(cfg_obj_asstring(typeobj), "master") != 0) &&
|
||||
(strcasecmp(cfg_obj_asstring(typeobj), "redirect") != 0))
|
||||
{
|
||||
(strcasecmp(cfg_obj_asstring(typeobj), "redirect") != 0)) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -399,8 +401,8 @@ configure_zone(const char *vclass, const char *view,
|
|||
ISC_UNREACHABLE();
|
||||
}
|
||||
} else {
|
||||
zone_options |= DNS_ZONEOPT_CHECKNAMES;
|
||||
zone_options |= DNS_ZONEOPT_CHECKNAMESFAIL;
|
||||
zone_options |= DNS_ZONEOPT_CHECKNAMES;
|
||||
zone_options |= DNS_ZONEOPT_CHECKNAMESFAIL;
|
||||
}
|
||||
|
||||
masterformat = dns_masterformat_text;
|
||||
|
|
@ -425,8 +427,8 @@ configure_zone(const char *vclass, const char *view,
|
|||
zone_options |= DNS_ZONEOPT_CHECKTTL;
|
||||
}
|
||||
|
||||
result = load_zone(mctx, zname, zfile, masterformat,
|
||||
zclass, maxttl, NULL);
|
||||
result = load_zone(mctx, zname, zfile, masterformat, zclass, maxttl,
|
||||
NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fprintf(stderr, "%s/%s/%s: %s\n", view, zname, zclass,
|
||||
dns_result_totext(result));
|
||||
|
|
@ -439,10 +441,10 @@ configure_view(const char *vclass, const char *view, const cfg_obj_t *config,
|
|||
const cfg_obj_t *vconfig, isc_mem_t *mctx, bool list)
|
||||
{
|
||||
const cfg_listelt_t *element;
|
||||
const cfg_obj_t *voptions;
|
||||
const cfg_obj_t *zonelist;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_result_t tresult;
|
||||
const cfg_obj_t * voptions;
|
||||
const cfg_obj_t * zonelist;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_result_t tresult;
|
||||
|
||||
voptions = NULL;
|
||||
if (vconfig != NULL)
|
||||
|
|
@ -454,13 +456,11 @@ configure_view(const char *vclass, const char *view, const cfg_obj_t *config,
|
|||
else
|
||||
(void)cfg_map_get(config, "zone", &zonelist);
|
||||
|
||||
for (element = cfg_list_first(zonelist);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
for (element = cfg_list_first(zonelist); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
const cfg_obj_t *zconfig = cfg_listelt_value(element);
|
||||
tresult = configure_zone(vclass, view, zconfig, vconfig,
|
||||
config, mctx, list);
|
||||
tresult = configure_zone(vclass, view, zconfig, vconfig, config,
|
||||
mctx, list);
|
||||
if (tresult != ISC_R_SUCCESS)
|
||||
result = tresult;
|
||||
}
|
||||
|
|
@ -484,34 +484,30 @@ config_getclass(const cfg_obj_t *classobj, dns_rdataclass_t defclass,
|
|||
|
||||
/*% load zones from the configuration */
|
||||
static isc_result_t
|
||||
load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx,
|
||||
bool list_zones)
|
||||
load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx, bool list_zones)
|
||||
{
|
||||
const cfg_listelt_t *element;
|
||||
const cfg_obj_t *views;
|
||||
const cfg_obj_t *vconfig;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_result_t tresult;
|
||||
const cfg_obj_t * views;
|
||||
const cfg_obj_t * vconfig;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_result_t tresult;
|
||||
|
||||
views = NULL;
|
||||
|
||||
(void)cfg_map_get(config, "view", &views);
|
||||
for (element = cfg_list_first(views);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
for (element = cfg_list_first(views); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
const cfg_obj_t *classobj;
|
||||
dns_rdataclass_t viewclass;
|
||||
const char *vname;
|
||||
char buf[sizeof("CLASS65535")];
|
||||
const char * vname;
|
||||
char buf[sizeof("CLASS65535")];
|
||||
|
||||
vconfig = cfg_listelt_value(element);
|
||||
if (vconfig == NULL)
|
||||
continue;
|
||||
|
||||
classobj = cfg_tuple_get(vconfig, "class");
|
||||
CHECK(config_getclass(classobj, dns_rdataclass_in,
|
||||
&viewclass));
|
||||
CHECK(config_getclass(classobj, dns_rdataclass_in, &viewclass));
|
||||
if (dns_rdataclass_ismeta(viewclass))
|
||||
CHECK(ISC_R_FAILURE);
|
||||
|
||||
|
|
@ -535,7 +531,8 @@ cleanup:
|
|||
}
|
||||
|
||||
static void
|
||||
output(void *closure, const char *text, int textlen) {
|
||||
output(void *closure, const char *text, int textlen)
|
||||
{
|
||||
UNUSED(closure);
|
||||
if (fwrite(text, 1, textlen, stdout) != (size_t)textlen) {
|
||||
perror("fwrite");
|
||||
|
|
@ -545,19 +542,20 @@ output(void *closure, const char *text, int textlen) {
|
|||
|
||||
/*% The main processing routine */
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
int c;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
const char *conffile = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_result_t result;
|
||||
int exit_status = 0;
|
||||
bool load_zones = false;
|
||||
bool list_zones = false;
|
||||
bool print = false;
|
||||
bool nodeprecate = false;
|
||||
unsigned int flags = 0;
|
||||
cfg_obj_t * config = NULL;
|
||||
const char * conffile = NULL;
|
||||
isc_mem_t * mctx = NULL;
|
||||
isc_result_t result;
|
||||
int exit_status = 0;
|
||||
bool load_zones = false;
|
||||
bool list_zones = false;
|
||||
bool print = false;
|
||||
bool nodeprecate = false;
|
||||
unsigned int flags = 0;
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
|
|
@ -649,8 +647,8 @@ main(int argc, char **argv) {
|
|||
usage();
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -687,8 +685,7 @@ main(int argc, char **argv) {
|
|||
cfg_parser_setcallback(parser, directory_callback, NULL);
|
||||
|
||||
if (cfg_parse_file(parser, conffile, &cfg_type_namedconf, &config) !=
|
||||
ISC_R_SUCCESS)
|
||||
{
|
||||
ISC_R_SUCCESS) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,11 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <isc/app.h>
|
||||
#include <isc/commandline.h>
|
||||
|
|
@ -43,31 +42,32 @@
|
|||
|
||||
#include "check-tool.h"
|
||||
|
||||
static int quiet = 0;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
dns_zone_t *zone = NULL;
|
||||
dns_zonetype_t zonetype = dns_zone_master;
|
||||
static int dumpzone = 0;
|
||||
static const char *output_filename;
|
||||
static const char *prog_name = NULL;
|
||||
static int quiet = 0;
|
||||
static isc_mem_t * mctx = NULL;
|
||||
dns_zone_t * zone = NULL;
|
||||
dns_zonetype_t zonetype = dns_zone_master;
|
||||
static int dumpzone = 0;
|
||||
static const char * output_filename;
|
||||
static const char * prog_name = NULL;
|
||||
static const dns_master_style_t *outputstyle = NULL;
|
||||
static enum { progmode_check, progmode_compile } progmode;
|
||||
|
||||
#define ERRRET(result, function) \
|
||||
do { \
|
||||
if (result != ISC_R_SUCCESS) { \
|
||||
if (!quiet) \
|
||||
fprintf(stderr, "%s() returned %s\n", \
|
||||
#define ERRRET(result, function) \
|
||||
do { \
|
||||
if (result != ISC_R_SUCCESS) { \
|
||||
if (!quiet) \
|
||||
fprintf(stderr, "%s() returned %s\n", \
|
||||
function, dns_result_totext(result)); \
|
||||
return (result); \
|
||||
} \
|
||||
return (result); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
ISC_PLATFORM_NORETURN_PRE static void
|
||||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-djqvD] [-c class] "
|
||||
"[-f inputformat] [-F outputformat] [-J filename] "
|
||||
|
|
@ -84,7 +84,8 @@ usage(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
destroy(void) {
|
||||
destroy(void)
|
||||
{
|
||||
if (zone != NULL) {
|
||||
dns_zone_detach(&zone);
|
||||
}
|
||||
|
|
@ -92,26 +93,27 @@ destroy(void) {
|
|||
|
||||
/*% main processing routine */
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
int c;
|
||||
char *origin = NULL;
|
||||
char *filename = NULL;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_result_t result;
|
||||
char classname_in[] = "IN";
|
||||
char *classname = classname_in;
|
||||
const char *workdir = NULL;
|
||||
const char *inputformatstr = NULL;
|
||||
const char *outputformatstr = NULL;
|
||||
dns_masterformat_t inputformat = dns_masterformat_text;
|
||||
dns_masterformat_t outputformat = dns_masterformat_text;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
char * origin = NULL;
|
||||
char * filename = NULL;
|
||||
isc_log_t * lctx = NULL;
|
||||
isc_result_t result;
|
||||
char classname_in[] = "IN";
|
||||
char * classname = classname_in;
|
||||
const char * workdir = NULL;
|
||||
const char * inputformatstr = NULL;
|
||||
const char * outputformatstr = NULL;
|
||||
dns_masterformat_t inputformat = dns_masterformat_text;
|
||||
dns_masterformat_t outputformat = dns_masterformat_text;
|
||||
dns_masterrawheader_t header;
|
||||
uint32_t rawversion = 1, serialnum = 0;
|
||||
dns_ttl_t maxttl = 0;
|
||||
bool snset = false;
|
||||
bool logdump = false;
|
||||
FILE *errout = stdout;
|
||||
char *endp;
|
||||
uint32_t rawversion = 1, serialnum = 0;
|
||||
dns_ttl_t maxttl = 0;
|
||||
bool snset = false;
|
||||
bool logdump = false;
|
||||
FILE * errout = stdout;
|
||||
char * endp;
|
||||
|
||||
/*
|
||||
* Uncomment the following line if memory debugging is needed:
|
||||
|
|
@ -148,24 +150,21 @@ main(int argc, char **argv) {
|
|||
|
||||
/* Compilation specific defaults */
|
||||
if (progmode == progmode_compile) {
|
||||
zone_options |= (DNS_ZONEOPT_CHECKNS |
|
||||
DNS_ZONEOPT_FATALNS |
|
||||
DNS_ZONEOPT_CHECKSPF |
|
||||
DNS_ZONEOPT_CHECKDUPRR |
|
||||
DNS_ZONEOPT_CHECKNAMES |
|
||||
DNS_ZONEOPT_CHECKNAMESFAIL |
|
||||
DNS_ZONEOPT_CHECKWILDCARD);
|
||||
zone_options |=
|
||||
(DNS_ZONEOPT_CHECKNS | DNS_ZONEOPT_FATALNS |
|
||||
DNS_ZONEOPT_CHECKSPF | DNS_ZONEOPT_CHECKDUPRR |
|
||||
DNS_ZONEOPT_CHECKNAMES | DNS_ZONEOPT_CHECKNAMESFAIL |
|
||||
DNS_ZONEOPT_CHECKWILDCARD);
|
||||
} else
|
||||
zone_options |= (DNS_ZONEOPT_CHECKDUPRR |
|
||||
DNS_ZONEOPT_CHECKSPF);
|
||||
zone_options |= (DNS_ZONEOPT_CHECKDUPRR | DNS_ZONEOPT_CHECKSPF);
|
||||
|
||||
#define ARGCMP(X) (strcmp(isc_commandline_argument, X) == 0)
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv,
|
||||
"c:df:hi:jJ:k:L:l:m:n:qr:s:t:o:vw:DF:M:S:T:W:"))
|
||||
!= EOF) {
|
||||
"c:df:hi:jJ:k:L:l:m:n:qr:s:t:o:vw:DF:"
|
||||
"M:S:T:W:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
classname = isc_commandline_argument;
|
||||
|
|
@ -269,16 +268,15 @@ main(int argc, char **argv) {
|
|||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'n':
|
||||
if (ARGCMP("ignore")) {
|
||||
zone_options &= ~(DNS_ZONEOPT_CHECKNS|
|
||||
zone_options &= ~(DNS_ZONEOPT_CHECKNS |
|
||||
DNS_ZONEOPT_FATALNS);
|
||||
} else if (ARGCMP("warn")) {
|
||||
zone_options |= DNS_ZONEOPT_CHECKNS;
|
||||
zone_options &= ~DNS_ZONEOPT_FATALNS;
|
||||
} else if (ARGCMP("fail")) {
|
||||
zone_options |= DNS_ZONEOPT_CHECKNS|
|
||||
zone_options |= DNS_ZONEOPT_CHECKNS |
|
||||
DNS_ZONEOPT_FATALNS;
|
||||
} else {
|
||||
fprintf(stderr, "invalid argument to -n: %s\n",
|
||||
|
|
@ -426,8 +424,8 @@ main(int argc, char **argv) {
|
|||
usage();
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
prog_name, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", prog_name,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -435,8 +433,8 @@ main(int argc, char **argv) {
|
|||
if (workdir != NULL) {
|
||||
result = isc_dir_chdir(workdir);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "isc_dir_chdir: %s: %s\n",
|
||||
workdir, isc_result_totext(result));
|
||||
fprintf(stderr, "isc_dir_chdir: %s: %s\n", workdir,
|
||||
isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -448,13 +446,13 @@ main(int argc, char **argv) {
|
|||
inputformat = dns_masterformat_raw;
|
||||
else if (strncasecmp(inputformatstr, "raw=", 4) == 0) {
|
||||
inputformat = dns_masterformat_raw;
|
||||
fprintf(stderr,
|
||||
"WARNING: input format raw, version ignored\n");
|
||||
fprintf(stderr, "WARNING: input format raw, version "
|
||||
"ignored\n");
|
||||
} else if (strcasecmp(inputformatstr, "map") == 0) {
|
||||
inputformat = dns_masterformat_map;
|
||||
} else {
|
||||
fprintf(stderr, "unknown file format: %s\n",
|
||||
inputformatstr);
|
||||
inputformatstr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -471,8 +469,7 @@ main(int argc, char **argv) {
|
|||
rawversion = strtol(outputformatstr + 4, &end, 10);
|
||||
if (end == outputformatstr + 4 || *end != '\0' ||
|
||||
rawversion > 1U) {
|
||||
fprintf(stderr,
|
||||
"unknown raw format version\n");
|
||||
fprintf(stderr, "unknown raw format version\n");
|
||||
exit(1);
|
||||
}
|
||||
} else if (strcasecmp(outputformatstr, "map") == 0) {
|
||||
|
|
@ -485,11 +482,11 @@ main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (progmode == progmode_compile) {
|
||||
dumpzone = 1; /* always dump */
|
||||
dumpzone = 1; /* always dump */
|
||||
logdump = !quiet;
|
||||
if (output_filename == NULL) {
|
||||
fprintf(stderr,
|
||||
"output file required, but not specified\n");
|
||||
fprintf(stderr, "output file required, but not "
|
||||
"specified\n");
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
|
@ -502,8 +499,7 @@ main(int argc, char **argv) {
|
|||
* output to stderr.
|
||||
*/
|
||||
if (dumpzone &&
|
||||
(output_filename == NULL ||
|
||||
strcmp(output_filename, "-") == 0 ||
|
||||
(output_filename == NULL || strcmp(output_filename, "-") == 0 ||
|
||||
strcmp(output_filename, "/dev/fd/1") == 0 ||
|
||||
strcmp(output_filename, "/dev/stdout") == 0)) {
|
||||
errout = stderr;
|
||||
|
|
@ -519,8 +515,8 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_mem_create(&mctx);
|
||||
if (!quiet)
|
||||
RUNTIME_CHECK(setup_logging(mctx, errout, &lctx)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(setup_logging(mctx, errout, &lctx) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
dns_result_register();
|
||||
|
||||
|
|
@ -541,8 +537,8 @@ main(int argc, char **argv) {
|
|||
fprintf(errout, "dump zone to %s...", output_filename);
|
||||
fflush(errout);
|
||||
}
|
||||
result = dump_zone(origin, zone, output_filename,
|
||||
outputformat, outputstyle, rawversion);
|
||||
result = dump_zone(origin, zone, output_filename, outputformat,
|
||||
outputstyle, rawversion);
|
||||
if (logdump)
|
||||
fprintf(errout, "done\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,25 +42,26 @@
|
|||
#include <dns/name.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
#include <confgen/os.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "keygen.h"
|
||||
#include "util.h"
|
||||
|
||||
#define KEYGEN_DEFAULT "tsig-key"
|
||||
#define CONFGEN_DEFAULT "ddns-key"
|
||||
#include <confgen/os.h>
|
||||
#include <dst/dst.h>
|
||||
|
||||
#define KEYGEN_DEFAULT "tsig-key"
|
||||
#define CONFGEN_DEFAULT "ddns-key"
|
||||
|
||||
static char program[256];
|
||||
const char *progname;
|
||||
static enum { progmode_keygen, progmode_confgen} progmode;
|
||||
static enum { progmode_keygen, progmode_confgen } progmode;
|
||||
bool verbose = false; /* needed by util.c but not used here */
|
||||
|
||||
ISC_PLATFORM_NORETURN_PRE static void
|
||||
usage(int status) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(int status) {
|
||||
usage(int status)
|
||||
{
|
||||
if (progmode == progmode_confgen) {
|
||||
fprintf(stderr, "\
|
||||
Usage:\n\
|
||||
|
|
@ -70,35 +71,36 @@ Usage:\n\
|
|||
-s name: domain name to be updated using the created key\n\
|
||||
-z zone: name of the zone as it will be used in named.conf\n\
|
||||
-q: quiet mode: print the key, with no explanatory text\n",
|
||||
progname);
|
||||
progname);
|
||||
} else {
|
||||
fprintf(stderr, "\
|
||||
Usage:\n\
|
||||
%s [-a alg] [keyname]\n\
|
||||
-a alg: algorithm (default hmac-sha256)\n\n",
|
||||
progname);
|
||||
progname);
|
||||
}
|
||||
|
||||
exit (status);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
bool show_final_mem = false;
|
||||
bool quiet = false;
|
||||
bool show_final_mem = false;
|
||||
bool quiet = false;
|
||||
isc_buffer_t key_txtbuffer;
|
||||
char key_txtsecret[256];
|
||||
isc_mem_t *mctx = NULL;
|
||||
const char *keyname = NULL;
|
||||
const char *zone = NULL;
|
||||
const char *self_domain = NULL;
|
||||
char *keybuf = NULL;
|
||||
char key_txtsecret[256];
|
||||
isc_mem_t * mctx = NULL;
|
||||
const char * keyname = NULL;
|
||||
const char * zone = NULL;
|
||||
const char * self_domain = NULL;
|
||||
char * keybuf = NULL;
|
||||
dns_secalg_t alg = DST_ALG_HMACSHA256;
|
||||
const char *algname;
|
||||
int keysize = 256;
|
||||
int len = 0;
|
||||
int ch;
|
||||
const char * algname;
|
||||
int keysize = 256;
|
||||
int len = 0;
|
||||
int ch;
|
||||
|
||||
#if USE_PKCS11
|
||||
pk11_result_register();
|
||||
|
|
@ -132,8 +134,8 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv,
|
||||
"a:hk:Mmr:qs:y:z:")) != -1) {
|
||||
while ((ch = isc_commandline_parse(argc, argv, "a:hk:Mmr:qs:y:z:")) !=
|
||||
-1) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
algname = isc_commandline_argument;
|
||||
|
|
@ -187,8 +189,8 @@ main(int argc, char **argv) {
|
|||
usage(0);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -199,7 +201,7 @@ main(int argc, char **argv) {
|
|||
POST(argv);
|
||||
|
||||
if (self_domain != NULL && zone != NULL)
|
||||
usage(1); /* -s and -z cannot coexist */
|
||||
usage(1); /* -s and -z cannot coexist */
|
||||
|
||||
if (argc > isc_commandline_index)
|
||||
usage(1);
|
||||
|
|
@ -212,9 +214,8 @@ main(int argc, char **argv) {
|
|||
if (keyname == NULL) {
|
||||
const char *suffix = NULL;
|
||||
|
||||
keyname = ((progmode == progmode_keygen)
|
||||
? KEYGEN_DEFAULT
|
||||
: CONFGEN_DEFAULT);
|
||||
keyname = ((progmode == progmode_keygen) ? KEYGEN_DEFAULT
|
||||
: CONFGEN_DEFAULT);
|
||||
if (self_domain != NULL)
|
||||
suffix = self_domain;
|
||||
else if (zone != NULL)
|
||||
|
|
@ -223,7 +224,7 @@ main(int argc, char **argv) {
|
|||
len = strlen(keyname) + strlen(suffix) + 2;
|
||||
keybuf = isc_mem_get(mctx, len);
|
||||
snprintf(keybuf, len, "%s.%s", keyname, suffix);
|
||||
keyname = (const char *) keybuf;
|
||||
keyname = (const char *)keybuf;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +232,6 @@ main(int argc, char **argv) {
|
|||
|
||||
generate_key(mctx, alg, keysize, &key_txtbuffer);
|
||||
|
||||
|
||||
if (!quiet)
|
||||
printf("\
|
||||
# To activate this key, place the following in named.conf, and\n\
|
||||
|
|
@ -243,8 +243,7 @@ key \"%s\" {\n\
|
|||
algorithm %s;\n\
|
||||
secret \"%.*s\";\n\
|
||||
};\n",
|
||||
keyname, algname,
|
||||
(int)isc_buffer_usedlength(&key_txtbuffer),
|
||||
keyname, algname, (int)isc_buffer_usedlength(&key_txtbuffer),
|
||||
(char *)isc_buffer_base(&key_txtbuffer));
|
||||
|
||||
if (!quiet) {
|
||||
|
|
@ -282,7 +281,6 @@ update-policy {\n\
|
|||
# After the keyfile has been placed, the following command will\n\
|
||||
# execute nsupdate using this key:\n\
|
||||
nsupdate -k <keyfile>\n");
|
||||
|
||||
}
|
||||
|
||||
if (keybuf != NULL)
|
||||
|
|
|
|||
|
|
@ -9,18 +9,19 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#ifndef RNDC_OS_H
|
||||
#define RNDC_OS_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
int set_user(FILE *fd, const char *user);
|
||||
int
|
||||
set_user(FILE *fd, const char *user);
|
||||
/*%<
|
||||
* Set the owner of the file referenced by 'fd' to 'user'.
|
||||
* Returns:
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "keygen.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/base64.h>
|
||||
#include <isc/buffer.h>
|
||||
|
|
@ -23,36 +24,35 @@
|
|||
#include <isc/result.h>
|
||||
#include <isc/string.h>
|
||||
|
||||
#include <pk11/site.h>
|
||||
|
||||
#include <dns/keyvalues.h>
|
||||
#include <dns/name.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
#include <confgen/os.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "keygen.h"
|
||||
|
||||
#include <confgen/os.h>
|
||||
#include <dst/dst.h>
|
||||
#include <pk11/site.h>
|
||||
|
||||
/*%
|
||||
* Convert algorithm type to string.
|
||||
*/
|
||||
const char *
|
||||
alg_totext(dns_secalg_t alg) {
|
||||
alg_totext(dns_secalg_t alg)
|
||||
{
|
||||
switch (alg) {
|
||||
case DST_ALG_HMACMD5:
|
||||
case DST_ALG_HMACMD5:
|
||||
return "hmac-md5";
|
||||
case DST_ALG_HMACSHA1:
|
||||
case DST_ALG_HMACSHA1:
|
||||
return "hmac-sha1";
|
||||
case DST_ALG_HMACSHA224:
|
||||
case DST_ALG_HMACSHA224:
|
||||
return "hmac-sha224";
|
||||
case DST_ALG_HMACSHA256:
|
||||
case DST_ALG_HMACSHA256:
|
||||
return "hmac-sha256";
|
||||
case DST_ALG_HMACSHA384:
|
||||
case DST_ALG_HMACSHA384:
|
||||
return "hmac-sha384";
|
||||
case DST_ALG_HMACSHA512:
|
||||
case DST_ALG_HMACSHA512:
|
||||
return "hmac-sha512";
|
||||
default:
|
||||
default:
|
||||
return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
|
@ -61,7 +61,8 @@ alg_totext(dns_secalg_t alg) {
|
|||
* Convert string to algorithm type.
|
||||
*/
|
||||
dns_secalg_t
|
||||
alg_fromtext(const char *name) {
|
||||
alg_fromtext(const char *name)
|
||||
{
|
||||
const char *p = name;
|
||||
if (strncasecmp(p, "hmac-", 5) == 0)
|
||||
p = &name[5];
|
||||
|
|
@ -85,21 +86,22 @@ alg_fromtext(const char *name) {
|
|||
* Return default keysize for a given algorithm type.
|
||||
*/
|
||||
int
|
||||
alg_bits(dns_secalg_t alg) {
|
||||
alg_bits(dns_secalg_t alg)
|
||||
{
|
||||
switch (alg) {
|
||||
case DST_ALG_HMACMD5:
|
||||
case DST_ALG_HMACMD5:
|
||||
return 128;
|
||||
case DST_ALG_HMACSHA1:
|
||||
case DST_ALG_HMACSHA1:
|
||||
return 160;
|
||||
case DST_ALG_HMACSHA224:
|
||||
case DST_ALG_HMACSHA224:
|
||||
return 224;
|
||||
case DST_ALG_HMACSHA256:
|
||||
case DST_ALG_HMACSHA256:
|
||||
return 256;
|
||||
case DST_ALG_HMACSHA384:
|
||||
case DST_ALG_HMACSHA384:
|
||||
return 384;
|
||||
case DST_ALG_HMACSHA512:
|
||||
case DST_ALG_HMACSHA512:
|
||||
return 512;
|
||||
default:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -109,38 +111,38 @@ alg_bits(dns_secalg_t alg) {
|
|||
*/
|
||||
void
|
||||
generate_key(isc_mem_t *mctx, dns_secalg_t alg, int keysize,
|
||||
isc_buffer_t *key_txtbuffer) {
|
||||
isc_buffer_t *key_txtbuffer)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_buffer_t key_rawbuffer;
|
||||
isc_region_t key_rawregion;
|
||||
char key_rawsecret[64];
|
||||
dst_key_t *key = NULL;
|
||||
char key_rawsecret[64];
|
||||
dst_key_t * key = NULL;
|
||||
|
||||
switch (alg) {
|
||||
case DST_ALG_HMACMD5:
|
||||
case DST_ALG_HMACSHA1:
|
||||
case DST_ALG_HMACSHA224:
|
||||
case DST_ALG_HMACSHA256:
|
||||
case DST_ALG_HMACMD5:
|
||||
case DST_ALG_HMACSHA1:
|
||||
case DST_ALG_HMACSHA224:
|
||||
case DST_ALG_HMACSHA256:
|
||||
if (keysize < 1 || keysize > 512)
|
||||
fatal("keysize %d out of range (must be 1-512)\n",
|
||||
keysize);
|
||||
break;
|
||||
case DST_ALG_HMACSHA384:
|
||||
case DST_ALG_HMACSHA512:
|
||||
case DST_ALG_HMACSHA384:
|
||||
case DST_ALG_HMACSHA512:
|
||||
if (keysize < 1 || keysize > 1024)
|
||||
fatal("keysize %d out of range (must be 1-1024)\n",
|
||||
keysize);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
fatal("unsupported algorithm %d\n", alg);
|
||||
}
|
||||
|
||||
DO("initialize dst library", dst_lib_init(mctx, NULL));
|
||||
|
||||
DO("generate key", dst_key_generate(dns_rootname, alg,
|
||||
keysize, 0, 0, DNS_KEYPROTO_ANY,
|
||||
dns_rdataclass_in, mctx, &key,
|
||||
NULL));
|
||||
DO("generate key",
|
||||
dst_key_generate(dns_rootname, alg, keysize, 0, 0, DNS_KEYPROTO_ANY,
|
||||
dns_rdataclass_in, mctx, &key, NULL));
|
||||
|
||||
isc_buffer_init(&key_rawbuffer, &key_rawsecret, sizeof(key_rawsecret));
|
||||
|
||||
|
|
@ -148,8 +150,8 @@ generate_key(isc_mem_t *mctx, dns_secalg_t alg, int keysize,
|
|||
|
||||
isc_buffer_usedregion(&key_rawbuffer, &key_rawregion);
|
||||
|
||||
DO("bsse64 encode secret", isc_base64_totext(&key_rawregion, -1, "",
|
||||
key_txtbuffer));
|
||||
DO("bsse64 encode secret",
|
||||
isc_base64_totext(&key_rawregion, -1, "", key_txtbuffer));
|
||||
|
||||
if (key != NULL)
|
||||
dst_key_free(&key);
|
||||
|
|
@ -163,12 +165,12 @@ generate_key(isc_mem_t *mctx, dns_secalg_t alg, int keysize,
|
|||
* the name 'keyname' and the secret in the buffer 'secret'.
|
||||
*/
|
||||
void
|
||||
write_key_file(const char *keyfile, const char *user,
|
||||
const char *keyname, isc_buffer_t *secret,
|
||||
dns_secalg_t alg) {
|
||||
write_key_file(const char *keyfile, const char *user, const char *keyname,
|
||||
isc_buffer_t *secret, dns_secalg_t alg)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char *algname = alg_totext(alg);
|
||||
FILE *fd = NULL;
|
||||
const char * algname = alg_totext(alg);
|
||||
FILE * fd = NULL;
|
||||
|
||||
DO("create keyfile", isc_file_safecreate(keyfile, &fd));
|
||||
|
||||
|
|
@ -177,10 +179,10 @@ write_key_file(const char *keyfile, const char *user,
|
|||
fatal("unable to set file owner\n");
|
||||
}
|
||||
|
||||
fprintf(fd, "key \"%s\" {\n\talgorithm %s;\n"
|
||||
fprintf(fd,
|
||||
"key \"%s\" {\n\talgorithm %s;\n"
|
||||
"\tsecret \"%.*s\";\n};\n",
|
||||
keyname, algname,
|
||||
(int)isc_buffer_usedlength(secret),
|
||||
keyname, algname, (int)isc_buffer_usedlength(secret),
|
||||
(char *)isc_buffer_base(secret));
|
||||
fflush(fd);
|
||||
if (ferror(fd))
|
||||
|
|
|
|||
|
|
@ -9,26 +9,33 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef RNDC_KEYGEN_H
|
||||
#define RNDC_KEYGEN_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/mem.h>
|
||||
|
||||
#include <dns/secalg.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void generate_key(isc_mem_t *mctx, dns_secalg_t alg, int keysize,
|
||||
isc_buffer_t *key_txtbuffer);
|
||||
void
|
||||
generate_key(isc_mem_t *mctx, dns_secalg_t alg, int keysize,
|
||||
isc_buffer_t *key_txtbuffer);
|
||||
|
||||
void write_key_file(const char *keyfile, const char *user,
|
||||
const char *keyname, isc_buffer_t *secret,
|
||||
dns_secalg_t alg);
|
||||
void
|
||||
write_key_file(const char *keyfile, const char *user, const char *keyname,
|
||||
isc_buffer_t *secret, dns_secalg_t alg);
|
||||
|
||||
const char *alg_totext(dns_secalg_t alg);
|
||||
dns_secalg_t alg_fromtext(const char *name);
|
||||
int alg_bits(dns_secalg_t alg);
|
||||
const char *
|
||||
alg_totext(dns_secalg_t alg);
|
||||
dns_secalg_t
|
||||
alg_fromtext(const char *name);
|
||||
int
|
||||
alg_bits(dns_secalg_t alg);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -37,20 +37,19 @@
|
|||
#include <isc/time.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <pk11/site.h>
|
||||
|
||||
#include <dns/keyvalues.h>
|
||||
#include <dns/name.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
#include <confgen/os.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "keygen.h"
|
||||
#include "util.h"
|
||||
|
||||
#define DEFAULT_KEYNAME "rndc-key"
|
||||
#define DEFAULT_SERVER "127.0.0.1"
|
||||
#define DEFAULT_PORT 953
|
||||
#include <confgen/os.h>
|
||||
#include <dst/dst.h>
|
||||
#include <pk11/site.h>
|
||||
|
||||
#define DEFAULT_KEYNAME "rndc-key"
|
||||
#define DEFAULT_SERVER "127.0.0.1"
|
||||
#define DEFAULT_PORT 953
|
||||
|
||||
static char program[256];
|
||||
const char *progname;
|
||||
|
|
@ -63,8 +62,8 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
usage(int status) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(int status) {
|
||||
|
||||
usage(int status)
|
||||
{
|
||||
fprintf(stderr, "\
|
||||
Usage:\n\
|
||||
%s [-a] [-b bits] [-c keyfile] [-k keyname] [-p port] \
|
||||
|
|
@ -78,32 +77,33 @@ Usage:\n\
|
|||
-s addr: the address to which rndc should connect\n\
|
||||
-t chrootdir: write a keyfile in chrootdir as well (requires -a)\n\
|
||||
-u user: set the keyfile owner to \"user\" (requires -a)\n",
|
||||
progname, keydef);
|
||||
progname, keydef);
|
||||
|
||||
exit (status);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
bool show_final_mem = false;
|
||||
isc_buffer_t key_txtbuffer;
|
||||
char key_txtsecret[256];
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
const char *keyname = NULL;
|
||||
const char *serveraddr = NULL;
|
||||
dns_secalg_t alg;
|
||||
const char *algname;
|
||||
char *p;
|
||||
int ch;
|
||||
int port;
|
||||
int keysize = -1;
|
||||
struct in_addr addr4_dummy;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
bool show_final_mem = false;
|
||||
isc_buffer_t key_txtbuffer;
|
||||
char key_txtsecret[256];
|
||||
isc_mem_t * mctx = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
const char * keyname = NULL;
|
||||
const char * serveraddr = NULL;
|
||||
dns_secalg_t alg;
|
||||
const char * algname;
|
||||
char * p;
|
||||
int ch;
|
||||
int port;
|
||||
int keysize = -1;
|
||||
struct in_addr addr4_dummy;
|
||||
struct in6_addr addr6_dummy;
|
||||
char *chrootdir = NULL;
|
||||
char *user = NULL;
|
||||
bool keyonly = false;
|
||||
int len;
|
||||
char * chrootdir = NULL;
|
||||
char * user = NULL;
|
||||
bool keyonly = false;
|
||||
int len;
|
||||
|
||||
keydef = keyfile = RNDC_KEYFILE;
|
||||
|
||||
|
|
@ -120,8 +120,7 @@ main(int argc, char **argv) {
|
|||
isc_commandline_errprint = false;
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv,
|
||||
"aA:b:c:hk:Mmp:r:s:t:u:Vy")) != -1)
|
||||
{
|
||||
"aA:b:c:hk:Mmp:r:s:t:u:Vy")) != -1) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
keyonly = true;
|
||||
|
|
@ -143,7 +142,7 @@ main(int argc, char **argv) {
|
|||
case 'h':
|
||||
usage(0);
|
||||
case 'k':
|
||||
case 'y': /* Compatible with rndc -y. */
|
||||
case 'y': /* Compatible with rndc -y. */
|
||||
keyname = isc_commandline_argument;
|
||||
break;
|
||||
case 'M':
|
||||
|
|
@ -186,8 +185,8 @@ main(int argc, char **argv) {
|
|||
usage(0);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -200,9 +199,9 @@ main(int argc, char **argv) {
|
|||
usage(1);
|
||||
|
||||
if (alg == DST_ALG_HMACMD5) {
|
||||
fprintf(stderr,
|
||||
"warning: use of hmac-md5 for RNDC keys "
|
||||
"is deprecated; hmac-sha256 is now recommended.\n");
|
||||
fprintf(stderr, "warning: use of hmac-md5 for RNDC keys "
|
||||
"is deprecated; hmac-sha256 is now "
|
||||
"recommended.\n");
|
||||
}
|
||||
|
||||
if (keysize < 0)
|
||||
|
|
@ -256,12 +255,11 @@ options {\n\
|
|||
# End of named.conf\n",
|
||||
keyname, algname,
|
||||
(int)isc_buffer_usedlength(&key_txtbuffer),
|
||||
(char *)isc_buffer_base(&key_txtbuffer),
|
||||
keyname, serveraddr, port,
|
||||
keyname, algname,
|
||||
(char *)isc_buffer_base(&key_txtbuffer), keyname,
|
||||
serveraddr, port, keyname, algname,
|
||||
(int)isc_buffer_usedlength(&key_txtbuffer),
|
||||
(char *)isc_buffer_base(&key_txtbuffer),
|
||||
serveraddr, port, serveraddr, keyname);
|
||||
(char *)isc_buffer_base(&key_txtbuffer), serveraddr,
|
||||
port, serveraddr, keyname);
|
||||
}
|
||||
|
||||
if (show_final_mem)
|
||||
|
|
|
|||
|
|
@ -9,21 +9,21 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <confgen/os.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <confgen/os.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int
|
||||
set_user(FILE *fd, const char *user) {
|
||||
set_user(FILE *fd, const char *user)
|
||||
{
|
||||
struct passwd *pw;
|
||||
|
||||
pw = getpwnam(user);
|
||||
|
|
|
|||
|
|
@ -9,23 +9,23 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
extern bool verbose;
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
|
||||
extern bool verbose;
|
||||
extern const char *progname;
|
||||
|
||||
void
|
||||
notify(const char *fmt, ...) {
|
||||
notify(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (verbose) {
|
||||
|
|
@ -37,7 +37,8 @@ notify(const char *fmt, ...) {
|
|||
}
|
||||
|
||||
void
|
||||
fatal(const char *format, ...) {
|
||||
fatal(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr, "%s: ", progname);
|
||||
|
|
|
|||
|
|
@ -9,27 +9,25 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef RNDC_UTIL_H
|
||||
#define RNDC_UTIL_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/formatcheck.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
#include <isc/formatcheck.h>
|
||||
|
||||
#define NS_CONTROL_PORT 953
|
||||
#define NS_CONTROL_PORT 953
|
||||
|
||||
#undef DO
|
||||
#define DO(name, function) \
|
||||
do { \
|
||||
result = function; \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
#define DO(name, function) \
|
||||
do { \
|
||||
result = function; \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
fatal("%s: %s", name, isc_result_totext(result)); \
|
||||
else \
|
||||
notify("%s", name); \
|
||||
else \
|
||||
notify("%s", name); \
|
||||
} while (0)
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
|
@ -39,7 +37,7 @@ notify(const char *fmt, ...) ISC_FORMAT_PRINTF(1, 2);
|
|||
|
||||
ISC_PLATFORM_NORETURN_PRE void
|
||||
fatal(const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -9,17 +9,18 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <confgen/os.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <confgen/os.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int
|
||||
set_user(FILE *fd, const char *user) {
|
||||
set_user(FILE *fd, const char *user)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
638
bin/delv/delv.c
638
bin/delv/delv.c
File diff suppressed because it is too large
Load diff
906
bin/dig/dig.c
906
bin/dig/dig.c
File diff suppressed because it is too large
Load diff
1224
bin/dig/dighost.c
1224
bin/dig/dighost.c
File diff suppressed because it is too large
Load diff
423
bin/dig/host.c
423
bin/dig/host.c
|
|
@ -12,9 +12,9 @@
|
|||
/*! \file */
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
|
|
@ -25,8 +25,8 @@
|
|||
#include <isc/netaddr.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/byaddr.h>
|
||||
#include <dns/fixedname.h>
|
||||
|
|
@ -35,81 +35,54 @@
|
|||
#include <dns/rdata.h>
|
||||
#include <dns/rdataclass.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/rdatatype.h>
|
||||
#include <dns/rdatastruct.h>
|
||||
#include <dns/rdatatype.h>
|
||||
|
||||
#include <dig/dig.h>
|
||||
|
||||
static bool short_form = true, listed_server = false;
|
||||
static bool default_lookups = true;
|
||||
static int seen_error = -1;
|
||||
static bool list_addresses = true;
|
||||
static bool list_almost_all = false;
|
||||
static bool short_form = true, listed_server = false;
|
||||
static bool default_lookups = true;
|
||||
static int seen_error = -1;
|
||||
static bool list_addresses = true;
|
||||
static bool list_almost_all = false;
|
||||
static dns_rdatatype_t list_type = dns_rdatatype_a;
|
||||
static bool printed_server = false;
|
||||
static bool ipv4only = false, ipv6only = false;
|
||||
static bool printed_server = false;
|
||||
static bool ipv4only = false, ipv6only = false;
|
||||
|
||||
static const char *opcodetext[] = {
|
||||
"QUERY",
|
||||
"IQUERY",
|
||||
"STATUS",
|
||||
"RESERVED3",
|
||||
"NOTIFY",
|
||||
"UPDATE",
|
||||
"RESERVED6",
|
||||
"RESERVED7",
|
||||
"RESERVED8",
|
||||
"RESERVED9",
|
||||
"RESERVED10",
|
||||
"RESERVED11",
|
||||
"RESERVED12",
|
||||
"RESERVED13",
|
||||
"RESERVED14",
|
||||
"RESERVED15"
|
||||
};
|
||||
static const char *opcodetext[] = { "QUERY", "IQUERY", "STATUS",
|
||||
"RESERVED3", "NOTIFY", "UPDATE",
|
||||
"RESERVED6", "RESERVED7", "RESERVED8",
|
||||
"RESERVED9", "RESERVED10", "RESERVED11",
|
||||
"RESERVED12", "RESERVED13", "RESERVED14",
|
||||
"RESERVED15" };
|
||||
|
||||
static const char *rcodetext[] = {
|
||||
"NOERROR",
|
||||
"FORMERR",
|
||||
"SERVFAIL",
|
||||
"NXDOMAIN",
|
||||
"NOTIMP",
|
||||
"REFUSED",
|
||||
"YXDOMAIN",
|
||||
"YXRRSET",
|
||||
"NXRRSET",
|
||||
"NOTAUTH",
|
||||
"NOTZONE",
|
||||
"RESERVED11",
|
||||
"RESERVED12",
|
||||
"RESERVED13",
|
||||
"RESERVED14",
|
||||
"RESERVED15",
|
||||
"BADVERS"
|
||||
};
|
||||
static const char *rcodetext[] = { "NOERROR", "FORMERR", "SERVFAIL",
|
||||
"NXDOMAIN", "NOTIMP", "REFUSED",
|
||||
"YXDOMAIN", "YXRRSET", "NXRRSET",
|
||||
"NOTAUTH", "NOTZONE", "RESERVED11",
|
||||
"RESERVED12", "RESERVED13", "RESERVED14",
|
||||
"RESERVED15", "BADVERS" };
|
||||
|
||||
struct rtype {
|
||||
unsigned int type;
|
||||
const char *text;
|
||||
const char * text;
|
||||
};
|
||||
|
||||
struct rtype rtypes[] = {
|
||||
{ 1, "has address" },
|
||||
{ 2, "name server" },
|
||||
{ 5, "is an alias for" },
|
||||
{ 11, "has well known services" },
|
||||
{ 12, "domain name pointer" },
|
||||
{ 13, "host information" },
|
||||
{ 15, "mail is handled by" },
|
||||
{ 16, "descriptive text" },
|
||||
{ 19, "x25 address" },
|
||||
{ 20, "ISDN address" },
|
||||
{ 24, "has signature" },
|
||||
{ 25, "has key" },
|
||||
{ 28, "has IPv6 address" },
|
||||
{ 29, "location" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
struct rtype rtypes[] = { { 1, "has address" },
|
||||
{ 2, "name server" },
|
||||
{ 5, "is an alias for" },
|
||||
{ 11, "has well known services" },
|
||||
{ 12, "domain name pointer" },
|
||||
{ 13, "host information" },
|
||||
{ 15, "mail is handled by" },
|
||||
{ 16, "descriptive text" },
|
||||
{ 19, "x25 address" },
|
||||
{ 20, "ISDN address" },
|
||||
{ 24, "has signature" },
|
||||
{ 25, "has key" },
|
||||
{ 28, "has IPv6 address" },
|
||||
{ 29, "location" },
|
||||
{ 0, NULL } };
|
||||
|
||||
static char *
|
||||
rcode_totext(dns_rcode_t rcode)
|
||||
|
|
@ -117,10 +90,10 @@ rcode_totext(dns_rcode_t rcode)
|
|||
static char buf[sizeof("?65535")];
|
||||
union {
|
||||
const char *consttext;
|
||||
char *deconsttext;
|
||||
char * deconsttext;
|
||||
} totext;
|
||||
|
||||
if (rcode >= (sizeof(rcodetext)/sizeof(rcodetext[0]))) {
|
||||
if (rcode >= (sizeof(rcodetext) / sizeof(rcodetext[0]))) {
|
||||
snprintf(buf, sizeof(buf), "?%u", rcode);
|
||||
totext.deconsttext = buf;
|
||||
} else
|
||||
|
|
@ -132,55 +105,61 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
show_usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
show_usage(void) {
|
||||
fputs(
|
||||
"Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W time]\n"
|
||||
" [-R number] [-m flag] hostname [server]\n"
|
||||
" -a is equivalent to -v -t ANY\n"
|
||||
" -A is like -a but omits RRSIG, NSEC, NSEC3\n"
|
||||
" -c specifies query class for non-IN data\n"
|
||||
" -C compares SOA records on authoritative nameservers\n"
|
||||
" -d is equivalent to -v\n"
|
||||
" -l lists all hosts in a domain, using AXFR\n"
|
||||
" -m set memory debugging flag (trace|record|usage)\n"
|
||||
" -N changes the number of dots allowed before root lookup is done\n"
|
||||
" -r disables recursive processing\n"
|
||||
" -R specifies number of retries for UDP packets\n"
|
||||
" -s a SERVFAIL response should stop query\n"
|
||||
" -t specifies the query type\n"
|
||||
" -T enables TCP/IP mode\n"
|
||||
" -U enables UDP mode\n"
|
||||
" -v enables verbose output\n"
|
||||
" -V print version number and exit\n"
|
||||
" -w specifies to wait forever for a reply\n"
|
||||
" -W specifies how long to wait for a reply\n"
|
||||
" -4 use IPv4 query transport only\n"
|
||||
" -6 use IPv6 query transport only\n", stderr);
|
||||
show_usage(void)
|
||||
{
|
||||
fputs("Usage: host [-aCdilrTvVw] [-c class] [-N ndots] [-t type] [-W "
|
||||
"time]\n"
|
||||
" [-R number] [-m flag] hostname [server]\n"
|
||||
" -a is equivalent to -v -t ANY\n"
|
||||
" -A is like -a but omits RRSIG, NSEC, NSEC3\n"
|
||||
" -c specifies query class for non-IN data\n"
|
||||
" -C compares SOA records on authoritative nameservers\n"
|
||||
" -d is equivalent to -v\n"
|
||||
" -l lists all hosts in a domain, using AXFR\n"
|
||||
" -m set memory debugging flag (trace|record|usage)\n"
|
||||
" -N changes the number of dots allowed before root lookup "
|
||||
"is done\n"
|
||||
" -r disables recursive processing\n"
|
||||
" -R specifies number of retries for UDP packets\n"
|
||||
" -s a SERVFAIL response should stop query\n"
|
||||
" -t specifies the query type\n"
|
||||
" -T enables TCP/IP mode\n"
|
||||
" -U enables UDP mode\n"
|
||||
" -v enables verbose output\n"
|
||||
" -V print version number and exit\n"
|
||||
" -w specifies to wait forever for a reply\n"
|
||||
" -W specifies how long to wait for a reply\n"
|
||||
" -4 use IPv4 query transport only\n"
|
||||
" -6 use IPv6 query transport only\n",
|
||||
stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
host_shutdown(void) {
|
||||
(void) isc_app_shutdown();
|
||||
host_shutdown(void)
|
||||
{
|
||||
(void)isc_app_shutdown();
|
||||
}
|
||||
|
||||
static void
|
||||
received(unsigned int bytes, isc_sockaddr_t *from, dig_query_t *query) {
|
||||
received(unsigned int bytes, isc_sockaddr_t *from, dig_query_t *query)
|
||||
{
|
||||
isc_time_t now;
|
||||
int diff;
|
||||
int diff;
|
||||
|
||||
if (!short_form) {
|
||||
char fromtext[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_sockaddr_format(from, fromtext, sizeof(fromtext));
|
||||
TIME_NOW(&now);
|
||||
diff = (int) isc_time_microdiff(&now, &query->time_sent);
|
||||
printf("Received %u bytes from %s in %d ms\n",
|
||||
bytes, fromtext, diff/1000);
|
||||
diff = (int)isc_time_microdiff(&now, &query->time_sent);
|
||||
printf("Received %u bytes from %s in %d ms\n", bytes, fromtext,
|
||||
diff / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
trying(char *frm, dig_lookup_t *lookup) {
|
||||
trying(char *frm, dig_lookup_t *lookup)
|
||||
{
|
||||
UNUSED(lookup);
|
||||
|
||||
if (!short_form)
|
||||
|
|
@ -192,13 +171,13 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
|
|||
dig_query_t *query)
|
||||
{
|
||||
isc_buffer_t *b = NULL;
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
isc_region_t r;
|
||||
isc_result_t result;
|
||||
unsigned int bufsize = BUFSIZ;
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
isc_region_t r;
|
||||
isc_result_t result;
|
||||
unsigned int bufsize = BUFSIZ;
|
||||
|
||||
dns_name_format(name, namestr, sizeof(namestr));
|
||||
retry:
|
||||
retry:
|
||||
isc_buffer_allocate(mctx, &b, bufsize);
|
||||
result = dns_rdata_totext(rdata, NULL, b);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
|
|
@ -209,11 +188,9 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
|
|||
check_result(result, "dns_rdata_totext");
|
||||
isc_buffer_usedregion(b, &r);
|
||||
if (query->lookup->identify_previous_line) {
|
||||
printf("Nameserver %s:\n\t",
|
||||
query->servname);
|
||||
printf("Nameserver %s:\n\t", query->servname);
|
||||
}
|
||||
printf("%s %s %.*s", namestr,
|
||||
msg, (int)r.length, (char *)r.base);
|
||||
printf("%s %s %.*s", namestr, msg, (int)r.length, (char *)r.base);
|
||||
if (query->lookup->identify) {
|
||||
printf(" on server %s", query->servname);
|
||||
}
|
||||
|
|
@ -223,19 +200,18 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
|
|||
|
||||
static isc_result_t
|
||||
printsection(dns_message_t *msg, dns_section_t sectionid,
|
||||
const char *section_name, bool headers,
|
||||
dig_query_t *query)
|
||||
const char *section_name, bool headers, dig_query_t *query)
|
||||
{
|
||||
dns_name_t *name, *print_name;
|
||||
dns_name_t * name, *print_name;
|
||||
dns_rdataset_t *rdataset;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
isc_buffer_t target;
|
||||
isc_result_t result, loopresult;
|
||||
isc_region_t r;
|
||||
dns_name_t empty_name;
|
||||
char tbuf[4096];
|
||||
bool first;
|
||||
bool no_rdata;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
isc_buffer_t target;
|
||||
isc_result_t result, loopresult;
|
||||
isc_region_t r;
|
||||
dns_name_t empty_name;
|
||||
char tbuf[4096];
|
||||
bool first;
|
||||
bool no_rdata;
|
||||
|
||||
if (sectionid == DNS_SECTION_QUESTION)
|
||||
no_rdata = true;
|
||||
|
|
@ -261,8 +237,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid,
|
|||
first = true;
|
||||
print_name = name;
|
||||
|
||||
for (rdataset = ISC_LIST_HEAD(name->list);
|
||||
rdataset != NULL;
|
||||
for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
|
||||
rdataset = ISC_LIST_NEXT(rdataset, link)) {
|
||||
if (query->lookup->rdtype == dns_rdatatype_axfr &&
|
||||
!((!list_addresses &&
|
||||
|
|
@ -275,16 +250,14 @@ printsection(dns_message_t *msg, dns_section_t sectionid,
|
|||
rdataset->type == dns_rdatatype_ptr))))
|
||||
continue;
|
||||
if (list_almost_all &&
|
||||
(rdataset->type == dns_rdatatype_rrsig ||
|
||||
rdataset->type == dns_rdatatype_nsec ||
|
||||
rdataset->type == dns_rdatatype_nsec3))
|
||||
(rdataset->type == dns_rdatatype_rrsig ||
|
||||
rdataset->type == dns_rdatatype_nsec ||
|
||||
rdataset->type == dns_rdatatype_nsec3))
|
||||
continue;
|
||||
if (!short_form) {
|
||||
result = dns_rdataset_totext(rdataset,
|
||||
print_name,
|
||||
false,
|
||||
no_rdata,
|
||||
&target);
|
||||
print_name, false,
|
||||
no_rdata, &target);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
#ifdef USEINITALWS
|
||||
|
|
@ -299,10 +272,10 @@ printsection(dns_message_t *msg, dns_section_t sectionid,
|
|||
loopresult = dns_rdataset_first(rdataset);
|
||||
while (loopresult == ISC_R_SUCCESS) {
|
||||
struct rtype *t;
|
||||
const char *rtt;
|
||||
const char * rtt;
|
||||
char typebuf[DNS_RDATATYPE_FORMATSIZE];
|
||||
char typebuf2[DNS_RDATATYPE_FORMATSIZE
|
||||
+ 20];
|
||||
char typebuf2[DNS_RDATATYPE_FORMATSIZE +
|
||||
20];
|
||||
dns_rdataset_current(rdataset, &rdata);
|
||||
|
||||
for (t = rtypes; t->text != NULL; t++) {
|
||||
|
|
@ -319,8 +292,8 @@ printsection(dns_message_t *msg, dns_section_t sectionid,
|
|||
"has %s record", typebuf);
|
||||
rtt = typebuf2;
|
||||
found:
|
||||
say_message(print_name, rtt,
|
||||
&rdata, query);
|
||||
say_message(print_name, rtt, &rdata,
|
||||
query);
|
||||
dns_rdata_reset(&rdata);
|
||||
loopresult =
|
||||
dns_rdataset_next(rdataset);
|
||||
|
|
@ -330,8 +303,7 @@ printsection(dns_message_t *msg, dns_section_t sectionid,
|
|||
if (!short_form) {
|
||||
isc_buffer_usedregion(&target, &r);
|
||||
if (no_rdata)
|
||||
printf(";%.*s", (int)r.length,
|
||||
(char *)r.base);
|
||||
printf(";%.*s", (int)r.length, (char *)r.base);
|
||||
else
|
||||
printf("%.*s", (int)r.length, (char *)r.base);
|
||||
}
|
||||
|
|
@ -348,13 +320,12 @@ printsection(dns_message_t *msg, dns_section_t sectionid,
|
|||
|
||||
static isc_result_t
|
||||
printrdata(dns_message_t *msg, dns_rdataset_t *rdataset,
|
||||
const dns_name_t *owner, const char *set_name,
|
||||
bool headers)
|
||||
const dns_name_t *owner, const char *set_name, bool headers)
|
||||
{
|
||||
isc_buffer_t target;
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
char tbuf[4096];
|
||||
char tbuf[4096];
|
||||
|
||||
UNUSED(msg);
|
||||
if (headers)
|
||||
|
|
@ -362,8 +333,7 @@ printrdata(dns_message_t *msg, dns_rdataset_t *rdataset,
|
|||
|
||||
isc_buffer_init(&target, tbuf, sizeof(tbuf));
|
||||
|
||||
result = dns_rdataset_totext(rdataset, owner, false, false,
|
||||
&target);
|
||||
result = dns_rdataset_totext(rdataset, owner, false, false, &target);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_buffer_usedregion(&target, &r);
|
||||
|
|
@ -373,12 +343,13 @@ printrdata(dns_message_t *msg, dns_rdataset_t *rdataset,
|
|||
}
|
||||
|
||||
static void
|
||||
chase_cnamechain(dns_message_t *msg, dns_name_t *qname) {
|
||||
isc_result_t result;
|
||||
dns_rdataset_t *rdataset;
|
||||
chase_cnamechain(dns_message_t *msg, dns_name_t *qname)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdataset_t * rdataset;
|
||||
dns_rdata_cname_t cname;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
unsigned int i = msg->counts[DNS_SECTION_ANSWER];
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
unsigned int i = msg->counts[DNS_SECTION_ANSWER];
|
||||
|
||||
while (i-- > 0) {
|
||||
rdataset = NULL;
|
||||
|
|
@ -399,14 +370,14 @@ chase_cnamechain(dns_message_t *msg, dns_name_t *qname) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
||||
dns_message_t *msg, bool headers)
|
||||
printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
|
||||
bool headers)
|
||||
{
|
||||
bool did_flag = false;
|
||||
dns_rdataset_t *opt, *tsig = NULL;
|
||||
bool did_flag = false;
|
||||
dns_rdataset_t * opt, *tsig = NULL;
|
||||
const dns_name_t *tsigname;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
int force_error;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
int force_error;
|
||||
|
||||
UNUSED(msgbuf);
|
||||
UNUSED(headers);
|
||||
|
|
@ -422,8 +393,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
|
||||
printf("Using domain server:\n");
|
||||
printf("Name: %s\n", query->userarg);
|
||||
isc_sockaddr_format(&query->sockaddr, sockstr,
|
||||
sizeof(sockstr));
|
||||
isc_sockaddr_format(&query->sockaddr, sockstr, sizeof(sockstr));
|
||||
printf("Address: %s\n", sockstr);
|
||||
printf("Aliases: \n\n");
|
||||
printed_server = true;
|
||||
|
|
@ -436,22 +406,24 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
if (query->lookup->identify_previous_line)
|
||||
printf("Nameserver %s:\n\t%s not found: %d(%s)\n",
|
||||
query->servname,
|
||||
(msg->rcode != dns_rcode_nxdomain) ? namestr :
|
||||
query->lookup->textname, msg->rcode,
|
||||
rcode_totext(msg->rcode));
|
||||
(msg->rcode != dns_rcode_nxdomain)
|
||||
? namestr
|
||||
: query->lookup->textname,
|
||||
msg->rcode, rcode_totext(msg->rcode));
|
||||
else
|
||||
printf("Host %s not found: %d(%s)\n",
|
||||
(msg->rcode != dns_rcode_nxdomain) ? namestr :
|
||||
query->lookup->textname, msg->rcode,
|
||||
rcode_totext(msg->rcode));
|
||||
(msg->rcode != dns_rcode_nxdomain)
|
||||
? namestr
|
||||
: query->lookup->textname,
|
||||
msg->rcode, rcode_totext(msg->rcode));
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
if (default_lookups && query->lookup->rdtype == dns_rdatatype_a) {
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
dig_lookup_t *lookup;
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
dig_lookup_t * lookup;
|
||||
dns_fixedname_t fixed;
|
||||
dns_name_t *name;
|
||||
dns_name_t * name;
|
||||
|
||||
/* Add AAAA and MX lookups. */
|
||||
name = dns_fixedname_initname(&fixed);
|
||||
|
|
@ -530,7 +502,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
if (tsig != NULL)
|
||||
printf(";; PSEUDOSECTIONS: TSIG\n");
|
||||
}
|
||||
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_QUESTION]) &&
|
||||
if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_QUESTION]) &&
|
||||
!short_form) {
|
||||
printf("\n");
|
||||
result = printsection(msg, DNS_SECTION_QUESTION, "QUESTION",
|
||||
|
|
@ -538,7 +510,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
}
|
||||
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER])) {
|
||||
if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER])) {
|
||||
if (!short_form)
|
||||
printf("\n");
|
||||
result = printsection(msg, DNS_SECTION_ANSWER, "ANSWER",
|
||||
|
|
@ -547,7 +519,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
return (result);
|
||||
}
|
||||
|
||||
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) &&
|
||||
if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) &&
|
||||
!short_form) {
|
||||
printf("\n");
|
||||
result = printsection(msg, DNS_SECTION_AUTHORITY, "AUTHORITY",
|
||||
|
|
@ -555,18 +527,18 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
}
|
||||
if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ADDITIONAL]) &&
|
||||
if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ADDITIONAL]) &&
|
||||
!short_form) {
|
||||
printf("\n");
|
||||
result = printsection(msg, DNS_SECTION_ADDITIONAL,
|
||||
"ADDITIONAL", true, query);
|
||||
result = printsection(msg, DNS_SECTION_ADDITIONAL, "ADDITIONAL",
|
||||
true, query);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
}
|
||||
if ((tsig != NULL) && !short_form) {
|
||||
printf("\n");
|
||||
result = printrdata(msg, tsig, tsigname,
|
||||
"PSEUDOSECTION TSIG", true);
|
||||
result = printrdata(msg, tsig, tsigname, "PSEUDOSECTION TSIG",
|
||||
true);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -586,16 +558,18 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
return (result);
|
||||
}
|
||||
|
||||
static const char * optstring = "46aAc:dilnm:rst:vVwCDN:R:TUW:";
|
||||
static const char *optstring = "46aAc:dilnm:rst:vVwCDN:R:TUW:";
|
||||
|
||||
/*% version */
|
||||
static void
|
||||
version(void) {
|
||||
version(void)
|
||||
{
|
||||
fputs("host " VERSION "\n", stderr);
|
||||
}
|
||||
|
||||
static void
|
||||
pre_parse_args(int argc, char **argv) {
|
||||
pre_parse_args(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, optstring)) != -1) {
|
||||
|
|
@ -622,33 +596,51 @@ pre_parse_args(int argc, char **argv) {
|
|||
fatal("only one of -4 and -6 allowed");
|
||||
ipv6only = true;
|
||||
break;
|
||||
case 'a': break;
|
||||
case 'A': break;
|
||||
case 'c': break;
|
||||
case 'C': break;
|
||||
case 'd': break;
|
||||
case 'a':
|
||||
break;
|
||||
case 'A':
|
||||
break;
|
||||
case 'c':
|
||||
break;
|
||||
case 'C':
|
||||
break;
|
||||
case 'd':
|
||||
break;
|
||||
case 'D':
|
||||
if (debugging)
|
||||
debugtiming = true;
|
||||
debugging = true;
|
||||
break;
|
||||
case 'i': break;
|
||||
case 'l': break;
|
||||
case 'n': break;
|
||||
case 'N': break;
|
||||
case 'r': break;
|
||||
case 'R': break;
|
||||
case 's': break;
|
||||
case 't': break;
|
||||
case 'T': break;
|
||||
case 'U': break;
|
||||
case 'v': break;
|
||||
case 'i':
|
||||
break;
|
||||
case 'l':
|
||||
break;
|
||||
case 'n':
|
||||
break;
|
||||
case 'N':
|
||||
break;
|
||||
case 'r':
|
||||
break;
|
||||
case 'R':
|
||||
break;
|
||||
case 's':
|
||||
break;
|
||||
case 't':
|
||||
break;
|
||||
case 'T':
|
||||
break;
|
||||
case 'U':
|
||||
break;
|
||||
case 'v':
|
||||
break;
|
||||
case 'V':
|
||||
version();
|
||||
exit(0);
|
||||
break;
|
||||
case 'w': break;
|
||||
case 'W': break;
|
||||
version();
|
||||
exit(0);
|
||||
break;
|
||||
case 'w':
|
||||
break;
|
||||
case 'W':
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
|
@ -658,16 +650,17 @@ pre_parse_args(int argc, char **argv) {
|
|||
}
|
||||
|
||||
static void
|
||||
parse_args(bool is_batchfile, int argc, char **argv) {
|
||||
char hostname[MXNAME];
|
||||
dig_lookup_t *lookup;
|
||||
int c;
|
||||
char store[MXNAME];
|
||||
parse_args(bool is_batchfile, int argc, char **argv)
|
||||
{
|
||||
char hostname[MXNAME];
|
||||
dig_lookup_t * lookup;
|
||||
int c;
|
||||
char store[MXNAME];
|
||||
isc_textregion_t tr;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
dns_rdatatype_t rdtype;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
dns_rdatatype_t rdtype;
|
||||
dns_rdataclass_t rdclass;
|
||||
uint32_t serial = 0;
|
||||
uint32_t serial = 0;
|
||||
|
||||
UNUSED(is_batchfile);
|
||||
|
||||
|
|
@ -693,8 +686,8 @@ parse_args(bool is_batchfile, int argc, char **argv) {
|
|||
lookup->recurse = false;
|
||||
break;
|
||||
case 't':
|
||||
if (strncasecmp(isc_commandline_argument,
|
||||
"ixfr=", 5) == 0) {
|
||||
if (strncasecmp(isc_commandline_argument, "ixfr=", 5) ==
|
||||
0) {
|
||||
rdtype = dns_rdatatype_ixfr;
|
||||
/* XXXMPA add error checking */
|
||||
serial = strtoul(isc_commandline_argument + 5,
|
||||
|
|
@ -703,8 +696,8 @@ parse_args(bool is_batchfile, int argc, char **argv) {
|
|||
} else {
|
||||
tr.base = isc_commandline_argument;
|
||||
tr.length = strlen(isc_commandline_argument);
|
||||
result = dns_rdatatype_fromtext(&rdtype,
|
||||
(isc_textregion_t *)&tr);
|
||||
result = dns_rdatatype_fromtext(
|
||||
&rdtype, (isc_textregion_t *)&tr);
|
||||
}
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -736,8 +729,8 @@ parse_args(bool is_batchfile, int argc, char **argv) {
|
|||
case 'c':
|
||||
tr.base = isc_commandline_argument;
|
||||
tr.length = strlen(isc_commandline_argument);
|
||||
result = dns_rdataclass_fromtext(&rdclass,
|
||||
(isc_textregion_t *)&tr);
|
||||
result = dns_rdataclass_fromtext(
|
||||
&rdclass, (isc_textregion_t *)&tr);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatalexit = 2;
|
||||
|
|
@ -808,8 +801,7 @@ parse_args(bool is_batchfile, int argc, char **argv) {
|
|||
default_lookups = false;
|
||||
break;
|
||||
case 'N':
|
||||
debug("setting NDOTS to %s",
|
||||
isc_commandline_argument);
|
||||
debug("setting NDOTS to %s", isc_commandline_argument);
|
||||
ndots = atoi(isc_commandline_argument);
|
||||
break;
|
||||
case 'D':
|
||||
|
|
@ -835,15 +827,15 @@ parse_args(bool is_batchfile, int argc, char **argv) {
|
|||
strlcpy(hostname, argv[isc_commandline_index], sizeof(hostname));
|
||||
|
||||
if (argc > isc_commandline_index + 1) {
|
||||
set_nameserver(argv[isc_commandline_index+1]);
|
||||
debug("server is %s", argv[isc_commandline_index+1]);
|
||||
set_nameserver(argv[isc_commandline_index + 1]);
|
||||
debug("server is %s", argv[isc_commandline_index + 1]);
|
||||
listed_server = true;
|
||||
} else
|
||||
check_ra = true;
|
||||
|
||||
lookup->pending = false;
|
||||
if (get_reverse(store, sizeof(store), hostname, true)
|
||||
== ISC_R_SUCCESS) {
|
||||
if (get_reverse(store, sizeof(store), hostname, true) ==
|
||||
ISC_R_SUCCESS) {
|
||||
strlcpy(lookup->textname, store, sizeof(lookup->textname));
|
||||
lookup->rdtype = dns_rdatatype_ptr;
|
||||
lookup->rdtypeset = true;
|
||||
|
|
@ -857,7 +849,8 @@ parse_args(bool is_batchfile, int argc, char **argv) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
tries = 2;
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <dns/rdatalist.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/bufferlist.h>
|
||||
#include <isc/formatcheck.h>
|
||||
|
|
@ -32,12 +28,16 @@
|
|||
#include <isc/sockaddr.h>
|
||||
#include <isc/socket.h>
|
||||
|
||||
#include <dns/rdatalist.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#define MXSERV 20
|
||||
#define MXNAME (DNS_NAME_MAXTEXT+1)
|
||||
#define MXNAME (DNS_NAME_MAXTEXT + 1)
|
||||
#define MXRD 32
|
||||
/*% Buffer Size */
|
||||
#define BUFSIZE 512
|
||||
|
|
@ -77,155 +77,107 @@
|
|||
ISC_LANG_BEGINDECLS
|
||||
|
||||
typedef struct dig_lookup dig_lookup_t;
|
||||
typedef struct dig_query dig_query_t;
|
||||
typedef struct dig_query dig_query_t;
|
||||
typedef struct dig_server dig_server_t;
|
||||
typedef ISC_LIST(dig_server_t) dig_serverlist_t;
|
||||
typedef struct dig_searchlist dig_searchlist_t;
|
||||
|
||||
#define DIG_QUERY_MAGIC ISC_MAGIC('D','i','g','q')
|
||||
|
||||
#define DIG_VALID_QUERY(x) ISC_MAGIC_VALID((x), DIG_QUERY_MAGIC)
|
||||
#define DIG_QUERY_MAGIC ISC_MAGIC('D', 'i', 'g', 'q')
|
||||
|
||||
#define DIG_VALID_QUERY(x) ISC_MAGIC_VALID((x), DIG_QUERY_MAGIC)
|
||||
|
||||
/*% The dig_lookup structure */
|
||||
struct dig_lookup {
|
||||
bool
|
||||
pending, /*%< Pending a successful answer */
|
||||
waiting_connect,
|
||||
doing_xfr,
|
||||
ns_search_only, /*%< dig +nssearch, host -C */
|
||||
bool pending, /*%< Pending a successful answer */
|
||||
waiting_connect, doing_xfr, ns_search_only, /*%< dig +nssearch,
|
||||
host -C */
|
||||
identify, /*%< Append an "on server <foo>" message */
|
||||
identify_previous_line, /*% Prepend a "Nameserver <foo>:"
|
||||
message, with newline and tab */
|
||||
ignore,
|
||||
recurse,
|
||||
aaonly,
|
||||
adflag,
|
||||
cdflag,
|
||||
raflag,
|
||||
tcflag,
|
||||
zflag,
|
||||
trace, /*% dig +trace */
|
||||
ignore, recurse, aaonly, adflag, cdflag, raflag, tcflag, zflag,
|
||||
trace, /*% dig +trace */
|
||||
trace_root, /*% initial query for either +trace or +nssearch */
|
||||
tcp_mode,
|
||||
tcp_mode_set,
|
||||
comments,
|
||||
stats,
|
||||
section_question,
|
||||
section_answer,
|
||||
section_authority,
|
||||
section_additional,
|
||||
servfail_stops,
|
||||
new_search,
|
||||
need_search,
|
||||
done_as_is,
|
||||
besteffort,
|
||||
dnssec,
|
||||
expire,
|
||||
sendcookie,
|
||||
seenbadcookie,
|
||||
badcookie,
|
||||
nsid, /*% Name Server ID (RFC 5001) */
|
||||
tcp_keepalive,
|
||||
header_only,
|
||||
ednsneg,
|
||||
mapped,
|
||||
print_unknown_format,
|
||||
multiline,
|
||||
nottl,
|
||||
noclass,
|
||||
onesoa,
|
||||
use_usec,
|
||||
nocrypto,
|
||||
ttlunits,
|
||||
idnin,
|
||||
idnout,
|
||||
expandaaaa,
|
||||
qr,
|
||||
accept_reply_unexpected_src; /*% print replies from unexpected
|
||||
sources. */
|
||||
tcp_mode, tcp_mode_set, comments, stats, section_question,
|
||||
section_answer, section_authority, section_additional,
|
||||
servfail_stops, new_search, need_search, done_as_is, besteffort,
|
||||
dnssec, expire, sendcookie, seenbadcookie, badcookie,
|
||||
nsid, /*% Name Server ID (RFC 5001) */
|
||||
tcp_keepalive, header_only, ednsneg, mapped,
|
||||
print_unknown_format, multiline, nottl, noclass, onesoa,
|
||||
use_usec, nocrypto, ttlunits, idnin, idnout, expandaaaa, qr,
|
||||
accept_reply_unexpected_src; /*% print replies from unexpected
|
||||
sources. */
|
||||
char textname[MXNAME]; /*% Name we're going to be looking up */
|
||||
char cmdline[MXNAME];
|
||||
dns_rdatatype_t rdtype;
|
||||
dns_rdatatype_t qrdtype;
|
||||
dns_rdatatype_t rdtype;
|
||||
dns_rdatatype_t qrdtype;
|
||||
dns_rdataclass_t rdclass;
|
||||
bool rdtypeset;
|
||||
bool rdclassset;
|
||||
char name_space[BUFSIZE];
|
||||
char oname_space[BUFSIZE];
|
||||
isc_buffer_t namebuf;
|
||||
isc_buffer_t onamebuf;
|
||||
isc_buffer_t renderbuf;
|
||||
char *sendspace;
|
||||
dns_name_t *name;
|
||||
isc_interval_t interval;
|
||||
dns_message_t *sendmsg;
|
||||
dns_name_t *oname;
|
||||
bool rdtypeset;
|
||||
bool rdclassset;
|
||||
char name_space[BUFSIZE];
|
||||
char oname_space[BUFSIZE];
|
||||
isc_buffer_t namebuf;
|
||||
isc_buffer_t onamebuf;
|
||||
isc_buffer_t renderbuf;
|
||||
char * sendspace;
|
||||
dns_name_t * name;
|
||||
isc_interval_t interval;
|
||||
dns_message_t * sendmsg;
|
||||
dns_name_t * oname;
|
||||
ISC_LINK(dig_lookup_t) link;
|
||||
ISC_LIST(dig_query_t) q;
|
||||
ISC_LIST(dig_query_t) connecting;
|
||||
dig_query_t *current_query;
|
||||
dig_serverlist_t my_server_list;
|
||||
dig_query_t * current_query;
|
||||
dig_serverlist_t my_server_list;
|
||||
dig_searchlist_t *origin;
|
||||
dig_query_t *xfr_q;
|
||||
uint32_t retries;
|
||||
int nsfound;
|
||||
uint16_t udpsize;
|
||||
int16_t edns;
|
||||
int16_t padding;
|
||||
uint32_t ixfr_serial;
|
||||
isc_buffer_t rdatabuf;
|
||||
char rdatastore[MXNAME];
|
||||
dst_context_t *tsigctx;
|
||||
isc_buffer_t *querysig;
|
||||
uint32_t msgcounter;
|
||||
dns_fixedname_t fdomain;
|
||||
isc_sockaddr_t *ecs_addr;
|
||||
char *cookie;
|
||||
dns_ednsopt_t *ednsopts;
|
||||
unsigned int ednsoptscnt;
|
||||
isc_dscp_t dscp;
|
||||
unsigned int ednsflags;
|
||||
dns_opcode_t opcode;
|
||||
int rrcomments;
|
||||
unsigned int eoferr;
|
||||
dig_query_t * xfr_q;
|
||||
uint32_t retries;
|
||||
int nsfound;
|
||||
uint16_t udpsize;
|
||||
int16_t edns;
|
||||
int16_t padding;
|
||||
uint32_t ixfr_serial;
|
||||
isc_buffer_t rdatabuf;
|
||||
char rdatastore[MXNAME];
|
||||
dst_context_t * tsigctx;
|
||||
isc_buffer_t * querysig;
|
||||
uint32_t msgcounter;
|
||||
dns_fixedname_t fdomain;
|
||||
isc_sockaddr_t * ecs_addr;
|
||||
char * cookie;
|
||||
dns_ednsopt_t * ednsopts;
|
||||
unsigned int ednsoptscnt;
|
||||
isc_dscp_t dscp;
|
||||
unsigned int ednsflags;
|
||||
dns_opcode_t opcode;
|
||||
int rrcomments;
|
||||
unsigned int eoferr;
|
||||
};
|
||||
|
||||
/*% The dig_query structure */
|
||||
struct dig_query {
|
||||
unsigned int magic;
|
||||
unsigned int magic;
|
||||
dig_lookup_t *lookup;
|
||||
bool waiting_connect,
|
||||
pending_free,
|
||||
waiting_senddone,
|
||||
first_pass,
|
||||
first_soa_rcvd,
|
||||
second_rr_rcvd,
|
||||
first_repeat_rcvd,
|
||||
recv_made,
|
||||
warn_id,
|
||||
timedout;
|
||||
uint32_t first_rr_serial;
|
||||
uint32_t second_rr_serial;
|
||||
uint32_t msg_count;
|
||||
uint32_t rr_count;
|
||||
bool ixfr_axfr;
|
||||
char *servname;
|
||||
char *userarg;
|
||||
isc_buffer_t recvbuf,
|
||||
lengthbuf,
|
||||
tmpsendbuf,
|
||||
sendbuf;
|
||||
char *recvspace, *tmpsendspace,
|
||||
lengthspace[4];
|
||||
bool waiting_connect, pending_free, waiting_senddone, first_pass,
|
||||
first_soa_rcvd, second_rr_rcvd, first_repeat_rcvd, recv_made,
|
||||
warn_id, timedout;
|
||||
uint32_t first_rr_serial;
|
||||
uint32_t second_rr_serial;
|
||||
uint32_t msg_count;
|
||||
uint32_t rr_count;
|
||||
bool ixfr_axfr;
|
||||
char * servname;
|
||||
char * userarg;
|
||||
isc_buffer_t recvbuf, lengthbuf, tmpsendbuf, sendbuf;
|
||||
char * recvspace, *tmpsendspace, lengthspace[4];
|
||||
isc_socket_t *sock;
|
||||
ISC_LINK(dig_query_t) link;
|
||||
ISC_LINK(dig_query_t) clink;
|
||||
isc_sockaddr_t sockaddr;
|
||||
isc_time_t time_sent;
|
||||
isc_time_t time_recv;
|
||||
uint64_t byte_count;
|
||||
isc_timer_t *timer;
|
||||
isc_time_t time_sent;
|
||||
isc_time_t time_recv;
|
||||
uint64_t byte_count;
|
||||
isc_timer_t * timer;
|
||||
};
|
||||
|
||||
struct dig_server {
|
||||
|
|
@ -246,38 +198,38 @@ typedef ISC_LIST(dig_lookup_t) dig_lookuplist_t;
|
|||
* Externals from dighost.c
|
||||
*/
|
||||
|
||||
extern dig_lookuplist_t lookup_list;
|
||||
extern dig_serverlist_t server_list;
|
||||
extern dig_lookuplist_t lookup_list;
|
||||
extern dig_serverlist_t server_list;
|
||||
extern dig_searchlistlist_t search_list;
|
||||
extern unsigned int extrabytes;
|
||||
extern unsigned int extrabytes;
|
||||
|
||||
extern bool check_ra, have_ipv4, have_ipv6, specified_source,
|
||||
usesearch, showsearch, yaml;
|
||||
extern in_port_t port;
|
||||
extern unsigned int timeout;
|
||||
extern isc_mem_t *mctx;
|
||||
extern int sendcount;
|
||||
extern int ndots;
|
||||
extern int lookup_counter;
|
||||
extern int exitcode;
|
||||
extern isc_sockaddr_t bind_address;
|
||||
extern char keynametext[MXNAME];
|
||||
extern char keyfile[MXNAME];
|
||||
extern char keysecret[MXNAME];
|
||||
extern bool check_ra, have_ipv4, have_ipv6, specified_source, usesearch,
|
||||
showsearch, yaml;
|
||||
extern in_port_t port;
|
||||
extern unsigned int timeout;
|
||||
extern isc_mem_t * mctx;
|
||||
extern int sendcount;
|
||||
extern int ndots;
|
||||
extern int lookup_counter;
|
||||
extern int exitcode;
|
||||
extern isc_sockaddr_t bind_address;
|
||||
extern char keynametext[MXNAME];
|
||||
extern char keyfile[MXNAME];
|
||||
extern char keysecret[MXNAME];
|
||||
extern const dns_name_t *hmacname;
|
||||
extern unsigned int digestbits;
|
||||
extern dns_tsigkey_t *tsigkey;
|
||||
extern bool validated;
|
||||
extern isc_taskmgr_t *taskmgr;
|
||||
extern isc_task_t *global_task;
|
||||
extern bool free_now;
|
||||
extern bool debugging, debugtiming, memdebugging;
|
||||
extern bool keep_open;
|
||||
extern unsigned int digestbits;
|
||||
extern dns_tsigkey_t * tsigkey;
|
||||
extern bool validated;
|
||||
extern isc_taskmgr_t * taskmgr;
|
||||
extern isc_task_t * global_task;
|
||||
extern bool free_now;
|
||||
extern bool debugging, debugtiming, memdebugging;
|
||||
extern bool keep_open;
|
||||
|
||||
extern char *progname;
|
||||
extern int tries;
|
||||
extern int fatalexit;
|
||||
extern bool verbose;
|
||||
extern int tries;
|
||||
extern int fatalexit;
|
||||
extern bool verbose;
|
||||
|
||||
/*
|
||||
* Routines in dighost.c.
|
||||
|
|
@ -293,14 +245,13 @@ get_reverse(char *reverse, size_t len, char *value, bool strict);
|
|||
|
||||
ISC_PLATFORM_NORETURN_PRE void
|
||||
fatal(const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
void
|
||||
warn(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||
|
||||
ISC_PLATFORM_NORETURN_PRE void
|
||||
digexit(void)
|
||||
ISC_PLATFORM_NORETURN_POST;
|
||||
digexit(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
void
|
||||
debug(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||
|
|
@ -333,12 +284,10 @@ void
|
|||
setup_system(bool ipv4only, bool ipv6only);
|
||||
|
||||
isc_result_t
|
||||
parse_uint(uint32_t *uip, const char *value, uint32_t max,
|
||||
const char *desc);
|
||||
parse_uint(uint32_t *uip, const char *value, uint32_t max, const char *desc);
|
||||
|
||||
isc_result_t
|
||||
parse_xint(uint32_t *uip, const char *value, uint32_t max,
|
||||
const char *desc);
|
||||
parse_xint(uint32_t *uip, const char *value, uint32_t max, const char *desc);
|
||||
|
||||
isc_result_t
|
||||
parse_netprefix(isc_sockaddr_t **sap, const char *value);
|
||||
|
|
@ -365,8 +314,7 @@ void
|
|||
set_nameserver(char *opt);
|
||||
|
||||
void
|
||||
clone_server_list(dig_serverlist_t src,
|
||||
dig_serverlist_t *dest);
|
||||
clone_server_list(dig_serverlist_t src, dig_serverlist_t *dest);
|
||||
|
||||
void
|
||||
cancel_all(void);
|
||||
|
|
@ -381,54 +329,50 @@ set_search_domain(char *domain);
|
|||
* Routines to be defined in dig.c, host.c, and nslookup.c. and
|
||||
* then assigned to the appropriate function pointer
|
||||
*/
|
||||
extern isc_result_t
|
||||
(*dighost_printmessage)(dig_query_t *query, const isc_buffer_t *msgbuf,
|
||||
dns_message_t *msg, bool headers);
|
||||
extern isc_result_t (*dighost_printmessage)(dig_query_t * query,
|
||||
const isc_buffer_t *msgbuf,
|
||||
dns_message_t *msg, bool headers);
|
||||
|
||||
/*
|
||||
* Print an error message in the appropriate format.
|
||||
*/
|
||||
extern void
|
||||
(*dighost_error)(const char *format, ...);
|
||||
extern void (*dighost_error)(const char *format, ...);
|
||||
|
||||
/*
|
||||
* Print a warning message in the appropriate format.
|
||||
*/
|
||||
extern void
|
||||
(*dighost_warning)(const char *format, ...);
|
||||
extern void (*dighost_warning)(const char *format, ...);
|
||||
|
||||
/*
|
||||
* Print a comment in the appropriate format.
|
||||
*/
|
||||
extern void
|
||||
(*dighost_comments)(dig_lookup_t *lookup, const char *format, ...);
|
||||
extern void (*dighost_comments)(dig_lookup_t *lookup, const char *format, ...);
|
||||
|
||||
/*%<
|
||||
* Print the final result of the lookup.
|
||||
*/
|
||||
|
||||
extern void
|
||||
(*dighost_received)(unsigned int bytes, isc_sockaddr_t *from,
|
||||
dig_query_t *query);
|
||||
extern void (*dighost_received)(unsigned int bytes, isc_sockaddr_t *from,
|
||||
dig_query_t *query);
|
||||
/*%<
|
||||
* Print a message about where and when the response
|
||||
* was received from, like the final comment in the
|
||||
* output of "dig".
|
||||
*/
|
||||
|
||||
extern void
|
||||
(*dighost_trying)(char *frm, dig_lookup_t *lookup);
|
||||
extern void (*dighost_trying)(char *frm, dig_lookup_t *lookup);
|
||||
|
||||
extern void
|
||||
(*dighost_shutdown)(void);
|
||||
extern void (*dighost_shutdown)(void);
|
||||
|
||||
extern void
|
||||
(*dighost_pre_exit_hook)(void);
|
||||
extern void (*dighost_pre_exit_hook)(void);
|
||||
|
||||
void save_opt(dig_lookup_t *lookup, char *code, char *value);
|
||||
void
|
||||
save_opt(dig_lookup_t *lookup, char *code, char *value);
|
||||
|
||||
void setup_file_key(void);
|
||||
void setup_text_key(void);
|
||||
void
|
||||
setup_file_key(void);
|
||||
void
|
||||
setup_text_key(void);
|
||||
|
||||
/*
|
||||
* Routines exported from dig.c for use by dig for iOS
|
||||
|
|
|
|||
|
|
@ -18,22 +18,22 @@
|
|||
#include <isc/buffer.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/event.h>
|
||||
#include <isc/netaddr.h>
|
||||
#include <isc/parseint.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/netaddr.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/byaddr.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/message.h>
|
||||
#include <dns/name.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/rdata.h>
|
||||
#include <dns/rdataclass.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/rdatastruct.h>
|
||||
#include <dns/rdatatype.h>
|
||||
#include <dns/byaddr.h>
|
||||
|
||||
#include <dig/dig.h>
|
||||
|
||||
|
|
@ -47,100 +47,87 @@
|
|||
#include <editline/readline.h>
|
||||
#elif defined(HAVE_READLINE_READLINE_H)
|
||||
#include <readline/readline.h>
|
||||
#if defined (HAVE_READLINE_HISTORY_H)
|
||||
#if defined(HAVE_READLINE_HISTORY_H)
|
||||
#include <readline/history.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static bool short_form = true,
|
||||
tcpmode = false, tcpmode_set = false,
|
||||
identify = false, stats = true,
|
||||
comments = true, section_question = true,
|
||||
section_answer = true, section_authority = true,
|
||||
section_additional = true, recurse = true,
|
||||
aaonly = false, nofail = true,
|
||||
default_lookups = true, a_noanswer = false;
|
||||
static bool short_form = true, tcpmode = false, tcpmode_set = false,
|
||||
identify = false, stats = true, comments = true,
|
||||
section_question = true, section_answer = true,
|
||||
section_authority = true, section_additional = true, recurse = true,
|
||||
aaonly = false, nofail = true, default_lookups = true,
|
||||
a_noanswer = false;
|
||||
|
||||
static bool interactive;
|
||||
|
||||
static bool in_use = false;
|
||||
static char defclass[MXRD] = "IN";
|
||||
static char deftype[MXRD] = "A";
|
||||
static bool in_use = false;
|
||||
static char defclass[MXRD] = "IN";
|
||||
static char deftype[MXRD] = "A";
|
||||
static isc_event_t *global_event = NULL;
|
||||
static int query_error = 1, print_error = 0;
|
||||
static int query_error = 1, print_error = 0;
|
||||
|
||||
static char domainopt[DNS_NAME_MAXTEXT];
|
||||
|
||||
static const char *rcodetext[] = {
|
||||
"NOERROR",
|
||||
"FORMERR",
|
||||
"SERVFAIL",
|
||||
"NXDOMAIN",
|
||||
"NOTIMP",
|
||||
"REFUSED",
|
||||
"YXDOMAIN",
|
||||
"YXRRSET",
|
||||
"NXRRSET",
|
||||
"NOTAUTH",
|
||||
"NOTZONE",
|
||||
"RESERVED11",
|
||||
"RESERVED12",
|
||||
"RESERVED13",
|
||||
"RESERVED14",
|
||||
"RESERVED15",
|
||||
"BADVERS"
|
||||
};
|
||||
static const char *rcodetext[] = { "NOERROR", "FORMERR", "SERVFAIL",
|
||||
"NXDOMAIN", "NOTIMP", "REFUSED",
|
||||
"YXDOMAIN", "YXRRSET", "NXRRSET",
|
||||
"NOTAUTH", "NOTZONE", "RESERVED11",
|
||||
"RESERVED12", "RESERVED13", "RESERVED14",
|
||||
"RESERVED15", "BADVERS" };
|
||||
|
||||
static const char *rtypetext[] = {
|
||||
"rtype_0 = ", /* 0 */
|
||||
"internet address = ", /* 1 */
|
||||
"nameserver = ", /* 2 */
|
||||
"md = ", /* 3 */
|
||||
"mf = ", /* 4 */
|
||||
"canonical name = ", /* 5 */
|
||||
"soa = ", /* 6 */
|
||||
"mb = ", /* 7 */
|
||||
"mg = ", /* 8 */
|
||||
"mr = ", /* 9 */
|
||||
"rtype_10 = ", /* 10 */
|
||||
"protocol = ", /* 11 */
|
||||
"name = ", /* 12 */
|
||||
"hinfo = ", /* 13 */
|
||||
"minfo = ", /* 14 */
|
||||
"mail exchanger = ", /* 15 */
|
||||
"text = ", /* 16 */
|
||||
"rp = ", /* 17 */
|
||||
"afsdb = ", /* 18 */
|
||||
"x25 address = ", /* 19 */
|
||||
"isdn address = ", /* 20 */
|
||||
"rt = ", /* 21 */
|
||||
"nsap = ", /* 22 */
|
||||
"nsap_ptr = ", /* 23 */
|
||||
"signature = ", /* 24 */
|
||||
"key = ", /* 25 */
|
||||
"px = ", /* 26 */
|
||||
"gpos = ", /* 27 */
|
||||
"has AAAA address ", /* 28 */
|
||||
"loc = ", /* 29 */
|
||||
"next = ", /* 30 */
|
||||
"rtype_31 = ", /* 31 */
|
||||
"rtype_32 = ", /* 32 */
|
||||
"service = ", /* 33 */
|
||||
"rtype_34 = ", /* 34 */
|
||||
"naptr = ", /* 35 */
|
||||
"kx = ", /* 36 */
|
||||
"cert = ", /* 37 */
|
||||
"v6 address = ", /* 38 */
|
||||
"dname = ", /* 39 */
|
||||
"rtype_40 = ", /* 40 */
|
||||
"optional = " /* 41 */
|
||||
"rtype_0 = ", /* 0 */
|
||||
"internet address = ", /* 1 */
|
||||
"nameserver = ", /* 2 */
|
||||
"md = ", /* 3 */
|
||||
"mf = ", /* 4 */
|
||||
"canonical name = ", /* 5 */
|
||||
"soa = ", /* 6 */
|
||||
"mb = ", /* 7 */
|
||||
"mg = ", /* 8 */
|
||||
"mr = ", /* 9 */
|
||||
"rtype_10 = ", /* 10 */
|
||||
"protocol = ", /* 11 */
|
||||
"name = ", /* 12 */
|
||||
"hinfo = ", /* 13 */
|
||||
"minfo = ", /* 14 */
|
||||
"mail exchanger = ", /* 15 */
|
||||
"text = ", /* 16 */
|
||||
"rp = ", /* 17 */
|
||||
"afsdb = ", /* 18 */
|
||||
"x25 address = ", /* 19 */
|
||||
"isdn address = ", /* 20 */
|
||||
"rt = ", /* 21 */
|
||||
"nsap = ", /* 22 */
|
||||
"nsap_ptr = ", /* 23 */
|
||||
"signature = ", /* 24 */
|
||||
"key = ", /* 25 */
|
||||
"px = ", /* 26 */
|
||||
"gpos = ", /* 27 */
|
||||
"has AAAA address ", /* 28 */
|
||||
"loc = ", /* 29 */
|
||||
"next = ", /* 30 */
|
||||
"rtype_31 = ", /* 31 */
|
||||
"rtype_32 = ", /* 32 */
|
||||
"service = ", /* 33 */
|
||||
"rtype_34 = ", /* 34 */
|
||||
"naptr = ", /* 35 */
|
||||
"kx = ", /* 36 */
|
||||
"cert = ", /* 37 */
|
||||
"v6 address = ", /* 38 */
|
||||
"dname = ", /* 39 */
|
||||
"rtype_40 = ", /* 40 */
|
||||
"optional = " /* 41 */
|
||||
};
|
||||
|
||||
#define N_KNOWN_RRTYPES (sizeof(rtypetext) / sizeof(rtypetext[0]))
|
||||
|
||||
static void flush_lookup_list(void);
|
||||
static void getinput(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
flush_lookup_list(void);
|
||||
static void
|
||||
getinput(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
static char *
|
||||
rcode_totext(dns_rcode_t rcode)
|
||||
|
|
@ -148,10 +135,10 @@ rcode_totext(dns_rcode_t rcode)
|
|||
static char buf[sizeof("?65535")];
|
||||
union {
|
||||
const char *consttext;
|
||||
char *deconsttext;
|
||||
char * deconsttext;
|
||||
} totext;
|
||||
|
||||
if (rcode >= (sizeof(rcodetext)/sizeof(rcodetext[0]))) {
|
||||
if (rcode >= (sizeof(rcodetext) / sizeof(rcodetext[0]))) {
|
||||
snprintf(buf, sizeof(buf), "?%u", rcode);
|
||||
totext.deconsttext = buf;
|
||||
} else
|
||||
|
|
@ -160,7 +147,8 @@ rcode_totext(dns_rcode_t rcode)
|
|||
}
|
||||
|
||||
static void
|
||||
query_finished(void) {
|
||||
query_finished(void)
|
||||
{
|
||||
isc_event_t *event = global_event;
|
||||
|
||||
flush_lookup_list();
|
||||
|
|
@ -175,10 +163,11 @@ query_finished(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
printsoa(dns_rdata_t *rdata) {
|
||||
printsoa(dns_rdata_t *rdata)
|
||||
{
|
||||
dns_rdata_soa_t soa;
|
||||
isc_result_t result;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
isc_result_t result;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
|
||||
result = dns_rdata_tostruct(rdata, &soa, NULL);
|
||||
check_result(result, "dns_rdata_tostruct");
|
||||
|
|
@ -196,7 +185,8 @@ printsoa(dns_rdata_t *rdata) {
|
|||
}
|
||||
|
||||
static void
|
||||
printaddr(dns_rdata_t *rdata) {
|
||||
printaddr(dns_rdata_t *rdata)
|
||||
{
|
||||
isc_result_t result;
|
||||
char text[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
||||
isc_buffer_t b;
|
||||
|
|
@ -209,11 +199,12 @@ printaddr(dns_rdata_t *rdata) {
|
|||
}
|
||||
|
||||
static void
|
||||
printrdata(dns_rdata_t *rdata) {
|
||||
isc_result_t result;
|
||||
printrdata(dns_rdata_t *rdata)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t *b = NULL;
|
||||
unsigned int size = 1024;
|
||||
bool done = false;
|
||||
unsigned int size = 1024;
|
||||
bool done = false;
|
||||
|
||||
if (rdata->type < N_KNOWN_RRTYPES)
|
||||
printf("%s", rtypetext[rdata->type]);
|
||||
|
|
@ -236,12 +227,13 @@ printrdata(dns_rdata_t *rdata) {
|
|||
|
||||
static isc_result_t
|
||||
printsection(dig_query_t *query, dns_message_t *msg, bool headers,
|
||||
dns_section_t section) {
|
||||
isc_result_t result, loopresult;
|
||||
dns_name_t *name;
|
||||
dns_section_t section)
|
||||
{
|
||||
isc_result_t result, loopresult;
|
||||
dns_name_t * name;
|
||||
dns_rdataset_t *rdataset = NULL;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
|
||||
UNUSED(query);
|
||||
UNUSED(headers);
|
||||
|
|
@ -255,10 +247,8 @@ printsection(dig_query_t *query, dns_message_t *msg, bool headers,
|
|||
return (result);
|
||||
for (;;) {
|
||||
name = NULL;
|
||||
dns_message_currentname(msg, section,
|
||||
&name);
|
||||
for (rdataset = ISC_LIST_HEAD(name->list);
|
||||
rdataset != NULL;
|
||||
dns_message_currentname(msg, section, &name);
|
||||
for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
|
||||
rdataset = ISC_LIST_NEXT(rdataset, link)) {
|
||||
loopresult = dns_rdataset_first(rdataset);
|
||||
while (loopresult == ISC_R_SUCCESS) {
|
||||
|
|
@ -303,12 +293,13 @@ printsection(dig_query_t *query, dns_message_t *msg, bool headers,
|
|||
|
||||
static isc_result_t
|
||||
detailsection(dig_query_t *query, dns_message_t *msg, bool headers,
|
||||
dns_section_t section) {
|
||||
isc_result_t result, loopresult;
|
||||
dns_name_t *name;
|
||||
dns_section_t section)
|
||||
{
|
||||
isc_result_t result, loopresult;
|
||||
dns_name_t * name;
|
||||
dns_rdataset_t *rdataset = NULL;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
|
||||
UNUSED(query);
|
||||
|
||||
|
|
@ -338,30 +329,24 @@ detailsection(dig_query_t *query, dns_message_t *msg, bool headers,
|
|||
return (result);
|
||||
for (;;) {
|
||||
name = NULL;
|
||||
dns_message_currentname(msg, section,
|
||||
&name);
|
||||
for (rdataset = ISC_LIST_HEAD(name->list);
|
||||
rdataset != NULL;
|
||||
dns_message_currentname(msg, section, &name);
|
||||
for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
|
||||
rdataset = ISC_LIST_NEXT(rdataset, link)) {
|
||||
if (section == DNS_SECTION_QUESTION) {
|
||||
dns_name_format(name, namebuf,
|
||||
sizeof(namebuf));
|
||||
dns_name_format(name, namebuf, sizeof(namebuf));
|
||||
printf("\t%s, ", namebuf);
|
||||
dns_rdatatype_format(rdataset->type,
|
||||
namebuf,
|
||||
dns_rdatatype_format(rdataset->type, namebuf,
|
||||
sizeof(namebuf));
|
||||
printf("type = %s, ", namebuf);
|
||||
dns_rdataclass_format(rdataset->rdclass,
|
||||
namebuf,
|
||||
sizeof(namebuf));
|
||||
namebuf, sizeof(namebuf));
|
||||
printf("class = %s\n", namebuf);
|
||||
}
|
||||
loopresult = dns_rdataset_first(rdataset);
|
||||
while (loopresult == ISC_R_SUCCESS) {
|
||||
dns_rdataset_current(rdataset, &rdata);
|
||||
|
||||
dns_name_format(name, namebuf,
|
||||
sizeof(namebuf));
|
||||
dns_name_format(name, namebuf, sizeof(namebuf));
|
||||
printf(" -> %s\n", namebuf);
|
||||
|
||||
switch (rdata.type) {
|
||||
|
|
@ -396,23 +381,26 @@ received(unsigned int bytes, isc_sockaddr_t *from, dig_query_t *query)
|
|||
}
|
||||
|
||||
static void
|
||||
trying(char *frm, dig_lookup_t *lookup) {
|
||||
trying(char *frm, dig_lookup_t *lookup)
|
||||
{
|
||||
UNUSED(frm);
|
||||
UNUSED(lookup);
|
||||
}
|
||||
|
||||
static void
|
||||
chase_cnamechain(dns_message_t *msg, dns_name_t *qname) {
|
||||
isc_result_t result;
|
||||
dns_rdataset_t *rdataset;
|
||||
chase_cnamechain(dns_message_t *msg, dns_name_t *qname)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdataset_t * rdataset;
|
||||
dns_rdata_cname_t cname;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
unsigned int i = msg->counts[DNS_SECTION_ANSWER];
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
unsigned int i = msg->counts[DNS_SECTION_ANSWER];
|
||||
|
||||
while (i-- > 0) {
|
||||
rdataset = NULL;
|
||||
result = dns_message_findname(msg, DNS_SECTION_ANSWER, qname,
|
||||
dns_rdatatype_cname, 0, NULL, &rdataset);
|
||||
dns_rdatatype_cname, 0, NULL,
|
||||
&rdataset);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return;
|
||||
result = dns_rdataset_first(rdataset);
|
||||
|
|
@ -427,8 +415,8 @@ chase_cnamechain(dns_message_t *msg, dns_name_t *qname) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
||||
dns_message_t *msg, bool headers)
|
||||
printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
|
||||
bool headers)
|
||||
{
|
||||
char servtext[ISC_SOCKADDR_FORMATSIZE];
|
||||
|
||||
|
|
@ -439,7 +427,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
|
||||
debug("printmessage()");
|
||||
|
||||
if(!default_lookups || query->lookup->rdtype == dns_rdatatype_a) {
|
||||
if (!default_lookups || query->lookup->rdtype == dns_rdatatype_a) {
|
||||
isc_sockaddr_format(&query->sockaddr, servtext,
|
||||
sizeof(servtext));
|
||||
printf("Server:\t\t%s\n", query->userarg);
|
||||
|
|
@ -460,10 +448,10 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
|
||||
if (msg->rcode != 0) {
|
||||
char nametext[DNS_NAME_FORMATSIZE];
|
||||
dns_name_format(query->lookup->name,
|
||||
nametext, sizeof(nametext));
|
||||
printf("** server can't find %s: %s\n",
|
||||
nametext, rcode_totext(msg->rcode));
|
||||
dns_name_format(query->lookup->name, nametext,
|
||||
sizeof(nametext));
|
||||
printf("** server can't find %s: %s\n", nametext,
|
||||
rcode_totext(msg->rcode));
|
||||
debug("returning with rcode == 0");
|
||||
|
||||
/* the lookup failed */
|
||||
|
|
@ -471,11 +459,11 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
if ( default_lookups && query->lookup->rdtype == dns_rdatatype_a) {
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
dig_lookup_t *lookup;
|
||||
if (default_lookups && query->lookup->rdtype == dns_rdatatype_a) {
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
dig_lookup_t * lookup;
|
||||
dns_fixedname_t fixed;
|
||||
dns_name_t *name;
|
||||
dns_name_t * name;
|
||||
|
||||
/* Add AAAA lookup. */
|
||||
name = dns_fixedname_initname(&fixed);
|
||||
|
|
@ -495,7 +483,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
}
|
||||
|
||||
if ((msg->flags & DNS_MESSAGEFLAG_AA) == 0 &&
|
||||
( !default_lookups || query->lookup->rdtype == dns_rdatatype_a) )
|
||||
(!default_lookups || query->lookup->rdtype == dns_rdatatype_a))
|
||||
puts("Non-authoritative answer:");
|
||||
if (!ISC_LIST_EMPTY(msg->sections[DNS_SECTION_ANSWER]))
|
||||
printsection(query, msg, headers, DNS_SECTION_ANSWER);
|
||||
|
|
@ -505,29 +493,28 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf,
|
|||
|
||||
else if (!default_lookups ||
|
||||
(query->lookup->rdtype == dns_rdatatype_aaaa &&
|
||||
a_noanswer ) )
|
||||
a_noanswer))
|
||||
printf("*** Can't find %s: No answer\n",
|
||||
query->lookup->textname);
|
||||
query->lookup->textname);
|
||||
}
|
||||
|
||||
if (((msg->flags & DNS_MESSAGEFLAG_AA) == 0) &&
|
||||
(query->lookup->rdtype != dns_rdatatype_a) &&
|
||||
(query->lookup->rdtype != dns_rdatatype_aaaa) ) {
|
||||
(query->lookup->rdtype != dns_rdatatype_aaaa)) {
|
||||
puts("\nAuthoritative answers can be found from:");
|
||||
printsection(query, msg, headers,
|
||||
DNS_SECTION_AUTHORITY);
|
||||
printsection(query, msg, headers,
|
||||
DNS_SECTION_ADDITIONAL);
|
||||
printsection(query, msg, headers, DNS_SECTION_AUTHORITY);
|
||||
printsection(query, msg, headers, DNS_SECTION_ADDITIONAL);
|
||||
}
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
show_settings(bool full, bool serv_only) {
|
||||
dig_server_t *srv;
|
||||
isc_sockaddr_t sockaddr;
|
||||
show_settings(bool full, bool serv_only)
|
||||
{
|
||||
dig_server_t * srv;
|
||||
isc_sockaddr_t sockaddr;
|
||||
dig_searchlist_t *listent;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
srv = ISC_LIST_HEAD(server_list);
|
||||
|
||||
|
|
@ -538,8 +525,8 @@ show_settings(bool full, bool serv_only) {
|
|||
check_result(result, "get_address");
|
||||
|
||||
isc_sockaddr_format(&sockaddr, sockstr, sizeof(sockstr));
|
||||
printf("Default server: %s\nAddress: %s\n",
|
||||
srv->userarg, sockstr);
|
||||
printf("Default server: %s\nAddress: %s\n", srv->userarg,
|
||||
sockstr);
|
||||
if (!full)
|
||||
return;
|
||||
srv = ISC_LIST_NEXT(srv, link);
|
||||
|
|
@ -547,32 +534,29 @@ show_settings(bool full, bool serv_only) {
|
|||
if (serv_only)
|
||||
return;
|
||||
printf("\nSet options:\n");
|
||||
printf(" %s\t\t\t%s\t\t%s\n",
|
||||
tcpmode ? "vc" : "novc",
|
||||
short_form ? "nodebug" : "debug",
|
||||
debugging ? "d2" : "nod2");
|
||||
printf(" %s\t\t%s\n",
|
||||
usesearch ? "search" : "nosearch",
|
||||
printf(" %s\t\t\t%s\t\t%s\n", tcpmode ? "vc" : "novc",
|
||||
short_form ? "nodebug" : "debug", debugging ? "d2" : "nod2");
|
||||
printf(" %s\t\t%s\n", usesearch ? "search" : "nosearch",
|
||||
recurse ? "recurse" : "norecurse");
|
||||
printf(" timeout = %u\t\tretry = %d\tport = %u\tndots = %d\n",
|
||||
timeout, tries, port, ndots);
|
||||
printf(" timeout = %u\t\tretry = %d\tport = %u\tndots = %d\n", timeout,
|
||||
tries, port, ndots);
|
||||
printf(" querytype = %-8s\tclass = %s\n", deftype, defclass);
|
||||
printf(" srchlist = ");
|
||||
for (listent = ISC_LIST_HEAD(search_list);
|
||||
listent != NULL;
|
||||
for (listent = ISC_LIST_HEAD(search_list); listent != NULL;
|
||||
listent = ISC_LIST_NEXT(listent, link)) {
|
||||
printf("%s", listent->origin);
|
||||
if (ISC_LIST_NEXT(listent, link) != NULL)
|
||||
printf("/");
|
||||
printf("%s", listent->origin);
|
||||
if (ISC_LIST_NEXT(listent, link) != NULL)
|
||||
printf("/");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static bool
|
||||
testtype(char *typetext) {
|
||||
isc_result_t result;
|
||||
testtype(char *typetext)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_textregion_t tr;
|
||||
dns_rdatatype_t rdtype;
|
||||
dns_rdatatype_t rdtype;
|
||||
|
||||
tr.base = typetext;
|
||||
tr.length = strlen(typetext);
|
||||
|
|
@ -586,8 +570,9 @@ testtype(char *typetext) {
|
|||
}
|
||||
|
||||
static bool
|
||||
testclass(char *typetext) {
|
||||
isc_result_t result;
|
||||
testclass(char *typetext)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_textregion_t tr;
|
||||
dns_rdataclass_t rdclass;
|
||||
|
||||
|
|
@ -603,44 +588,50 @@ testclass(char *typetext) {
|
|||
}
|
||||
|
||||
static void
|
||||
set_port(const char *value) {
|
||||
uint32_t n;
|
||||
set_port(const char *value)
|
||||
{
|
||||
uint32_t n;
|
||||
isc_result_t result = parse_uint(&n, value, 65535, "port");
|
||||
if (result == ISC_R_SUCCESS)
|
||||
port = (uint16_t) n;
|
||||
port = (uint16_t)n;
|
||||
}
|
||||
|
||||
static void
|
||||
set_timeout(const char *value) {
|
||||
uint32_t n;
|
||||
set_timeout(const char *value)
|
||||
{
|
||||
uint32_t n;
|
||||
isc_result_t result = parse_uint(&n, value, UINT_MAX, "timeout");
|
||||
if (result == ISC_R_SUCCESS)
|
||||
timeout = n;
|
||||
}
|
||||
|
||||
static void
|
||||
set_tries(const char *value) {
|
||||
uint32_t n;
|
||||
set_tries(const char *value)
|
||||
{
|
||||
uint32_t n;
|
||||
isc_result_t result = parse_uint(&n, value, INT_MAX, "tries");
|
||||
if (result == ISC_R_SUCCESS)
|
||||
tries = n;
|
||||
}
|
||||
|
||||
static void
|
||||
set_ndots(const char *value) {
|
||||
uint32_t n;
|
||||
set_ndots(const char *value)
|
||||
{
|
||||
uint32_t n;
|
||||
isc_result_t result = parse_uint(&n, value, 128, "ndots");
|
||||
if (result == ISC_R_SUCCESS)
|
||||
ndots = n;
|
||||
}
|
||||
|
||||
static void
|
||||
version(void) {
|
||||
version(void)
|
||||
{
|
||||
fputs("nslookup " VERSION "\n", stderr);
|
||||
}
|
||||
|
||||
static void
|
||||
setoption(char *opt) {
|
||||
setoption(char *opt)
|
||||
{
|
||||
size_t l = strlen(opt);
|
||||
|
||||
#define CHECKOPT(A, N) \
|
||||
|
|
@ -735,9 +726,9 @@ setoption(char *opt) {
|
|||
} else if (CHECKOPT("sil", 3)) {
|
||||
/* deprecation_msg = false; */
|
||||
} else if (CHECKOPT("fail", 3)) {
|
||||
nofail=false;
|
||||
nofail = false;
|
||||
} else if (CHECKOPT("nofail", 5)) {
|
||||
nofail=true;
|
||||
nofail = true;
|
||||
} else if (strncasecmp(opt, "ndots=", 6) == 0) {
|
||||
set_ndots(&opt[6]);
|
||||
} else {
|
||||
|
|
@ -746,13 +737,14 @@ setoption(char *opt) {
|
|||
}
|
||||
|
||||
static void
|
||||
addlookup(char *opt) {
|
||||
dig_lookup_t *lookup;
|
||||
isc_result_t result;
|
||||
addlookup(char *opt)
|
||||
{
|
||||
dig_lookup_t * lookup;
|
||||
isc_result_t result;
|
||||
isc_textregion_t tr;
|
||||
dns_rdatatype_t rdtype;
|
||||
dns_rdatatype_t rdtype;
|
||||
dns_rdataclass_t rdclass;
|
||||
char store[MXNAME];
|
||||
char store[MXNAME];
|
||||
|
||||
debug("addlookup()");
|
||||
|
||||
|
|
@ -773,8 +765,7 @@ addlookup(char *opt) {
|
|||
rdclass = dns_rdataclass_in;
|
||||
}
|
||||
lookup = make_empty_lookup();
|
||||
if (get_reverse(store, sizeof(store), opt, true)
|
||||
== ISC_R_SUCCESS) {
|
||||
if (get_reverse(store, sizeof(store), opt, true) == ISC_R_SUCCESS) {
|
||||
strlcpy(lookup->textname, store, sizeof(lookup->textname));
|
||||
lookup->rdtype = dns_rdatatype_ptr;
|
||||
lookup->rdtypeset = true;
|
||||
|
|
@ -815,15 +806,15 @@ addlookup(char *opt) {
|
|||
}
|
||||
|
||||
static void
|
||||
do_next_command(char *input) {
|
||||
do_next_command(char *input)
|
||||
{
|
||||
char *ptr, *arg, *last;
|
||||
|
||||
if ((ptr = strtok_r(input, " \t\r\n", &last)) == NULL) {
|
||||
return;
|
||||
}
|
||||
arg = strtok_r(NULL, " \t\r\n", &last);
|
||||
if ((strcasecmp(ptr, "set") == 0) &&
|
||||
(arg != NULL))
|
||||
if ((strcasecmp(ptr, "set") == 0) && (arg != NULL))
|
||||
setoption(arg);
|
||||
else if ((strcasecmp(ptr, "server") == 0) ||
|
||||
(strcasecmp(ptr, "lserver") == 0)) {
|
||||
|
|
@ -834,12 +825,10 @@ do_next_command(char *input) {
|
|||
show_settings(true, true);
|
||||
} else if (strcasecmp(ptr, "exit") == 0) {
|
||||
in_use = false;
|
||||
} else if (strcasecmp(ptr, "help") == 0 ||
|
||||
strcasecmp(ptr, "?") == 0) {
|
||||
} else if (strcasecmp(ptr, "help") == 0 || strcasecmp(ptr, "?") == 0) {
|
||||
printf("The '%s' command is not yet implemented.\n", ptr);
|
||||
} else if (strcasecmp(ptr, "finger") == 0 ||
|
||||
strcasecmp(ptr, "root") == 0 ||
|
||||
strcasecmp(ptr, "ls") == 0 ||
|
||||
strcasecmp(ptr, "root") == 0 || strcasecmp(ptr, "ls") == 0 ||
|
||||
strcasecmp(ptr, "view") == 0) {
|
||||
printf("The '%s' command is not implemented.\n", ptr);
|
||||
} else
|
||||
|
|
@ -847,7 +836,8 @@ do_next_command(char *input) {
|
|||
}
|
||||
|
||||
static void
|
||||
get_next_command(void) {
|
||||
get_next_command(void)
|
||||
{
|
||||
char *buf;
|
||||
char *ptr;
|
||||
|
||||
|
|
@ -882,21 +872,23 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr,
|
||||
" nslookup [-opt ...] # interactive mode using default server\n");
|
||||
fprintf(stderr,
|
||||
" nslookup [-opt ...] - server # interactive mode using 'server'\n");
|
||||
fprintf(stderr,
|
||||
" nslookup [-opt ...] host # just look up 'host' using default server\n");
|
||||
fprintf(stderr,
|
||||
" nslookup [-opt ...] host server # just look up 'host' using 'server'\n");
|
||||
exit(1);
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " nslookup [-opt ...] # interactive mode "
|
||||
"using default server\n");
|
||||
fprintf(stderr, " nslookup [-opt ...] - server # interactive mode "
|
||||
"using 'server'\n");
|
||||
fprintf(stderr, " nslookup [-opt ...] host # just look up "
|
||||
"'host' using default server\n");
|
||||
fprintf(stderr, " nslookup [-opt ...] host server # just look up "
|
||||
"'host' using 'server'\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_args(int argc, char **argv) {
|
||||
parse_args(int argc, char **argv)
|
||||
{
|
||||
bool have_lookup = false;
|
||||
|
||||
usesearch = true;
|
||||
|
|
@ -927,9 +919,10 @@ parse_args(int argc, char **argv) {
|
|||
}
|
||||
|
||||
static void
|
||||
flush_lookup_list(void) {
|
||||
flush_lookup_list(void)
|
||||
{
|
||||
dig_lookup_t *l, *lp;
|
||||
dig_query_t *q, *qp;
|
||||
dig_query_t * q, *qp;
|
||||
dig_server_t *s, *sp;
|
||||
|
||||
lookup_counter = 0;
|
||||
|
|
@ -955,7 +948,6 @@ flush_lookup_list(void) {
|
|||
s = ISC_LIST_NEXT(s, link);
|
||||
ISC_LIST_DEQUEUE(l->my_server_list, sp, link);
|
||||
isc_mem_free(mctx, sp);
|
||||
|
||||
}
|
||||
if (l->sendmsg != NULL)
|
||||
dns_message_destroy(&l->sendmsg);
|
||||
|
|
@ -967,7 +959,8 @@ flush_lookup_list(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
getinput(isc_task_t *task, isc_event_t *event) {
|
||||
getinput(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
UNUSED(task);
|
||||
if (global_event == NULL)
|
||||
global_event = event;
|
||||
|
|
@ -982,7 +975,8 @@ getinput(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
interactive = isatty(0);
|
||||
|
|
@ -1014,8 +1008,7 @@ main(int argc, char **argv) {
|
|||
if (domainopt[0] != '\0')
|
||||
set_search_domain(domainopt);
|
||||
if (in_use)
|
||||
result = isc_app_onrun(mctx, global_task, onrun_callback,
|
||||
NULL);
|
||||
result = isc_app_onrun(mctx, global_task, onrun_callback, NULL);
|
||||
else
|
||||
result = isc_app_onrun(mctx, global_task, getinput, NULL);
|
||||
check_result(result, "isc_app_onrun");
|
||||
|
|
|
|||
|
|
@ -70,14 +70,14 @@ static isc_mem_t *mctx = NULL;
|
|||
/*
|
||||
* The domain we are working on
|
||||
*/
|
||||
static const char *namestr = NULL;
|
||||
static dns_fixedname_t fixed;
|
||||
static dns_name_t *name = NULL;
|
||||
static const char * namestr = NULL;
|
||||
static dns_fixedname_t fixed;
|
||||
static dns_name_t * name = NULL;
|
||||
static dns_rdataclass_t rdclass = dns_rdataclass_in;
|
||||
|
||||
static const char *startstr = NULL; /* from which we derive notbefore */
|
||||
static isc_stdtime_t notbefore = 0; /* restrict sig inception times */
|
||||
static dns_rdata_rrsig_t oldestsig; /* for recording inception time */
|
||||
static const char * startstr = NULL; /* from which we derive notbefore */
|
||||
static isc_stdtime_t notbefore = 0; /* restrict sig inception times */
|
||||
static dns_rdata_rrsig_t oldestsig; /* for recording inception time */
|
||||
|
||||
static int nkey; /* number of child zone DNSKEY records */
|
||||
|
||||
|
|
@ -114,8 +114,8 @@ static int nkey; /* number of child zone DNSKEY records */
|
|||
* match.
|
||||
*/
|
||||
typedef struct keyinfo {
|
||||
dns_rdata_t rdata;
|
||||
dst_key_t *dst;
|
||||
dns_rdata_t rdata;
|
||||
dst_key_t * dst;
|
||||
dns_secalg_t algo;
|
||||
dns_keytag_t tag;
|
||||
} keyinfo_t;
|
||||
|
|
@ -131,13 +131,14 @@ static dns_rdataset_t old_ds_set, new_ds_set;
|
|||
|
||||
static keyinfo_t *old_key_tbl, *new_key_tbl;
|
||||
|
||||
isc_buffer_t *new_ds_buf = NULL; /* backing store for new_ds_set */
|
||||
isc_buffer_t *new_ds_buf = NULL; /* backing store for new_ds_set */
|
||||
|
||||
static void
|
||||
verbose_time(int level, const char *msg, isc_stdtime_t time) {
|
||||
verbose_time(int level, const char *msg, isc_stdtime_t time)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t timebuf;
|
||||
char timestr[32];
|
||||
char timestr[32];
|
||||
|
||||
if (verbose < level) {
|
||||
return;
|
||||
|
|
@ -150,13 +151,13 @@ verbose_time(int level, const char *msg, isc_stdtime_t time) {
|
|||
if (verbose < 3) {
|
||||
vbprintf(level, "%s %s\n", msg, timestr);
|
||||
} else {
|
||||
vbprintf(level, "%s %s (%" PRIu32 ")\n",
|
||||
msg, timestr, time);
|
||||
vbprintf(level, "%s %s (%" PRIu32 ")\n", msg, timestr, time);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
initname(char *setname) {
|
||||
initname(char *setname)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t buf;
|
||||
|
||||
|
|
@ -181,24 +182,26 @@ findset(dns_db_t *db, dns_dbnode_t *node, dns_rdatatype_t type,
|
|||
if (sigrdataset != NULL) {
|
||||
dns_rdataset_init(sigrdataset);
|
||||
}
|
||||
result = dns_db_findrdataset(db, node, NULL, type, 0, 0,
|
||||
rdataset, sigrdataset);
|
||||
result = dns_db_findrdataset(db, node, NULL, type, 0, 0, rdataset,
|
||||
sigrdataset);
|
||||
if (result != ISC_R_NOTFOUND) {
|
||||
check_result(result, "dns_db_findrdataset()");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
freeset(dns_rdataset_t *rdataset) {
|
||||
freeset(dns_rdataset_t *rdataset)
|
||||
{
|
||||
if (dns_rdataset_isassociated(rdataset)) {
|
||||
dns_rdataset_disassociate(rdataset);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
freelist(dns_rdataset_t *rdataset) {
|
||||
freelist(dns_rdataset_t *rdataset)
|
||||
{
|
||||
dns_rdatalist_t *rdlist;
|
||||
dns_rdata_t *rdata;
|
||||
dns_rdata_t * rdata;
|
||||
|
||||
if (!dns_rdataset_isassociated(rdataset)) {
|
||||
return;
|
||||
|
|
@ -206,10 +209,8 @@ freelist(dns_rdataset_t *rdataset) {
|
|||
|
||||
dns_rdatalist_fromrdataset(rdataset, &rdlist);
|
||||
|
||||
for (rdata = ISC_LIST_HEAD(rdlist->rdata);
|
||||
rdata != NULL;
|
||||
rdata = ISC_LIST_HEAD(rdlist->rdata))
|
||||
{
|
||||
for (rdata = ISC_LIST_HEAD(rdlist->rdata); rdata != NULL;
|
||||
rdata = ISC_LIST_HEAD(rdlist->rdata)) {
|
||||
ISC_LIST_UNLINK(rdlist->rdata, rdata, link);
|
||||
isc_mem_put(mctx, rdata, sizeof(*rdata));
|
||||
}
|
||||
|
|
@ -218,7 +219,8 @@ freelist(dns_rdataset_t *rdataset) {
|
|||
}
|
||||
|
||||
static void
|
||||
free_all_sets(void) {
|
||||
free_all_sets(void)
|
||||
{
|
||||
freeset(&cdnskey_set);
|
||||
freeset(&cdnskey_sig);
|
||||
freeset(&cds_set);
|
||||
|
|
@ -233,18 +235,18 @@ free_all_sets(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
load_db(const char *filename, dns_db_t **dbp, dns_dbnode_t **nodep) {
|
||||
load_db(const char *filename, dns_db_t **dbp, dns_dbnode_t **nodep)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, dbp);
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone, rdclass, 0,
|
||||
NULL, dbp);
|
||||
check_result(result, "dns_db_create()");
|
||||
|
||||
result = dns_db_load(*dbp, filename,
|
||||
dns_masterformat_text, DNS_MASTER_HINT);
|
||||
result = dns_db_load(*dbp, filename, dns_masterformat_text,
|
||||
DNS_MASTER_HINT);
|
||||
if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) {
|
||||
fatal("can't load %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
fatal("can't load %s: %s", filename, isc_result_totext(result));
|
||||
}
|
||||
|
||||
result = dns_db_findnode(*dbp, name, false, nodep);
|
||||
|
|
@ -254,14 +256,16 @@ load_db(const char *filename, dns_db_t **dbp, dns_dbnode_t **nodep) {
|
|||
}
|
||||
|
||||
static void
|
||||
free_db(dns_db_t **dbp, dns_dbnode_t **nodep) {
|
||||
free_db(dns_db_t **dbp, dns_dbnode_t **nodep)
|
||||
{
|
||||
dns_db_detachnode(*dbp, nodep);
|
||||
dns_db_detach(dbp);
|
||||
}
|
||||
|
||||
static void
|
||||
load_child_sets(const char *file) {
|
||||
dns_db_t *db = NULL;
|
||||
load_child_sets(const char *file)
|
||||
{
|
||||
dns_db_t * db = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
|
||||
load_db(file, &db, &node);
|
||||
|
|
@ -272,12 +276,12 @@ load_child_sets(const char *file) {
|
|||
}
|
||||
|
||||
static void
|
||||
get_dsset_name(char *filename, size_t size,
|
||||
const char *path, const char *suffix)
|
||||
get_dsset_name(char *filename, size_t size, const char *path,
|
||||
const char *suffix)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t buf;
|
||||
size_t len;
|
||||
size_t len;
|
||||
|
||||
isc_buffer_init(&buf, filename, size);
|
||||
|
||||
|
|
@ -316,19 +320,20 @@ get_dsset_name(char *filename, size_t size,
|
|||
}
|
||||
|
||||
static void
|
||||
load_parent_set(const char *path) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
load_parent_set(const char *path)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_db_t * db = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
isc_time_t modtime;
|
||||
char filename[PATH_MAX + 1];
|
||||
isc_time_t modtime;
|
||||
char filename[PATH_MAX + 1];
|
||||
|
||||
get_dsset_name(filename, sizeof(filename), path, "");
|
||||
|
||||
result = isc_file_getmodtime(filename, &modtime);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("could not get modification time of %s: %s",
|
||||
filename, isc_result_totext(result));
|
||||
fatal("could not get modification time of %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
}
|
||||
notbefore = isc_time_seconds(&modtime);
|
||||
if (startstr != NULL) {
|
||||
|
|
@ -342,8 +347,8 @@ load_parent_set(const char *path) {
|
|||
findset(db, node, dns_rdatatype_ds, &old_ds_set, NULL);
|
||||
|
||||
if (!dns_rdataset_isassociated(&old_ds_set)) {
|
||||
fatal("could not find DS records for %s in %s",
|
||||
namestr, filename);
|
||||
fatal("could not find DS records for %s in %s", namestr,
|
||||
filename);
|
||||
}
|
||||
|
||||
free_db(&db, &node);
|
||||
|
|
@ -352,11 +357,12 @@ load_parent_set(const char *path) {
|
|||
#define MAX_CDS_RDATA_TEXT_SIZE DNS_RDATA_MAXLENGTH * 2
|
||||
|
||||
static isc_buffer_t *
|
||||
formatset(dns_rdataset_t *rdataset) {
|
||||
isc_result_t result;
|
||||
isc_buffer_t *buf = NULL;
|
||||
formatset(dns_rdataset_t *rdataset)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t * buf = NULL;
|
||||
dns_master_style_t *style = NULL;
|
||||
unsigned int styleflags;
|
||||
unsigned int styleflags;
|
||||
|
||||
styleflags = (rdataset->ttl == 0) ? DNS_STYLEFLAG_NO_TTL : 0;
|
||||
|
||||
|
|
@ -365,9 +371,8 @@ formatset(dns_rdataset_t *rdataset) {
|
|||
* which just separates fields with spaces. The huge tab stop width
|
||||
* eliminates any tab characters.
|
||||
*/
|
||||
result = dns_master_stylecreate(&style, styleflags,
|
||||
0, 0, 0, 0, 0, 1000000, 0,
|
||||
mctx);
|
||||
result = dns_master_stylecreate(&style, styleflags, 0, 0, 0, 0, 0,
|
||||
1000000, 0, mctx);
|
||||
check_result(result, "dns_master_stylecreate2 failed");
|
||||
|
||||
isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
|
||||
|
|
@ -387,17 +392,17 @@ formatset(dns_rdataset_t *rdataset) {
|
|||
}
|
||||
|
||||
static void
|
||||
write_parent_set(const char *path, const char *inplace,
|
||||
bool nsupdate, dns_rdataset_t *rdataset)
|
||||
write_parent_set(const char *path, const char *inplace, bool nsupdate,
|
||||
dns_rdataset_t *rdataset)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
isc_buffer_t *buf = NULL;
|
||||
isc_region_t r;
|
||||
isc_time_t filetime;
|
||||
char backname[PATH_MAX + 1];
|
||||
char filename[PATH_MAX + 1];
|
||||
char tmpname[PATH_MAX + 1];
|
||||
FILE *fp = NULL;
|
||||
isc_region_t r;
|
||||
isc_time_t filetime;
|
||||
char backname[PATH_MAX + 1];
|
||||
char filename[PATH_MAX + 1];
|
||||
char tmpname[PATH_MAX + 1];
|
||||
FILE * fp = NULL;
|
||||
|
||||
if (nsupdate && inplace == NULL) {
|
||||
return;
|
||||
|
|
@ -440,8 +445,8 @@ write_parent_set(const char *path, const char *inplace,
|
|||
result = isc_file_settime(tmpname, &filetime);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_file_remove(tmpname);
|
||||
fatal("can't set modification time of %s: %s",
|
||||
tmpname, isc_result_totext(result));
|
||||
fatal("can't set modification time of %s: %s", tmpname,
|
||||
isc_result_totext(result));
|
||||
}
|
||||
|
||||
if (inplace[0] != '\0') {
|
||||
|
|
@ -458,17 +463,15 @@ typedef enum { LOOSE, TIGHT } strictness_t;
|
|||
static bool
|
||||
match_key_dsset(keyinfo_t *ki, dns_rdataset_t *dsset, strictness_t strictness)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
unsigned char dsbuf[DNS_DS_BUFFERSIZE];
|
||||
|
||||
for (result = dns_rdataset_first(dsset);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(dsset))
|
||||
{
|
||||
for (result = dns_rdataset_first(dsset); result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(dsset)) {
|
||||
dns_rdata_ds_t ds;
|
||||
dns_rdata_t dsrdata = DNS_RDATA_INIT;
|
||||
dns_rdata_t newdsrdata = DNS_RDATA_INIT;
|
||||
bool c;
|
||||
dns_rdata_t dsrdata = DNS_RDATA_INIT;
|
||||
dns_rdata_t newdsrdata = DNS_RDATA_INIT;
|
||||
bool c;
|
||||
|
||||
dns_rdataset_current(dsset, &dsrdata);
|
||||
result = dns_rdata_tostruct(&dsrdata, &ds, NULL);
|
||||
|
|
@ -481,7 +484,8 @@ match_key_dsset(keyinfo_t *ki, dns_rdataset_t *dsset, strictness_t strictness)
|
|||
result = dns_ds_buildrdata(name, &ki->rdata, ds.digest_type,
|
||||
dsbuf, &newdsrdata);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
vbprintf(3, "dns_ds_buildrdata("
|
||||
vbprintf(3,
|
||||
"dns_ds_buildrdata("
|
||||
"keytag=%d, algo=%d, digest=%d): %s\n",
|
||||
ds.key_tag, ds.algorithm, ds.digest_type,
|
||||
dns_result_totext(result));
|
||||
|
|
@ -492,23 +496,22 @@ match_key_dsset(keyinfo_t *ki, dns_rdataset_t *dsset, strictness_t strictness)
|
|||
dsrdata.type = dns_rdatatype_ds;
|
||||
if (dns_rdata_compare(&dsrdata, &newdsrdata) == 0) {
|
||||
vbprintf(1, "found matching %s %d %d %d\n",
|
||||
c ? "CDS" : "DS",
|
||||
ds.key_tag, ds.algorithm, ds.digest_type);
|
||||
c ? "CDS" : "DS", ds.key_tag, ds.algorithm,
|
||||
ds.digest_type);
|
||||
return (true);
|
||||
} else if (strictness == TIGHT) {
|
||||
vbprintf(0, "key does not match %s %d %d %d "
|
||||
"when it looks like it should\n",
|
||||
c ? "CDS" : "DS",
|
||||
ds.key_tag, ds.algorithm, ds.digest_type);
|
||||
vbprintf(0,
|
||||
"key does not match %s %d %d %d "
|
||||
"when it looks like it should\n",
|
||||
c ? "CDS" : "DS", ds.key_tag, ds.algorithm,
|
||||
ds.digest_type);
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
vbprintf(1, "no matching %s for %s %d %d\n",
|
||||
dsset->type == dns_rdatatype_cds
|
||||
? "CDS" : "DS",
|
||||
ki->rdata.type == dns_rdatatype_cdnskey
|
||||
? "CDNSKEY" : "DNSKEY",
|
||||
dsset->type == dns_rdatatype_cds ? "CDS" : "DS",
|
||||
ki->rdata.type == dns_rdatatype_cdnskey ? "CDNSKEY" : "DNSKEY",
|
||||
ki->tag, ki->algo);
|
||||
|
||||
return (false);
|
||||
|
|
@ -523,21 +526,19 @@ match_keyset_dsset(dns_rdataset_t *keyset, dns_rdataset_t *dsset,
|
|||
strictness_t strictness)
|
||||
{
|
||||
isc_result_t result;
|
||||
keyinfo_t *keytable;
|
||||
int i;
|
||||
keyinfo_t * keytable;
|
||||
int i;
|
||||
|
||||
nkey = dns_rdataset_count(keyset);
|
||||
|
||||
keytable = isc_mem_get(mctx, sizeof(keyinfo_t) * nkey);
|
||||
|
||||
for (result = dns_rdataset_first(keyset), i = 0;
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(keyset), i++)
|
||||
{
|
||||
keyinfo_t *ki;
|
||||
result == ISC_R_SUCCESS; result = dns_rdataset_next(keyset), i++) {
|
||||
keyinfo_t * ki;
|
||||
dns_rdata_dnskey_t dnskey;
|
||||
dns_rdata_t *keyrdata;
|
||||
isc_region_t r;
|
||||
dns_rdata_t * keyrdata;
|
||||
isc_region_t r;
|
||||
|
||||
INSIST(i < nkey);
|
||||
ki = &keytable[i];
|
||||
|
|
@ -558,13 +559,13 @@ match_keyset_dsset(dns_rdataset_t *keyset, dns_rdataset_t *dsset,
|
|||
continue;
|
||||
}
|
||||
|
||||
result = dns_dnssec_keyfromrdata(name, keyrdata,
|
||||
mctx, &ki->dst);
|
||||
result =
|
||||
dns_dnssec_keyfromrdata(name, keyrdata, mctx, &ki->dst);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
vbprintf(3, "dns_dnssec_keyfromrdata("
|
||||
vbprintf(3,
|
||||
"dns_dnssec_keyfromrdata("
|
||||
"keytag=%d, algo=%d): %s\n",
|
||||
ki->tag, ki->algo,
|
||||
dns_result_totext(result));
|
||||
ki->tag, ki->algo, dns_result_totext(result));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -572,11 +573,12 @@ match_keyset_dsset(dns_rdataset_t *keyset, dns_rdataset_t *dsset,
|
|||
}
|
||||
|
||||
static void
|
||||
free_keytable(keyinfo_t **keytable_p) {
|
||||
free_keytable(keyinfo_t **keytable_p)
|
||||
{
|
||||
keyinfo_t *keytable = *keytable_p;
|
||||
*keytable_p = NULL;
|
||||
keyinfo_t *ki;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nkey; i++) {
|
||||
ki = &keytable[i];
|
||||
|
|
@ -601,18 +603,16 @@ static dns_secalg_t *
|
|||
matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset,
|
||||
dns_rdataset_t *sigset)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
dns_secalg_t *algo;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
algo = isc_mem_get(mctx, nkey);
|
||||
memset(algo, 0, nkey);
|
||||
|
||||
for (result = dns_rdataset_first(sigset);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(sigset))
|
||||
{
|
||||
dns_rdata_t sigrdata = DNS_RDATA_INIT;
|
||||
for (result = dns_rdataset_first(sigset); result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(sigset)) {
|
||||
dns_rdata_t sigrdata = DNS_RDATA_INIT;
|
||||
dns_rdata_rrsig_t sig;
|
||||
|
||||
dns_rdataset_current(sigset, &sigrdata);
|
||||
|
|
@ -630,26 +630,26 @@ matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset,
|
|||
|
||||
for (i = 0; i < nkey; i++) {
|
||||
keyinfo_t *ki = &keytbl[i];
|
||||
if (sig.keyid != ki->tag ||
|
||||
sig.algorithm != ki->algo ||
|
||||
!dns_name_equal(&sig.signer, name))
|
||||
{
|
||||
if (sig.keyid != ki->tag || sig.algorithm != ki->algo ||
|
||||
!dns_name_equal(&sig.signer, name)) {
|
||||
continue;
|
||||
}
|
||||
if (ki->dst == NULL) {
|
||||
vbprintf(1, "skip RRSIG by key %d:"
|
||||
vbprintf(1,
|
||||
"skip RRSIG by key %d:"
|
||||
" no matching (C)DS\n",
|
||||
sig.keyid);
|
||||
continue;
|
||||
}
|
||||
|
||||
result = dns_dnssec_verify(name, rdataset, ki->dst,
|
||||
false, 0, mctx,
|
||||
&sigrdata, NULL);
|
||||
false, 0, mctx, &sigrdata,
|
||||
NULL);
|
||||
|
||||
if (result != ISC_R_SUCCESS &&
|
||||
result != DNS_R_FROMWILDCARD) {
|
||||
vbprintf(1, "skip RRSIG by key %d:"
|
||||
vbprintf(1,
|
||||
"skip RRSIG by key %d:"
|
||||
" verification failed: %s\n",
|
||||
sig.keyid, isc_result_totext(result));
|
||||
continue;
|
||||
|
|
@ -664,8 +664,7 @@ matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset,
|
|||
*/
|
||||
if (oldestsig.timesigned == 0 ||
|
||||
isc_serial_lt(sig.timesigned,
|
||||
oldestsig.timesigned))
|
||||
{
|
||||
oldestsig.timesigned)) {
|
||||
verbose_time(2, "this is the oldest so far",
|
||||
sig.timesigned);
|
||||
oldestsig = sig;
|
||||
|
|
@ -681,9 +680,10 @@ matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset,
|
|||
* fetched from the child zone, any working signature is enough.
|
||||
*/
|
||||
static bool
|
||||
signed_loose(dns_secalg_t *algo) {
|
||||
signed_loose(dns_secalg_t *algo)
|
||||
{
|
||||
bool ok = false;
|
||||
int i;
|
||||
int i;
|
||||
for (i = 0; i < nkey; i++) {
|
||||
if (algo[i] != 0) {
|
||||
ok = true;
|
||||
|
|
@ -700,18 +700,17 @@ signed_loose(dns_secalg_t *algo) {
|
|||
* RRset.
|
||||
*/
|
||||
static bool
|
||||
signed_strict(dns_rdataset_t *dsset, dns_secalg_t *algo) {
|
||||
signed_strict(dns_rdataset_t *dsset, dns_secalg_t *algo)
|
||||
{
|
||||
isc_result_t result;
|
||||
bool all_ok = true;
|
||||
bool all_ok = true;
|
||||
|
||||
for (result = dns_rdataset_first(dsset);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(dsset))
|
||||
{
|
||||
dns_rdata_t dsrdata = DNS_RDATA_INIT;
|
||||
for (result = dns_rdataset_first(dsset); result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(dsset)) {
|
||||
dns_rdata_t dsrdata = DNS_RDATA_INIT;
|
||||
dns_rdata_ds_t ds;
|
||||
bool ds_ok;
|
||||
int i;
|
||||
bool ds_ok;
|
||||
int i;
|
||||
|
||||
dns_rdataset_current(dsset, &dsrdata);
|
||||
result = dns_rdata_tostruct(&dsrdata, &ds, NULL);
|
||||
|
|
@ -724,8 +723,10 @@ signed_strict(dns_rdataset_t *dsset, dns_secalg_t *algo) {
|
|||
}
|
||||
}
|
||||
if (!ds_ok) {
|
||||
vbprintf(0, "missing signature for algorithm %d "
|
||||
"(key %d)\n", ds.algorithm, ds.key_tag);
|
||||
vbprintf(0,
|
||||
"missing signature for algorithm %d "
|
||||
"(key %d)\n",
|
||||
ds.algorithm, ds.key_tag);
|
||||
all_ok = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -735,7 +736,8 @@ signed_strict(dns_rdataset_t *dsset, dns_secalg_t *algo) {
|
|||
}
|
||||
|
||||
static dns_rdata_t *
|
||||
rdata_get(void) {
|
||||
rdata_get(void)
|
||||
{
|
||||
dns_rdata_t *rdata;
|
||||
|
||||
rdata = isc_mem_get(mctx, sizeof(*rdata));
|
||||
|
|
@ -745,7 +747,8 @@ rdata_get(void) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
rdata_put(isc_result_t result, dns_rdatalist_t *rdlist, dns_rdata_t *rdata) {
|
||||
rdata_put(isc_result_t result, dns_rdatalist_t *rdlist, dns_rdata_t *rdata)
|
||||
{
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
ISC_LIST_APPEND(rdlist->rdata, rdata, link);
|
||||
} else {
|
||||
|
|
@ -761,10 +764,11 @@ rdata_put(isc_result_t result, dns_rdatalist_t *rdlist, dns_rdata_t *rdata) {
|
|||
* dns_rdata_cds_t and dns_rdata_ds_t types are aliases.
|
||||
*/
|
||||
static isc_result_t
|
||||
ds_from_cds(dns_rdatalist_t *dslist, isc_buffer_t *buf, dns_rdata_t *cds) {
|
||||
isc_result_t result;
|
||||
ds_from_cds(dns_rdatalist_t *dslist, isc_buffer_t *buf, dns_rdata_t *cds)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdata_ds_t ds;
|
||||
dns_rdata_t *rdata;
|
||||
dns_rdata_t * rdata;
|
||||
|
||||
rdata = rdata_get();
|
||||
|
||||
|
|
@ -772,20 +776,20 @@ ds_from_cds(dns_rdatalist_t *dslist, isc_buffer_t *buf, dns_rdata_t *cds) {
|
|||
check_result(result, "dns_rdata_tostruct(CDS)");
|
||||
ds.common.rdtype = dns_rdatatype_ds;
|
||||
|
||||
result = dns_rdata_fromstruct(rdata, rdclass, dns_rdatatype_ds,
|
||||
&ds, buf);
|
||||
result = dns_rdata_fromstruct(rdata, rdclass, dns_rdatatype_ds, &ds,
|
||||
buf);
|
||||
|
||||
return (rdata_put(result, dslist, rdata));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
ds_from_cdnskey(dns_rdatalist_t *dslist, isc_buffer_t *buf,
|
||||
dns_rdata_t *cdnskey)
|
||||
dns_rdata_t *cdnskey)
|
||||
{
|
||||
isc_result_t result;
|
||||
unsigned i, n;
|
||||
unsigned i, n;
|
||||
|
||||
n = sizeof(dtype)/sizeof(dtype[0]);
|
||||
n = sizeof(dtype) / sizeof(dtype[0]);
|
||||
for (i = 0; i < n; i++) {
|
||||
if (dtype[i] != 0) {
|
||||
dns_rdata_t *rdata;
|
||||
|
|
@ -814,12 +818,12 @@ ds_from_cdnskey(dns_rdatalist_t *dslist, isc_buffer_t *buf,
|
|||
}
|
||||
|
||||
static void
|
||||
make_new_ds_set(ds_maker_func_t *ds_from_rdata,
|
||||
uint32_t ttl, dns_rdataset_t *rdset)
|
||||
make_new_ds_set(ds_maker_func_t *ds_from_rdata, uint32_t ttl,
|
||||
dns_rdataset_t *rdset)
|
||||
{
|
||||
unsigned int size = 16;
|
||||
for (;;) {
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
dns_rdatalist_t *dslist;
|
||||
|
||||
dslist = isc_mem_get(mctx, sizeof(*dslist));
|
||||
|
|
@ -837,10 +841,9 @@ make_new_ds_set(ds_maker_func_t *ds_from_rdata,
|
|||
|
||||
for (result = dns_rdataset_first(rdset);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(rdset))
|
||||
{
|
||||
result = dns_rdataset_next(rdset)) {
|
||||
isc_result_t tresult;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
|
||||
dns_rdataset_current(rdset, &rdata);
|
||||
|
||||
|
|
@ -863,7 +866,8 @@ make_new_ds_set(ds_maker_func_t *ds_from_rdata,
|
|||
}
|
||||
|
||||
static inline int
|
||||
rdata_cmp(const void *rdata1, const void *rdata2) {
|
||||
rdata_cmp(const void *rdata1, const void *rdata2)
|
||||
{
|
||||
return (dns_rdata_compare((const dns_rdata_t *)rdata1,
|
||||
(const dns_rdata_t *)rdata2));
|
||||
}
|
||||
|
|
@ -873,14 +877,15 @@ rdata_cmp(const void *rdata1, const void *rdata2) {
|
|||
* digest types.
|
||||
*/
|
||||
static bool
|
||||
consistent_digests(dns_rdataset_t *dsset) {
|
||||
isc_result_t result;
|
||||
dns_rdata_t *arrdata;
|
||||
consistent_digests(dns_rdataset_t *dsset)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdata_t * arrdata;
|
||||
dns_rdata_ds_t *ds;
|
||||
dns_keytag_t key_tag;
|
||||
dns_secalg_t algorithm;
|
||||
bool match;
|
||||
int i, j, n, d;
|
||||
dns_keytag_t key_tag;
|
||||
dns_secalg_t algorithm;
|
||||
bool match;
|
||||
int i, j, n, d;
|
||||
|
||||
/*
|
||||
* First sort the dsset. DS rdata fields are tag, algorithm, digest,
|
||||
|
|
@ -891,10 +896,8 @@ consistent_digests(dns_rdataset_t *dsset) {
|
|||
|
||||
arrdata = isc_mem_get(mctx, n * sizeof(dns_rdata_t));
|
||||
|
||||
for (result = dns_rdataset_first(dsset), i = 0;
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(dsset), i++)
|
||||
{
|
||||
for (result = dns_rdataset_first(dsset), i = 0; result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(dsset), i++) {
|
||||
dns_rdata_init(&arrdata[i]);
|
||||
dns_rdataset_current(dsset, &arrdata[i]);
|
||||
}
|
||||
|
|
@ -929,11 +932,10 @@ consistent_digests(dns_rdataset_t *dsset) {
|
|||
while (i < n) {
|
||||
key_tag = ds[i].key_tag;
|
||||
algorithm = ds[i].algorithm;
|
||||
for (j = 0; j < d && i+j < n; j++) {
|
||||
if (ds[i+j].key_tag != key_tag ||
|
||||
ds[i+j].algorithm != algorithm ||
|
||||
ds[i+j].digest_type != ds[j].digest_type)
|
||||
{
|
||||
for (j = 0; j < d && i + j < n; j++) {
|
||||
if (ds[i + j].key_tag != key_tag ||
|
||||
ds[i + j].algorithm != algorithm ||
|
||||
ds[i + j].digest_type != ds[j].digest_type) {
|
||||
match = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -950,11 +952,12 @@ consistent_digests(dns_rdataset_t *dsset) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_diff(const char *cmd, dns_rdataset_t *rdataset) {
|
||||
isc_buffer_t *buf;
|
||||
isc_region_t r;
|
||||
print_diff(const char *cmd, dns_rdataset_t *rdataset)
|
||||
{
|
||||
isc_buffer_t * buf;
|
||||
isc_region_t r;
|
||||
unsigned char *nl;
|
||||
size_t len;
|
||||
size_t len;
|
||||
|
||||
buf = formatset(rdataset);
|
||||
isc_buffer_usedregion(buf, &r);
|
||||
|
|
@ -969,19 +972,19 @@ print_diff(const char *cmd, dns_rdataset_t *rdataset) {
|
|||
}
|
||||
|
||||
static void
|
||||
update_diff(const char *cmd, uint32_t ttl,
|
||||
dns_rdataset_t *addset, dns_rdataset_t *delset)
|
||||
update_diff(const char *cmd, uint32_t ttl, dns_rdataset_t *addset,
|
||||
dns_rdataset_t *delset)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_db_t *db;
|
||||
dns_dbnode_t *node;
|
||||
isc_result_t result;
|
||||
dns_db_t * db;
|
||||
dns_dbnode_t * node;
|
||||
dns_dbversion_t *ver;
|
||||
dns_rdataset_t diffset;
|
||||
uint32_t save;
|
||||
dns_rdataset_t diffset;
|
||||
uint32_t save;
|
||||
|
||||
db = NULL;
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, &db);
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone, rdclass, 0,
|
||||
NULL, &db);
|
||||
check_result(result, "dns_db_create()");
|
||||
|
||||
ver = NULL;
|
||||
|
|
@ -994,12 +997,11 @@ update_diff(const char *cmd, uint32_t ttl,
|
|||
|
||||
dns_rdataset_init(&diffset);
|
||||
|
||||
result = dns_db_addrdataset(db, node, ver, 0, addset,
|
||||
DNS_DBADD_MERGE, NULL);
|
||||
result = dns_db_addrdataset(db, node, ver, 0, addset, DNS_DBADD_MERGE,
|
||||
NULL);
|
||||
check_result(result, "dns_db_addrdataset()");
|
||||
|
||||
result = dns_db_subtractrdataset(db, node, ver, delset,
|
||||
0, &diffset);
|
||||
result = dns_db_subtractrdataset(db, node, ver, delset, 0, &diffset);
|
||||
if (result == DNS_R_UNCHANGED) {
|
||||
save = addset->ttl;
|
||||
addset->ttl = ttl;
|
||||
|
|
@ -1018,7 +1020,8 @@ update_diff(const char *cmd, uint32_t ttl,
|
|||
}
|
||||
|
||||
static void
|
||||
nsdiff(uint32_t ttl, dns_rdataset_t *oldset, dns_rdataset_t *newset) {
|
||||
nsdiff(uint32_t ttl, dns_rdataset_t *oldset, dns_rdataset_t *newset)
|
||||
{
|
||||
if (ttl == 0) {
|
||||
vbprintf(1, "warning: no TTL in nsupdate script\n");
|
||||
}
|
||||
|
|
@ -1038,39 +1041,45 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr,
|
||||
" %s options [options] -f <file> -d <path> <domain>\n",
|
||||
program);
|
||||
fprintf(stderr, "Version: %s\n", VERSION);
|
||||
fprintf(stderr, "Options:\n"
|
||||
" -a <algorithm> digest algorithm (SHA-1 / SHA-256 / SHA-384)\n"
|
||||
" -c <class> of domain (default IN)\n"
|
||||
" -D prefer CDNSKEY records instead of CDS\n"
|
||||
" -d <file|dir> where to find parent dsset- file\n"
|
||||
" -f <file> child DNSKEY+CDNSKEY+CDS+RRSIG records\n"
|
||||
" -i[extension] update dsset- file in place\n"
|
||||
" -s <start-time> oldest permitted child signatures\n"
|
||||
" -u emit nsupdate script\n"
|
||||
" -T <ttl> TTL of DS records\n"
|
||||
" -V print version\n"
|
||||
" -v <verbosity>\n"
|
||||
);
|
||||
" -a <algorithm> digest algorithm (SHA-1 / "
|
||||
"SHA-256 / SHA-384)\n"
|
||||
" -c <class> of domain (default IN)\n"
|
||||
" -D prefer CDNSKEY records instead "
|
||||
"of CDS\n"
|
||||
" -d <file|dir> where to find parent dsset- "
|
||||
"file\n"
|
||||
" -f <file> child DNSKEY+CDNSKEY+CDS+RRSIG "
|
||||
"records\n"
|
||||
" -i[extension] update dsset- file in place\n"
|
||||
" -s <start-time> oldest permitted child "
|
||||
"signatures\n"
|
||||
" -u emit nsupdate script\n"
|
||||
" -T <ttl> TTL of DS records\n"
|
||||
" -V print version\n"
|
||||
" -v <verbosity>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
const char *child_path = NULL;
|
||||
const char *ds_path = NULL;
|
||||
const char *inplace = NULL;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const char * child_path = NULL;
|
||||
const char * ds_path = NULL;
|
||||
const char * inplace = NULL;
|
||||
isc_result_t result;
|
||||
bool prefer_cdnskey = false;
|
||||
bool nsupdate = false;
|
||||
uint32_t ttl = 0;
|
||||
int ch;
|
||||
char *endp;
|
||||
bool prefer_cdnskey = false;
|
||||
bool nsupdate = false;
|
||||
uint32_t ttl = 0;
|
||||
int ch;
|
||||
char * endp;
|
||||
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
|
|
@ -1105,8 +1114,7 @@ main(int argc, char *argv[]) {
|
|||
* so that it works just like sed(1).
|
||||
*/
|
||||
if (isc_commandline_argument ==
|
||||
argv[isc_commandline_index - 1])
|
||||
{
|
||||
argv[isc_commandline_index - 1]) {
|
||||
isc_commandline_index--;
|
||||
inplace = "";
|
||||
} else {
|
||||
|
|
@ -1115,7 +1123,7 @@ main(int argc, char *argv[]) {
|
|||
break;
|
||||
case 'm':
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD;
|
||||
ISC_MEM_DEBUGRECORD;
|
||||
break;
|
||||
case 's':
|
||||
startstr = isc_commandline_argument;
|
||||
|
|
@ -1187,19 +1195,16 @@ main(int argc, char *argv[]) {
|
|||
*/
|
||||
|
||||
if (!dns_rdataset_isassociated(&dnskey_set) ||
|
||||
!dns_rdataset_isassociated(&dnskey_sig))
|
||||
{
|
||||
!dns_rdataset_isassociated(&dnskey_sig)) {
|
||||
fatal("could not find signed DNSKEY RRset for %s", namestr);
|
||||
}
|
||||
|
||||
if (dns_rdataset_isassociated(&cdnskey_set) &&
|
||||
!dns_rdataset_isassociated(&cdnskey_sig))
|
||||
{
|
||||
!dns_rdataset_isassociated(&cdnskey_sig)) {
|
||||
fatal("missing RRSIG CDNSKEY records for %s", namestr);
|
||||
}
|
||||
if (dns_rdataset_isassociated(&cds_set) &&
|
||||
!dns_rdataset_isassociated(&cds_sig))
|
||||
{
|
||||
!dns_rdataset_isassociated(&cds_sig)) {
|
||||
fatal("missing RRSIG CDS records for %s", namestr);
|
||||
}
|
||||
|
||||
|
|
@ -1213,25 +1218,23 @@ main(int argc, char *argv[]) {
|
|||
*/
|
||||
|
||||
vbprintf(1, "verify DNSKEY signature(s)\n");
|
||||
if (!signed_loose(matching_sigs(old_key_tbl, &dnskey_set, &dnskey_sig)))
|
||||
{
|
||||
if (!signed_loose(
|
||||
matching_sigs(old_key_tbl, &dnskey_set, &dnskey_sig))) {
|
||||
fatal("could not validate child DNSKEY RRset for %s", namestr);
|
||||
}
|
||||
|
||||
if (dns_rdataset_isassociated(&cdnskey_set)) {
|
||||
vbprintf(1, "verify CDNSKEY signature(s)\n");
|
||||
if (!signed_loose(matching_sigs(old_key_tbl,
|
||||
&cdnskey_set, &cdnskey_sig)))
|
||||
{
|
||||
if (!signed_loose(matching_sigs(old_key_tbl, &cdnskey_set,
|
||||
&cdnskey_sig))) {
|
||||
fatal("could not validate child CDNSKEY RRset for %s",
|
||||
namestr);
|
||||
}
|
||||
}
|
||||
if (dns_rdataset_isassociated(&cds_set)) {
|
||||
vbprintf(1, "verify CDS signature(s)\n");
|
||||
if (!signed_loose(matching_sigs(old_key_tbl,
|
||||
&cds_set, &cds_sig)))
|
||||
{
|
||||
if (!signed_loose(
|
||||
matching_sigs(old_key_tbl, &cds_set, &cds_sig))) {
|
||||
fatal("could not validate child CDS RRset for %s",
|
||||
namestr);
|
||||
}
|
||||
|
|
@ -1248,8 +1251,7 @@ main(int argc, char *argv[]) {
|
|||
dns_rdatatype_format(oldestsig.covered, type, sizeof(type));
|
||||
verbose_time(1, "child signature inception time",
|
||||
oldestsig.timesigned);
|
||||
vbprintf(2, "from RRSIG %s by key %d\n",
|
||||
type, oldestsig.keyid);
|
||||
vbprintf(2, "from RRSIG %s by key %d\n", type, oldestsig.keyid);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1257,8 +1259,7 @@ main(int argc, char *argv[]) {
|
|||
* RFC 7344 section 4.1 first paragraph
|
||||
*/
|
||||
if (!dns_rdataset_isassociated(&cdnskey_set) &&
|
||||
!dns_rdataset_isassociated(&cds_set))
|
||||
{
|
||||
!dns_rdataset_isassociated(&cds_set)) {
|
||||
vbprintf(1, "%s has neither CDS nor CDNSKEY records\n",
|
||||
namestr);
|
||||
write_parent_set(ds_path, inplace, nsupdate, &old_ds_set);
|
||||
|
|
@ -1286,16 +1287,16 @@ main(int argc, char *argv[]) {
|
|||
|
||||
if (!consistent_digests(&new_ds_set)) {
|
||||
fatal("CDS records at %s do not cover each key "
|
||||
"with the same set of digest types", namestr);
|
||||
"with the same set of digest types",
|
||||
namestr);
|
||||
}
|
||||
|
||||
vbprintf(1, "verify DNSKEY signature(s)\n");
|
||||
if (!signed_strict(&new_ds_set,
|
||||
matching_sigs(new_key_tbl,
|
||||
&dnskey_set, &dnskey_sig)))
|
||||
{
|
||||
if (!signed_strict(&new_ds_set, matching_sigs(new_key_tbl, &dnskey_set,
|
||||
&dnskey_sig))) {
|
||||
fatal("could not validate child DNSKEY RRset "
|
||||
"with new DS records for %s", namestr);
|
||||
"with new DS records for %s",
|
||||
namestr);
|
||||
}
|
||||
|
||||
free_keytable(&new_key_tbl);
|
||||
|
|
|
|||
|
|
@ -51,13 +51,14 @@ const char *program = "dnssec-dsfromkey";
|
|||
|
||||
static dns_rdataclass_t rdclass;
|
||||
static dns_fixedname_t fixed;
|
||||
static dns_name_t *name = NULL;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static uint32_t ttl;
|
||||
static bool emitttl = false;
|
||||
static dns_name_t * name = NULL;
|
||||
static isc_mem_t * mctx = NULL;
|
||||
static uint32_t ttl;
|
||||
static bool emitttl = false;
|
||||
|
||||
static isc_result_t
|
||||
initname(char *setname) {
|
||||
initname(char *setname)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t buf;
|
||||
|
||||
|
|
@ -70,8 +71,9 @@ initname(char *setname) {
|
|||
}
|
||||
|
||||
static void
|
||||
db_load_from_stream(dns_db_t *db, FILE *fp) {
|
||||
isc_result_t result;
|
||||
db_load_from_stream(dns_db_t *db, FILE *fp)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdatacallbacks_t callbacks;
|
||||
|
||||
dns_rdatacallbacks_init(&callbacks);
|
||||
|
|
@ -79,8 +81,8 @@ db_load_from_stream(dns_db_t *db, FILE *fp) {
|
|||
if (result != ISC_R_SUCCESS)
|
||||
fatal("dns_db_beginload failed: %s", isc_result_totext(result));
|
||||
|
||||
result = dns_master_loadstream(fp, name, name, rdclass, 0,
|
||||
&callbacks, mctx);
|
||||
result = dns_master_loadstream(fp, name, name, rdclass, 0, &callbacks,
|
||||
mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("can't load from input: %s", isc_result_totext(result));
|
||||
|
||||
|
|
@ -90,16 +92,17 @@ db_load_from_stream(dns_db_t *db, FILE *fp) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
loadset(const char *filename, dns_rdataset_t *rdataset) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
char setname[DNS_NAME_FORMATSIZE];
|
||||
loadset(const char *filename, dns_rdataset_t *rdataset)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_db_t * db = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
char setname[DNS_NAME_FORMATSIZE];
|
||||
|
||||
dns_name_format(name, setname, sizeof(setname));
|
||||
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, &db);
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone, rdclass, 0,
|
||||
NULL, &db);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("can't create database");
|
||||
|
||||
|
|
@ -117,8 +120,8 @@ loadset(const char *filename, dns_rdataset_t *rdataset) {
|
|||
if (result != ISC_R_SUCCESS)
|
||||
fatal("can't find %s node in %s", setname, filename);
|
||||
|
||||
result = dns_db_findrdataset(db, node, NULL, dns_rdatatype_dnskey,
|
||||
0, 0, rdataset, NULL);
|
||||
result = dns_db_findrdataset(db, node, NULL, dns_rdatatype_dnskey, 0, 0,
|
||||
rdataset, NULL);
|
||||
|
||||
if (result == ISC_R_NOTFOUND)
|
||||
fatal("no DNSKEY RR for %s in %s", setname, filename);
|
||||
|
|
@ -133,10 +136,11 @@ loadset(const char *filename, dns_rdataset_t *rdataset) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
loadkeyset(char *dirname, dns_rdataset_t *rdataset) {
|
||||
isc_result_t result;
|
||||
char filename[PATH_MAX + 1];
|
||||
isc_buffer_t buf;
|
||||
loadkeyset(char *dirname, dns_rdataset_t *rdataset)
|
||||
{
|
||||
isc_result_t result;
|
||||
char filename[PATH_MAX + 1];
|
||||
isc_buffer_t buf;
|
||||
|
||||
dns_rdataset_init(rdataset);
|
||||
|
||||
|
|
@ -167,20 +171,20 @@ static void
|
|||
loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
|
||||
dns_rdata_t *rdata)
|
||||
{
|
||||
isc_result_t result;
|
||||
dst_key_t *key = NULL;
|
||||
isc_buffer_t keyb;
|
||||
isc_region_t r;
|
||||
isc_result_t result;
|
||||
dst_key_t * key = NULL;
|
||||
isc_buffer_t keyb;
|
||||
isc_region_t r;
|
||||
|
||||
dns_rdata_init(rdata);
|
||||
|
||||
isc_buffer_init(&keyb, key_buf, key_buf_size);
|
||||
|
||||
result = dst_key_fromnamedfile(filename, NULL, DST_TYPE_PUBLIC,
|
||||
mctx, &key);
|
||||
result = dst_key_fromnamedfile(filename, NULL, DST_TYPE_PUBLIC, mctx,
|
||||
&key);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("can't load %s.key: %s",
|
||||
filename, isc_result_totext(result));
|
||||
fatal("can't load %s.key: %s", filename,
|
||||
isc_result_totext(result));
|
||||
|
||||
if (verbose > 2) {
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
|
|
@ -194,8 +198,8 @@ loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
|
|||
fatal("can't decode key");
|
||||
|
||||
isc_buffer_usedregion(&keyb, &r);
|
||||
dns_rdata_fromregion(rdata, dst_key_class(key),
|
||||
dns_rdatatype_dnskey, &r);
|
||||
dns_rdata_fromregion(rdata, dst_key_class(key), dns_rdatatype_dnskey,
|
||||
&r);
|
||||
|
||||
rdclass = dst_key_class(key);
|
||||
|
||||
|
|
@ -206,9 +210,10 @@ loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
|
|||
}
|
||||
|
||||
static void
|
||||
logkey(dns_rdata_t *rdata) {
|
||||
logkey(dns_rdata_t *rdata)
|
||||
{
|
||||
isc_result_t result;
|
||||
dst_key_t *key = NULL;
|
||||
dst_key_t * key = NULL;
|
||||
isc_buffer_t buf;
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
|
||||
|
|
@ -225,15 +230,16 @@ logkey(dns_rdata_t *rdata) {
|
|||
}
|
||||
|
||||
static void
|
||||
emit(dns_dsdigest_t dt, bool showall, bool cds, dns_rdata_t *rdata) {
|
||||
isc_result_t result;
|
||||
unsigned char buf[DNS_DS_BUFFERSIZE];
|
||||
char text_buf[DST_KEY_MAXTEXTSIZE];
|
||||
char name_buf[DNS_NAME_MAXWIRE];
|
||||
char class_buf[10];
|
||||
isc_buffer_t textb, nameb, classb;
|
||||
isc_region_t r;
|
||||
dns_rdata_t ds;
|
||||
emit(dns_dsdigest_t dt, bool showall, bool cds, dns_rdata_t *rdata)
|
||||
{
|
||||
isc_result_t result;
|
||||
unsigned char buf[DNS_DS_BUFFERSIZE];
|
||||
char text_buf[DST_KEY_MAXTEXTSIZE];
|
||||
char name_buf[DNS_NAME_MAXWIRE];
|
||||
char class_buf[10];
|
||||
isc_buffer_t textb, nameb, classb;
|
||||
isc_region_t r;
|
||||
dns_rdata_t ds;
|
||||
dns_rdata_dnskey_t dnskey;
|
||||
|
||||
isc_buffer_init(&textb, text_buf, sizeof(text_buf));
|
||||
|
|
@ -257,7 +263,7 @@ emit(dns_dsdigest_t dt, bool showall, bool cds, dns_rdata_t *rdata) {
|
|||
if (result != ISC_R_SUCCESS)
|
||||
fatal("can't print name");
|
||||
|
||||
result = dns_rdata_tofmttext(&ds, (dns_name_t *) NULL, 0, 0, 0, "",
|
||||
result = dns_rdata_tofmttext(&ds, (dns_name_t *)NULL, 0, 0, 0, "",
|
||||
&textb);
|
||||
|
||||
if (result != ISC_R_SUCCESS)
|
||||
|
|
@ -287,10 +293,11 @@ emit(dns_dsdigest_t dt, bool showall, bool cds, dns_rdata_t *rdata) {
|
|||
}
|
||||
|
||||
static void
|
||||
emits(bool showall, bool cds, dns_rdata_t *rdata) {
|
||||
emits(bool showall, bool cds, dns_rdata_t *rdata)
|
||||
{
|
||||
unsigned i, n;
|
||||
|
||||
n = sizeof(dtype)/sizeof(dtype[0]);
|
||||
n = sizeof(dtype) / sizeof(dtype[0]);
|
||||
for (i = 0; i < n; i++) {
|
||||
if (dtype[i] != 0) {
|
||||
emit(dtype[i], showall, cds, rdata);
|
||||
|
|
@ -302,45 +309,50 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s [options] keyfile\n\n", program);
|
||||
fprintf(stderr, " %s [options] keyfile\n\n", program);
|
||||
fprintf(stderr, " %s [options] -f zonefile [zonename]\n\n", program);
|
||||
fprintf(stderr, " %s [options] -s dnsname\n\n", program);
|
||||
fprintf(stderr, " %s [-h|-V]\n\n", program);
|
||||
fprintf(stderr, "Version: %s\n", VERSION);
|
||||
fprintf(stderr, "Options:\n"
|
||||
" -1: digest algorithm SHA-1\n"
|
||||
" -2: digest algorithm SHA-256\n"
|
||||
" -a algorithm: digest algorithm (SHA-1, SHA-256 or SHA-384)\n"
|
||||
" -A: include all keys in DS set, not just KSKs (-f only)\n"
|
||||
" -c class: rdata class for DS set (default IN) (-f or -s only)\n"
|
||||
" -C: print CDS records\n"
|
||||
" -f zonefile: read keys from a zone file\n"
|
||||
" -h: print help information\n"
|
||||
" -K directory: where to find key or keyset files\n"
|
||||
" -s: read keys from keyset-<dnsname> file\n"
|
||||
" -T: TTL of output records (omitted by default)\n"
|
||||
" -v level: verbosity\n"
|
||||
" -V: print version information\n");
|
||||
" -1: digest algorithm SHA-1\n"
|
||||
" -2: digest algorithm SHA-256\n"
|
||||
" -a algorithm: digest algorithm (SHA-1, SHA-256 or "
|
||||
"SHA-384)\n"
|
||||
" -A: include all keys in DS set, not just KSKs (-f "
|
||||
"only)\n"
|
||||
" -c class: rdata class for DS set (default IN) (-f "
|
||||
"or -s only)\n"
|
||||
" -C: print CDS records\n"
|
||||
" -f zonefile: read keys from a zone file\n"
|
||||
" -h: print help information\n"
|
||||
" -K directory: where to find key or keyset files\n"
|
||||
" -s: read keys from keyset-<dnsname> file\n"
|
||||
" -T: TTL of output records (omitted by default)\n"
|
||||
" -v level: verbosity\n"
|
||||
" -V: print version information\n");
|
||||
fprintf(stderr, "Output: DS or CDS RRs\n");
|
||||
|
||||
exit (-1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
char *classname = NULL;
|
||||
char *filename = NULL, *dir = NULL, *namestr;
|
||||
char *endp, *arg1;
|
||||
int ch;
|
||||
bool cds = false;
|
||||
bool usekeyset = false;
|
||||
bool showall = false;
|
||||
isc_result_t result;
|
||||
isc_log_t *log = NULL;
|
||||
dns_rdataset_t rdataset;
|
||||
dns_rdata_t rdata;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char * classname = NULL;
|
||||
char * filename = NULL, *dir = NULL, *namestr;
|
||||
char * endp, *arg1;
|
||||
int ch;
|
||||
bool cds = false;
|
||||
bool usekeyset = false;
|
||||
bool showall = false;
|
||||
isc_result_t result;
|
||||
isc_log_t * log = NULL;
|
||||
dns_rdataset_t rdataset;
|
||||
dns_rdata_t rdata;
|
||||
|
||||
dns_rdata_init(&rdata);
|
||||
|
||||
|
|
@ -379,8 +391,10 @@ main(int argc, char **argv) {
|
|||
classname = isc_commandline_argument;
|
||||
break;
|
||||
case 'd':
|
||||
fprintf(stderr, "%s: the -d option is deprecated; "
|
||||
"use -K\n", program);
|
||||
fprintf(stderr,
|
||||
"%s: the -d option is deprecated; "
|
||||
"use -K\n",
|
||||
program);
|
||||
/* fall through */
|
||||
case 'K':
|
||||
dir = isc_commandline_argument;
|
||||
|
|
@ -422,8 +436,8 @@ main(int argc, char **argv) {
|
|||
version(program);
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -493,8 +507,7 @@ main(int argc, char **argv) {
|
|||
|
||||
for (result = dns_rdataset_first(&rdataset);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(&rdataset))
|
||||
{
|
||||
result = dns_rdataset_next(&rdataset)) {
|
||||
dns_rdata_init(&rdata);
|
||||
dns_rdataset_current(&rdataset, &rdata);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,18 +50,19 @@ const char *program = "dnssec-importkey";
|
|||
|
||||
static dns_rdataclass_t rdclass;
|
||||
static dns_fixedname_t fixed;
|
||||
static dns_name_t *name = NULL;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static bool setpub = false, setdel = false;
|
||||
static bool setttl = false;
|
||||
static dns_name_t * name = NULL;
|
||||
static isc_mem_t * mctx = NULL;
|
||||
static bool setpub = false, setdel = false;
|
||||
static bool setttl = false;
|
||||
static isc_stdtime_t pub = 0, del = 0;
|
||||
static dns_ttl_t ttl = 0;
|
||||
static isc_stdtime_t syncadd = 0, syncdel = 0;
|
||||
static bool setsyncadd = false;
|
||||
static bool setsyncdel = false;
|
||||
static bool setsyncadd = false;
|
||||
static bool setsyncdel = false;
|
||||
|
||||
static isc_result_t
|
||||
initname(char *setname) {
|
||||
initname(char *setname)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t buf;
|
||||
|
||||
|
|
@ -74,8 +75,9 @@ initname(char *setname) {
|
|||
}
|
||||
|
||||
static void
|
||||
db_load_from_stream(dns_db_t *db, FILE *fp) {
|
||||
isc_result_t result;
|
||||
db_load_from_stream(dns_db_t *db, FILE *fp)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdatacallbacks_t callbacks;
|
||||
|
||||
dns_rdatacallbacks_init(&callbacks);
|
||||
|
|
@ -83,8 +85,8 @@ db_load_from_stream(dns_db_t *db, FILE *fp) {
|
|||
if (result != ISC_R_SUCCESS)
|
||||
fatal("dns_db_beginload failed: %s", isc_result_totext(result));
|
||||
|
||||
result = dns_master_loadstream(fp, name, name, rdclass, 0,
|
||||
&callbacks, mctx);
|
||||
result = dns_master_loadstream(fp, name, name, rdclass, 0, &callbacks,
|
||||
mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("can't load from input: %s", isc_result_totext(result));
|
||||
|
||||
|
|
@ -94,16 +96,17 @@ db_load_from_stream(dns_db_t *db, FILE *fp) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
loadset(const char *filename, dns_rdataset_t *rdataset) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
char setname[DNS_NAME_FORMATSIZE];
|
||||
loadset(const char *filename, dns_rdataset_t *rdataset)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_db_t * db = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
char setname[DNS_NAME_FORMATSIZE];
|
||||
|
||||
dns_name_format(name, setname, sizeof(setname));
|
||||
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, &db);
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone, rdclass, 0,
|
||||
NULL, &db);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("can't create database");
|
||||
|
||||
|
|
@ -122,8 +125,8 @@ loadset(const char *filename, dns_rdataset_t *rdataset) {
|
|||
if (result != ISC_R_SUCCESS)
|
||||
fatal("can't find %s node in %s", setname, filename);
|
||||
|
||||
result = dns_db_findrdataset(db, node, NULL, dns_rdatatype_dnskey,
|
||||
0, 0, rdataset, NULL);
|
||||
result = dns_db_findrdataset(db, node, NULL, dns_rdatatype_dnskey, 0, 0,
|
||||
rdataset, NULL);
|
||||
|
||||
if (result == ISC_R_NOTFOUND)
|
||||
fatal("no DNSKEY RR for %s in %s", setname, filename);
|
||||
|
|
@ -141,20 +144,20 @@ static void
|
|||
loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
|
||||
dns_rdata_t *rdata)
|
||||
{
|
||||
isc_result_t result;
|
||||
dst_key_t *key = NULL;
|
||||
isc_buffer_t keyb;
|
||||
isc_region_t r;
|
||||
isc_result_t result;
|
||||
dst_key_t * key = NULL;
|
||||
isc_buffer_t keyb;
|
||||
isc_region_t r;
|
||||
|
||||
dns_rdata_init(rdata);
|
||||
|
||||
isc_buffer_init(&keyb, key_buf, key_buf_size);
|
||||
|
||||
result = dst_key_fromnamedfile(filename, NULL, DST_TYPE_PUBLIC,
|
||||
mctx, &key);
|
||||
result = dst_key_fromnamedfile(filename, NULL, DST_TYPE_PUBLIC, mctx,
|
||||
&key);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("invalid keyfile name %s: %s",
|
||||
filename, isc_result_totext(result));
|
||||
fatal("invalid keyfile name %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
|
||||
if (verbose > 2) {
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
|
|
@ -168,8 +171,8 @@ loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
|
|||
fatal("can't decode key");
|
||||
|
||||
isc_buffer_usedregion(&keyb, &r);
|
||||
dns_rdata_fromregion(rdata, dst_key_class(key),
|
||||
dns_rdatatype_dnskey, &r);
|
||||
dns_rdata_fromregion(rdata, dst_key_class(key), dns_rdatatype_dnskey,
|
||||
&r);
|
||||
|
||||
rdclass = dst_key_class(key);
|
||||
|
||||
|
|
@ -180,13 +183,14 @@ loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
|
|||
}
|
||||
|
||||
static void
|
||||
emit(const char *dir, dns_rdata_t *rdata) {
|
||||
emit(const char *dir, dns_rdata_t *rdata)
|
||||
{
|
||||
isc_result_t result;
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
char pubname[1024];
|
||||
char priname[1024];
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
char pubname[1024];
|
||||
char priname[1024];
|
||||
isc_buffer_t buf;
|
||||
dst_key_t *key = NULL, *tmp = NULL;
|
||||
dst_key_t * key = NULL, *tmp = NULL;
|
||||
|
||||
isc_buffer_init(&buf, rdata->data, rdata->length);
|
||||
isc_buffer_add(&buf, rdata->length);
|
||||
|
|
@ -208,10 +212,9 @@ emit(const char *dir, dns_rdata_t *rdata) {
|
|||
isc_result_totext(result));
|
||||
}
|
||||
|
||||
result = dst_key_fromfile(dst_key_name(key), dst_key_id(key),
|
||||
dst_key_alg(key),
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE,
|
||||
dir, mctx, &tmp);
|
||||
result = dst_key_fromfile(
|
||||
dst_key_name(key), dst_key_id(key), dst_key_alg(key),
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, dir, mctx, &tmp);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (dst_key_isprivate(tmp) && !dst_key_isexternal(tmp))
|
||||
fatal("Private key already exists in %s", priname);
|
||||
|
|
@ -231,8 +234,7 @@ emit(const char *dir, dns_rdata_t *rdata) {
|
|||
if (setttl)
|
||||
dst_key_setttl(key, ttl);
|
||||
|
||||
result = dst_key_tofile(key, DST_TYPE_PUBLIC|DST_TYPE_PRIVATE,
|
||||
dir);
|
||||
result = dst_key_tofile(key, DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, dir);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dst_key_format(key, keystr, sizeof(keystr));
|
||||
fatal("Failed to write key %s: %s", keystr,
|
||||
|
|
@ -254,43 +256,45 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s options [-K dir] keyfile\n\n", program);
|
||||
fprintf(stderr, " %s options [-K dir] keyfile\n\n", program);
|
||||
fprintf(stderr, " %s options -f file [keyname]\n\n", program);
|
||||
fprintf(stderr, "Version: %s\n", VERSION);
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr, " -f file: read key from zone file\n");
|
||||
fprintf(stderr, " -K <directory>: directory in which to store "
|
||||
"the key files\n");
|
||||
"the key files\n");
|
||||
fprintf(stderr, " -L ttl: set default key TTL\n");
|
||||
fprintf(stderr, " -v <verbose level>\n");
|
||||
fprintf(stderr, " -V: print version information\n");
|
||||
fprintf(stderr, " -h: print usage and exit\n");
|
||||
fprintf(stderr, "Timing options:\n");
|
||||
fprintf(stderr, " -P date/[+-]offset/none: set/unset key "
|
||||
"publication date\n");
|
||||
"publication date\n");
|
||||
fprintf(stderr, " -P sync date/[+-]offset/none: set/unset "
|
||||
"CDS and CDNSKEY publication date\n");
|
||||
"CDS and CDNSKEY publication date\n");
|
||||
fprintf(stderr, " -D date/[+-]offset/none: set/unset key "
|
||||
"deletion date\n");
|
||||
"deletion date\n");
|
||||
fprintf(stderr, " -D sync date/[+-]offset/none: set/unset "
|
||||
"CDS and CDNSKEY deletion date\n");
|
||||
"CDS and CDNSKEY deletion date\n");
|
||||
|
||||
exit (-1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
char *classname = NULL;
|
||||
char *filename = NULL, *dir = NULL, *namestr;
|
||||
char *endp;
|
||||
int ch;
|
||||
isc_result_t result;
|
||||
isc_log_t *log = NULL;
|
||||
dns_rdataset_t rdataset;
|
||||
dns_rdata_t rdata;
|
||||
isc_stdtime_t now;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char * classname = NULL;
|
||||
char * filename = NULL, *dir = NULL, *namestr;
|
||||
char * endp;
|
||||
int ch;
|
||||
isc_result_t result;
|
||||
isc_log_t * log = NULL;
|
||||
dns_rdataset_t rdataset;
|
||||
dns_rdata_t rdata;
|
||||
isc_stdtime_t now;
|
||||
|
||||
dns_rdata_init(&rdata);
|
||||
isc_stdtime_get(&now);
|
||||
|
|
@ -318,7 +322,7 @@ main(int argc, char **argv) {
|
|||
"once");
|
||||
|
||||
syncdel = strtotime(isc_commandline_argument,
|
||||
now, now, &setsyncdel);
|
||||
now, now, &setsyncdel);
|
||||
break;
|
||||
}
|
||||
/* -Ddnskey ? */
|
||||
|
|
@ -326,8 +330,8 @@ main(int argc, char **argv) {
|
|||
if (setdel)
|
||||
fatal("-D specified more than once");
|
||||
|
||||
del = strtotime(isc_commandline_argument,
|
||||
now, now, &setdel);
|
||||
del = strtotime(isc_commandline_argument, now, now,
|
||||
&setdel);
|
||||
break;
|
||||
case 'K':
|
||||
dir = isc_commandline_argument;
|
||||
|
|
@ -346,7 +350,7 @@ main(int argc, char **argv) {
|
|||
"once");
|
||||
|
||||
syncadd = strtotime(isc_commandline_argument,
|
||||
now, now, &setsyncadd);
|
||||
now, now, &setsyncadd);
|
||||
break;
|
||||
}
|
||||
/* -Pdnskey ? */
|
||||
|
|
@ -354,8 +358,8 @@ main(int argc, char **argv) {
|
|||
if (setpub)
|
||||
fatal("-P specified more than once");
|
||||
|
||||
pub = strtotime(isc_commandline_argument,
|
||||
now, now, &setpub);
|
||||
pub = strtotime(isc_commandline_argument, now, now,
|
||||
&setpub);
|
||||
break;
|
||||
case 'f':
|
||||
filename = isc_commandline_argument;
|
||||
|
|
@ -379,8 +383,8 @@ main(int argc, char **argv) {
|
|||
version(program);
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -421,7 +425,6 @@ main(int argc, char **argv) {
|
|||
for (result = dns_rdataset_first(&rdataset);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_rdataset_next(&rdataset)) {
|
||||
|
||||
dns_rdata_init(&rdata);
|
||||
dns_rdataset_current(&rdataset, &rdata);
|
||||
emit(dir, &rdata);
|
||||
|
|
@ -429,8 +432,8 @@ main(int argc, char **argv) {
|
|||
} else {
|
||||
unsigned char key_buf[DST_KEY_MAXSIZE];
|
||||
|
||||
loadkey(argv[isc_commandline_index], key_buf,
|
||||
DST_KEY_MAXSIZE, &rdata);
|
||||
loadkey(argv[isc_commandline_index], key_buf, DST_KEY_MAXSIZE,
|
||||
&rdata);
|
||||
|
||||
emit(dir, &rdata);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,11 @@
|
|||
#include <isc/buffer.h>
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/region.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/region.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <pk11/site.h>
|
||||
|
||||
#include <dns/dnssec.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/keyvalues.h>
|
||||
|
|
@ -36,6 +34,7 @@
|
|||
#include <dns/secalg.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
#include <pk11/site.h>
|
||||
|
||||
#if USE_PKCS11
|
||||
#include <pk11/result.h>
|
||||
|
|
@ -51,10 +50,10 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s -l label [options] name\n\n",
|
||||
program);
|
||||
fprintf(stderr, " %s -l label [options] name\n\n", program);
|
||||
fprintf(stderr, "Version: %s\n", VERSION);
|
||||
fprintf(stderr, "Required options:\n");
|
||||
fprintf(stderr, " -l label: label of the key pair\n");
|
||||
|
|
@ -69,8 +68,10 @@ usage(void) {
|
|||
fprintf(stderr, " -c class (default: IN)\n");
|
||||
fprintf(stderr, " -E <engine>:\n");
|
||||
#if USE_PKCS11
|
||||
fprintf(stderr, " path to PKCS#11 provider library "
|
||||
"(default is %s)\n", PK11_LIB_LOCATION);
|
||||
fprintf(stderr,
|
||||
" path to PKCS#11 provider library "
|
||||
"(default is %s)\n",
|
||||
PK11_LIB_LOCATION);
|
||||
#else
|
||||
fprintf(stderr, " name of an OpenSSL engine to use\n");
|
||||
#endif
|
||||
|
|
@ -79,12 +80,13 @@ usage(void) {
|
|||
"key files\n");
|
||||
fprintf(stderr, " -k: generate a TYPE=KEY key\n");
|
||||
fprintf(stderr, " -L ttl: default key TTL\n");
|
||||
fprintf(stderr, " -n nametype: ZONE | HOST | ENTITY | USER | OTHER\n");
|
||||
fprintf(stderr, " -n nametype: ZONE | HOST | ENTITY | USER | "
|
||||
"OTHER\n");
|
||||
fprintf(stderr, " (DNSKEY generation defaults to ZONE\n");
|
||||
fprintf(stderr, " -p protocol: default: 3 [dnssec]\n");
|
||||
fprintf(stderr, " -t type: "
|
||||
"AUTHCONF | NOAUTHCONF | NOAUTH | NOCONF "
|
||||
"(default: AUTHCONF)\n");
|
||||
"AUTHCONF | NOAUTHCONF | NOAUTH | NOCONF "
|
||||
"(default: AUTHCONF)\n");
|
||||
fprintf(stderr, " -y: permit keys that might collide\n");
|
||||
fprintf(stderr, " -v verbose level\n");
|
||||
fprintf(stderr, " -V: print version information\n");
|
||||
|
|
@ -102,63 +104,64 @@ usage(void) {
|
|||
fprintf(stderr, " -C: generate a backward-compatible key, omitting"
|
||||
" all dates\n");
|
||||
fprintf(stderr, " -S <key>: generate a successor to an existing "
|
||||
"key\n");
|
||||
"key\n");
|
||||
fprintf(stderr, " -i <interval>: prepublication interval for "
|
||||
"successor key "
|
||||
"(default: 30 days)\n");
|
||||
"successor key "
|
||||
"(default: 30 days)\n");
|
||||
fprintf(stderr, "Output:\n");
|
||||
fprintf(stderr, " K<name>+<alg>+<id>.key, "
|
||||
"K<name>+<alg>+<id>.private\n");
|
||||
|
||||
exit (-1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
char *algname = NULL, *freeit = NULL;
|
||||
char *nametype = NULL, *type = NULL;
|
||||
const char *directory = NULL;
|
||||
const char *predecessor = NULL;
|
||||
dst_key_t *prevkey = NULL;
|
||||
const char *engine = NULL;
|
||||
char *classname = NULL;
|
||||
char *endp;
|
||||
dst_key_t *key = NULL;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t *name;
|
||||
uint16_t flags = 0, kskflag = 0, revflag = 0;
|
||||
dns_secalg_t alg;
|
||||
bool oldstyle = false;
|
||||
isc_mem_t *mctx = NULL;
|
||||
int ch;
|
||||
int protocol = -1, signatory = 0;
|
||||
isc_result_t ret;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char * algname = NULL, *freeit = NULL;
|
||||
char * nametype = NULL, *type = NULL;
|
||||
const char * directory = NULL;
|
||||
const char * predecessor = NULL;
|
||||
dst_key_t * prevkey = NULL;
|
||||
const char * engine = NULL;
|
||||
char * classname = NULL;
|
||||
char * endp;
|
||||
dst_key_t * key = NULL;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t * name;
|
||||
uint16_t flags = 0, kskflag = 0, revflag = 0;
|
||||
dns_secalg_t alg;
|
||||
bool oldstyle = false;
|
||||
isc_mem_t * mctx = NULL;
|
||||
int ch;
|
||||
int protocol = -1, signatory = 0;
|
||||
isc_result_t ret;
|
||||
isc_textregion_t r;
|
||||
char filename[255];
|
||||
isc_buffer_t buf;
|
||||
isc_log_t *log = NULL;
|
||||
char filename[255];
|
||||
isc_buffer_t buf;
|
||||
isc_log_t * log = NULL;
|
||||
dns_rdataclass_t rdclass;
|
||||
int options = DST_TYPE_PRIVATE | DST_TYPE_PUBLIC;
|
||||
char *label = NULL;
|
||||
dns_ttl_t ttl = 0;
|
||||
isc_stdtime_t publish = 0, activate = 0, revoke = 0;
|
||||
isc_stdtime_t inactive = 0, deltime = 0;
|
||||
isc_stdtime_t now;
|
||||
int prepub = -1;
|
||||
bool setpub = false, setact = false;
|
||||
bool setrev = false, setinact = false;
|
||||
bool setdel = false, setttl = false;
|
||||
bool unsetpub = false, unsetact = false;
|
||||
bool unsetrev = false, unsetinact = false;
|
||||
bool unsetdel = false;
|
||||
bool genonly = false;
|
||||
bool use_nsec3 = false;
|
||||
bool avoid_collisions = true;
|
||||
bool exact;
|
||||
unsigned char c;
|
||||
isc_stdtime_t syncadd = 0, syncdel = 0;
|
||||
bool unsetsyncadd = false, setsyncadd = false;
|
||||
bool unsetsyncdel = false, setsyncdel = false;
|
||||
int options = DST_TYPE_PRIVATE | DST_TYPE_PUBLIC;
|
||||
char * label = NULL;
|
||||
dns_ttl_t ttl = 0;
|
||||
isc_stdtime_t publish = 0, activate = 0, revoke = 0;
|
||||
isc_stdtime_t inactive = 0, deltime = 0;
|
||||
isc_stdtime_t now;
|
||||
int prepub = -1;
|
||||
bool setpub = false, setact = false;
|
||||
bool setrev = false, setinact = false;
|
||||
bool setdel = false, setttl = false;
|
||||
bool unsetpub = false, unsetact = false;
|
||||
bool unsetrev = false, unsetinact = false;
|
||||
bool unsetdel = false;
|
||||
bool genonly = false;
|
||||
bool use_nsec3 = false;
|
||||
bool avoid_collisions = true;
|
||||
bool exact;
|
||||
unsigned char c;
|
||||
isc_stdtime_t syncadd = 0, syncdel = 0;
|
||||
bool unsetsyncadd = false, setsyncadd = false;
|
||||
bool unsetsyncdel = false, setsyncdel = false;
|
||||
|
||||
if (argc == 1)
|
||||
usage();
|
||||
|
|
@ -176,7 +179,7 @@ main(int argc, char **argv) {
|
|||
|
||||
#define CMDLINE_FLAGS "3A:a:Cc:D:E:Ff:GhI:i:kK:L:l:n:P:p:R:S:t:v:Vy"
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
switch (ch) {
|
||||
case '3':
|
||||
use_nsec3 = true;
|
||||
break;
|
||||
|
|
@ -206,8 +209,8 @@ main(int argc, char **argv) {
|
|||
directory = isc_commandline_argument;
|
||||
ret = try_dir(directory);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("cannot open directory %s: %s",
|
||||
directory, isc_result_totext(ret));
|
||||
fatal("cannot open directory %s: %s", directory,
|
||||
isc_result_totext(ret));
|
||||
break;
|
||||
case 'k':
|
||||
options |= DST_TYPE_KEY;
|
||||
|
|
@ -250,7 +253,7 @@ main(int argc, char **argv) {
|
|||
"once");
|
||||
|
||||
syncadd = strtotime(isc_commandline_argument,
|
||||
now, now, &setsyncadd);
|
||||
now, now, &setsyncadd);
|
||||
unsetsyncadd = !setsyncadd;
|
||||
break;
|
||||
}
|
||||
|
|
@ -259,32 +262,32 @@ main(int argc, char **argv) {
|
|||
if (setpub || unsetpub)
|
||||
fatal("-P specified more than once");
|
||||
|
||||
publish = strtotime(isc_commandline_argument,
|
||||
now, now, &setpub);
|
||||
publish = strtotime(isc_commandline_argument, now, now,
|
||||
&setpub);
|
||||
unsetpub = !setpub;
|
||||
break;
|
||||
case 'A':
|
||||
if (setact || unsetact)
|
||||
fatal("-A specified more than once");
|
||||
|
||||
activate = strtotime(isc_commandline_argument,
|
||||
now, now, &setact);
|
||||
activate = strtotime(isc_commandline_argument, now, now,
|
||||
&setact);
|
||||
unsetact = !setact;
|
||||
break;
|
||||
case 'R':
|
||||
if (setrev || unsetrev)
|
||||
fatal("-R specified more than once");
|
||||
|
||||
revoke = strtotime(isc_commandline_argument,
|
||||
now, now, &setrev);
|
||||
revoke = strtotime(isc_commandline_argument, now, now,
|
||||
&setrev);
|
||||
unsetrev = !setrev;
|
||||
break;
|
||||
case 'I':
|
||||
if (setinact || unsetinact)
|
||||
fatal("-I specified more than once");
|
||||
|
||||
inactive = strtotime(isc_commandline_argument,
|
||||
now, now, &setinact);
|
||||
inactive = strtotime(isc_commandline_argument, now, now,
|
||||
&setinact);
|
||||
unsetinact = !setinact;
|
||||
break;
|
||||
case 'D':
|
||||
|
|
@ -295,7 +298,7 @@ main(int argc, char **argv) {
|
|||
"once");
|
||||
|
||||
syncdel = strtotime(isc_commandline_argument,
|
||||
now, now, &setsyncdel);
|
||||
now, now, &setsyncdel);
|
||||
unsetsyncdel = !setsyncdel;
|
||||
break;
|
||||
}
|
||||
|
|
@ -304,8 +307,8 @@ main(int argc, char **argv) {
|
|||
if (setdel || unsetdel)
|
||||
fatal("-D specified more than once");
|
||||
|
||||
deltime = strtotime(isc_commandline_argument,
|
||||
now, now, &setdel);
|
||||
deltime = strtotime(isc_commandline_argument, now, now,
|
||||
&setdel);
|
||||
unsetdel = !setdel;
|
||||
break;
|
||||
case 'S':
|
||||
|
|
@ -331,16 +334,15 @@ main(int argc, char **argv) {
|
|||
version(program);
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
ret = dst_lib_init(mctx, engine);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("could not initialize dst: %s",
|
||||
isc_result_totext(ret));
|
||||
fatal("could not initialize dst: %s", isc_result_totext(ret));
|
||||
|
||||
setup_logging(mctx, &log);
|
||||
|
||||
|
|
@ -364,7 +366,7 @@ main(int argc, char **argv) {
|
|||
|
||||
if (strchr(label, ':') == NULL) {
|
||||
char *l;
|
||||
int len;
|
||||
int len;
|
||||
|
||||
len = strlen(label) + 8;
|
||||
l = isc_mem_allocate(mctx, len);
|
||||
|
|
@ -402,7 +404,8 @@ main(int argc, char **argv) {
|
|||
break;
|
||||
default:
|
||||
fatal("%s is incompatible with NSEC3; "
|
||||
"do not use the -3 option", algname);
|
||||
"do not use the -3 option",
|
||||
algname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -443,9 +446,9 @@ main(int argc, char **argv) {
|
|||
"than the\n\tprepublication interval.");
|
||||
}
|
||||
} else {
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
isc_stdtime_t when;
|
||||
int major, minor;
|
||||
int major, minor;
|
||||
|
||||
if (prepub == -1)
|
||||
prepub = (30 * 86400);
|
||||
|
|
@ -471,8 +474,8 @@ main(int argc, char **argv) {
|
|||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE,
|
||||
mctx, &prevkey);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("Invalid keyfile %s: %s",
|
||||
predecessor, isc_result_totext(ret));
|
||||
fatal("Invalid keyfile %s: %s", predecessor,
|
||||
isc_result_totext(ret));
|
||||
if (!dst_key_isprivate(prevkey))
|
||||
fatal("%s is not a private key", predecessor);
|
||||
|
||||
|
|
@ -491,13 +494,15 @@ main(int argc, char **argv) {
|
|||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("Key %s has no activation date.\n\t"
|
||||
"You must use dnssec-settime -A to set one "
|
||||
"before generating a successor.", keystr);
|
||||
"before generating a successor.",
|
||||
keystr);
|
||||
|
||||
ret = dst_key_gettime(prevkey, DST_TIME_INACTIVE, &activate);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("Key %s has no inactivation date.\n\t"
|
||||
"You must use dnssec-settime -I to set one "
|
||||
"before generating a successor.", keystr);
|
||||
"before generating a successor.",
|
||||
keystr);
|
||||
|
||||
publish = activate - prepub;
|
||||
if (publish < now)
|
||||
|
|
@ -507,15 +512,18 @@ main(int argc, char **argv) {
|
|||
"Either change the inactivation date with "
|
||||
"dnssec-settime -I,\n\t"
|
||||
"or use the -i option to set a shorter "
|
||||
"prepublication interval.", keystr);
|
||||
"prepublication interval.",
|
||||
keystr);
|
||||
|
||||
ret = dst_key_gettime(prevkey, DST_TIME_DELETE, &when);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fprintf(stderr, "%s: WARNING: Key %s has no removal "
|
||||
"date;\n\t it will remain in the zone "
|
||||
"indefinitely after rollover.\n\t "
|
||||
"You can use dnssec-settime -D to "
|
||||
"change this.\n", program, keystr);
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: Key %s has no removal "
|
||||
"date;\n\t it will remain in the zone "
|
||||
"indefinitely after rollover.\n\t "
|
||||
"You can use dnssec-settime -D to "
|
||||
"change this.\n",
|
||||
program, keystr);
|
||||
|
||||
setpub = setact = true;
|
||||
}
|
||||
|
|
@ -523,12 +531,12 @@ main(int argc, char **argv) {
|
|||
if (nametype == NULL) {
|
||||
if ((options & DST_TYPE_KEY) != 0) /* KEY */
|
||||
fatal("no nametype specified");
|
||||
flags |= DNS_KEYOWNER_ZONE; /* DNSKEY */
|
||||
flags |= DNS_KEYOWNER_ZONE; /* DNSKEY */
|
||||
} else if (strcasecmp(nametype, "zone") == 0)
|
||||
flags |= DNS_KEYOWNER_ZONE;
|
||||
else if ((options & DST_TYPE_KEY) != 0) { /* KEY */
|
||||
else if ((options & DST_TYPE_KEY) != 0) { /* KEY */
|
||||
if (strcasecmp(nametype, "host") == 0 ||
|
||||
strcasecmp(nametype, "entity") == 0)
|
||||
strcasecmp(nametype, "entity") == 0)
|
||||
flags |= DNS_KEYOWNER_ENTITY;
|
||||
else if (strcasecmp(nametype, "user") == 0)
|
||||
flags |= DNS_KEYOWNER_USER;
|
||||
|
|
@ -542,7 +550,7 @@ main(int argc, char **argv) {
|
|||
if (directory == NULL)
|
||||
directory = ".";
|
||||
|
||||
if ((options & DST_TYPE_KEY) != 0) /* KEY */
|
||||
if ((options & DST_TYPE_KEY) != 0) /* KEY */
|
||||
flags |= signatory;
|
||||
else if ((flags & DNS_KEYOWNER_ZONE) != 0) { /* DNSKEY */
|
||||
flags |= kskflag;
|
||||
|
|
@ -581,8 +589,8 @@ main(int argc, char **argv) {
|
|||
char algstr[DNS_SECALG_FORMATSIZE];
|
||||
dns_name_format(name, namestr, sizeof(namestr));
|
||||
dns_secalg_format(alg, algstr, sizeof(algstr));
|
||||
fatal("failed to get key %s/%s: %s",
|
||||
namestr, algstr, isc_result_totext(ret));
|
||||
fatal("failed to get key %s/%s: %s", namestr, algstr,
|
||||
isc_result_totext(ret));
|
||||
/* NOTREACHED */
|
||||
exit(-1);
|
||||
}
|
||||
|
|
@ -613,7 +621,8 @@ main(int argc, char **argv) {
|
|||
|
||||
if (setrev) {
|
||||
if (kskflag == 0)
|
||||
fprintf(stderr, "%s: warning: Key is "
|
||||
fprintf(stderr,
|
||||
"%s: warning: Key is "
|
||||
"not flagged as a KSK, but -R "
|
||||
"was used. Revoking a ZSK is "
|
||||
"legal, but undefined.\n",
|
||||
|
|
@ -632,10 +641,9 @@ main(int argc, char **argv) {
|
|||
dst_key_settime(key, DST_TIME_SYNCDELETE, syncdel);
|
||||
|
||||
} else {
|
||||
if (setpub || setact || setrev || setinact ||
|
||||
setdel || unsetpub || unsetact ||
|
||||
unsetrev || unsetinact || unsetdel || genonly ||
|
||||
setsyncadd || setsyncdel)
|
||||
if (setpub || setact || setrev || setinact || setdel ||
|
||||
unsetpub || unsetact || unsetrev || unsetinact ||
|
||||
unsetdel || genonly || setsyncadd || setsyncdel)
|
||||
fatal("cannot use -C together with "
|
||||
"-P, -A, -R, -I, -D, or -G options");
|
||||
/*
|
||||
|
|
@ -665,13 +673,15 @@ main(int argc, char **argv) {
|
|||
|
||||
if (avoid_collisions)
|
||||
fatal("%s: %s could collide with another key upon "
|
||||
"revokation\n", program, filename);
|
||||
"revokation\n",
|
||||
program, filename);
|
||||
|
||||
fprintf(stderr, "%s: WARNING: Key %s could collide with "
|
||||
"another key upon revokation. If you plan "
|
||||
"to revoke keys, destroy this key and "
|
||||
"generate a different one.\n",
|
||||
program, filename);
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: Key %s could collide with "
|
||||
"another key upon revokation. If you plan "
|
||||
"to revoke keys, destroy this key and "
|
||||
"generate a different one.\n",
|
||||
program, filename);
|
||||
}
|
||||
|
||||
ret = dst_key_tofile(key, options, directory);
|
||||
|
|
|
|||
|
|
@ -39,13 +39,6 @@
|
|||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <isccfg/cfg.h>
|
||||
#include <isccfg/namedconf.h>
|
||||
#include <isccfg/kaspconf.h>
|
||||
#include <isccfg/grammar.h>
|
||||
|
||||
#include <pk11/site.h>
|
||||
|
||||
#include <dns/dnssec.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/kasp.h>
|
||||
|
|
@ -56,7 +49,13 @@
|
|||
#include <dns/result.h>
|
||||
#include <dns/secalg.h>
|
||||
|
||||
#include <isccfg/cfg.h>
|
||||
#include <isccfg/grammar.h>
|
||||
#include <isccfg/kaspconf.h>
|
||||
#include <isccfg/namedconf.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
#include <pk11/site.h>
|
||||
|
||||
#if USE_PKCS11
|
||||
#include <pk11/result.h>
|
||||
|
|
@ -73,66 +72,68 @@ isc_log_t *lctx = NULL;
|
|||
ISC_PLATFORM_NORETURN_PRE static void
|
||||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void progress(int p);
|
||||
static void
|
||||
progress(int p);
|
||||
|
||||
struct keygen_ctx {
|
||||
const char *predecessor;
|
||||
const char *policy;
|
||||
const char *configfile;
|
||||
const char *directory;
|
||||
char *algname;
|
||||
char *nametype;
|
||||
char *type;
|
||||
int generator;
|
||||
int protocol;
|
||||
int size;
|
||||
int signatory;
|
||||
const char * predecessor;
|
||||
const char * policy;
|
||||
const char * configfile;
|
||||
const char * directory;
|
||||
char * algname;
|
||||
char * nametype;
|
||||
char * type;
|
||||
int generator;
|
||||
int protocol;
|
||||
int size;
|
||||
int signatory;
|
||||
dns_rdataclass_t rdclass;
|
||||
int options;
|
||||
int dbits;
|
||||
dns_ttl_t ttl;
|
||||
uint16_t kskflag;
|
||||
uint16_t revflag;
|
||||
int options;
|
||||
int dbits;
|
||||
dns_ttl_t ttl;
|
||||
uint16_t kskflag;
|
||||
uint16_t revflag;
|
||||
dns_secalg_t alg;
|
||||
/* timing data */
|
||||
int prepub;
|
||||
isc_stdtime_t now;
|
||||
isc_stdtime_t publish;
|
||||
isc_stdtime_t activate;
|
||||
isc_stdtime_t inactive;
|
||||
isc_stdtime_t revokekey;
|
||||
isc_stdtime_t deltime;
|
||||
isc_stdtime_t syncadd;
|
||||
isc_stdtime_t syncdel;
|
||||
bool setpub;
|
||||
bool setact;
|
||||
bool setinact;
|
||||
bool setrev;
|
||||
bool setdel;
|
||||
bool setsyncadd;
|
||||
bool setsyncdel;
|
||||
bool unsetpub;
|
||||
bool unsetact;
|
||||
bool unsetinact;
|
||||
bool unsetrev;
|
||||
bool unsetdel;
|
||||
int prepub;
|
||||
isc_stdtime_t now;
|
||||
isc_stdtime_t publish;
|
||||
isc_stdtime_t activate;
|
||||
isc_stdtime_t inactive;
|
||||
isc_stdtime_t revokekey;
|
||||
isc_stdtime_t deltime;
|
||||
isc_stdtime_t syncadd;
|
||||
isc_stdtime_t syncdel;
|
||||
bool setpub;
|
||||
bool setact;
|
||||
bool setinact;
|
||||
bool setrev;
|
||||
bool setdel;
|
||||
bool setsyncadd;
|
||||
bool setsyncdel;
|
||||
bool unsetpub;
|
||||
bool unsetact;
|
||||
bool unsetinact;
|
||||
bool unsetrev;
|
||||
bool unsetdel;
|
||||
/* how to generate the key */
|
||||
bool setttl;
|
||||
bool use_nsec3;
|
||||
bool genonly;
|
||||
bool showprogress;
|
||||
bool quiet;
|
||||
bool oldstyle;
|
||||
bool setttl;
|
||||
bool use_nsec3;
|
||||
bool genonly;
|
||||
bool showprogress;
|
||||
bool quiet;
|
||||
bool oldstyle;
|
||||
/* state */
|
||||
time_t lifetime;
|
||||
bool ksk;
|
||||
bool zsk;
|
||||
time_t lifetime;
|
||||
bool ksk;
|
||||
bool zsk;
|
||||
};
|
||||
|
||||
typedef struct keygen_ctx keygen_ctx_t;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s [options] name\n\n", program);
|
||||
fprintf(stderr, "Version: %s\n", VERSION);
|
||||
|
|
@ -141,7 +142,7 @@ usage(void) {
|
|||
fprintf(stderr, " -K <directory>: write keys into directory\n");
|
||||
fprintf(stderr, " -k <policy>: generate keys for dnssec-policy\n");
|
||||
fprintf(stderr, " -l <file>: configuration file with dnssec-policy "
|
||||
"statement\n");
|
||||
"statement\n");
|
||||
fprintf(stderr, " -a <algorithm>:\n");
|
||||
fprintf(stderr, " RSASHA1 | NSEC3RSASHA1 |\n");
|
||||
fprintf(stderr, " RSASHA256 | RSASHA512 |\n");
|
||||
|
|
@ -161,14 +162,16 @@ usage(void) {
|
|||
fprintf(stderr, " (key size defaults are set according to\n"
|
||||
" algorithm and usage (ZSK or KSK)\n");
|
||||
fprintf(stderr, " -n <nametype>: ZONE | HOST | ENTITY | "
|
||||
"USER | OTHER\n");
|
||||
"USER | OTHER\n");
|
||||
fprintf(stderr, " (DNSKEY generation defaults to ZONE)\n");
|
||||
fprintf(stderr, " -c <class>: (default: IN)\n");
|
||||
fprintf(stderr, " -d <digest bits> (0 => max, default)\n");
|
||||
fprintf(stderr, " -E <engine>:\n");
|
||||
#if USE_PKCS11
|
||||
fprintf(stderr, " path to PKCS#11 provider library "
|
||||
"(default is %s)\n", PK11_LIB_LOCATION);
|
||||
fprintf(stderr,
|
||||
" path to PKCS#11 provider library "
|
||||
"(default is %s)\n",
|
||||
PK11_LIB_LOCATION);
|
||||
#else
|
||||
fprintf(stderr, " name of an OpenSSL engine to use\n");
|
||||
#endif
|
||||
|
|
@ -191,32 +194,32 @@ usage(void) {
|
|||
fprintf(stderr, " -V: print version information\n");
|
||||
fprintf(stderr, "Timing options:\n");
|
||||
fprintf(stderr, " -P date/[+-]offset/none: set key publication date "
|
||||
"(default: now)\n");
|
||||
"(default: now)\n");
|
||||
fprintf(stderr, " -P sync date/[+-]offset/none: set CDS and CDNSKEY "
|
||||
"publication date\n");
|
||||
"publication date\n");
|
||||
fprintf(stderr, " -A date/[+-]offset/none: set key activation date "
|
||||
"(default: now)\n");
|
||||
"(default: now)\n");
|
||||
fprintf(stderr, " -R date/[+-]offset/none: set key "
|
||||
"revocation date\n");
|
||||
"revocation date\n");
|
||||
fprintf(stderr, " -I date/[+-]offset/none: set key "
|
||||
"inactivation date\n");
|
||||
"inactivation date\n");
|
||||
fprintf(stderr, " -D date/[+-]offset/none: set key deletion date\n");
|
||||
fprintf(stderr, " -D sync date/[+-]offset/none: set CDS and CDNSKEY "
|
||||
"deletion date\n");
|
||||
"deletion date\n");
|
||||
|
||||
fprintf(stderr, " -G: generate key only; do not set -P or -A\n");
|
||||
fprintf(stderr, " -C: generate a backward-compatible key, omitting "
|
||||
"all dates\n");
|
||||
fprintf(stderr, " -S <key>: generate a successor to an existing "
|
||||
"key\n");
|
||||
"key\n");
|
||||
fprintf(stderr, " -i <interval>: prepublication interval for "
|
||||
"successor key "
|
||||
"(default: 30 days)\n");
|
||||
"successor key "
|
||||
"(default: 30 days)\n");
|
||||
fprintf(stderr, "Output:\n");
|
||||
fprintf(stderr, " K<name>+<alg>+<id>.key, "
|
||||
"K<name>+<alg>+<id>.private\n");
|
||||
|
||||
exit (-1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -240,31 +243,29 @@ progress(int p)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
(void) putc(c, stderr);
|
||||
(void) fflush(stderr);
|
||||
(void)putc(c, stderr);
|
||||
(void)fflush(stderr);
|
||||
}
|
||||
|
||||
static void
|
||||
kasp_from_conf(cfg_obj_t* config, isc_mem_t* mctx, const char* name,
|
||||
dns_kasp_t** kaspp)
|
||||
kasp_from_conf(cfg_obj_t *config, isc_mem_t *mctx, const char *name,
|
||||
dns_kasp_t **kaspp)
|
||||
{
|
||||
const cfg_listelt_t *element;
|
||||
const cfg_obj_t *kasps = NULL;
|
||||
dns_kasp_t *kasp = NULL, *kasp_next;
|
||||
isc_result_t result = ISC_R_NOTFOUND;
|
||||
dns_kasplist_t kasplist;
|
||||
const cfg_obj_t * kasps = NULL;
|
||||
dns_kasp_t * kasp = NULL, *kasp_next;
|
||||
isc_result_t result = ISC_R_NOTFOUND;
|
||||
dns_kasplist_t kasplist;
|
||||
|
||||
ISC_LIST_INIT(kasplist);
|
||||
|
||||
(void)cfg_map_get(config, "dnssec-policy", &kasps);
|
||||
for (element = cfg_list_first(kasps); element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
element = cfg_list_next(element)) {
|
||||
cfg_obj_t *kconfig = cfg_listelt_value(element);
|
||||
kasp = NULL;
|
||||
if (strcmp(cfg_obj_asstring(cfg_tuple_get(kconfig, "name")),
|
||||
name) != 0)
|
||||
{
|
||||
name) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -295,19 +296,19 @@ kasp_from_conf(cfg_obj_t* config, isc_mem_t* mctx, const char* name,
|
|||
static void
|
||||
keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
||||
{
|
||||
char filename[255];
|
||||
char algstr[DNS_SECALG_FORMATSIZE];
|
||||
uint16_t flags = 0;
|
||||
int param = 0;
|
||||
bool null_key = false;
|
||||
bool conflict = false;
|
||||
bool show_progress = false;
|
||||
isc_buffer_t buf;
|
||||
dns_name_t *name;
|
||||
dns_fixedname_t fname;
|
||||
isc_result_t ret;
|
||||
dst_key_t* key = NULL;
|
||||
dst_key_t* prevkey = NULL;
|
||||
char filename[255];
|
||||
char algstr[DNS_SECALG_FORMATSIZE];
|
||||
uint16_t flags = 0;
|
||||
int param = 0;
|
||||
bool null_key = false;
|
||||
bool conflict = false;
|
||||
bool show_progress = false;
|
||||
isc_buffer_t buf;
|
||||
dns_name_t * name;
|
||||
dns_fixedname_t fname;
|
||||
isc_result_t ret;
|
||||
dst_key_t * key = NULL;
|
||||
dst_key_t * prevkey = NULL;
|
||||
|
||||
UNUSED(argc);
|
||||
|
||||
|
|
@ -351,7 +352,8 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
break;
|
||||
default:
|
||||
fatal("algorithm %s is incompatible with NSEC3"
|
||||
", do not use the -3 option", algstr);
|
||||
", do not use the -3 option",
|
||||
algstr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -380,9 +382,11 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
case DST_ALG_RSASHA512:
|
||||
ctx->size = 2048;
|
||||
if (verbose > 0) {
|
||||
fprintf(stderr, "key size not "
|
||||
"specified; defaulting"
|
||||
" to %d\n", ctx->size);
|
||||
fprintf(stderr,
|
||||
"key size not "
|
||||
"specified; defaulting"
|
||||
" to %d\n",
|
||||
ctx->size);
|
||||
}
|
||||
break;
|
||||
case DST_ALG_ECDSA256:
|
||||
|
|
@ -397,8 +401,7 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
|
||||
if (!ctx->oldstyle && ctx->prepub > 0) {
|
||||
if (ctx->setpub && ctx->setact &&
|
||||
(ctx->activate - ctx->prepub) < ctx->publish)
|
||||
{
|
||||
(ctx->activate - ctx->prepub) < ctx->publish) {
|
||||
fatal("Activation and publication dates "
|
||||
"are closer together than the\n\t"
|
||||
"prepublication interval.");
|
||||
|
|
@ -421,9 +424,9 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
"than the\n\tprepublication interval.");
|
||||
}
|
||||
} else {
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
isc_stdtime_t when;
|
||||
int major, minor;
|
||||
int major, minor;
|
||||
|
||||
if (ctx->prepub == -1)
|
||||
ctx->prepub = (30 * 86400);
|
||||
|
|
@ -447,13 +450,13 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
if (ctx->genonly)
|
||||
fatal("-S and -G cannot be used together");
|
||||
|
||||
ret = dst_key_fromnamedfile(ctx->predecessor, ctx->directory,
|
||||
(DST_TYPE_PUBLIC|
|
||||
DST_TYPE_PRIVATE|DST_TYPE_STATE),
|
||||
mctx, &prevkey);
|
||||
ret = dst_key_fromnamedfile(
|
||||
ctx->predecessor, ctx->directory,
|
||||
(DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_STATE),
|
||||
mctx, &prevkey);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("Invalid keyfile %s: %s",
|
||||
ctx->predecessor, isc_result_totext(ret));
|
||||
fatal("Invalid keyfile %s: %s", ctx->predecessor,
|
||||
isc_result_totext(ret));
|
||||
if (!dst_key_isprivate(prevkey))
|
||||
fatal("%s is not a private key", ctx->predecessor);
|
||||
|
||||
|
|
@ -473,14 +476,16 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("Key %s has no activation date.\n\t"
|
||||
"You must use dnssec-settime -A to set one "
|
||||
"before generating a successor.", keystr);
|
||||
"before generating a successor.",
|
||||
keystr);
|
||||
|
||||
ret = dst_key_gettime(prevkey, DST_TIME_INACTIVE,
|
||||
&ctx->activate);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("Key %s has no inactivation date.\n\t"
|
||||
"You must use dnssec-settime -I to set one "
|
||||
"before generating a successor.", keystr);
|
||||
"before generating a successor.",
|
||||
keystr);
|
||||
|
||||
ctx->publish = ctx->activate - ctx->prepub;
|
||||
if (ctx->publish < ctx->now)
|
||||
|
|
@ -490,15 +495,18 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
"Either change the inactivation date with "
|
||||
"dnssec-settime -I,\n\t"
|
||||
"or use the -i option to set a shorter "
|
||||
"prepublication interval.", keystr);
|
||||
"prepublication interval.",
|
||||
keystr);
|
||||
|
||||
ret = dst_key_gettime(prevkey, DST_TIME_DELETE, &when);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fprintf(stderr, "%s: WARNING: Key %s has no removal "
|
||||
"date;\n\t it will remain in the zone "
|
||||
"indefinitely after rollover.\n\t "
|
||||
"You can use dnssec-settime -D to "
|
||||
"change this.\n", program, keystr);
|
||||
fprintf(stderr,
|
||||
"%s: WARNING: Key %s has no removal "
|
||||
"date;\n\t it will remain in the zone "
|
||||
"indefinitely after rollover.\n\t "
|
||||
"You can use dnssec-settime -D to "
|
||||
"change this.\n",
|
||||
program, keystr);
|
||||
|
||||
ctx->setpub = ctx->setact = true;
|
||||
}
|
||||
|
|
@ -538,12 +546,12 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
if (ctx->nametype == NULL) {
|
||||
if ((ctx->options & DST_TYPE_KEY) != 0) /* KEY */
|
||||
fatal("no nametype specified");
|
||||
flags |= DNS_KEYOWNER_ZONE; /* DNSKEY */
|
||||
flags |= DNS_KEYOWNER_ZONE; /* DNSKEY */
|
||||
} else if (strcasecmp(ctx->nametype, "zone") == 0)
|
||||
flags |= DNS_KEYOWNER_ZONE;
|
||||
else if ((ctx->options & DST_TYPE_KEY) != 0) { /* KEY */
|
||||
else if ((ctx->options & DST_TYPE_KEY) != 0) { /* KEY */
|
||||
if (strcasecmp(ctx->nametype, "host") == 0 ||
|
||||
strcasecmp(ctx->nametype, "entity") == 0)
|
||||
strcasecmp(ctx->nametype, "entity") == 0)
|
||||
flags |= DNS_KEYOWNER_ENTITY;
|
||||
else if (strcasecmp(ctx->nametype, "user") == 0)
|
||||
flags |= DNS_KEYOWNER_USER;
|
||||
|
|
@ -555,7 +563,7 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
if (ctx->directory == NULL)
|
||||
ctx->directory = ".";
|
||||
|
||||
if ((ctx->options & DST_TYPE_KEY) != 0) /* KEY */
|
||||
if ((ctx->options & DST_TYPE_KEY) != 0) /* KEY */
|
||||
flags |= ctx->signatory;
|
||||
else if ((flags & DNS_KEYOWNER_ZONE) != 0) { /* DNSKEY */
|
||||
flags |= ctx->kskflag;
|
||||
|
|
@ -576,12 +584,11 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
}
|
||||
|
||||
if ((flags & DNS_KEYFLAG_OWNERMASK) == DNS_KEYOWNER_ZONE &&
|
||||
ctx->alg == DNS_KEYALG_DH)
|
||||
{
|
||||
ctx->alg == DNS_KEYALG_DH) {
|
||||
fatal("a key with algorithm %s cannot be a zone key", algstr);
|
||||
}
|
||||
|
||||
switch(ctx->alg) {
|
||||
switch (ctx->alg) {
|
||||
case DNS_KEYALG_RSASHA1:
|
||||
case DNS_KEYALG_NSEC3RSASHA1:
|
||||
case DNS_KEYALG_RSASHA256:
|
||||
|
|
@ -611,23 +618,23 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
|
||||
if (!ctx->quiet && show_progress) {
|
||||
fprintf(stderr, "Generating key pair.");
|
||||
ret = dst_key_generate(name, ctx->alg, ctx->size,
|
||||
param, flags, ctx->protocol,
|
||||
ret = dst_key_generate(name, ctx->alg, ctx->size, param,
|
||||
flags, ctx->protocol,
|
||||
ctx->rdclass, mctx, &key,
|
||||
&progress);
|
||||
putc('\n', stderr);
|
||||
fflush(stderr);
|
||||
} else {
|
||||
ret = dst_key_generate(name, ctx->alg, ctx->size,
|
||||
param, flags, ctx->protocol,
|
||||
ret = dst_key_generate(name, ctx->alg, ctx->size, param,
|
||||
flags, ctx->protocol,
|
||||
ctx->rdclass, mctx, &key, NULL);
|
||||
}
|
||||
|
||||
if (ret != ISC_R_SUCCESS) {
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
dns_name_format(name, namestr, sizeof(namestr));
|
||||
fatal("failed to generate key %s/%s: %s\n",
|
||||
namestr, algstr, isc_result_totext(ret));
|
||||
fatal("failed to generate key %s/%s: %s\n", namestr,
|
||||
algstr, isc_result_totext(ret));
|
||||
}
|
||||
|
||||
dst_key_setbits(key, ctx->dbits);
|
||||
|
|
@ -674,7 +681,8 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
|
||||
if (ctx->setrev) {
|
||||
if (ctx->kskflag == 0)
|
||||
fprintf(stderr, "%s: warning: Key is "
|
||||
fprintf(stderr,
|
||||
"%s: warning: Key is "
|
||||
"not flagged as a KSK, but -R "
|
||||
"was used. Revoking a ZSK is "
|
||||
"legal, but undefined.\n",
|
||||
|
|
@ -689,9 +697,9 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
|
||||
if (ctx->setdel) {
|
||||
if (ctx->setinact &&
|
||||
ctx->deltime < ctx->inactive)
|
||||
{
|
||||
fprintf(stderr, "%s: warning: Key is "
|
||||
ctx->deltime < ctx->inactive) {
|
||||
fprintf(stderr,
|
||||
"%s: warning: Key is "
|
||||
"scheduled to be deleted "
|
||||
"before it is scheduled to be "
|
||||
"made inactive.\n",
|
||||
|
|
@ -711,10 +719,9 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
} else {
|
||||
if (ctx->setpub || ctx->setact || ctx->setrev ||
|
||||
ctx->setinact || ctx->setdel || ctx->unsetpub ||
|
||||
ctx->unsetact || ctx->unsetrev ||
|
||||
ctx->unsetinact || ctx->unsetdel || ctx->genonly ||
|
||||
ctx->setsyncadd || ctx->setsyncdel)
|
||||
{
|
||||
ctx->unsetact || ctx->unsetrev || ctx->unsetinact ||
|
||||
ctx->unsetdel || ctx->genonly || ctx->setsyncadd ||
|
||||
ctx->setsyncdel) {
|
||||
fatal("cannot use -C together with "
|
||||
"-P, -A, -R, -I, -D, or -G options");
|
||||
}
|
||||
|
|
@ -750,9 +757,8 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
|
||||
if (verbose > 0) {
|
||||
isc_buffer_clear(&buf);
|
||||
ret = dst_key_buildfilename(key, 0,
|
||||
ctx->directory,
|
||||
&buf);
|
||||
ret = dst_key_buildfilename(
|
||||
key, 0, ctx->directory, &buf);
|
||||
if (ret == ISC_R_SUCCESS)
|
||||
fprintf(stderr,
|
||||
"%s: %s already exists, or "
|
||||
|
|
@ -805,16 +811,17 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv)
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
char *algname = NULL, *freeit = NULL;
|
||||
char *classname = NULL;
|
||||
char *endp;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_result_t ret;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char * algname = NULL, *freeit = NULL;
|
||||
char * classname = NULL;
|
||||
char * endp;
|
||||
isc_mem_t * mctx = NULL;
|
||||
isc_result_t ret;
|
||||
isc_textregion_t r;
|
||||
const char *engine = NULL;
|
||||
unsigned char c;
|
||||
int ch;
|
||||
const char * engine = NULL;
|
||||
unsigned char c;
|
||||
int ch;
|
||||
|
||||
keygen_ctx_t ctx = {
|
||||
.options = DST_TYPE_PRIVATE | DST_TYPE_PUBLIC,
|
||||
|
|
@ -837,8 +844,9 @@ main(int argc, char **argv) {
|
|||
/*
|
||||
* Process memory debugging argument first.
|
||||
*/
|
||||
#define CMDLINE_FLAGS "3A:a:b:Cc:D:d:E:eFf:Gg:hI:i:K:k:L:l:m:n:P:p:qR:r:S:s:" \
|
||||
"T:t:v:V"
|
||||
#define CMDLINE_FLAGS \
|
||||
"3A:a:b:Cc:D:d:E:eFf:Gg:hI:i:K:k:L:l:m:n:P:p:qR:r:S:s:" \
|
||||
"T:t:v:V"
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
case 'm':
|
||||
|
|
@ -863,7 +871,7 @@ main(int argc, char **argv) {
|
|||
isc_stdtime_get(&ctx.now);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
switch (ch) {
|
||||
case '3':
|
||||
ctx.use_nsec3 = true;
|
||||
break;
|
||||
|
|
@ -890,9 +898,8 @@ main(int argc, char **argv) {
|
|||
engine = isc_commandline_argument;
|
||||
break;
|
||||
case 'e':
|
||||
fprintf(stderr,
|
||||
"phased-out option -e "
|
||||
"(was 'use (RSA) large exponent')\n");
|
||||
fprintf(stderr, "phased-out option -e "
|
||||
"(was 'use (RSA) large exponent')\n");
|
||||
break;
|
||||
case 'f':
|
||||
c = (unsigned char)(isc_commandline_argument[0]);
|
||||
|
|
@ -905,8 +912,8 @@ main(int argc, char **argv) {
|
|||
isc_commandline_argument);
|
||||
break;
|
||||
case 'g':
|
||||
ctx.generator = strtol(isc_commandline_argument,
|
||||
&endp, 10);
|
||||
ctx.generator =
|
||||
strtol(isc_commandline_argument, &endp, 10);
|
||||
if (*endp != '\0' || ctx.generator <= 0)
|
||||
fatal("-g requires a positive number");
|
||||
break;
|
||||
|
|
@ -933,11 +940,10 @@ main(int argc, char **argv) {
|
|||
case 'm':
|
||||
break;
|
||||
case 'p':
|
||||
ctx.protocol = strtol(isc_commandline_argument, &endp,
|
||||
10);
|
||||
ctx.protocol =
|
||||
strtol(isc_commandline_argument, &endp, 10);
|
||||
if (*endp != '\0' || ctx.protocol < 0 ||
|
||||
ctx.protocol > 255)
|
||||
{
|
||||
ctx.protocol > 255) {
|
||||
fatal("-p must be followed by a number "
|
||||
"[0..255]");
|
||||
}
|
||||
|
|
@ -950,11 +956,10 @@ main(int argc, char **argv) {
|
|||
"System random data is always used.\n");
|
||||
break;
|
||||
case 's':
|
||||
ctx.signatory = strtol(isc_commandline_argument,
|
||||
&endp, 10);
|
||||
ctx.signatory =
|
||||
strtol(isc_commandline_argument, &endp, 10);
|
||||
if (*endp != '\0' || ctx.signatory < 0 ||
|
||||
ctx.signatory > 15)
|
||||
{
|
||||
ctx.signatory > 15) {
|
||||
fatal("-s must be followed by a number "
|
||||
"[0..15]");
|
||||
}
|
||||
|
|
@ -962,8 +967,8 @@ main(int argc, char **argv) {
|
|||
case 'T':
|
||||
if (strcasecmp(isc_commandline_argument, "KEY") == 0)
|
||||
ctx.options |= DST_TYPE_KEY;
|
||||
else if (strcasecmp(isc_commandline_argument,
|
||||
"DNSKEY") == 0)
|
||||
else if (strcasecmp(isc_commandline_argument, "DNSKE"
|
||||
"Y") == 0)
|
||||
/* default behavior */
|
||||
;
|
||||
else
|
||||
|
|
@ -990,9 +995,8 @@ main(int argc, char **argv) {
|
|||
"once");
|
||||
|
||||
ctx.syncadd = strtotime(
|
||||
isc_commandline_argument,
|
||||
ctx.now, ctx.now,
|
||||
&ctx.setsyncadd);
|
||||
isc_commandline_argument, ctx.now,
|
||||
ctx.now, &ctx.setsyncadd);
|
||||
break;
|
||||
}
|
||||
(void)isoptarg("dnskey", argv, usage);
|
||||
|
|
@ -1016,7 +1020,8 @@ main(int argc, char **argv) {
|
|||
fatal("-R specified more than once");
|
||||
|
||||
ctx.revokekey = strtotime(isc_commandline_argument,
|
||||
ctx.now, ctx.now, &ctx.setrev);
|
||||
ctx.now, ctx.now,
|
||||
&ctx.setrev);
|
||||
ctx.unsetrev = !ctx.setrev;
|
||||
break;
|
||||
case 'I':
|
||||
|
|
@ -1024,7 +1029,8 @@ main(int argc, char **argv) {
|
|||
fatal("-I specified more than once");
|
||||
|
||||
ctx.inactive = strtotime(isc_commandline_argument,
|
||||
ctx.now, ctx.now, &ctx.setinact);
|
||||
ctx.now, ctx.now,
|
||||
&ctx.setinact);
|
||||
ctx.unsetinact = !ctx.setinact;
|
||||
break;
|
||||
case 'D':
|
||||
|
|
@ -1035,9 +1041,8 @@ main(int argc, char **argv) {
|
|||
"once");
|
||||
|
||||
ctx.syncdel = strtotime(
|
||||
isc_commandline_argument,
|
||||
ctx.now, ctx.now,
|
||||
&ctx.setsyncdel);
|
||||
isc_commandline_argument, ctx.now,
|
||||
ctx.now, &ctx.setsyncdel);
|
||||
break;
|
||||
}
|
||||
(void)isoptarg("dnskey", argv, usage);
|
||||
|
|
@ -1071,8 +1076,8 @@ main(int argc, char **argv) {
|
|||
version(program);
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -1082,8 +1087,7 @@ main(int argc, char **argv) {
|
|||
|
||||
ret = dst_lib_init(mctx, engine);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
fatal("could not initialize dst: %s",
|
||||
isc_result_totext(ret));
|
||||
fatal("could not initialize dst: %s", isc_result_totext(ret));
|
||||
|
||||
setup_logging(mctx, &lctx);
|
||||
|
||||
|
|
@ -1147,8 +1151,7 @@ main(int argc, char **argv) {
|
|||
if (ctx.setpub || ctx.setact || ctx.setrev || ctx.setinact ||
|
||||
ctx.setdel || ctx.unsetpub || ctx.unsetact ||
|
||||
ctx.unsetrev || ctx.unsetinact || ctx.unsetdel ||
|
||||
ctx.setsyncadd || ctx.setsyncdel)
|
||||
{
|
||||
ctx.setsyncadd || ctx.setsyncdel) {
|
||||
fatal("cannot use -k together with "
|
||||
"-P, -A, -R, -I, or -D options "
|
||||
"(use dnssec-settime on keys afterwards)");
|
||||
|
|
@ -1170,18 +1173,19 @@ main(int argc, char **argv) {
|
|||
|
||||
keygen(&ctx, mctx, argc, argv);
|
||||
} else {
|
||||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
dns_kasp_t* kasp = NULL;
|
||||
dns_kasp_key_t* kaspkey = NULL;
|
||||
cfg_parser_t * parser = NULL;
|
||||
cfg_obj_t * config = NULL;
|
||||
dns_kasp_t * kasp = NULL;
|
||||
dns_kasp_key_t *kaspkey = NULL;
|
||||
|
||||
RUNTIME_CHECK(cfg_parser_create(mctx, lctx, &parser)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(cfg_parser_create(mctx, lctx, &parser) ==
|
||||
ISC_R_SUCCESS);
|
||||
if (cfg_parse_file(parser, ctx.configfile,
|
||||
&cfg_type_namedconf, &config) != ISC_R_SUCCESS)
|
||||
{
|
||||
&cfg_type_namedconf,
|
||||
&config) != ISC_R_SUCCESS) {
|
||||
fatal("unable to load dnssec-policy '%s' from "
|
||||
"'%s'", ctx.policy, ctx.configfile);
|
||||
"'%s'",
|
||||
ctx.policy, ctx.configfile);
|
||||
}
|
||||
|
||||
kasp_from_conf(config, mctx, ctx.policy, &kasp);
|
||||
|
|
@ -1191,7 +1195,8 @@ main(int argc, char **argv) {
|
|||
}
|
||||
if (ISC_LIST_EMPTY(dns_kasp_keys(kasp))) {
|
||||
fatal("dnssec-policy '%s' has no keys "
|
||||
"configured", ctx.policy);
|
||||
"configured",
|
||||
ctx.policy);
|
||||
}
|
||||
|
||||
ctx.ttl = dns_kasp_dnskeyttl(kasp);
|
||||
|
|
@ -1203,8 +1208,9 @@ main(int argc, char **argv) {
|
|||
ctx.use_nsec3 = false;
|
||||
ctx.alg = dns_kasp_key_algorithm(kaspkey);
|
||||
ctx.size = dns_kasp_key_size(kaspkey);
|
||||
ctx.kskflag = dns_kasp_key_ksk(kaspkey) ?
|
||||
DNS_KEYFLAG_KSK : 0;
|
||||
ctx.kskflag = dns_kasp_key_ksk(kaspkey)
|
||||
? DNS_KEYFLAG_KSK
|
||||
: 0;
|
||||
ctx.ksk = dns_kasp_key_ksk(kaspkey);
|
||||
ctx.zsk = dns_kasp_key_zsk(kaspkey);
|
||||
ctx.lifetime = dns_kasp_key_lifetime(kaspkey);
|
||||
|
|
|
|||
|
|
@ -38,19 +38,22 @@
|
|||
|
||||
const char *program = "dnssec-revoke";
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
|
||||
ISC_PLATFORM_NORETURN_PRE static void
|
||||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s [options] keyfile\n\n", program);
|
||||
fprintf(stderr, " %s [options] keyfile\n\n", program);
|
||||
fprintf(stderr, "Version: %s\n", VERSION);
|
||||
#if USE_PKCS11
|
||||
fprintf(stderr, " -E engine: specify PKCS#11 provider "
|
||||
"(default: %s)\n", PK11_LIB_LOCATION);
|
||||
fprintf(stderr,
|
||||
" -E engine: specify PKCS#11 provider "
|
||||
"(default: %s)\n",
|
||||
PK11_LIB_LOCATION);
|
||||
#else
|
||||
fprintf(stderr, " -E engine: specify OpenSSL engine\n");
|
||||
#endif
|
||||
|
|
@ -58,32 +61,33 @@ usage(void) {
|
|||
fprintf(stderr, " -h: help\n");
|
||||
fprintf(stderr, " -K directory: use directory for key files\n");
|
||||
fprintf(stderr, " -r: remove old keyfiles after "
|
||||
"creating revoked version\n");
|
||||
"creating revoked version\n");
|
||||
fprintf(stderr, " -v level: set level of verbosity\n");
|
||||
fprintf(stderr, " -V: print version information\n");
|
||||
fprintf(stderr, "Output:\n");
|
||||
fprintf(stderr, " K<name>+<alg>+<new id>.key, "
|
||||
"K<name>+<alg>+<new id>.private\n");
|
||||
"K<name>+<alg>+<new id>.private\n");
|
||||
|
||||
exit (-1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char *engine = NULL;
|
||||
char const *filename = NULL;
|
||||
char *dir = NULL;
|
||||
char newname[1024], oldname[1024];
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
char *endp;
|
||||
int ch;
|
||||
dst_key_t *key = NULL;
|
||||
uint32_t flags;
|
||||
const char * engine = NULL;
|
||||
char const * filename = NULL;
|
||||
char * dir = NULL;
|
||||
char newname[1024], oldname[1024];
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
char * endp;
|
||||
int ch;
|
||||
dst_key_t * key = NULL;
|
||||
uint32_t flags;
|
||||
isc_buffer_t buf;
|
||||
bool force = false;
|
||||
bool removefile = false;
|
||||
bool id = false;
|
||||
bool force = false;
|
||||
bool removefile = false;
|
||||
bool id = false;
|
||||
|
||||
if (argc == 1)
|
||||
usage();
|
||||
|
|
@ -99,46 +103,46 @@ main(int argc, char **argv) {
|
|||
|
||||
while ((ch = isc_commandline_parse(argc, argv, "E:fK:rRhv:V")) != -1) {
|
||||
switch (ch) {
|
||||
case 'E':
|
||||
case 'E':
|
||||
engine = isc_commandline_argument;
|
||||
break;
|
||||
case 'f':
|
||||
case 'f':
|
||||
force = true;
|
||||
break;
|
||||
case 'K':
|
||||
case 'K':
|
||||
/*
|
||||
* We don't have to copy it here, but do it to
|
||||
* simplify cleanup later
|
||||
*/
|
||||
dir = isc_mem_strdup(mctx, isc_commandline_argument);
|
||||
break;
|
||||
case 'r':
|
||||
case 'r':
|
||||
removefile = true;
|
||||
break;
|
||||
case 'R':
|
||||
case 'R':
|
||||
id = true;
|
||||
break;
|
||||
case 'v':
|
||||
case 'v':
|
||||
verbose = strtol(isc_commandline_argument, &endp, 0);
|
||||
if (*endp != '\0')
|
||||
fatal("-v must be followed by a number");
|
||||
break;
|
||||
case '?':
|
||||
case '?':
|
||||
if (isc_commandline_option != '?')
|
||||
fprintf(stderr, "%s: invalid argument -%c\n",
|
||||
program, isc_commandline_option);
|
||||
/* FALLTHROUGH */
|
||||
case 'h':
|
||||
case 'h':
|
||||
/* Does not return. */
|
||||
usage();
|
||||
|
||||
case 'V':
|
||||
case 'V':
|
||||
/* Does not return. */
|
||||
version(program);
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -169,12 +173,11 @@ main(int argc, char **argv) {
|
|||
fatal("Could not initialize dst: %s",
|
||||
isc_result_totext(result));
|
||||
|
||||
result = dst_key_fromnamedfile(filename, dir,
|
||||
DST_TYPE_PUBLIC|DST_TYPE_PRIVATE,
|
||||
mctx, &key);
|
||||
result = dst_key_fromnamedfile(
|
||||
filename, dir, DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, mctx, &key);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("Invalid keyfile name %s: %s",
|
||||
filename, isc_result_totext(result));
|
||||
fatal("Invalid keyfile name %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
|
||||
if (id) {
|
||||
fprintf(stdout, "%u\n", dst_key_rid(key));
|
||||
|
|
@ -190,16 +193,16 @@ main(int argc, char **argv) {
|
|||
else
|
||||
check_keyversion(key, keystr);
|
||||
|
||||
|
||||
flags = dst_key_flags(key);
|
||||
if ((flags & DNS_KEYFLAG_REVOKE) == 0) {
|
||||
isc_stdtime_t now;
|
||||
|
||||
if ((flags & DNS_KEYFLAG_KSK) == 0)
|
||||
fprintf(stderr, "%s: warning: Key is not flagged "
|
||||
"as a KSK. Revoking a ZSK is "
|
||||
"legal, but undefined.\n",
|
||||
program);
|
||||
fprintf(stderr,
|
||||
"%s: warning: Key is not flagged "
|
||||
"as a KSK. Revoking a ZSK is "
|
||||
"legal, but undefined.\n",
|
||||
program);
|
||||
|
||||
isc_stdtime_get(&now);
|
||||
dst_key_settime(key, DST_TIME_REVOKE, now);
|
||||
|
|
@ -211,10 +214,11 @@ main(int argc, char **argv) {
|
|||
|
||||
if (access(newname, F_OK) == 0 && !force) {
|
||||
fatal("Key file %s already exists; "
|
||||
"use -f to force overwrite", newname);
|
||||
"use -f to force overwrite",
|
||||
newname);
|
||||
}
|
||||
|
||||
result = dst_key_tofile(key, DST_TYPE_PUBLIC|DST_TYPE_PRIVATE,
|
||||
result = dst_key_tofile(key, DST_TYPE_PUBLIC | DST_TYPE_PRIVATE,
|
||||
dir);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dst_key_format(key, keystr, sizeof(keystr));
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/commandline.h>
|
||||
|
|
@ -28,8 +28,8 @@
|
|||
#include <isc/util.h>
|
||||
|
||||
#include <dns/keyvalues.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
|
||||
|
|
@ -41,28 +41,31 @@
|
|||
|
||||
const char *program = "dnssec-settime";
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
|
||||
ISC_PLATFORM_NORETURN_PRE static void
|
||||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s [options] keyfile\n\n", program);
|
||||
fprintf(stderr, " %s [options] keyfile\n\n", program);
|
||||
fprintf(stderr, "Version: %s\n", VERSION);
|
||||
fprintf(stderr, "General options:\n");
|
||||
#if USE_PKCS11
|
||||
fprintf(stderr, " -E engine: specify PKCS#11 provider "
|
||||
"(default: %s)\n", PK11_LIB_LOCATION);
|
||||
fprintf(stderr,
|
||||
" -E engine: specify PKCS#11 provider "
|
||||
"(default: %s)\n",
|
||||
PK11_LIB_LOCATION);
|
||||
#elif defined(USE_PKCS11)
|
||||
fprintf(stderr, " -E engine: specify OpenSSL engine "
|
||||
"(default \"pkcs11\")\n");
|
||||
"(default \"pkcs11\")\n");
|
||||
#else
|
||||
fprintf(stderr, " -E engine: specify OpenSSL engine\n");
|
||||
#endif
|
||||
fprintf(stderr, " -f: force update of old-style "
|
||||
"keys\n");
|
||||
"keys\n");
|
||||
fprintf(stderr, " -K directory: set key file location\n");
|
||||
fprintf(stderr, " -L ttl: set default key TTL\n");
|
||||
fprintf(stderr, " -v level: set level of verbosity\n");
|
||||
|
|
@ -70,51 +73,50 @@ usage(void) {
|
|||
fprintf(stderr, " -h: help\n");
|
||||
fprintf(stderr, "Timing options:\n");
|
||||
fprintf(stderr, " -P date/[+-]offset/none: set/unset key "
|
||||
"publication date\n");
|
||||
"publication date\n");
|
||||
fprintf(stderr, " -P sync date/[+-]offset/none: set/unset "
|
||||
"CDS and CDNSKEY publication date\n");
|
||||
"CDS and CDNSKEY publication date\n");
|
||||
fprintf(stderr, " -A date/[+-]offset/none: set/unset key "
|
||||
"activation date\n");
|
||||
"activation date\n");
|
||||
fprintf(stderr, " -R date/[+-]offset/none: set/unset key "
|
||||
"revocation date\n");
|
||||
"revocation date\n");
|
||||
fprintf(stderr, " -I date/[+-]offset/none: set/unset key "
|
||||
"inactivation date\n");
|
||||
"inactivation date\n");
|
||||
fprintf(stderr, " -D date/[+-]offset/none: set/unset key "
|
||||
"deletion date\n");
|
||||
"deletion date\n");
|
||||
fprintf(stderr, " -D sync date/[+-]offset/none: set/unset "
|
||||
"CDS and CDNSKEY deletion date\n");
|
||||
"CDS and CDNSKEY deletion date\n");
|
||||
fprintf(stderr, " -S <key>: generate a successor to an existing "
|
||||
"key\n");
|
||||
"key\n");
|
||||
fprintf(stderr, " -i <interval>: prepublication interval for "
|
||||
"successor key "
|
||||
"(default: 30 days)\n");
|
||||
"successor key "
|
||||
"(default: 30 days)\n");
|
||||
fprintf(stderr, "Key state options:\n");
|
||||
fprintf(stderr, " -s: update key state file (default no)\n");
|
||||
fprintf(stderr, " -g state: set the goal state for this key\n");
|
||||
fprintf(stderr, " -d state date/[+-]offset: set the DS state\n");
|
||||
fprintf(stderr, " -k state date/[+-]offset: set the DNSKEY state\n");
|
||||
fprintf(stderr, " -r state date/[+-]offset: set the RRSIG (KSK) "
|
||||
"state\n");
|
||||
"state\n");
|
||||
fprintf(stderr, " -z state date/[+-]offset: set the RRSIG (ZSK) "
|
||||
"state\n");
|
||||
"state\n");
|
||||
fprintf(stderr, "Printing options:\n");
|
||||
fprintf(stderr, " -p C/P/Psync/A/R/I/D/Dsync/all: print a "
|
||||
"particular time value or values\n");
|
||||
"particular time value or values\n");
|
||||
fprintf(stderr, " -u: print times in unix epoch "
|
||||
"format\n");
|
||||
"format\n");
|
||||
fprintf(stderr, "Output:\n");
|
||||
fprintf(stderr, " K<name>+<alg>+<new id>.key, "
|
||||
"K<name>+<alg>+<new id>.private\n");
|
||||
"K<name>+<alg>+<new id>.private\n");
|
||||
|
||||
exit (-1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static void
|
||||
printtime(dst_key_t *key, int type, const char *tag, bool epoch,
|
||||
FILE *stream)
|
||||
printtime(dst_key_t *key, int type, const char *tag, bool epoch, FILE *stream)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char *output = NULL;
|
||||
isc_result_t result;
|
||||
const char * output = NULL;
|
||||
isc_stdtime_t when;
|
||||
|
||||
if (tag != NULL)
|
||||
|
|
@ -124,7 +126,7 @@ printtime(dst_key_t *key, int type, const char *tag, bool epoch,
|
|||
if (result == ISC_R_NOTFOUND) {
|
||||
fprintf(stream, "UNSET\n");
|
||||
} else if (epoch) {
|
||||
fprintf(stream, "%d\n", (int) when);
|
||||
fprintf(stream, "%d\n", (int)when);
|
||||
} else {
|
||||
time_t timet = when;
|
||||
output = ctime(&timet);
|
||||
|
|
@ -135,11 +137,11 @@ printtime(dst_key_t *key, int type, const char *tag, bool epoch,
|
|||
static void
|
||||
writekey(dst_key_t *key, const char *directory, bool write_state)
|
||||
{
|
||||
char newname[1024];
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
char newname[1024];
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
isc_buffer_t buf;
|
||||
isc_result_t result;
|
||||
int options = DST_TYPE_PUBLIC|DST_TYPE_PRIVATE;
|
||||
int options = DST_TYPE_PUBLIC | DST_TYPE_PRIVATE;
|
||||
|
||||
if (write_state) {
|
||||
options |= DST_TYPE_STATE;
|
||||
|
|
@ -181,20 +183,21 @@ writekey(dst_key_t *key, const char *directory, bool write_state)
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char *engine = NULL;
|
||||
const char *filename = NULL;
|
||||
char *directory = NULL;
|
||||
const char * engine = NULL;
|
||||
const char * filename = NULL;
|
||||
char * directory = NULL;
|
||||
char keystr[DST_KEY_FORMATSIZE];
|
||||
char *endp, *p;
|
||||
char * endp, *p;
|
||||
int ch;
|
||||
const char *predecessor = NULL;
|
||||
dst_key_t *prevkey = NULL;
|
||||
dst_key_t *key = NULL;
|
||||
dns_name_t *name = NULL;
|
||||
dns_secalg_t alg = 0;
|
||||
unsigned int size = 0;
|
||||
const char * predecessor = NULL;
|
||||
dst_key_t * prevkey = NULL;
|
||||
dst_key_t * key = NULL;
|
||||
dns_name_t * name = NULL;
|
||||
dns_secalg_t alg = 0;
|
||||
unsigned int size = 0;
|
||||
uint16_t flags = 0;
|
||||
int prepub = -1;
|
||||
int options;
|
||||
|
|
@ -204,35 +207,35 @@ main(int argc, char **argv) {
|
|||
isc_stdtime_t krrsigtime = 0, zrrsigtime = 0;
|
||||
isc_stdtime_t pub = 0, act = 0, rev = 0, inact = 0, del = 0;
|
||||
isc_stdtime_t prevact = 0, previnact = 0, prevdel = 0;
|
||||
dst_key_state_t goal = DST_KEY_STATE_NA;
|
||||
dst_key_state_t ds = DST_KEY_STATE_NA;
|
||||
dst_key_state_t dnskey = DST_KEY_STATE_NA;
|
||||
dst_key_state_t krrsig = DST_KEY_STATE_NA;
|
||||
dst_key_state_t zrrsig = DST_KEY_STATE_NA;
|
||||
bool setgoal = false, setds = false, setdnskey = false;
|
||||
bool setkrrsig = false, setzrrsig = false;
|
||||
bool setdstime = false, setdnskeytime = false;
|
||||
bool setkrrsigtime = false, setzrrsigtime = false;
|
||||
bool setpub = false, setact = false;
|
||||
bool setrev = false, setinact = false;
|
||||
bool setdel = false, setttl = false;
|
||||
bool unsetpub = false, unsetact = false;
|
||||
bool unsetrev = false, unsetinact = false;
|
||||
bool unsetdel = false;
|
||||
bool printcreate = false, printpub = false;
|
||||
bool printact = false, printrev = false;
|
||||
bool printinact = false, printdel = false;
|
||||
bool force = false;
|
||||
bool epoch = false;
|
||||
bool changed = false;
|
||||
bool write_state = false;
|
||||
isc_log_t *log = NULL;
|
||||
dst_key_state_t goal = DST_KEY_STATE_NA;
|
||||
dst_key_state_t ds = DST_KEY_STATE_NA;
|
||||
dst_key_state_t dnskey = DST_KEY_STATE_NA;
|
||||
dst_key_state_t krrsig = DST_KEY_STATE_NA;
|
||||
dst_key_state_t zrrsig = DST_KEY_STATE_NA;
|
||||
bool setgoal = false, setds = false, setdnskey = false;
|
||||
bool setkrrsig = false, setzrrsig = false;
|
||||
bool setdstime = false, setdnskeytime = false;
|
||||
bool setkrrsigtime = false, setzrrsigtime = false;
|
||||
bool setpub = false, setact = false;
|
||||
bool setrev = false, setinact = false;
|
||||
bool setdel = false, setttl = false;
|
||||
bool unsetpub = false, unsetact = false;
|
||||
bool unsetrev = false, unsetinact = false;
|
||||
bool unsetdel = false;
|
||||
bool printcreate = false, printpub = false;
|
||||
bool printact = false, printrev = false;
|
||||
bool printinact = false, printdel = false;
|
||||
bool force = false;
|
||||
bool epoch = false;
|
||||
bool changed = false;
|
||||
bool write_state = false;
|
||||
isc_log_t * log = NULL;
|
||||
isc_stdtime_t syncadd = 0, syncdel = 0;
|
||||
bool unsetsyncadd = false, setsyncadd = false;
|
||||
bool unsetsyncdel = false, setsyncdel = false;
|
||||
bool printsyncadd = false, printsyncdel = false;
|
||||
bool unsetsyncadd = false, setsyncadd = false;
|
||||
bool unsetsyncdel = false, setsyncdel = false;
|
||||
bool printsyncadd = false, printsyncdel = false;
|
||||
|
||||
options = DST_TYPE_PUBLIC|DST_TYPE_PRIVATE|DST_TYPE_STATE;
|
||||
options = DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_STATE;
|
||||
|
||||
if (argc == 1)
|
||||
usage();
|
||||
|
|
@ -258,8 +261,8 @@ main(int argc, char **argv) {
|
|||
fatal("-A specified more than once");
|
||||
|
||||
changed = true;
|
||||
act = strtotime(isc_commandline_argument,
|
||||
now, now, &setact);
|
||||
act = strtotime(isc_commandline_argument, now, now,
|
||||
&setact);
|
||||
unsetact = !setact;
|
||||
break;
|
||||
case 'D':
|
||||
|
|
@ -271,7 +274,7 @@ main(int argc, char **argv) {
|
|||
|
||||
changed = true;
|
||||
syncdel = strtotime(isc_commandline_argument,
|
||||
now, now, &setsyncdel);
|
||||
now, now, &setsyncdel);
|
||||
unsetsyncdel = !setsyncdel;
|
||||
break;
|
||||
}
|
||||
|
|
@ -281,8 +284,8 @@ main(int argc, char **argv) {
|
|||
fatal("-D specified more than once");
|
||||
|
||||
changed = true;
|
||||
del = strtotime(isc_commandline_argument,
|
||||
now, now, &setdel);
|
||||
del = strtotime(isc_commandline_argument, now, now,
|
||||
&setdel);
|
||||
unsetdel = !setdel;
|
||||
break;
|
||||
case 'd':
|
||||
|
|
@ -294,8 +297,8 @@ main(int argc, char **argv) {
|
|||
setds = true;
|
||||
/* time */
|
||||
(void)isoptarg(isc_commandline_argument, argv, usage);
|
||||
dstime = strtotime(isc_commandline_argument,
|
||||
now, now, &setdstime);
|
||||
dstime = strtotime(isc_commandline_argument, now, now,
|
||||
&setdstime);
|
||||
break;
|
||||
case 'E':
|
||||
engine = isc_commandline_argument;
|
||||
|
|
@ -330,8 +333,8 @@ main(int argc, char **argv) {
|
|||
fatal("-I specified more than once");
|
||||
|
||||
changed = true;
|
||||
inact = strtotime(isc_commandline_argument,
|
||||
now, now, &setinact);
|
||||
inact = strtotime(isc_commandline_argument, now, now,
|
||||
&setinact);
|
||||
unsetinact = !setinact;
|
||||
break;
|
||||
case 'i':
|
||||
|
|
@ -342,8 +345,8 @@ main(int argc, char **argv) {
|
|||
* We don't have to copy it here, but do it to
|
||||
* simplify cleanup later
|
||||
*/
|
||||
directory = isc_mem_strdup(mctx,
|
||||
isc_commandline_argument);
|
||||
directory =
|
||||
isc_mem_strdup(mctx, isc_commandline_argument);
|
||||
break;
|
||||
case 'k':
|
||||
if (setdnskey) {
|
||||
|
|
@ -354,8 +357,8 @@ main(int argc, char **argv) {
|
|||
setdnskey = true;
|
||||
/* time */
|
||||
(void)isoptarg(isc_commandline_argument, argv, usage);
|
||||
dnskeytime = strtotime(isc_commandline_argument,
|
||||
now, now, &setdnskeytime);
|
||||
dnskeytime = strtotime(isc_commandline_argument, now,
|
||||
now, &setdnskeytime);
|
||||
break;
|
||||
case 'L':
|
||||
ttl = strtottl(isc_commandline_argument);
|
||||
|
|
@ -370,7 +373,7 @@ main(int argc, char **argv) {
|
|||
|
||||
changed = true;
|
||||
syncadd = strtotime(isc_commandline_argument,
|
||||
now, now, &setsyncadd);
|
||||
now, now, &setsyncadd);
|
||||
unsetsyncadd = !setsyncadd;
|
||||
break;
|
||||
}
|
||||
|
|
@ -379,8 +382,8 @@ main(int argc, char **argv) {
|
|||
fatal("-P specified more than once");
|
||||
|
||||
changed = true;
|
||||
pub = strtotime(isc_commandline_argument,
|
||||
now, now, &setpub);
|
||||
pub = strtotime(isc_commandline_argument, now, now,
|
||||
&setpub);
|
||||
unsetpub = !setpub;
|
||||
break;
|
||||
case 'p':
|
||||
|
|
@ -440,8 +443,8 @@ main(int argc, char **argv) {
|
|||
fatal("-R specified more than once");
|
||||
|
||||
changed = true;
|
||||
rev = strtotime(isc_commandline_argument,
|
||||
now, now, &setrev);
|
||||
rev = strtotime(isc_commandline_argument, now, now,
|
||||
&setrev);
|
||||
unsetrev = !setrev;
|
||||
break;
|
||||
case 'r':
|
||||
|
|
@ -453,8 +456,8 @@ main(int argc, char **argv) {
|
|||
setkrrsig = true;
|
||||
/* time */
|
||||
(void)isoptarg(isc_commandline_argument, argv, usage);
|
||||
krrsigtime = strtotime(isc_commandline_argument,
|
||||
now, now, &setkrrsigtime);
|
||||
krrsigtime = strtotime(isc_commandline_argument, now,
|
||||
now, &setkrrsigtime);
|
||||
break;
|
||||
case 'S':
|
||||
predecessor = isc_commandline_argument;
|
||||
|
|
@ -481,13 +484,13 @@ main(int argc, char **argv) {
|
|||
zrrsig = strtokeystate(isc_commandline_argument);
|
||||
setzrrsig = true;
|
||||
(void)isoptarg(isc_commandline_argument, argv, usage);
|
||||
zrrsigtime = strtotime(isc_commandline_argument,
|
||||
now, now, &setzrrsigtime);
|
||||
zrrsigtime = strtotime(isc_commandline_argument, now,
|
||||
now, &setzrrsigtime);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -499,8 +502,7 @@ main(int argc, char **argv) {
|
|||
fatal("Extraneous arguments");
|
||||
|
||||
if ((setgoal || setds || setdnskey || setkrrsig || setzrrsig) &&
|
||||
!write_state)
|
||||
{
|
||||
!write_state) {
|
||||
fatal("Options -g, -d, -k, -r and -z require -s to be set");
|
||||
}
|
||||
|
||||
|
|
@ -523,8 +525,8 @@ main(int argc, char **argv) {
|
|||
result = dst_key_fromnamedfile(predecessor, directory, options,
|
||||
mctx, &prevkey);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("Invalid keyfile %s: %s",
|
||||
filename, isc_result_totext(result));
|
||||
fatal("Invalid keyfile %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
if (!dst_key_isprivate(prevkey) && !dst_key_isexternal(prevkey))
|
||||
fatal("%s is not a private key", filename);
|
||||
|
||||
|
|
@ -537,7 +539,8 @@ main(int argc, char **argv) {
|
|||
dst_key_getprivateformat(prevkey, &major, &minor);
|
||||
if (major != DST_MAJOR_VERSION || minor < DST_MINOR_VERSION)
|
||||
fatal("Predecessor has incompatible format "
|
||||
"version %d.%d\n\t", major, minor);
|
||||
"version %d.%d\n\t",
|
||||
major, minor);
|
||||
|
||||
result = dst_key_gettime(prevkey, DST_TIME_ACTIVATE, &prevact);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
|
|
@ -545,8 +548,8 @@ main(int argc, char **argv) {
|
|||
"You must set one before\n\t"
|
||||
"generating a successor.");
|
||||
|
||||
result = dst_key_gettime(prevkey, DST_TIME_INACTIVE,
|
||||
&previnact);
|
||||
result =
|
||||
dst_key_gettime(prevkey, DST_TIME_INACTIVE, &previnact);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("Predecessor has no inactivation date. "
|
||||
"You must set one before\n\t"
|
||||
|
|
@ -565,16 +568,19 @@ main(int argc, char **argv) {
|
|||
|
||||
result = dst_key_gettime(prevkey, DST_TIME_DELETE, &prevdel);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fprintf(stderr, "%s: warning: Predecessor has no "
|
||||
"removal date;\n\t"
|
||||
"it will remain in the zone "
|
||||
"indefinitely after rollover.\n",
|
||||
program);
|
||||
fprintf(stderr,
|
||||
"%s: warning: Predecessor has no "
|
||||
"removal date;\n\t"
|
||||
"it will remain in the zone "
|
||||
"indefinitely after rollover.\n",
|
||||
program);
|
||||
else if (prevdel < previnact)
|
||||
fprintf(stderr, "%s: warning: Predecessor is "
|
||||
"scheduled to be deleted\n\t"
|
||||
"before it is scheduled to be "
|
||||
"inactive.\n", program);
|
||||
fprintf(stderr,
|
||||
"%s: warning: Predecessor is "
|
||||
"scheduled to be deleted\n\t"
|
||||
"before it is scheduled to be "
|
||||
"inactive.\n",
|
||||
program);
|
||||
|
||||
changed = setpub = setact = true;
|
||||
} else {
|
||||
|
|
@ -612,11 +618,11 @@ main(int argc, char **argv) {
|
|||
isc_result_totext(result));
|
||||
}
|
||||
|
||||
result = dst_key_fromnamedfile(filename, directory, options, mctx,
|
||||
&key);
|
||||
result =
|
||||
dst_key_fromnamedfile(filename, directory, options, mctx, &key);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("Invalid keyfile %s: %s",
|
||||
filename, isc_result_totext(result));
|
||||
fatal("Invalid keyfile %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
|
||||
if (!dst_key_isprivate(key) && !dst_key_isexternal(key))
|
||||
fatal("%s is not a private key", filename);
|
||||
|
|
@ -636,17 +642,17 @@ main(int argc, char **argv) {
|
|||
|
||||
prevdel = previnact = 0;
|
||||
if ((setdel && setinact && del < inact) ||
|
||||
(dst_key_gettime(key, DST_TIME_INACTIVE,
|
||||
&previnact) == ISC_R_SUCCESS &&
|
||||
(dst_key_gettime(key, DST_TIME_INACTIVE, &previnact) ==
|
||||
ISC_R_SUCCESS &&
|
||||
setdel && !setinact && !unsetinact && del < previnact) ||
|
||||
(dst_key_gettime(key, DST_TIME_DELETE,
|
||||
&prevdel) == ISC_R_SUCCESS &&
|
||||
(dst_key_gettime(key, DST_TIME_DELETE, &prevdel) == ISC_R_SUCCESS &&
|
||||
setinact && !setdel && !unsetdel && prevdel < inact) ||
|
||||
(!setdel && !unsetdel && !setinact && !unsetinact &&
|
||||
prevdel != 0 && prevdel < previnact))
|
||||
fprintf(stderr, "%s: warning: Key is scheduled to "
|
||||
"be deleted before it is\n\t"
|
||||
"scheduled to be inactive.\n",
|
||||
(!setdel && !unsetdel && !setinact && !unsetinact && prevdel != 0 &&
|
||||
prevdel < previnact))
|
||||
fprintf(stderr,
|
||||
"%s: warning: Key is scheduled to "
|
||||
"be deleted before it is\n\t"
|
||||
"scheduled to be inactive.\n",
|
||||
program);
|
||||
|
||||
if (force)
|
||||
|
|
@ -672,22 +678,25 @@ main(int argc, char **argv) {
|
|||
|
||||
if (setrev) {
|
||||
if ((dst_key_flags(key) & DNS_KEYFLAG_REVOKE) != 0)
|
||||
fprintf(stderr, "%s: warning: Key %s is already "
|
||||
"revoked; changing the revocation date "
|
||||
"will not affect this.\n",
|
||||
program, keystr);
|
||||
fprintf(stderr,
|
||||
"%s: warning: Key %s is already "
|
||||
"revoked; changing the revocation date "
|
||||
"will not affect this.\n",
|
||||
program, keystr);
|
||||
if ((dst_key_flags(key) & DNS_KEYFLAG_KSK) == 0)
|
||||
fprintf(stderr, "%s: warning: Key %s is not flagged as "
|
||||
"a KSK, but -R was used. Revoking a "
|
||||
"ZSK is legal, but undefined.\n",
|
||||
program, keystr);
|
||||
fprintf(stderr,
|
||||
"%s: warning: Key %s is not flagged as "
|
||||
"a KSK, but -R was used. Revoking a "
|
||||
"ZSK is legal, but undefined.\n",
|
||||
program, keystr);
|
||||
dst_key_settime(key, DST_TIME_REVOKE, rev);
|
||||
} else if (unsetrev) {
|
||||
if ((dst_key_flags(key) & DNS_KEYFLAG_REVOKE) != 0)
|
||||
fprintf(stderr, "%s: warning: Key %s is already "
|
||||
"revoked; removing the revocation date "
|
||||
"will not affect this.\n",
|
||||
program, keystr);
|
||||
fprintf(stderr,
|
||||
"%s: warning: Key %s is already "
|
||||
"revoked; removing the revocation date "
|
||||
"will not affect this.\n",
|
||||
program, keystr);
|
||||
dst_key_unsettime(key, DST_TIME_REVOKE);
|
||||
}
|
||||
|
||||
|
|
@ -811,12 +820,12 @@ main(int argc, char **argv) {
|
|||
printtime(key, DST_TIME_DELETE, "Delete", epoch, stdout);
|
||||
|
||||
if (printsyncadd)
|
||||
printtime(key, DST_TIME_SYNCPUBLISH, "SYNC Publish",
|
||||
epoch, stdout);
|
||||
printtime(key, DST_TIME_SYNCPUBLISH, "SYNC Publish", epoch,
|
||||
stdout);
|
||||
|
||||
if (printsyncdel)
|
||||
printtime(key, DST_TIME_SYNCDELETE, "SYNC Delete",
|
||||
epoch, stdout);
|
||||
printtime(key, DST_TIME_SYNCDELETE, "SYNC Delete", epoch,
|
||||
stdout);
|
||||
|
||||
if (changed) {
|
||||
writekey(key, directory, write_state);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -47,9 +47,9 @@
|
|||
#include <dns/nsec.h>
|
||||
#include <dns/nsec3.h>
|
||||
#include <dns/rdata.h>
|
||||
#include <dns/rdataclass.h>
|
||||
#include <dns/rdatalist.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/rdataclass.h>
|
||||
#include <dns/rdatasetiter.h>
|
||||
#include <dns/rdatastruct.h>
|
||||
#include <dns/rdatatype.h>
|
||||
|
|
@ -68,18 +68,19 @@
|
|||
|
||||
const char *program = "dnssec-verify";
|
||||
|
||||
static isc_stdtime_t now;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static isc_stdtime_t now;
|
||||
static isc_mem_t * mctx = NULL;
|
||||
static dns_masterformat_t inputformat = dns_masterformat_text;
|
||||
static dns_db_t *gdb; /* The database */
|
||||
static dns_dbversion_t *gversion; /* The database version */
|
||||
static dns_rdataclass_t gclass; /* The class */
|
||||
static dns_name_t *gorigin; /* The database origin */
|
||||
static bool ignore_kskflag = false;
|
||||
static bool keyset_kskonly = false;
|
||||
static dns_db_t * gdb; /* The database */
|
||||
static dns_dbversion_t * gversion; /* The database version */
|
||||
static dns_rdataclass_t gclass; /* The class */
|
||||
static dns_name_t * gorigin; /* The database origin */
|
||||
static bool ignore_kskflag = false;
|
||||
static bool keyset_kskonly = false;
|
||||
|
||||
static void
|
||||
report(const char *format, ...) {
|
||||
report(const char *format, ...)
|
||||
{
|
||||
if (!quiet) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
|
@ -92,12 +93,13 @@ report(const char *format, ...) {
|
|||
* Load the zone file from disk
|
||||
*/
|
||||
static void
|
||||
loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) {
|
||||
isc_buffer_t b;
|
||||
int len;
|
||||
loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db)
|
||||
{
|
||||
isc_buffer_t b;
|
||||
int len;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t *name;
|
||||
isc_result_t result;
|
||||
dns_name_t * name;
|
||||
isc_result_t result;
|
||||
|
||||
len = strlen(origin);
|
||||
isc_buffer_init(&b, origin, len);
|
||||
|
|
@ -106,11 +108,11 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) {
|
|||
name = dns_fixedname_initname(&fname);
|
||||
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("failed converting name '%s' to dns format: %s",
|
||||
origin, isc_result_totext(result));
|
||||
fatal("failed converting name '%s' to dns format: %s", origin,
|
||||
isc_result_totext(result));
|
||||
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, db);
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone, rdclass, 0,
|
||||
NULL, db);
|
||||
check_result(result, "dns_db_create()");
|
||||
|
||||
result = dns_db_load(*db, file, inputformat, 0);
|
||||
|
|
@ -131,8 +133,8 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) {
|
|||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
fatal("failed loading zone from '%s': %s",
|
||||
file, isc_result_totext(result));
|
||||
fatal("failed loading zone from '%s': %s", file,
|
||||
isc_result_totext(result));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +142,8 @@ ISC_PLATFORM_NORETURN_PRE static void
|
|||
usage(void) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, "\t%s [options] zonefile [keys]\n", program);
|
||||
|
||||
|
|
@ -159,8 +162,10 @@ usage(void) {
|
|||
fprintf(stderr, "\t-c class (IN)\n");
|
||||
fprintf(stderr, "\t-E engine:\n");
|
||||
#if USE_PKCS11
|
||||
fprintf(stderr, "\t\tpath to PKCS#11 provider library "
|
||||
"(default is %s)\n", PK11_LIB_LOCATION);
|
||||
fprintf(stderr,
|
||||
"\t\tpath to PKCS#11 provider library "
|
||||
"(default is %s)\n",
|
||||
PK11_LIB_LOCATION);
|
||||
#else
|
||||
fprintf(stderr, "\t\tname of an OpenSSL engine to use\n");
|
||||
#endif
|
||||
|
|
@ -171,19 +176,19 @@ usage(void) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
char *origin = NULL, *file = NULL;
|
||||
char *inputformatstr = NULL;
|
||||
isc_result_t result;
|
||||
isc_log_t *log = NULL;
|
||||
const char *engine = NULL;
|
||||
char *classname = NULL;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char * origin = NULL, *file = NULL;
|
||||
char * inputformatstr = NULL;
|
||||
isc_result_t result;
|
||||
isc_log_t * log = NULL;
|
||||
const char * engine = NULL;
|
||||
char * classname = NULL;
|
||||
dns_rdataclass_t rdclass;
|
||||
char *endp;
|
||||
int ch;
|
||||
char * endp;
|
||||
int ch;
|
||||
|
||||
#define CMDLINE_FLAGS \
|
||||
"c:E:hm:o:I:qv:Vxz"
|
||||
#define CMDLINE_FLAGS "c:E:hm:o:I:qv:Vxz"
|
||||
|
||||
/*
|
||||
* Process memory debugging argument first.
|
||||
|
|
@ -273,8 +278,8 @@ main(int argc, char *argv[]) {
|
|||
version(program);
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -326,9 +331,8 @@ main(int argc, char *argv[]) {
|
|||
result = dns_db_newversion(gdb, &gversion);
|
||||
check_result(result, "dns_db_newversion()");
|
||||
|
||||
result = dns_zoneverify_dnssec(NULL, gdb, gversion, gorigin, NULL,
|
||||
mctx, ignore_kskflag, keyset_kskonly,
|
||||
report);
|
||||
result = dns_zoneverify_dnssec(NULL, gdb, gversion, gorigin, NULL, mctx,
|
||||
ignore_kskflag, keyset_kskonly, report);
|
||||
|
||||
dns_db_closeversion(gdb, &gversion, false);
|
||||
dns_db_detach(&gdb);
|
||||
|
|
@ -339,7 +343,7 @@ main(int argc, char *argv[]) {
|
|||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_destroy(&mctx);
|
||||
|
||||
(void) isc_app_finish();
|
||||
(void)isc_app_finish();
|
||||
|
||||
return (result == ISC_R_SUCCESS ? 0 : 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@
|
|||
#include <dns/name.h>
|
||||
#include <dns/nsec.h>
|
||||
#include <dns/nsec3.h>
|
||||
#include <dns/rdatastruct.h>
|
||||
#include <dns/rdataclass.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/rdatasetiter.h>
|
||||
#include <dns/rdatastruct.h>
|
||||
#include <dns/rdatatype.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/secalg.h>
|
||||
|
|
@ -59,17 +59,21 @@
|
|||
|
||||
#define KEYSTATES_NVALUES 4
|
||||
static const char *keystates[KEYSTATES_NVALUES] = {
|
||||
"hidden", "rumoured", "omnipresent", "unretentive",
|
||||
"hidden",
|
||||
"rumoured",
|
||||
"omnipresent",
|
||||
"unretentive",
|
||||
};
|
||||
|
||||
int verbose = 0;
|
||||
bool quiet = false;
|
||||
int verbose = 0;
|
||||
bool quiet = false;
|
||||
uint8_t dtype[8];
|
||||
|
||||
static fatalcallback_t *fatalcallback = NULL;
|
||||
|
||||
void
|
||||
fatal(const char *format, ...) {
|
||||
fatal(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr, "%s: fatal: ", program);
|
||||
|
|
@ -83,18 +87,21 @@ fatal(const char *format, ...) {
|
|||
}
|
||||
|
||||
void
|
||||
setfatalcallback(fatalcallback_t *callback) {
|
||||
setfatalcallback(fatalcallback_t *callback)
|
||||
{
|
||||
fatalcallback = callback;
|
||||
}
|
||||
|
||||
void
|
||||
check_result(isc_result_t result, const char *message) {
|
||||
check_result(isc_result_t result, const char *message)
|
||||
{
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("%s: %s", message, isc_result_totext(result));
|
||||
}
|
||||
|
||||
void
|
||||
vbprintf(int level, const char *fmt, ...) {
|
||||
vbprintf(int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
if (level > verbose)
|
||||
return;
|
||||
|
|
@ -105,13 +112,15 @@ vbprintf(int level, const char *fmt, ...) {
|
|||
}
|
||||
|
||||
void
|
||||
version(const char *name) {
|
||||
version(const char *name)
|
||||
{
|
||||
fprintf(stderr, "%s %s\n", name, VERSION);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
sig_format(dns_rdata_rrsig_t *sig, char *cp, unsigned int size) {
|
||||
sig_format(dns_rdata_rrsig_t *sig, char *cp, unsigned int size)
|
||||
{
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
char algstr[DNS_NAME_FORMATSIZE];
|
||||
|
||||
|
|
@ -121,12 +130,13 @@ sig_format(dns_rdata_rrsig_t *sig, char *cp, unsigned int size) {
|
|||
}
|
||||
|
||||
void
|
||||
setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
|
||||
isc_result_t result;
|
||||
setup_logging(isc_mem_t *mctx, isc_log_t **logp)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
isc_log_t *log = NULL;
|
||||
int level;
|
||||
isc_logconfig_t * logconfig = NULL;
|
||||
isc_log_t * log = NULL;
|
||||
int level;
|
||||
|
||||
if (verbose < 0)
|
||||
verbose = 0;
|
||||
|
|
@ -163,21 +173,20 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
|
|||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
result = isc_log_createchannel(logconfig, "stderr",
|
||||
ISC_LOG_TOFILEDESC,
|
||||
level,
|
||||
&destination,
|
||||
ISC_LOG_PRINTTAG|ISC_LOG_PRINTLEVEL);
|
||||
result = isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
|
||||
level, &destination,
|
||||
ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL);
|
||||
check_result(result, "isc_log_createchannel()");
|
||||
|
||||
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr",
|
||||
NULL, NULL) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
*logp = log;
|
||||
}
|
||||
|
||||
void
|
||||
cleanup_logging(isc_log_t **logp) {
|
||||
cleanup_logging(isc_log_t **logp)
|
||||
{
|
||||
isc_log_t *log;
|
||||
|
||||
REQUIRE(logp != NULL);
|
||||
|
|
@ -194,53 +203,66 @@ cleanup_logging(isc_log_t **logp) {
|
|||
}
|
||||
|
||||
static isc_stdtime_t
|
||||
time_units(isc_stdtime_t offset, char *suffix, const char *str) {
|
||||
time_units(isc_stdtime_t offset, char *suffix, const char *str)
|
||||
{
|
||||
switch (suffix[0]) {
|
||||
case 'Y': case 'y':
|
||||
case 'Y':
|
||||
case 'y':
|
||||
return (offset * (365 * 24 * 3600));
|
||||
case 'M': case 'm':
|
||||
case 'M':
|
||||
case 'm':
|
||||
switch (suffix[1]) {
|
||||
case 'O': case 'o':
|
||||
case 'O':
|
||||
case 'o':
|
||||
return (offset * (30 * 24 * 3600));
|
||||
case 'I': case 'i':
|
||||
case 'I':
|
||||
case 'i':
|
||||
return (offset * 60);
|
||||
case '\0':
|
||||
case '\0':
|
||||
fatal("'%s' ambiguous: use 'mi' for minutes "
|
||||
"or 'mo' for months", str);
|
||||
default:
|
||||
"or 'mo' for months",
|
||||
str);
|
||||
default:
|
||||
fatal("time value %s is invalid", str);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
case 'W': case 'w':
|
||||
case 'W':
|
||||
case 'w':
|
||||
return (offset * (7 * 24 * 3600));
|
||||
case 'D': case 'd':
|
||||
case 'D':
|
||||
case 'd':
|
||||
return (offset * (24 * 3600));
|
||||
case 'H': case 'h':
|
||||
case 'H':
|
||||
case 'h':
|
||||
return (offset * 3600);
|
||||
case 'S': case 's': case '\0':
|
||||
case 'S':
|
||||
case 's':
|
||||
case '\0':
|
||||
return (offset);
|
||||
default:
|
||||
default:
|
||||
fatal("time value %s is invalid", str);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
return(0); /* silence compiler warning */
|
||||
return (0); /* silence compiler warning */
|
||||
}
|
||||
|
||||
static inline bool
|
||||
isnone(const char *str) {
|
||||
isnone(const char *str)
|
||||
{
|
||||
return ((strcasecmp(str, "none") == 0) ||
|
||||
(strcasecmp(str, "never") == 0));
|
||||
}
|
||||
|
||||
dns_ttl_t
|
||||
strtottl(const char *str) {
|
||||
strtottl(const char *str)
|
||||
{
|
||||
const char *orig = str;
|
||||
dns_ttl_t ttl;
|
||||
char *endp;
|
||||
dns_ttl_t ttl;
|
||||
char * endp;
|
||||
|
||||
if (isnone(str))
|
||||
return ((dns_ttl_t) 0);
|
||||
return ((dns_ttl_t)0);
|
||||
|
||||
ttl = strtol(str, &endp, 0);
|
||||
if (ttl == 0 && endp == str)
|
||||
|
|
@ -250,7 +272,8 @@ strtottl(const char *str) {
|
|||
}
|
||||
|
||||
dst_key_state_t
|
||||
strtokeystate(const char *str) {
|
||||
strtokeystate(const char *str)
|
||||
{
|
||||
if (isnone(str)) {
|
||||
return (DST_KEY_STATE_NA);
|
||||
}
|
||||
|
|
@ -258,33 +281,32 @@ strtokeystate(const char *str) {
|
|||
for (int i = 0; i < KEYSTATES_NVALUES; i++) {
|
||||
if (keystates[i] != NULL &&
|
||||
strcasecmp(str, keystates[i]) == 0) {
|
||||
return (dst_key_state_t) i;
|
||||
return (dst_key_state_t)i;
|
||||
}
|
||||
}
|
||||
fatal("unknown key state");
|
||||
}
|
||||
|
||||
isc_stdtime_t
|
||||
strtotime(const char *str, int64_t now, int64_t base,
|
||||
bool *setp)
|
||||
strtotime(const char *str, int64_t now, int64_t base, bool *setp)
|
||||
{
|
||||
int64_t val, offset;
|
||||
int64_t val, offset;
|
||||
isc_result_t result;
|
||||
const char *orig = str;
|
||||
char *endp;
|
||||
size_t n;
|
||||
const char * orig = str;
|
||||
char * endp;
|
||||
size_t n;
|
||||
|
||||
if (isnone(str)) {
|
||||
if (setp != NULL)
|
||||
*setp = false;
|
||||
return ((isc_stdtime_t) 0);
|
||||
return ((isc_stdtime_t)0);
|
||||
}
|
||||
|
||||
if (setp != NULL)
|
||||
*setp = true;
|
||||
|
||||
if ((str[0] == '0' || str[0] == '-') && str[1] == '\0')
|
||||
return ((isc_stdtime_t) 0);
|
||||
return ((isc_stdtime_t)0);
|
||||
|
||||
/*
|
||||
* We accept times in the following formats:
|
||||
|
|
@ -295,8 +317,7 @@ strtotime(const char *str, int64_t now, int64_t base,
|
|||
*/
|
||||
n = strspn(str, "0123456789");
|
||||
if ((n == 8u || n == 14u) &&
|
||||
(str[n] == '\0' || str[n] == '-' || str[n] == '+'))
|
||||
{
|
||||
(str[n] == '\0' || str[n] == '-' || str[n] == '+')) {
|
||||
char timestr[15];
|
||||
|
||||
strlcpy(timestr, str, sizeof(timestr));
|
||||
|
|
@ -315,26 +336,27 @@ strtotime(const char *str, int64_t now, int64_t base,
|
|||
}
|
||||
|
||||
if (str[0] == '\0')
|
||||
return ((isc_stdtime_t) base);
|
||||
return ((isc_stdtime_t)base);
|
||||
else if (str[0] == '+') {
|
||||
offset = strtol(str + 1, &endp, 0);
|
||||
offset = time_units((isc_stdtime_t) offset, endp, orig);
|
||||
offset = time_units((isc_stdtime_t)offset, endp, orig);
|
||||
val = base + offset;
|
||||
} else if (str[0] == '-') {
|
||||
offset = strtol(str + 1, &endp, 0);
|
||||
offset = time_units((isc_stdtime_t) offset, endp, orig);
|
||||
offset = time_units((isc_stdtime_t)offset, endp, orig);
|
||||
val = base - offset;
|
||||
} else
|
||||
fatal("time value %s is invalid", orig);
|
||||
|
||||
return ((isc_stdtime_t) val);
|
||||
return ((isc_stdtime_t)val);
|
||||
}
|
||||
|
||||
dns_rdataclass_t
|
||||
strtoclass(const char *str) {
|
||||
strtoclass(const char *str)
|
||||
{
|
||||
isc_textregion_t r;
|
||||
dns_rdataclass_t rdclass;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
if (str == NULL)
|
||||
return dns_rdataclass_in;
|
||||
|
|
@ -347,10 +369,11 @@ strtoclass(const char *str) {
|
|||
}
|
||||
|
||||
unsigned int
|
||||
strtodsdigest(const char *str) {
|
||||
strtodsdigest(const char *str)
|
||||
{
|
||||
isc_textregion_t r;
|
||||
dns_dsdigest_t alg;
|
||||
isc_result_t result;
|
||||
dns_dsdigest_t alg;
|
||||
isc_result_t result;
|
||||
|
||||
DE_CONST(str, r.base);
|
||||
r.length = strlen(str);
|
||||
|
|
@ -361,25 +384,27 @@ strtodsdigest(const char *str) {
|
|||
}
|
||||
|
||||
static int
|
||||
cmp_dtype(const void *ap, const void *bp) {
|
||||
cmp_dtype(const void *ap, const void *bp)
|
||||
{
|
||||
int a = *(const uint8_t *)ap;
|
||||
int b = *(const uint8_t *)bp;
|
||||
return (a - b);
|
||||
}
|
||||
|
||||
void
|
||||
add_dtype(unsigned int dt) {
|
||||
add_dtype(unsigned int dt)
|
||||
{
|
||||
unsigned i, n;
|
||||
|
||||
/* ensure there is space for a zero terminator */
|
||||
n = sizeof(dtype)/sizeof(dtype[0]) - 1;
|
||||
n = sizeof(dtype) / sizeof(dtype[0]) - 1;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (dtype[i] == dt) {
|
||||
return;
|
||||
}
|
||||
if (dtype[i] == 0) {
|
||||
dtype[i] = dt;
|
||||
qsort(dtype, i+1, 1, cmp_dtype);
|
||||
qsort(dtype, i + 1, 1, cmp_dtype);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -387,9 +412,10 @@ add_dtype(unsigned int dt) {
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
try_dir(const char *dirname) {
|
||||
try_dir(const char *dirname)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_dir_t d;
|
||||
isc_dir_t d;
|
||||
|
||||
isc_dir_init(&d);
|
||||
result = isc_dir_open(&d, dirname);
|
||||
|
|
@ -403,7 +429,8 @@ try_dir(const char *dirname) {
|
|||
* Check private key version compatibility.
|
||||
*/
|
||||
void
|
||||
check_keyversion(dst_key_t *key, char *keystr) {
|
||||
check_keyversion(dst_key_t *key, char *keystr)
|
||||
{
|
||||
int major, minor;
|
||||
dst_key_getprivateformat(key, &major, &minor);
|
||||
INSIST(major <= DST_MAJOR_VERSION); /* invalid private key */
|
||||
|
|
@ -419,7 +446,8 @@ check_keyversion(dst_key_t *key, char *keystr) {
|
|||
}
|
||||
|
||||
void
|
||||
set_keyversion(dst_key_t *key) {
|
||||
set_keyversion(dst_key_t *key)
|
||||
{
|
||||
int major, minor;
|
||||
dst_key_getprivateformat(key, &major, &minor);
|
||||
INSIST(major <= DST_MAJOR_VERSION);
|
||||
|
|
@ -443,16 +471,16 @@ bool
|
|||
key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
|
||||
isc_mem_t *mctx, bool *exact)
|
||||
{
|
||||
isc_result_t result;
|
||||
bool conflict = false;
|
||||
isc_result_t result;
|
||||
bool conflict = false;
|
||||
dns_dnsseckeylist_t matchkeys;
|
||||
dns_dnsseckey_t *key = NULL;
|
||||
uint16_t id, oldid;
|
||||
uint32_t rid, roldid;
|
||||
dns_secalg_t alg;
|
||||
char filename[NAME_MAX];
|
||||
isc_buffer_t fileb;
|
||||
isc_stdtime_t now;
|
||||
dns_dnsseckey_t * key = NULL;
|
||||
uint16_t id, oldid;
|
||||
uint32_t rid, roldid;
|
||||
dns_secalg_t alg;
|
||||
char filename[NAME_MAX];
|
||||
isc_buffer_t fileb;
|
||||
isc_stdtime_t now;
|
||||
|
||||
if (exact != NULL)
|
||||
*exact = false;
|
||||
|
|
@ -468,8 +496,8 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
|
|||
*/
|
||||
if (alg == DST_ALG_DH) {
|
||||
isc_buffer_init(&fileb, filename, sizeof(filename));
|
||||
result = dst_key_buildfilename(dstkey, DST_TYPE_PRIVATE,
|
||||
dir, &fileb);
|
||||
result = dst_key_buildfilename(dstkey, DST_TYPE_PRIVATE, dir,
|
||||
&fileb);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (true);
|
||||
return (isc_file_exists(filename));
|
||||
|
|
@ -493,7 +521,8 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
|
|||
conflict = true;
|
||||
if (id != oldid) {
|
||||
if (verbose > 1)
|
||||
fprintf(stderr, "Key ID %d could "
|
||||
fprintf(stderr,
|
||||
"Key ID %d could "
|
||||
"collide with %d\n",
|
||||
id, oldid);
|
||||
} else {
|
||||
|
|
@ -505,7 +534,7 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
|
|||
}
|
||||
}
|
||||
|
||||
next:
|
||||
next:
|
||||
ISC_LIST_UNLINK(matchkeys, key, link);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
}
|
||||
|
|
@ -521,7 +550,8 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir,
|
|||
}
|
||||
|
||||
bool
|
||||
isoptarg(const char *arg, char **argv, void(*usage)(void)) {
|
||||
isoptarg(const char *arg, char **argv, void (*usage)(void))
|
||||
{
|
||||
if (!strcasecmp(isc_commandline_argument, arg)) {
|
||||
if (argv[isc_commandline_index] == NULL) {
|
||||
fprintf(stderr, "%s: missing argument -%c %s\n",
|
||||
|
|
@ -539,14 +569,15 @@ isoptarg(const char *arg, char **argv, void(*usage)(void)) {
|
|||
|
||||
#ifdef _WIN32
|
||||
void
|
||||
InitSockets(void) {
|
||||
WORD wVersionRequested;
|
||||
InitSockets(void)
|
||||
{
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
int err;
|
||||
|
||||
wVersionRequested = MAKEWORD(2, 0);
|
||||
|
||||
err = WSAStartup( wVersionRequested, &wsaData );
|
||||
err = WSAStartup(wVersionRequested, &wsaData);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup() failed: %d\n", err);
|
||||
exit(1);
|
||||
|
|
@ -554,7 +585,8 @@ InitSockets(void) {
|
|||
}
|
||||
|
||||
void
|
||||
DestroySockets(void) {
|
||||
DestroySockets(void)
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DNSSECTOOL_H
|
||||
#define DNSSECTOOL_H 1
|
||||
|
||||
|
|
@ -19,11 +18,14 @@
|
|||
#include <isc/log.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/stdtime.h>
|
||||
|
||||
#include <dns/rdatastruct.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
|
||||
/*! verbosity: set by -v and -q option in each program, defined in dnssectool.c */
|
||||
extern int verbose;
|
||||
/*! verbosity: set by -v and -q option in each program, defined in dnssectool.c
|
||||
*/
|
||||
extern int verbose;
|
||||
extern bool quiet;
|
||||
|
||||
/*! program name, statically initialized in each program */
|
||||
|
|
@ -38,11 +40,11 @@ extern const char *program;
|
|||
*/
|
||||
extern uint8_t dtype[8];
|
||||
|
||||
typedef void (fatalcallback_t)(void);
|
||||
typedef void(fatalcallback_t)(void);
|
||||
|
||||
ISC_PLATFORM_NORETURN_PRE void
|
||||
fatal(const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
void
|
||||
setfatalcallback(fatalcallback_t *callback);
|
||||
|
|
@ -58,7 +60,8 @@ version(const char *program) ISC_PLATFORM_NORETURN_POST;
|
|||
|
||||
void
|
||||
sig_format(dns_rdata_rrsig_t *sig, char *cp, unsigned int size);
|
||||
#define SIG_FORMATSIZE (DNS_NAME_FORMATSIZE + DNS_SECALG_FORMATSIZE + sizeof("65535"))
|
||||
#define SIG_FORMATSIZE \
|
||||
(DNS_NAME_FORMATSIZE + DNS_SECALG_FORMATSIZE + sizeof("65535"))
|
||||
|
||||
void
|
||||
setup_logging(isc_mem_t *mctx, isc_log_t **logp);
|
||||
|
|
@ -66,13 +69,14 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp);
|
|||
void
|
||||
cleanup_logging(isc_log_t **logp);
|
||||
|
||||
dns_ttl_t strtottl(const char *str);
|
||||
dns_ttl_t
|
||||
strtottl(const char *str);
|
||||
|
||||
dst_key_state_t strtokeystate(const char *str);
|
||||
dst_key_state_t
|
||||
strtokeystate(const char *str);
|
||||
|
||||
isc_stdtime_t
|
||||
strtotime(const char *str, int64_t now, int64_t base,
|
||||
bool *setp);
|
||||
strtotime(const char *str, int64_t now, int64_t base, bool *setp);
|
||||
|
||||
dns_rdataclass_t
|
||||
strtoclass(const char *str);
|
||||
|
|
@ -100,8 +104,10 @@ bool
|
|||
isoptarg(const char *arg, char **argv, void (*usage)(void));
|
||||
|
||||
#ifdef _WIN32
|
||||
void InitSockets(void);
|
||||
void DestroySockets(void);
|
||||
void
|
||||
InitSockets(void);
|
||||
void
|
||||
DestroySockets(void);
|
||||
#endif
|
||||
|
||||
#endif /* DNSSEC_DNSSECTOOL_H */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Generated by convertxsl.pl 1.14 2008/07/17 23:43:26 jinmei Exp
|
||||
* Generated by convertxsl.pl 1.14 2008/07/17 23:43:26 jinmei Exp
|
||||
* From unknown
|
||||
*/
|
||||
static char xslmsg[] =
|
||||
|
|
@ -7,26 +7,34 @@ static char xslmsg[] =
|
|||
"<!--\n"
|
||||
" - Copyright (C) Internet Systems Consortium, Inc. (\"ISC\")\n"
|
||||
" -\n"
|
||||
" - This Source Code Form is subject to the terms of the Mozilla Public\n"
|
||||
" - License, v. 2.0. If a copy of the MPL was not distributed with this\n"
|
||||
" - This Source Code Form is subject to the terms of the Mozilla "
|
||||
"Public\n"
|
||||
" - License, v. 2.0. If a copy of the MPL was not distributed with "
|
||||
"this\n"
|
||||
" - file, You can obtain one at http://mozilla.org/MPL/2.0/.\n"
|
||||
" -\n"
|
||||
" - See the COPYRIGHT file distributed with this work for additional\n"
|
||||
" - information regarding copyright ownership.\n"
|
||||
"-->\n"
|
||||
"\n"
|
||||
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns=\"http://www.w3.org/1999/xhtml\" version=\"1.0\">\n"
|
||||
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" "
|
||||
"xmlns=\"http://www.w3.org/1999/xhtml\" version=\"1.0\">\n"
|
||||
" <xsl:output method=\"html\" indent=\"yes\" version=\"4.0\"/>\n"
|
||||
" <xsl:template match=\"statistics[@version="3.11"]\">\n"
|
||||
" <html>\n"
|
||||
" <head>\n"
|
||||
" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js\"></script>\n"
|
||||
" <script type=\"text/javascript\" "
|
||||
"src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/"
|
||||
"jquery.min.js\"></script>\n"
|
||||
" <script type=\"text/javascript\">\n"
|
||||
" $(function($) {\n"
|
||||
" var wid=0;\n"
|
||||
" $('table.zones').each(function(i) { if( $(this).width() > wid ) wid = $(this).width(); return true; });\n"
|
||||
" $('table.zones').each(function(i) { if( $(this).width() > wid ) wid "
|
||||
"= $(this).width(); return true; });\n"
|
||||
" $('table.zones').css('min-width', wid );\n"
|
||||
" $(\"h2+table,h3+table,h4+table,h2+div,h3+div,h2+script,h3+script\").prev().append(' <a class=\"tabletoggle\" href=\"#\" style=\"font-size:small\">Show/Hide</a>');\n"
|
||||
" $(\"h2+table,h3+table,h4+table,h2+div,h3+div,h2+script,h3+script\")."
|
||||
"prev().append(' <a class=\"tabletoggle\" href=\"#\" "
|
||||
"style=\"font-size:small\">Show/Hide</a>');\n"
|
||||
" $(\".tabletoggle\").click(function(){\n"
|
||||
" var n = $(this).closest(\"h2,h3,h4\").next();\n"
|
||||
" if (n.is(\"script\")) { n = n.next(); }\n"
|
||||
|
|
@ -39,7 +47,8 @@ static char xslmsg[] =
|
|||
"\n"
|
||||
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
|
||||
" <!-- Non Mozilla specific markup -->\n"
|
||||
" <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"/>\n"
|
||||
" <script type=\"text/javascript\" "
|
||||
"src=\"https://www.google.com/jsapi\"/>\n"
|
||||
" <script type=\"text/javascript\">\n"
|
||||
"\n"
|
||||
" google.load(\"visualization\", \"1\", {packages:[\"corechart\"]});\n"
|
||||
|
|
@ -56,10 +65,12 @@ static char xslmsg[] =
|
|||
"\n"
|
||||
" var chart;\n"
|
||||
" if (style == \"barchart\") {\n"
|
||||
" chart = new google.visualization.BarChart(document.getElementById(target));\n"
|
||||
" chart = new "
|
||||
"google.visualization.BarChart(document.getElementById(target));\n"
|
||||
" chart.draw(data, options);\n"
|
||||
" } else if (style == \"piechart\") {\n"
|
||||
" chart = new google.visualization.PieChart(document.getElementById(target));\n"
|
||||
" chart = new "
|
||||
"google.visualization.PieChart(document.getElementById(target));\n"
|
||||
" chart.draw(data, options);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
|
|
@ -81,7 +92,10 @@ static char xslmsg[] =
|
|||
" 'title' : \"Server Incoming Query Types\",\n"
|
||||
" 'target': 'chart_incoming_qtypes',\n"
|
||||
" 'style': 'barchart',\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each select=\"server/counters[@type="qtype"]/counter\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each "
|
||||
"select=\"server/counters[@type="qtype"]/"
|
||||
"counter\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of "
|
||||
"select=\".\"/>],</xsl:for-each>]\n"
|
||||
" });\n"
|
||||
" </xsl:if>\n"
|
||||
"\n"
|
||||
|
|
@ -91,7 +105,11 @@ static char xslmsg[] =
|
|||
" 'title' : \"Server Incoming Requests by DNS Opcode\",\n"
|
||||
" 'target': 'chart_incoming_opcodes',\n"
|
||||
" 'style': 'barchart',\n"
|
||||
" 'data': [['Opcode','Counter'],<xsl:for-each select=\"server/counters[@type="opcode"]/counter[. > 0 or substring(@name,1,3) != 'RES']\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]});\n"
|
||||
" 'data': [['Opcode','Counter'],<xsl:for-each "
|
||||
"select=\"server/counters[@type="opcode"]/counter[. > 0 "
|
||||
"or substring(@name,1,3) != 'RES']\">['<xsl:value-of "
|
||||
"select=\"@name\"/>',<xsl:value-of "
|
||||
"select=\".\"/>],</xsl:for-each>]});\n"
|
||||
" </xsl:if>\n"
|
||||
" </script>\n"
|
||||
" </xsl:if>\n"
|
||||
|
|
@ -361,7 +379,8 @@ static char xslmsg[] =
|
|||
" </tr>\n"
|
||||
" </table>\n"
|
||||
" <br/>\n"
|
||||
" <xsl:if test=\"server/counters[@type="opcode"]/counter[. > 0]\">\n"
|
||||
" <xsl:if test=\"server/counters[@type="opcode"]/counter[. "
|
||||
"> 0]\">\n"
|
||||
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
|
||||
" <h2>Incoming Requests by DNS Opcode</h2>\n"
|
||||
" <!-- Non Mozilla specific markup -->\n"
|
||||
|
|
@ -370,7 +389,9 @@ static char xslmsg[] =
|
|||
" </div>\n"
|
||||
" </xsl:if>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"server/counters[@type="opcode"]/counter[. > 0 or substring(@name,1,3) != 'RES']\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"server/counters[@type="opcode"]/counter[. > 0 "
|
||||
"or substring(@name,1,3) != 'RES']\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class0\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -390,7 +411,8 @@ static char xslmsg[] =
|
|||
" <tr>\n"
|
||||
" <th class=\"totals\">Total:</th>\n"
|
||||
" <td class=\"totals\">\n"
|
||||
" <xsl:value-of select=\"sum(server/counters[@type="opcode"]/counter)\"/>\n"
|
||||
" <xsl:value-of "
|
||||
"select=\"sum(server/counters[@type="opcode"]/counter)\"/>\n"
|
||||
" </td>\n"
|
||||
" </tr>\n"
|
||||
" </table>\n"
|
||||
|
|
@ -405,7 +427,8 @@ static char xslmsg[] =
|
|||
" </div>\n"
|
||||
" </xsl:if>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"server/counters[@type="qtype"]/counter\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"server/counters[@type="qtype"]/counter\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -425,33 +448,45 @@ static char xslmsg[] =
|
|||
" <tr>\n"
|
||||
" <th class=\"totals\">Total:</th>\n"
|
||||
" <td class=\"totals\">\n"
|
||||
" <xsl:value-of select=\"sum(server/counters[@type="qtype"]/counter)\"/>\n"
|
||||
" <xsl:value-of "
|
||||
"select=\"sum(server/counters[@type="qtype"]/counter)\"/>\n"
|
||||
" </td>\n"
|
||||
" </tr>\n"
|
||||
" </table>\n"
|
||||
" <br/>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"views/view[count(counters[@type="resqtype"]/counter) > 0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"views/view[count(counters[@type="resqtype"]/counter) "
|
||||
"> 0]\">\n"
|
||||
" <h2>Outgoing Queries per view</h2>\n"
|
||||
" <xsl:for-each select=\"views/view[count(counters[@type="resqtype"]/counter) > 0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"views/view[count(counters[@type="resqtype"]/"
|
||||
"counter) > 0]\">\n"
|
||||
" <h3>View <xsl:value-of select=\"@name\"/></h3>\n"
|
||||
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
|
||||
" <!-- Non Mozilla specific markup -->\n"
|
||||
" <script type=\"text/javascript\">\n"
|
||||
" graphs.push({\n"
|
||||
" 'title': \"Outgoing Queries for view: <xsl:value-of select=\"@name\"/>\",\n"
|
||||
" 'target': 'chart_outgoing_queries_view_<xsl:value-of select=\"@name\"/>',\n"
|
||||
" 'title': \"Outgoing Queries for view: <xsl:value-of "
|
||||
"select=\"@name\"/>\",\n"
|
||||
" 'target': 'chart_outgoing_queries_view_<xsl:value-of "
|
||||
"select=\"@name\"/>',\n"
|
||||
" 'style': 'barchart',\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each select=\"counters[@type="resqtype"]/counter\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each "
|
||||
"select=\"counters[@type="resqtype"]/"
|
||||
"counter\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of "
|
||||
"select=\".\"/>],</xsl:for-each>]\n"
|
||||
" });\n"
|
||||
" </script>\n"
|
||||
" <xsl:variable name=\"target\">\n"
|
||||
" <xsl:value-of select=\"@name\"/>\n"
|
||||
" </xsl:variable>\n"
|
||||
" <div class=\"pie\" id=\"chart_outgoing_queries_view_{$target}\">[no data to display]</div>\n"
|
||||
" <div class=\"pie\" id=\"chart_outgoing_queries_view_{$target}\">[no "
|
||||
"data to display]</div>\n"
|
||||
" </xsl:if>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"counters[@type="resqtype"]/counter\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"counters[@type="resqtype"]/counter\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class1\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -472,7 +507,8 @@ static char xslmsg[] =
|
|||
" <br/>\n"
|
||||
" </xsl:for-each>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"server/counters[@type="nsstat"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"server/counters[@type="nsstat"]/counter[.>0]\">\n"
|
||||
" <h2>Server Statistics</h2>\n"
|
||||
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
|
||||
" <!-- Non Mozilla specific markup -->\n"
|
||||
|
|
@ -481,13 +517,19 @@ static char xslmsg[] =
|
|||
" 'title' : \"Server Counters\",\n"
|
||||
" 'target': 'chart_server_nsstat_restype',\n"
|
||||
" 'style': 'barchart',\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each select=\"server/counters[@type="nsstat"]/counter[.>0]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each "
|
||||
"select=\"server/counters[@type="nsstat"]/"
|
||||
"counter[.>0]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of "
|
||||
"select=\".\"/>],</xsl:for-each>]\n"
|
||||
" });\n"
|
||||
" </script>\n"
|
||||
" <div class=\"pie\" id=\"chart_server_nsstat_restype\">[no data to display]</div>\n"
|
||||
" <div class=\"pie\" id=\"chart_server_nsstat_restype\">[no data to "
|
||||
"display]</div>\n"
|
||||
" </xsl:if>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"server/counters[@type="nsstat"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"server/counters[@type="nsstat"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class2\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -507,7 +549,9 @@ static char xslmsg[] =
|
|||
" </table>\n"
|
||||
" <br/>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"server/counters[@type="zonestat"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"server/counters[@type="zonestat"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
|
||||
" <h2>Zone Maintenance Statistics</h2>\n"
|
||||
" <script type=\"text/javascript\">\n"
|
||||
|
|
@ -515,14 +559,19 @@ static char xslmsg[] =
|
|||
" 'title' : \"Zone Maintenance Stats\",\n"
|
||||
" 'target': 'chart_server_zone_maint',\n"
|
||||
" 'style': 'barchart',\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each select=\"server/counters[@type="zonestat"]/counter[.>0]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each "
|
||||
"select=\"server/counters[@type="zonestat"]/"
|
||||
"counter[.>0]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of "
|
||||
"select=\".\"/>],</xsl:for-each>]\n"
|
||||
" });\n"
|
||||
" </script>\n"
|
||||
" <!-- Non Mozilla specific markup -->\n"
|
||||
" <div class=\"pie\" id=\"chart_server_zone_maint\">[no data to display]</div>\n"
|
||||
" <div class=\"pie\" id=\"chart_server_zone_maint\">[no data to "
|
||||
"display]</div>\n"
|
||||
" </xsl:if>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"server/counters[@type="zonestat"]/counter\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"server/counters[@type="zonestat"]/counter\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class3\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -541,10 +590,12 @@ static char xslmsg[] =
|
|||
" </xsl:for-each>\n"
|
||||
" </table>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"server/counters[@type="resstat"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"server/counters[@type="resstat"]/counter[.>0]\">\n"
|
||||
" <h2>Resolver Statistics (Common)</h2>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"server/counters[@type="resstat"]/counter\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"server/counters[@type="resstat"]/counter\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class4\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -564,10 +615,13 @@ static char xslmsg[] =
|
|||
" </table>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:for-each select=\"views/view\">\n"
|
||||
" <xsl:if test=\"counters[@type="resstats"]/counter[.>0]\">\n"
|
||||
" <h3>Resolver Statistics for View <xsl:value-of select=\"@name\"/></h3>\n"
|
||||
" <xsl:if "
|
||||
"test=\"counters[@type="resstats"]/counter[.>0]\">\n"
|
||||
" <h3>Resolver Statistics for View <xsl:value-of "
|
||||
"select=\"@name\"/></h3>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"counters[@type="resstats"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"counters[@type="resstats"]/counter[.>0]\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class5\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -588,10 +642,12 @@ static char xslmsg[] =
|
|||
" </xsl:if>\n"
|
||||
" </xsl:for-each>\n"
|
||||
" <xsl:for-each select=\"views/view\">\n"
|
||||
" <xsl:if test=\"counters[@type="adbstat"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"counters[@type="adbstat"]/counter[.>0]\">\n"
|
||||
" <h3>ADB Statistics for View <xsl:value-of select=\"@name\"/></h3>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"counters[@type="adbstat"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"counters[@type="adbstat"]/counter[.>0]\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class5\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -612,10 +668,12 @@ static char xslmsg[] =
|
|||
" </xsl:if>\n"
|
||||
" </xsl:for-each>\n"
|
||||
" <xsl:for-each select=\"views/view\">\n"
|
||||
" <xsl:if test=\"counters[@type="cachestats"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"counters[@type="cachestats"]/counter[.>0]\">\n"
|
||||
" <h3>Cache Statistics for View <xsl:value-of select=\"@name\"/></h3>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"counters[@type="cachestats"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"counters[@type="cachestats"]/counter[.>0]\">\n"
|
||||
" <xsl:sort select=\".\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class5\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -659,13 +717,25 @@ static char xslmsg[] =
|
|||
" <br/>\n"
|
||||
" </xsl:if>\n"
|
||||
" </xsl:for-each>\n"
|
||||
" <xsl:if test=\"traffic//udp/counters[@type="request-size"]/counter[.>0] or traffic//udp/counters[@type="response-size"]/counter[.>0] or traffic//tcp/counters[@type="request-size"]/counter[.>0] or traffic//tcp/counters[@type="response-size"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"traffic//udp/counters[@type="request-size"]/"
|
||||
"counter[.>0] or "
|
||||
"traffic//udp/counters[@type="response-size"]/"
|
||||
"counter[.>0] or "
|
||||
"traffic//tcp/counters[@type="request-size"]/counter[.>0] "
|
||||
"or "
|
||||
"traffic//tcp/counters[@type="response-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <h2>Traffic Size Statistics</h2>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"traffic//udp/counters[@type="request-size"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"traffic//udp/counters[@type="request-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <h4>UDP Requests Received</h4>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"traffic//udp/counters[@type="request-size"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"traffic//udp/counters[@type="request-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <xsl:variable name=\"css-class7\">\n"
|
||||
" <xsl:choose>\n"
|
||||
" <xsl:when test=\"position() mod 2 = 0\">even</xsl:when>\n"
|
||||
|
|
@ -685,10 +755,14 @@ static char xslmsg[] =
|
|||
" </table>\n"
|
||||
" <br/>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"traffic//udp/counters[@type="response-size"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"traffic//udp/counters[@type="response-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <h4>UDP Responses Sent</h4>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"traffic//udp/counters[@type="response-size"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"traffic//udp/counters[@type="response-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <xsl:variable name=\"css-class7\">\n"
|
||||
" <xsl:choose>\n"
|
||||
" <xsl:when test=\"position() mod 2 = 0\">even</xsl:when>\n"
|
||||
|
|
@ -708,10 +782,14 @@ static char xslmsg[] =
|
|||
" </table>\n"
|
||||
" <br/>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"traffic//tcp/counters[@type="request-size"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"traffic//tcp/counters[@type="request-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <h4>TCP Requests Received</h4>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"traffic//tcp/counters[@type="request-size"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"traffic//tcp/counters[@type="request-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <xsl:variable name=\"css-class7\">\n"
|
||||
" <xsl:choose>\n"
|
||||
" <xsl:when test=\"position() mod 2 = 0\">even</xsl:when>\n"
|
||||
|
|
@ -731,10 +809,14 @@ static char xslmsg[] =
|
|||
" </table>\n"
|
||||
" <br/>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"traffic//tcp/counters[@type="response-size"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"traffic//tcp/counters[@type="response-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <h4>TCP Responses Sent</h4>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"traffic//tcp/counters[@type="response-size"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"traffic//tcp/counters[@type="response-size"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <xsl:variable name=\"css-class7\">\n"
|
||||
" <xsl:choose>\n"
|
||||
" <xsl:when test=\"position() mod 2 = 0\">even</xsl:when>\n"
|
||||
|
|
@ -754,10 +836,14 @@ static char xslmsg[] =
|
|||
" </table>\n"
|
||||
" <br/>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"server/counters[@type="sockstat"]/counter[.>0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"server/counters[@type="sockstat"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <h2>Socket I/O Statistics</h2>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"server/counters[@type="sockstat"]/counter[.>0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"server/counters[@type="sockstat"]/"
|
||||
"counter[.>0]\">\n"
|
||||
" <xsl:variable name=\"css-class7\">\n"
|
||||
" <xsl:choose>\n"
|
||||
" <xsl:when test=\"position() mod 2 = 0\">even</xsl:when>\n"
|
||||
|
|
@ -780,7 +866,8 @@ static char xslmsg[] =
|
|||
" <xsl:for-each select=\"views/view\">\n"
|
||||
" <h3>Zones for View <xsl:value-of select=\"@name\"/></h3>\n"
|
||||
" <table class=\"zones\">\n"
|
||||
" <thead><tr><th>Name</th><th>Class</th><th>Type</th><th>Serial</th></tr></thead>\n"
|
||||
" <thead><tr><th>Name</th><th>Class</th><th>Type</th><th>Serial</th></"
|
||||
"tr></thead>\n"
|
||||
" <tbody>\n"
|
||||
" <xsl:for-each select=\"zones/zone\">\n"
|
||||
" <xsl:variable name=\"css-class15\">\n"
|
||||
|
|
@ -799,31 +886,41 @@ static char xslmsg[] =
|
|||
" </table>\n"
|
||||
" </xsl:for-each>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"views/view[zones/zone/counters[@type="qtype"]/counter >0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"views/view[zones/zone/counters[@type="qtype"]/"
|
||||
"counter >0]\">\n"
|
||||
" <h2>Received QTYPES per view/zone</h2>\n"
|
||||
" <xsl:for-each select=\"views/view[zones/zone/counters[@type="qtype"]/counter >0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"views/view[zones/zone/counters[@type="qtype"]/"
|
||||
"counter >0]\">\n"
|
||||
" <h3>View <xsl:value-of select=\"@name\"/></h3>\n"
|
||||
" <xsl:variable name=\"thisview\">\n"
|
||||
" <xsl:value-of select=\"@name\"/>\n"
|
||||
" </xsl:variable>\n"
|
||||
" <xsl:for-each select=\"zones/zone\">\n"
|
||||
" <xsl:if test=\"counters[@type="qtype"]/counter[count(.) > 0]\">\n"
|
||||
" <xsl:if test=\"counters[@type="qtype"]/counter[count(.) "
|
||||
"> 0]\">\n"
|
||||
" <h4>Zone <xsl:value-of select=\"@name\"/></h4>\n"
|
||||
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
|
||||
" <!-- Non Mozilla specific markup -->\n"
|
||||
" <script type=\"text/javascript\">\n"
|
||||
" graphs.push({\n"
|
||||
" 'title': \"Query types for zone <xsl:value-of select=\"@name\"/>\",\n"
|
||||
" 'target': 'chart_qtype_<xsl:value-of select=\"../../@name\"/>_<xsl:value-of select=\"@name\"/>',\n"
|
||||
" 'target': 'chart_qtype_<xsl:value-of "
|
||||
"select=\"../../@name\"/>_<xsl:value-of select=\"@name\"/>',\n"
|
||||
" 'style': 'barchart',\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each select=\"counters[@type="qtype"]/counter[.>0 and @name != "QryAuthAns"]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each "
|
||||
"select=\"counters[@type="qtype"]/counter[.>0 and @name "
|
||||
"!= "QryAuthAns"]\">['<xsl:value-of "
|
||||
"select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
|
||||
" });\n"
|
||||
"\n"
|
||||
" </script>\n"
|
||||
" <xsl:variable name=\"target\">\n"
|
||||
" <xsl:value-of select=\"@name\"/>\n"
|
||||
" </xsl:variable>\n"
|
||||
" <div class=\"pie\" id=\"chart_qtype_{$thisview}_{$target}\">[no data to display]</div>\n"
|
||||
" <div class=\"pie\" id=\"chart_qtype_{$thisview}_{$target}\">[no data "
|
||||
"to display]</div>\n"
|
||||
" </xsl:if>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"counters[@type="qtype"]/counter\">\n"
|
||||
|
|
@ -848,34 +945,47 @@ static char xslmsg[] =
|
|||
" </xsl:for-each>\n"
|
||||
" </xsl:for-each>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"views/view[zones/zone/counters[@type="rcode"]/counter >0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"views/view[zones/zone/counters[@type="rcode"]/"
|
||||
"counter >0]\">\n"
|
||||
" <h2>Response Codes per view/zone</h2>\n"
|
||||
" <xsl:for-each select=\"views/view[zones/zone/counters[@type="rcode"]/counter >0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"views/view[zones/zone/counters[@type="rcode"]/"
|
||||
"counter >0]\">\n"
|
||||
" <h3>View <xsl:value-of select=\"@name\"/></h3>\n"
|
||||
" <xsl:variable name=\"thisview2\">\n"
|
||||
" <xsl:value-of select=\"@name\"/>\n"
|
||||
" </xsl:variable>\n"
|
||||
" <xsl:for-each select=\"zones/zone\">\n"
|
||||
" <xsl:if test=\"counters[@type="rcode"]/counter[. > 0]\">\n"
|
||||
" <xsl:if test=\"counters[@type="rcode"]/counter[. > "
|
||||
"0]\">\n"
|
||||
" <h4>Zone <xsl:value-of select=\"@name\"/></h4>\n"
|
||||
" <xsl:if test=\"system-property('xsl:vendor')!='Transformiix'\">\n"
|
||||
" <!-- Non Mozilla specific markup -->\n"
|
||||
" <script type=\"text/javascript\">\n"
|
||||
" graphs.push({\n"
|
||||
" 'title': \"Response codes for zone <xsl:value-of select=\"@name\"/>\",\n"
|
||||
" 'target': 'chart_rescode_<xsl:value-of select=\"../../@name\"/>_<xsl:value-of select=\"@name\"/>',\n"
|
||||
" 'title': \"Response codes for zone <xsl:value-of "
|
||||
"select=\"@name\"/>\",\n"
|
||||
" 'target': 'chart_rescode_<xsl:value-of "
|
||||
"select=\"../../@name\"/>_<xsl:value-of select=\"@name\"/>',\n"
|
||||
" 'style': 'barchart',\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each select=\"counters[@type="rcode"]/counter[.>0 and @name != "QryAuthAns"]\">['<xsl:value-of select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
|
||||
" 'data': [['Type','Counter'],<xsl:for-each "
|
||||
"select=\"counters[@type="rcode"]/counter[.>0 and @name "
|
||||
"!= "QryAuthAns"]\">['<xsl:value-of "
|
||||
"select=\"@name\"/>',<xsl:value-of select=\".\"/>],</xsl:for-each>]\n"
|
||||
" });\n"
|
||||
"\n"
|
||||
" </script>\n"
|
||||
" <xsl:variable name=\"target\">\n"
|
||||
" <xsl:value-of select=\"@name\"/>\n"
|
||||
" </xsl:variable>\n"
|
||||
" <div class=\"pie\" id=\"chart_rescode_{$thisview2}_{$target}\">[no data to display]</div>\n"
|
||||
" <div class=\"pie\" id=\"chart_rescode_{$thisview2}_{$target}\">[no "
|
||||
"data to display]</div>\n"
|
||||
" </xsl:if>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"counters[@type="rcode"]/counter[.>0 and @name != "QryAuthAns"]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"counters[@type="rcode"]/counter[.>0 and @name "
|
||||
"!= "QryAuthAns"]\">\n"
|
||||
" <xsl:sort select=\".\"/>\n"
|
||||
" <xsl:variable name=\"css-class11\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -897,18 +1007,24 @@ static char xslmsg[] =
|
|||
" </xsl:for-each>\n"
|
||||
" </xsl:for-each>\n"
|
||||
" </xsl:if>\n"
|
||||
" <xsl:if test=\"views/view[zones/zone/counters[@type="gluecache"]/counter >0]\">\n"
|
||||
" <xsl:if "
|
||||
"test=\"views/view[zones/zone/counters[@type="gluecache"]/"
|
||||
"counter >0]\">\n"
|
||||
" <h2>Glue cache statistics</h2>\n"
|
||||
" <xsl:for-each select=\"views/view[zones/zone/counters[@type="gluecache"]/counter >0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"views/view[zones/zone/counters[@type="gluecache"]/"
|
||||
"counter >0]\">\n"
|
||||
" <h3>View <xsl:value-of select=\"@name\"/></h3>\n"
|
||||
" <xsl:variable name=\"thisview2\">\n"
|
||||
" <xsl:value-of select=\"@name\"/>\n"
|
||||
" </xsl:variable>\n"
|
||||
" <xsl:for-each select=\"zones/zone\">\n"
|
||||
" <xsl:if test=\"counters[@type="gluecache"]/counter[. > 0]\">\n"
|
||||
" <xsl:if test=\"counters[@type="gluecache"]/counter[. > "
|
||||
"0]\">\n"
|
||||
" <h4>Zone <xsl:value-of select=\"@name\"/></h4>\n"
|
||||
" <table class=\"counters\">\n"
|
||||
" <xsl:for-each select=\"counters[@type="gluecache"]/counter[. > 0]\">\n"
|
||||
" <xsl:for-each "
|
||||
"select=\"counters[@type="gluecache"]/counter[. > 0]\">\n"
|
||||
" <xsl:sort select=\".\"/>\n"
|
||||
" <xsl:variable name=\"css-class11\">\n"
|
||||
" <xsl:choose>\n"
|
||||
|
|
@ -1098,7 +1214,8 @@ static char xslmsg[] =
|
|||
" <th>LoWater</th>\n"
|
||||
" </tr>\n"
|
||||
" <xsl:for-each select=\"memory/contexts/context\">\n"
|
||||
" <xsl:sort select=\"total\" data-type=\"number\" order=\"descending\"/>\n"
|
||||
" <xsl:sort select=\"total\" data-type=\"number\" "
|
||||
"order=\"descending\"/>\n"
|
||||
" <xsl:variable name=\"css-class14\">\n"
|
||||
" <xsl:choose>\n"
|
||||
" <xsl:when test=\"position() mod 2 = 0\">even</xsl:when>\n"
|
||||
|
|
@ -1147,7 +1264,8 @@ static char xslmsg[] =
|
|||
" </table>\n"
|
||||
" </xsl:if>\n"
|
||||
" <hr/>\n"
|
||||
" <p class=\"footer\">Internet Systems Consortium Inc.<br/><a href=\"http://www.isc.org\">http://www.isc.org</a></p>\n"
|
||||
" <p class=\"footer\">Internet Systems Consortium Inc.<br/><a "
|
||||
"href=\"http://www.isc.org\">http://www.isc.org</a></p>\n"
|
||||
" </body>\n"
|
||||
" </html>\n"
|
||||
" </xsl:template>\n"
|
||||
|
|
|
|||
|
|
@ -9,14 +9,13 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file
|
||||
* \brief
|
||||
* The built-in "version", "hostname", "id", "authors" and "empty" databases.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
|
|
@ -28,17 +27,23 @@
|
|||
|
||||
#include <named/builtin.h>
|
||||
#include <named/globals.h>
|
||||
#include <named/server.h>
|
||||
#include <named/os.h>
|
||||
#include <named/server.h>
|
||||
|
||||
typedef struct builtin builtin_t;
|
||||
|
||||
static isc_result_t do_version_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t do_hostname_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t do_authors_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t do_id_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t do_empty_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t do_dns64_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t
|
||||
do_version_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t
|
||||
do_hostname_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t
|
||||
do_authors_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t
|
||||
do_id_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t
|
||||
do_empty_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t
|
||||
do_dns64_lookup(dns_sdblookup_t *lookup);
|
||||
|
||||
/*
|
||||
* We can't use function pointers as the db_data directly
|
||||
|
|
@ -52,7 +57,7 @@ struct builtin {
|
|||
char *contact;
|
||||
};
|
||||
|
||||
static builtin_t version_builtin = { do_version_lookup, NULL, NULL };
|
||||
static builtin_t version_builtin = { do_version_lookup, NULL, NULL };
|
||||
static builtin_t hostname_builtin = { do_hostname_lookup, NULL, NULL };
|
||||
static builtin_t authors_builtin = { do_authors_lookup, NULL, NULL };
|
||||
static builtin_t id_builtin = { do_id_lookup, NULL, NULL };
|
||||
|
|
@ -66,28 +71,29 @@ static dns_sdbimplementation_t *dns64_impl;
|
|||
* Pre computed HEX * 16 or 1 table.
|
||||
*/
|
||||
static const unsigned char hex16[256] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*00*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*10*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*20*/
|
||||
0, 16, 32, 48, 64, 80, 96,112,128,144, 1, 1, 1, 1, 1, 1, /*30*/
|
||||
1,160,176,192,208,224,240, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*40*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*50*/
|
||||
1,160,176,192,208,224,240, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*60*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*70*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*80*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*90*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*A0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*B0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*C0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*D0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*E0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 /*F0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*00*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*10*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*20*/
|
||||
0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 1, 1, 1, 1, 1, 1, /*30*/
|
||||
1, 160, 176, 192, 208, 224, 240, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*40*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*50*/
|
||||
1, 160, 176, 192, 208, 224, 240, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*60*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*70*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*80*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*90*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*A0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*B0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*C0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*D0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*E0*/
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 /*F0*/
|
||||
};
|
||||
|
||||
const unsigned char decimal[] = "0123456789";
|
||||
|
||||
static size_t
|
||||
dns64_rdata(unsigned char *v, size_t start, unsigned char *rdata) {
|
||||
dns64_rdata(unsigned char *v, size_t start, unsigned char *rdata)
|
||||
{
|
||||
size_t i, j = 0;
|
||||
|
||||
for (i = 0; i < 4U; i++) {
|
||||
|
|
@ -96,12 +102,15 @@ dns64_rdata(unsigned char *v, size_t start, unsigned char *rdata) {
|
|||
start++;
|
||||
if (c > 99) {
|
||||
rdata[j++] = 3;
|
||||
rdata[j++] = decimal[c/100]; c = c % 100;
|
||||
rdata[j++] = decimal[c/10]; c = c % 10;
|
||||
rdata[j++] = decimal[c / 100];
|
||||
c = c % 100;
|
||||
rdata[j++] = decimal[c / 10];
|
||||
c = c % 10;
|
||||
rdata[j++] = decimal[c];
|
||||
} else if (c > 9) {
|
||||
rdata[j++] = 2;
|
||||
rdata[j++] = decimal[c/10]; c = c % 10;
|
||||
rdata[j++] = decimal[c / 10];
|
||||
c = c % 10;
|
||||
rdata[j++] = decimal[c];
|
||||
} else {
|
||||
rdata[j++] = 1;
|
||||
|
|
@ -116,10 +125,10 @@ static isc_result_t
|
|||
dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
||||
dns_sdblookup_t *lookup)
|
||||
{
|
||||
size_t zlen, nlen, j, len;
|
||||
unsigned char v[16], n;
|
||||
unsigned int i;
|
||||
unsigned char rdata[sizeof("123.123.123.123.in-addr.arpa.")];
|
||||
size_t zlen, nlen, j, len;
|
||||
unsigned char v[16], n;
|
||||
unsigned int i;
|
||||
unsigned char rdata[sizeof("123.123.123.123.in-addr.arpa.")];
|
||||
unsigned char *ndata;
|
||||
|
||||
/*
|
||||
|
|
@ -156,13 +165,13 @@ dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
|||
j = nlen;
|
||||
memset(v, 0, sizeof(v));
|
||||
while (j != 0U) {
|
||||
INSIST((i/2) < sizeof(v));
|
||||
INSIST((i / 2) < sizeof(v));
|
||||
if (ndata[0] != 1)
|
||||
return (ISC_R_NOTFOUND);
|
||||
n = hex16[ndata[1]&0xff];
|
||||
n = hex16[ndata[1] & 0xff];
|
||||
if (n == 1)
|
||||
return (ISC_R_NOTFOUND);
|
||||
v[i/2] = n | (v[i/2]>>4);
|
||||
v[i / 2] = n | (v[i / 2] >> 4);
|
||||
j -= 2;
|
||||
ndata += 2;
|
||||
i++;
|
||||
|
|
@ -174,14 +183,14 @@ dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
|||
* it corresponds to a empty node in the zone or there should be
|
||||
* a CNAME.
|
||||
*/
|
||||
#define ZLEN(x) (10 + (x)/2)
|
||||
#define ZLEN(x) (10 + (x) / 2)
|
||||
switch (zlen) {
|
||||
case ZLEN(32): /* prefix len 32 */
|
||||
case ZLEN(32): /* prefix len 32 */
|
||||
/*
|
||||
* The nibbles that map to this byte must be zero for 'name'
|
||||
* to exist in the zone.
|
||||
*/
|
||||
if (nlen > 16U && v[(nlen-1)/4 - 4] != 0)
|
||||
if (nlen > 16U && v[(nlen - 1) / 4 - 4] != 0)
|
||||
return (ISC_R_NOTFOUND);
|
||||
/*
|
||||
* If the total length is not 74 then this is a empty node
|
||||
|
|
@ -191,12 +200,12 @@ dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
|||
return (ISC_R_SUCCESS);
|
||||
len = dns64_rdata(v, 8, rdata);
|
||||
break;
|
||||
case ZLEN(40): /* prefix len 40 */
|
||||
case ZLEN(40): /* prefix len 40 */
|
||||
/*
|
||||
* The nibbles that map to this byte must be zero for 'name'
|
||||
* to exist in the zone.
|
||||
*/
|
||||
if (nlen > 12U && v[(nlen-1)/4 - 3] != 0)
|
||||
if (nlen > 12U && v[(nlen - 1) / 4 - 3] != 0)
|
||||
return (ISC_R_NOTFOUND);
|
||||
/*
|
||||
* If the total length is not 74 then this is a empty node
|
||||
|
|
@ -206,12 +215,12 @@ dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
|||
return (ISC_R_SUCCESS);
|
||||
len = dns64_rdata(v, 6, rdata);
|
||||
break;
|
||||
case ZLEN(48): /* prefix len 48 */
|
||||
case ZLEN(48): /* prefix len 48 */
|
||||
/*
|
||||
* The nibbles that map to this byte must be zero for 'name'
|
||||
* to exist in the zone.
|
||||
*/
|
||||
if (nlen > 8U && v[(nlen-1)/4 - 2] != 0)
|
||||
if (nlen > 8U && v[(nlen - 1) / 4 - 2] != 0)
|
||||
return (ISC_R_NOTFOUND);
|
||||
/*
|
||||
* If the total length is not 74 then this is a empty node
|
||||
|
|
@ -221,12 +230,12 @@ dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
|||
return (ISC_R_SUCCESS);
|
||||
len = dns64_rdata(v, 5, rdata);
|
||||
break;
|
||||
case ZLEN(56): /* prefix len 56 */
|
||||
case ZLEN(56): /* prefix len 56 */
|
||||
/*
|
||||
* The nibbles that map to this byte must be zero for 'name'
|
||||
* to exist in the zone.
|
||||
*/
|
||||
if (nlen > 4U && v[(nlen-1)/4 - 1] != 0)
|
||||
if (nlen > 4U && v[(nlen - 1) / 4 - 1] != 0)
|
||||
return (ISC_R_NOTFOUND);
|
||||
/*
|
||||
* If the total length is not 74 then this is a empty node
|
||||
|
|
@ -236,12 +245,12 @@ dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
|||
return (ISC_R_SUCCESS);
|
||||
len = dns64_rdata(v, 4, rdata);
|
||||
break;
|
||||
case ZLEN(64): /* prefix len 64 */
|
||||
case ZLEN(64): /* prefix len 64 */
|
||||
/*
|
||||
* The nibbles that map to this byte must be zero for 'name'
|
||||
* to exist in the zone.
|
||||
*/
|
||||
if (v[(nlen-1)/4] != 0)
|
||||
if (v[(nlen - 1) / 4] != 0)
|
||||
return (ISC_R_NOTFOUND);
|
||||
/*
|
||||
* If the total length is not 74 then this is a empty node
|
||||
|
|
@ -251,7 +260,7 @@ dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
|||
return (ISC_R_SUCCESS);
|
||||
len = dns64_rdata(v, 3, rdata);
|
||||
break;
|
||||
case ZLEN(96): /* prefix len 96 */
|
||||
case ZLEN(96): /* prefix len 96 */
|
||||
/*
|
||||
* If the total length is not 74 then this is a empty node
|
||||
* so return success.
|
||||
|
|
@ -267,8 +276,8 @@ dns64_cname(const dns_name_t *zone, const dns_name_t *name,
|
|||
*/
|
||||
return (ISC_R_NOTFOUND);
|
||||
}
|
||||
return (dns_sdb_putrdata(lookup, dns_rdatatype_cname, 600,
|
||||
rdata, (unsigned int)len));
|
||||
return (dns_sdb_putrdata(lookup, dns_rdatatype_cname, 600, rdata,
|
||||
(unsigned int)len));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
|
|
@ -276,7 +285,7 @@ builtin_lookup(const char *zone, const char *name, void *dbdata,
|
|||
dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods,
|
||||
dns_clientinfo_t *clientinfo)
|
||||
{
|
||||
builtin_t *b = (builtin_t *) dbdata;
|
||||
builtin_t *b = (builtin_t *)dbdata;
|
||||
|
||||
UNUSED(zone);
|
||||
UNUSED(methods);
|
||||
|
|
@ -293,7 +302,7 @@ dns64_lookup(const dns_name_t *zone, const dns_name_t *name, void *dbdata,
|
|||
dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods,
|
||||
dns_clientinfo_t *clientinfo)
|
||||
{
|
||||
builtin_t *b = (builtin_t *) dbdata;
|
||||
builtin_t *b = (builtin_t *)dbdata;
|
||||
|
||||
UNUSED(methods);
|
||||
UNUSED(clientinfo);
|
||||
|
|
@ -305,9 +314,10 @@ dns64_lookup(const dns_name_t *zone, const dns_name_t *name, void *dbdata,
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
put_txt(dns_sdblookup_t *lookup, const char *text) {
|
||||
put_txt(dns_sdblookup_t *lookup, const char *text)
|
||||
{
|
||||
unsigned char buf[256];
|
||||
unsigned int len = strlen(text);
|
||||
unsigned int len = strlen(text);
|
||||
if (len > 255)
|
||||
len = 255; /* Silently truncate */
|
||||
buf[0] = len;
|
||||
|
|
@ -316,7 +326,8 @@ put_txt(dns_sdblookup_t *lookup, const char *text) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
do_version_lookup(dns_sdblookup_t *lookup) {
|
||||
do_version_lookup(dns_sdblookup_t *lookup)
|
||||
{
|
||||
if (named_g_server->version_set) {
|
||||
if (named_g_server->version == NULL)
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
@ -328,14 +339,15 @@ do_version_lookup(dns_sdblookup_t *lookup) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
do_hostname_lookup(dns_sdblookup_t *lookup) {
|
||||
do_hostname_lookup(dns_sdblookup_t *lookup)
|
||||
{
|
||||
if (named_g_server->hostname_set) {
|
||||
if (named_g_server->hostname == NULL)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (put_txt(lookup, named_g_server->hostname));
|
||||
} else {
|
||||
char buf[256];
|
||||
char buf[256];
|
||||
isc_result_t result = named_os_gethostname(buf, sizeof(buf));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
|
@ -344,31 +356,18 @@ do_hostname_lookup(dns_sdblookup_t *lookup) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
do_authors_lookup(dns_sdblookup_t *lookup) {
|
||||
isc_result_t result;
|
||||
const char **p;
|
||||
do_authors_lookup(dns_sdblookup_t *lookup)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char ** p;
|
||||
static const char *authors[] = {
|
||||
"Mark Andrews",
|
||||
"Curtis Blackburn",
|
||||
"James Brister",
|
||||
"Ben Cottrell",
|
||||
"John H. DuBois III",
|
||||
"Francis Dupont",
|
||||
"Michael Graff",
|
||||
"Andreas Gustafsson",
|
||||
"Bob Halley",
|
||||
"Evan Hunt",
|
||||
"JINMEI Tatuya",
|
||||
"Witold Krecicki",
|
||||
"David Lawrence",
|
||||
"Scott Mann",
|
||||
"Danny Mayer",
|
||||
"Damien Neil",
|
||||
"Matt Nelson",
|
||||
"Jeremy C. Reed",
|
||||
"Michael Sawyer",
|
||||
"Brian Wellington",
|
||||
NULL
|
||||
"Mark Andrews", "Curtis Blackburn", "James Brister",
|
||||
"Ben Cottrell", "John H. DuBois III", "Francis Dupont",
|
||||
"Michael Graff", "Andreas Gustafsson", "Bob Halley",
|
||||
"Evan Hunt", "JINMEI Tatuya", "Witold Krecicki",
|
||||
"David Lawrence", "Scott Mann", "Danny Mayer",
|
||||
"Damien Neil", "Matt Nelson", "Jeremy C. Reed",
|
||||
"Michael Sawyer", "Brian Wellington", NULL
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -386,9 +385,10 @@ do_authors_lookup(dns_sdblookup_t *lookup) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
do_id_lookup(dns_sdblookup_t *lookup) {
|
||||
do_id_lookup(dns_sdblookup_t *lookup)
|
||||
{
|
||||
if (named_g_server->sctx->gethostname != NULL) {
|
||||
char buf[256];
|
||||
char buf[256];
|
||||
isc_result_t result;
|
||||
|
||||
result = named_g_server->sctx->gethostname(buf, sizeof(buf));
|
||||
|
|
@ -402,24 +402,26 @@ do_id_lookup(dns_sdblookup_t *lookup) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
do_dns64_lookup(dns_sdblookup_t *lookup) {
|
||||
do_dns64_lookup(dns_sdblookup_t *lookup)
|
||||
{
|
||||
UNUSED(lookup);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
do_empty_lookup(dns_sdblookup_t *lookup) {
|
||||
|
||||
do_empty_lookup(dns_sdblookup_t *lookup)
|
||||
{
|
||||
UNUSED(lookup);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
builtin_authority(const char *zone, void *dbdata, dns_sdblookup_t *lookup) {
|
||||
builtin_authority(const char *zone, void *dbdata, dns_sdblookup_t *lookup)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char *contact = "hostmaster";
|
||||
const char *server = "@";
|
||||
builtin_t *b = (builtin_t *) dbdata;
|
||||
const char * contact = "hostmaster";
|
||||
const char * server = "@";
|
||||
builtin_t * b = (builtin_t *)dbdata;
|
||||
|
||||
UNUSED(zone);
|
||||
UNUSED(dbdata);
|
||||
|
|
@ -446,8 +448,8 @@ builtin_authority(const char *zone, void *dbdata, dns_sdblookup_t *lookup) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
builtin_create(const char *zone, int argc, char **argv,
|
||||
void *driverdata, void **dbdata)
|
||||
builtin_create(const char *zone, int argc, char **argv, void *driverdata,
|
||||
void **dbdata)
|
||||
{
|
||||
REQUIRE(argc >= 1);
|
||||
|
||||
|
|
@ -471,8 +473,8 @@ builtin_create(const char *zone, int argc, char **argv,
|
|||
else if (strcmp(argv[0], "empty") == 0 ||
|
||||
strcmp(argv[0], "dns64") == 0) {
|
||||
builtin_t *empty;
|
||||
char *server;
|
||||
char *contact;
|
||||
char * server;
|
||||
char * contact;
|
||||
/*
|
||||
* We don't want built-in zones to fail. Fallback to
|
||||
* the static configuration if memory allocation fails.
|
||||
|
|
@ -491,14 +493,14 @@ builtin_create(const char *zone, int argc, char **argv,
|
|||
isc_mem_free(named_g_mctx, contact);
|
||||
if (empty != NULL)
|
||||
isc_mem_put(named_g_mctx, empty,
|
||||
sizeof (*empty));
|
||||
sizeof(*empty));
|
||||
} else {
|
||||
if (strcmp(argv[0], "empty") == 0)
|
||||
memmove(empty, &empty_builtin,
|
||||
sizeof (empty_builtin));
|
||||
sizeof(empty_builtin));
|
||||
else
|
||||
memmove(empty, &dns64_builtin,
|
||||
sizeof (empty_builtin));
|
||||
sizeof(empty_builtin));
|
||||
empty->server = server;
|
||||
empty->contact = contact;
|
||||
*dbdata = empty;
|
||||
|
|
@ -509,8 +511,9 @@ builtin_create(const char *zone, int argc, char **argv,
|
|||
}
|
||||
|
||||
static void
|
||||
builtin_destroy(const char *zone, void *driverdata, void **dbdata) {
|
||||
builtin_t *b = (builtin_t *) *dbdata;
|
||||
builtin_destroy(const char *zone, void *driverdata, void **dbdata)
|
||||
{
|
||||
builtin_t *b = (builtin_t *)*dbdata;
|
||||
|
||||
UNUSED(zone);
|
||||
UNUSED(driverdata);
|
||||
|
|
@ -525,45 +528,39 @@ builtin_destroy(const char *zone, void *driverdata, void **dbdata) {
|
|||
|
||||
isc_mem_free(named_g_mctx, b->server);
|
||||
isc_mem_free(named_g_mctx, b->contact);
|
||||
isc_mem_put(named_g_mctx, b, sizeof (*b));
|
||||
isc_mem_put(named_g_mctx, b, sizeof(*b));
|
||||
}
|
||||
|
||||
static dns_sdbmethods_t builtin_methods = {
|
||||
builtin_lookup,
|
||||
builtin_authority,
|
||||
NULL, /* allnodes */
|
||||
builtin_create,
|
||||
builtin_destroy,
|
||||
NULL
|
||||
builtin_lookup, builtin_authority, NULL, /* allnodes */
|
||||
builtin_create, builtin_destroy, NULL
|
||||
};
|
||||
|
||||
static dns_sdbmethods_t dns64_methods = {
|
||||
NULL,
|
||||
builtin_authority,
|
||||
NULL, /* allnodes */
|
||||
builtin_create,
|
||||
builtin_destroy,
|
||||
dns64_lookup,
|
||||
NULL, builtin_authority, NULL, /* allnodes */
|
||||
builtin_create, builtin_destroy, dns64_lookup,
|
||||
};
|
||||
|
||||
isc_result_t
|
||||
named_builtin_init(void) {
|
||||
named_builtin_init(void)
|
||||
{
|
||||
RUNTIME_CHECK(dns_sdb_register("_builtin", &builtin_methods, NULL,
|
||||
DNS_SDBFLAG_RELATIVEOWNER |
|
||||
DNS_SDBFLAG_RELATIVERDATA,
|
||||
named_g_mctx, &builtin_impl)
|
||||
== ISC_R_SUCCESS);
|
||||
DNS_SDBFLAG_RELATIVERDATA,
|
||||
named_g_mctx,
|
||||
&builtin_impl) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(dns_sdb_register("_dns64", &dns64_methods, NULL,
|
||||
DNS_SDBFLAG_RELATIVEOWNER |
|
||||
DNS_SDBFLAG_RELATIVERDATA |
|
||||
DNS_SDBFLAG_DNS64,
|
||||
named_g_mctx, &dns64_impl)
|
||||
== ISC_R_SUCCESS);
|
||||
DNS_SDBFLAG_RELATIVERDATA |
|
||||
DNS_SDBFLAG_DNS64,
|
||||
named_g_mctx,
|
||||
&dns64_impl) == ISC_R_SUCCESS);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
named_builtin_deinit(void) {
|
||||
named_builtin_deinit(void)
|
||||
{
|
||||
dns_sdb_unregister(&builtin_impl);
|
||||
dns_sdb_unregister(&dns64_impl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <bind.keys.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
@ -24,11 +25,6 @@
|
|||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <pk11/site.h>
|
||||
|
||||
#include <isccfg/grammar.h>
|
||||
#include <isccfg/namedconf.h>
|
||||
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/name.h>
|
||||
#include <dns/rdataclass.h>
|
||||
|
|
@ -36,12 +32,13 @@
|
|||
#include <dns/tsig.h>
|
||||
#include <dns/zone.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
#include <isccfg/grammar.h>
|
||||
#include <isccfg/namedconf.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
#include <named/config.h>
|
||||
#include <named/globals.h>
|
||||
|
||||
#include <bind.keys.h>
|
||||
#include <pk11/site.h>
|
||||
|
||||
/*% default configuration */
|
||||
static char defaultconf[] = "\
|
||||
|
|
@ -50,12 +47,12 @@ options {\n\
|
|||
automatic-interface-scan yes;\n\
|
||||
bindkeys-file \"" NAMED_SYSCONFDIR "/bind.keys\";\n\
|
||||
# blackhole {none;};\n"
|
||||
" cookie-algorithm siphash24;\n"
|
||||
" cookie-algorithm siphash24;\n"
|
||||
#ifndef WIN32
|
||||
" coresize default;\n\
|
||||
" coresize default;\n\
|
||||
datasize default;\n"
|
||||
#endif
|
||||
"\
|
||||
"\
|
||||
# deallocate-on-exit <obsolete>;\n\
|
||||
# directory <none>\n\
|
||||
dnssec-policy \"none\";\n\
|
||||
|
|
@ -63,14 +60,16 @@ options {\n\
|
|||
edns-udp-size 4096;\n\
|
||||
# fake-iquery <obsolete>;\n"
|
||||
#ifndef WIN32
|
||||
" files unlimited;\n"
|
||||
" files unlimited;\n"
|
||||
#endif
|
||||
#if defined(HAVE_GEOIP2) && !defined(WIN32)
|
||||
" geoip-directory \"" MAXMINDDB_PREFIX "/share/GeoIP\";\n"
|
||||
" geoip-directory \"" MAXMINDDB_PREFIX "/share/"
|
||||
"GeoIP\";"
|
||||
"\n"
|
||||
#elif defined(HAVE_GEOIP2)
|
||||
" geoip-directory \".\";\n"
|
||||
" geoip-directory \".\";\n"
|
||||
#endif
|
||||
"\
|
||||
"\
|
||||
# has-old-clients <obsolete>;\n\
|
||||
heartbeat-interval 60;\n\
|
||||
# host-statistics <obsolete>;\n\
|
||||
|
|
@ -107,9 +106,9 @@ options {\n\
|
|||
# session-keyfile \"" NAMED_LOCALSTATEDIR "/run/named/session.key\";\n\
|
||||
session-keyname local-ddns;\n"
|
||||
#ifndef WIN32
|
||||
" stacksize default;\n"
|
||||
" stacksize default;\n"
|
||||
#endif
|
||||
" startup-notify-rate 20;\n\
|
||||
" startup-notify-rate 20;\n\
|
||||
statistics-file \"named.stats\";\n\
|
||||
# statistics-interval <obsolete>;\n\
|
||||
tcp-advertised-timeout 300;\n\
|
||||
|
|
@ -150,9 +149,9 @@ options {\n\
|
|||
dnssec-accept-expired no;\n\
|
||||
dnssec-validation " VALIDATION_DEFAULT "; \n"
|
||||
#ifdef HAVE_DNSTAP
|
||||
" dnstap-identity hostname;\n"
|
||||
" dnstap-identity hostname;\n"
|
||||
#endif
|
||||
"\
|
||||
"\
|
||||
# fetch-glue <obsolete>;\n\
|
||||
fetch-quota-params 100 0.1 0.3 0.7;\n\
|
||||
fetches-per-server 0;\n\
|
||||
|
|
@ -160,9 +159,9 @@ options {\n\
|
|||
glue-cache yes;\n\
|
||||
lame-ttl 600;\n"
|
||||
#ifdef HAVE_LMDB
|
||||
" lmdb-mapsize 32M;\n"
|
||||
" lmdb-mapsize 32M;\n"
|
||||
#endif
|
||||
" max-cache-size 90%;\n\
|
||||
" max-cache-size 90%;\n\
|
||||
max-cache-ttl 604800; /* 1 week */\n\
|
||||
max-clients-per-query 100;\n\
|
||||
max-ncache-ttl 10800; /* 3 hours */\n\
|
||||
|
|
@ -252,7 +251,7 @@ options {\n\
|
|||
};\n\
|
||||
"
|
||||
|
||||
"#\n\
|
||||
"#\n\
|
||||
# Zones in the \"_bind\" view are NOT counted in the count of zones.\n\
|
||||
#\n\
|
||||
view \"_bind\" chaos {\n\
|
||||
|
|
@ -288,17 +287,17 @@ view \"_bind\" chaos {\n\
|
|||
};\n\
|
||||
};\n\
|
||||
"
|
||||
"#\n\
|
||||
"#\n\
|
||||
# Default trusted key(s), used if \n\
|
||||
# \"dnssec-validation auto;\" is set and\n\
|
||||
# sysconfdir/bind.keys doesn't exist).\n\
|
||||
#\n\
|
||||
# BEGIN DNSSEC KEYS\n"
|
||||
|
||||
/* Imported from bind.keys.h: */
|
||||
TRUST_ANCHORS
|
||||
/* Imported from bind.keys.h: */
|
||||
TRUST_ANCHORS
|
||||
|
||||
"# END MANAGED KEYS\n\
|
||||
"# END MANAGED KEYS\n\
|
||||
\n\
|
||||
masters " DEFAULT_IANA_ROOT_ZONE_MASTERS " {\n\
|
||||
2001:500:84::b; # b.root-servers.net\n\
|
||||
|
|
@ -317,18 +316,18 @@ masters " DEFAULT_IANA_ROOT_ZONE_MASTERS " {\n\
|
|||
";
|
||||
|
||||
isc_result_t
|
||||
named_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf) {
|
||||
named_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf)
|
||||
{
|
||||
isc_buffer_t b;
|
||||
|
||||
isc_buffer_init(&b, defaultconf, sizeof(defaultconf) - 1);
|
||||
isc_buffer_add(&b, sizeof(defaultconf) - 1);
|
||||
return (cfg_parse_buffer(parser, &b, __FILE__, 0,
|
||||
&cfg_type_namedconf,
|
||||
return (cfg_parse_buffer(parser, &b, __FILE__, 0, &cfg_type_namedconf,
|
||||
CFG_PCTX_NODEPRECATED, conf));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
named_config_get(cfg_obj_t const * const *maps, const char *name,
|
||||
named_config_get(cfg_obj_t const *const *maps, const char *name,
|
||||
const cfg_obj_t **obj)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -346,17 +345,17 @@ named_checknames_get(const cfg_obj_t **maps, const char *which,
|
|||
const cfg_obj_t **obj)
|
||||
{
|
||||
const cfg_listelt_t *element;
|
||||
const cfg_obj_t *checknames;
|
||||
const cfg_obj_t *type;
|
||||
const cfg_obj_t *value;
|
||||
int i;
|
||||
const cfg_obj_t * checknames;
|
||||
const cfg_obj_t * type;
|
||||
const cfg_obj_t * value;
|
||||
int i;
|
||||
|
||||
for (i = 0;; i++) {
|
||||
if (maps[i] == NULL)
|
||||
return (ISC_R_NOTFOUND);
|
||||
checknames = NULL;
|
||||
if (cfg_map_get(maps[i], "check-names",
|
||||
&checknames) == ISC_R_SUCCESS) {
|
||||
if (cfg_map_get(maps[i], "check-names", &checknames) ==
|
||||
ISC_R_SUCCESS) {
|
||||
/*
|
||||
* Zone map entry is not a list.
|
||||
*/
|
||||
|
|
@ -369,21 +368,21 @@ named_checknames_get(const cfg_obj_t **maps, const char *which,
|
|||
element = cfg_list_next(element)) {
|
||||
value = cfg_listelt_value(element);
|
||||
type = cfg_tuple_get(value, "type");
|
||||
if (strcasecmp(cfg_obj_asstring(type),
|
||||
which) == 0) {
|
||||
if (strcasecmp(cfg_obj_asstring(type), which) ==
|
||||
0) {
|
||||
*obj = cfg_tuple_get(value, "mode");
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
named_config_listcount(const cfg_obj_t *list) {
|
||||
named_config_listcount(const cfg_obj_t *list)
|
||||
{
|
||||
const cfg_listelt_t *e;
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
|
||||
for (e = cfg_list_first(list); e != NULL; e = cfg_list_next(e))
|
||||
i++;
|
||||
|
|
@ -396,7 +395,7 @@ named_config_getclass(const cfg_obj_t *classobj, dns_rdataclass_t defclass,
|
|||
dns_rdataclass_t *classp)
|
||||
{
|
||||
isc_textregion_t r;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
if (!cfg_obj_isstring(classobj)) {
|
||||
*classp = defclass;
|
||||
|
|
@ -416,7 +415,7 @@ named_config_gettype(const cfg_obj_t *typeobj, dns_rdatatype_t deftype,
|
|||
dns_rdatatype_t *typep)
|
||||
{
|
||||
isc_textregion_t r;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
if (!cfg_obj_isstring(typeobj)) {
|
||||
*typep = deftype;
|
||||
|
|
@ -432,18 +431,16 @@ named_config_gettype(const cfg_obj_t *typeobj, dns_rdatatype_t deftype,
|
|||
}
|
||||
|
||||
dns_zonetype_t
|
||||
named_config_getzonetype(const cfg_obj_t *zonetypeobj) {
|
||||
named_config_getzonetype(const cfg_obj_t *zonetypeobj)
|
||||
{
|
||||
dns_zonetype_t ztype = dns_zone_none;
|
||||
const char *str;
|
||||
const char * str;
|
||||
|
||||
str = cfg_obj_asstring(zonetypeobj);
|
||||
if (strcasecmp(str, "primary") == 0 ||
|
||||
strcasecmp(str, "master") == 0)
|
||||
{
|
||||
if (strcasecmp(str, "primary") == 0 || strcasecmp(str, "master") == 0) {
|
||||
ztype = dns_zone_master;
|
||||
} else if (strcasecmp(str, "secondary") == 0 ||
|
||||
strcasecmp(str, "slave") == 0)
|
||||
{
|
||||
strcasecmp(str, "slave") == 0) {
|
||||
ztype = dns_zone_slave;
|
||||
} else if (strcasecmp(str, "mirror") == 0) {
|
||||
ztype = dns_zone_mirror;
|
||||
|
|
@ -462,18 +459,18 @@ named_config_getzonetype(const cfg_obj_t *zonetypeobj) {
|
|||
|
||||
isc_result_t
|
||||
named_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list,
|
||||
in_port_t defport, isc_mem_t *mctx,
|
||||
isc_sockaddr_t **addrsp, isc_dscp_t **dscpsp,
|
||||
uint32_t *countp)
|
||||
in_port_t defport, isc_mem_t *mctx,
|
||||
isc_sockaddr_t **addrsp, isc_dscp_t **dscpsp,
|
||||
uint32_t *countp)
|
||||
{
|
||||
int count, i = 0;
|
||||
const cfg_obj_t *addrlist;
|
||||
const cfg_obj_t *portobj, *dscpobj;
|
||||
int count, i = 0;
|
||||
const cfg_obj_t * addrlist;
|
||||
const cfg_obj_t * portobj, *dscpobj;
|
||||
const cfg_listelt_t *element;
|
||||
isc_sockaddr_t *addrs;
|
||||
in_port_t port;
|
||||
isc_dscp_t dscp = -1, *dscps = NULL;
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t * addrs;
|
||||
in_port_t port;
|
||||
isc_dscp_t dscp = -1, *dscps = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
INSIST(addrsp != NULL && *addrsp == NULL);
|
||||
INSIST(dscpsp == NULL || *dscpsp == NULL);
|
||||
|
|
@ -490,7 +487,7 @@ named_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
"port '%u' out of range", val);
|
||||
return (ISC_R_RANGE);
|
||||
}
|
||||
port = (in_port_t) val;
|
||||
port = (in_port_t)val;
|
||||
} else if (defport != 0)
|
||||
port = defport;
|
||||
else {
|
||||
|
|
@ -517,10 +514,8 @@ named_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
|
||||
addrs = isc_mem_get(mctx, count * sizeof(isc_sockaddr_t));
|
||||
|
||||
for (element = cfg_list_first(addrlist);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element), i++)
|
||||
{
|
||||
for (element = cfg_list_first(addrlist); element != NULL;
|
||||
element = cfg_list_next(element), i++) {
|
||||
const cfg_obj_t *addr;
|
||||
INSIST(i < count);
|
||||
addr = cfg_listelt_value(element);
|
||||
|
|
@ -566,18 +561,17 @@ isc_result_t
|
|||
named_config_getmastersdef(const cfg_obj_t *cctx, const char *name,
|
||||
const cfg_obj_t **ret)
|
||||
{
|
||||
isc_result_t result;
|
||||
const cfg_obj_t *masters = NULL;
|
||||
isc_result_t result;
|
||||
const cfg_obj_t * masters = NULL;
|
||||
const cfg_listelt_t *elt;
|
||||
|
||||
result = cfg_map_get(cctx, "masters", &masters);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
for (elt = cfg_list_first(masters);
|
||||
elt != NULL;
|
||||
for (elt = cfg_list_first(masters); elt != NULL;
|
||||
elt = cfg_list_next(elt)) {
|
||||
const cfg_obj_t *list;
|
||||
const char *listname;
|
||||
const char * listname;
|
||||
|
||||
list = cfg_listelt_value(elt);
|
||||
listname = cfg_obj_asstring(cfg_tuple_get(list, "name"));
|
||||
|
|
@ -592,27 +586,29 @@ named_config_getmastersdef(const cfg_obj_t *cctx, const char *name,
|
|||
|
||||
isc_result_t
|
||||
named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
||||
isc_mem_t *mctx, dns_ipkeylist_t *ipkl)
|
||||
isc_mem_t *mctx, dns_ipkeylist_t *ipkl)
|
||||
{
|
||||
uint32_t addrcount = 0, dscpcount = 0, keycount = 0, i = 0;
|
||||
uint32_t listcount = 0, l = 0, j;
|
||||
uint32_t stackcount = 0, pushed = 0;
|
||||
isc_result_t result;
|
||||
uint32_t addrcount = 0, dscpcount = 0, keycount = 0, i = 0;
|
||||
uint32_t listcount = 0, l = 0, j;
|
||||
uint32_t stackcount = 0, pushed = 0;
|
||||
isc_result_t result;
|
||||
const cfg_listelt_t *element;
|
||||
const cfg_obj_t *addrlist;
|
||||
const cfg_obj_t *portobj;
|
||||
const cfg_obj_t *dscpobj;
|
||||
in_port_t port;
|
||||
isc_dscp_t dscp = -1;
|
||||
dns_fixedname_t fname;
|
||||
isc_sockaddr_t *addrs = NULL;
|
||||
isc_dscp_t *dscps = NULL;
|
||||
dns_name_t **keys = NULL;
|
||||
struct { const char *name; } *lists = NULL;
|
||||
const cfg_obj_t * addrlist;
|
||||
const cfg_obj_t * portobj;
|
||||
const cfg_obj_t * dscpobj;
|
||||
in_port_t port;
|
||||
isc_dscp_t dscp = -1;
|
||||
dns_fixedname_t fname;
|
||||
isc_sockaddr_t * addrs = NULL;
|
||||
isc_dscp_t * dscps = NULL;
|
||||
dns_name_t ** keys = NULL;
|
||||
struct {
|
||||
const char *name;
|
||||
} *lists = NULL;
|
||||
struct {
|
||||
const cfg_listelt_t *element;
|
||||
in_port_t port;
|
||||
isc_dscp_t dscp;
|
||||
in_port_t port;
|
||||
isc_dscp_t dscp;
|
||||
} *stack = NULL;
|
||||
|
||||
REQUIRE(ipkl != NULL);
|
||||
|
|
@ -634,7 +630,7 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
newlist:
|
||||
newlist:
|
||||
addrlist = cfg_tuple_get(list, "addresses");
|
||||
portobj = cfg_tuple_get(list, "port");
|
||||
dscpobj = cfg_tuple_get(list, "dscp");
|
||||
|
|
@ -647,7 +643,7 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
result = ISC_R_RANGE;
|
||||
goto cleanup;
|
||||
}
|
||||
port = (in_port_t) val;
|
||||
port = (in_port_t)val;
|
||||
}
|
||||
|
||||
if (dscpobj != NULL && cfg_obj_isuint32(dscpobj)) {
|
||||
|
|
@ -664,29 +660,26 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
result = ISC_R_NOMEMORY;
|
||||
|
||||
element = cfg_list_first(addrlist);
|
||||
resume:
|
||||
for ( ;
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
resume:
|
||||
for (; element != NULL; element = cfg_list_next(element)) {
|
||||
const cfg_obj_t *addr;
|
||||
const cfg_obj_t *key;
|
||||
const char *keystr;
|
||||
isc_buffer_t b;
|
||||
const char * keystr;
|
||||
isc_buffer_t b;
|
||||
|
||||
addr = cfg_tuple_get(cfg_listelt_value(element),
|
||||
"masterselement");
|
||||
addr = cfg_tuple_get(cfg_listelt_value(element), "masterselemen"
|
||||
"t");
|
||||
key = cfg_tuple_get(cfg_listelt_value(element), "key");
|
||||
|
||||
if (!cfg_obj_issockaddr(addr)) {
|
||||
const char *listname = cfg_obj_asstring(addr);
|
||||
const char * listname = cfg_obj_asstring(addr);
|
||||
isc_result_t tresult;
|
||||
|
||||
/* Grow lists? */
|
||||
if (listcount == l) {
|
||||
void * tmp;
|
||||
void * tmp;
|
||||
uint32_t newlen = listcount + 16;
|
||||
size_t newsize, oldsize;
|
||||
size_t newsize, oldsize;
|
||||
|
||||
newsize = newlen * sizeof(*lists);
|
||||
oldsize = listcount * sizeof(*lists);
|
||||
|
|
@ -708,7 +701,8 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
&list);
|
||||
if (tresult == ISC_R_NOTFOUND) {
|
||||
cfg_obj_log(addr, named_g_lctx, ISC_LOG_ERROR,
|
||||
"masters \"%s\" not found", listname);
|
||||
"masters \"%s\" not found",
|
||||
listname);
|
||||
|
||||
result = tresult;
|
||||
goto cleanup;
|
||||
|
|
@ -718,9 +712,9 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
lists[l++].name = listname;
|
||||
/* Grow stack? */
|
||||
if (stackcount == pushed) {
|
||||
void * tmp;
|
||||
void * tmp;
|
||||
uint32_t newlen = stackcount + 16;
|
||||
size_t newsize, oldsize;
|
||||
size_t newsize, oldsize;
|
||||
|
||||
newsize = newlen * sizeof(*stack);
|
||||
oldsize = stackcount * sizeof(*stack);
|
||||
|
|
@ -744,9 +738,9 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
}
|
||||
|
||||
if (i == addrcount) {
|
||||
void * tmp;
|
||||
void * tmp;
|
||||
uint32_t newlen = addrcount + 16;
|
||||
size_t newsize, oldsize;
|
||||
size_t newsize, oldsize;
|
||||
|
||||
newsize = newlen * sizeof(isc_sockaddr_t);
|
||||
oldsize = addrcount * sizeof(isc_sockaddr_t);
|
||||
|
|
@ -786,7 +780,7 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
if (dscps[i] == -1)
|
||||
dscps[i] = dscp;
|
||||
keys[i] = NULL;
|
||||
i++; /* Increment here so that cleanup on error works. */
|
||||
i++; /* Increment here so that cleanup on error works. */
|
||||
if (!cfg_obj_isstring(key))
|
||||
continue;
|
||||
keys[i - 1] = isc_mem_get(mctx, sizeof(dns_name_t));
|
||||
|
|
@ -839,7 +833,7 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
oldsize = keycount * sizeof(dns_name_t *);
|
||||
if (i != 0) {
|
||||
tmp = isc_mem_get(mctx, newsize);
|
||||
memmove(tmp, keys, newsize);
|
||||
memmove(tmp, keys, newsize);
|
||||
} else
|
||||
tmp = NULL;
|
||||
isc_mem_put(mctx, keys, oldsize);
|
||||
|
|
@ -864,7 +858,7 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (addrs != NULL)
|
||||
isc_mem_put(mctx, addrs, addrcount * sizeof(isc_sockaddr_t));
|
||||
if (dscps != NULL)
|
||||
|
|
@ -887,12 +881,13 @@ named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
named_config_getport(const cfg_obj_t *config, in_port_t *portp) {
|
||||
named_config_getport(const cfg_obj_t *config, in_port_t *portp)
|
||||
{
|
||||
const cfg_obj_t *maps[3];
|
||||
const cfg_obj_t *options = NULL;
|
||||
const cfg_obj_t *portobj = NULL;
|
||||
isc_result_t result;
|
||||
int i;
|
||||
isc_result_t result;
|
||||
int i;
|
||||
|
||||
(void)cfg_map_get(config, "options", &options);
|
||||
i = 0;
|
||||
|
|
@ -914,10 +909,11 @@ named_config_getport(const cfg_obj_t *config, in_port_t *portp) {
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
named_config_getdscp(const cfg_obj_t *config, isc_dscp_t *dscpp) {
|
||||
named_config_getdscp(const cfg_obj_t *config, isc_dscp_t *dscpp)
|
||||
{
|
||||
const cfg_obj_t *options = NULL;
|
||||
const cfg_obj_t *dscpobj = NULL;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
(void)cfg_map_get(config, "options", &options);
|
||||
if (options == NULL)
|
||||
|
|
@ -940,21 +936,24 @@ named_config_getdscp(const cfg_obj_t *config, isc_dscp_t *dscpp) {
|
|||
|
||||
struct keyalgorithms {
|
||||
const char *str;
|
||||
enum { hmacnone, hmacmd5, hmacsha1, hmacsha224,
|
||||
hmacsha256, hmacsha384, hmacsha512 } hmac;
|
||||
enum { hmacnone,
|
||||
hmacmd5,
|
||||
hmacsha1,
|
||||
hmacsha224,
|
||||
hmacsha256,
|
||||
hmacsha384,
|
||||
hmacsha512 } hmac;
|
||||
unsigned int type;
|
||||
uint16_t size;
|
||||
} algorithms[] = {
|
||||
{ "hmac-md5", hmacmd5, DST_ALG_HMACMD5, 128 },
|
||||
{ "hmac-md5.sig-alg.reg.int", hmacmd5, DST_ALG_HMACMD5, 0 },
|
||||
{ "hmac-md5.sig-alg.reg.int.", hmacmd5, DST_ALG_HMACMD5, 0 },
|
||||
{ "hmac-sha1", hmacsha1, DST_ALG_HMACSHA1, 160 },
|
||||
{ "hmac-sha224", hmacsha224, DST_ALG_HMACSHA224, 224 },
|
||||
{ "hmac-sha256", hmacsha256, DST_ALG_HMACSHA256, 256 },
|
||||
{ "hmac-sha384", hmacsha384, DST_ALG_HMACSHA384, 384 },
|
||||
{ "hmac-sha512", hmacsha512, DST_ALG_HMACSHA512, 512 },
|
||||
{ NULL, hmacnone, DST_ALG_UNKNOWN, 0 }
|
||||
};
|
||||
uint16_t size;
|
||||
} algorithms[] = { { "hmac-md5", hmacmd5, DST_ALG_HMACMD5, 128 },
|
||||
{ "hmac-md5.sig-alg.reg.int", hmacmd5, DST_ALG_HMACMD5, 0 },
|
||||
{ "hmac-md5.sig-alg.reg.int.", hmacmd5, DST_ALG_HMACMD5, 0 },
|
||||
{ "hmac-sha1", hmacsha1, DST_ALG_HMACSHA1, 160 },
|
||||
{ "hmac-sha224", hmacsha224, DST_ALG_HMACSHA224, 224 },
|
||||
{ "hmac-sha256", hmacsha256, DST_ALG_HMACSHA256, 256 },
|
||||
{ "hmac-sha384", hmacsha384, DST_ALG_HMACSHA384, 384 },
|
||||
{ "hmac-sha512", hmacsha512, DST_ALG_HMACSHA512, 512 },
|
||||
{ NULL, hmacnone, DST_ALG_UNKNOWN, 0 } };
|
||||
|
||||
isc_result_t
|
||||
named_config_getkeyalgorithm(const char *str, const dns_name_t **name,
|
||||
|
|
@ -967,9 +966,9 @@ isc_result_t
|
|||
named_config_getkeyalgorithm2(const char *str, const dns_name_t **name,
|
||||
unsigned int *typep, uint16_t *digestbits)
|
||||
{
|
||||
int i;
|
||||
size_t len = 0;
|
||||
uint16_t bits;
|
||||
int i;
|
||||
size_t len = 0;
|
||||
uint16_t bits;
|
||||
isc_result_t result;
|
||||
|
||||
for (i = 0; algorithms[i].str != NULL; i++) {
|
||||
|
|
@ -994,12 +993,24 @@ named_config_getkeyalgorithm2(const char *str, const dns_name_t **name,
|
|||
|
||||
if (name != NULL) {
|
||||
switch (algorithms[i].hmac) {
|
||||
case hmacmd5: *name = dns_tsig_hmacmd5_name; break;
|
||||
case hmacsha1: *name = dns_tsig_hmacsha1_name; break;
|
||||
case hmacsha224: *name = dns_tsig_hmacsha224_name; break;
|
||||
case hmacsha256: *name = dns_tsig_hmacsha256_name; break;
|
||||
case hmacsha384: *name = dns_tsig_hmacsha384_name; break;
|
||||
case hmacsha512: *name = dns_tsig_hmacsha512_name; break;
|
||||
case hmacmd5:
|
||||
*name = dns_tsig_hmacmd5_name;
|
||||
break;
|
||||
case hmacsha1:
|
||||
*name = dns_tsig_hmacsha1_name;
|
||||
break;
|
||||
case hmacsha224:
|
||||
*name = dns_tsig_hmacsha224_name;
|
||||
break;
|
||||
case hmacsha256:
|
||||
*name = dns_tsig_hmacsha256_name;
|
||||
break;
|
||||
case hmacsha384:
|
||||
*name = dns_tsig_hmacsha384_name;
|
||||
break;
|
||||
case hmacsha512:
|
||||
*name = dns_tsig_hmacsha512_name;
|
||||
break;
|
||||
default:
|
||||
INSIST(0);
|
||||
ISC_UNREACHABLE();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <stdbool.h>
|
||||
|
|
@ -27,7 +26,6 @@
|
|||
#include <isccc/alist.h>
|
||||
#include <isccc/cc.h>
|
||||
#include <isccc/result.h>
|
||||
|
||||
#include <named/control.h>
|
||||
#include <named/globals.h>
|
||||
#include <named/log.h>
|
||||
|
|
@ -38,9 +36,10 @@
|
|||
#endif
|
||||
|
||||
static isc_result_t
|
||||
getcommand(isc_lex_t *lex, char **cmdp) {
|
||||
getcommand(isc_lex_t *lex, char **cmdp)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_token_t token;
|
||||
isc_token_t token;
|
||||
|
||||
REQUIRE(cmdp != NULL && *cmdp == NULL);
|
||||
|
||||
|
|
@ -59,7 +58,8 @@ getcommand(isc_lex_t *lex, char **cmdp) {
|
|||
}
|
||||
|
||||
static inline bool
|
||||
command_compare(const char *str, const char *command) {
|
||||
command_compare(const char *str, const char *command)
|
||||
{
|
||||
return (strcasecmp(str, command) == 0);
|
||||
}
|
||||
|
||||
|
|
@ -72,12 +72,12 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
|
|||
isc_buffer_t **text)
|
||||
{
|
||||
isccc_sexpr_t *data;
|
||||
char *cmdline = NULL;
|
||||
char *command = NULL;
|
||||
isc_result_t result;
|
||||
int log_level;
|
||||
isc_buffer_t src;
|
||||
isc_lex_t *lex = NULL;
|
||||
char * cmdline = NULL;
|
||||
char * command = NULL;
|
||||
isc_result_t result;
|
||||
int log_level;
|
||||
isc_buffer_t src;
|
||||
isc_lex_t * lex = NULL;
|
||||
#ifdef HAVE_LIBSCF
|
||||
named_smf_want_disable = 0;
|
||||
#endif
|
||||
|
|
@ -117,8 +117,7 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
|
|||
*/
|
||||
if ((command_compare(command, NAMED_COMMAND_NULL) &&
|
||||
strlen(cmdline) == 4) ||
|
||||
command_compare(command, NAMED_COMMAND_STATUS))
|
||||
{
|
||||
command_compare(command, NAMED_COMMAND_STATUS)) {
|
||||
log_level = ISC_LOG_DEBUG(1);
|
||||
} else {
|
||||
log_level = ISC_LOG_INFO;
|
||||
|
|
@ -129,26 +128,24 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
|
|||
* restricted commands here. rndc nta is handled specially
|
||||
* below.
|
||||
*/
|
||||
if (readonly &&
|
||||
!command_compare(command, NAMED_COMMAND_NTA) &&
|
||||
if (readonly && !command_compare(command, NAMED_COMMAND_NTA) &&
|
||||
!command_compare(command, NAMED_COMMAND_NULL) &&
|
||||
!command_compare(command, NAMED_COMMAND_STATUS) &&
|
||||
!command_compare(command, NAMED_COMMAND_SHOWZONE) &&
|
||||
!command_compare(command, NAMED_COMMAND_TESTGEN) &&
|
||||
!command_compare(command, NAMED_COMMAND_ZONESTATUS))
|
||||
{
|
||||
!command_compare(command, NAMED_COMMAND_ZONESTATUS)) {
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_CONTROL, log_level,
|
||||
"rejecting restricted control channel "
|
||||
"command '%s'", cmdline);
|
||||
"command '%s'",
|
||||
cmdline);
|
||||
result = ISC_R_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_CONTROL, log_level,
|
||||
"received control channel command '%s'",
|
||||
cmdline);
|
||||
"received control channel command '%s'", cmdline);
|
||||
|
||||
/*
|
||||
* After the lengthy "halt" and "stop", the commands are
|
||||
|
|
@ -171,11 +168,11 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
|
|||
*/
|
||||
if (named_smf_got_instance == 1 && named_smf_chroot == 0)
|
||||
named_smf_want_disable = 1;
|
||||
/*
|
||||
* If named_smf_got_instance = 0, named_smf_chroot
|
||||
* is not relevant and we fall through to
|
||||
* isc_app_shutdown below.
|
||||
*/
|
||||
/*
|
||||
* If named_smf_got_instance = 0, named_smf_chroot
|
||||
* is not relevant and we fall through to
|
||||
* isc_app_shutdown below.
|
||||
*/
|
||||
#endif
|
||||
/* Do not flush master files */
|
||||
named_server_flushonshutdown(named_g_server, false);
|
||||
|
|
@ -246,8 +243,8 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
|
|||
} else if (command_compare(command, NAMED_COMMAND_RELOAD)) {
|
||||
result = named_server_reloadcommand(named_g_server, lex, text);
|
||||
} else if (command_compare(command, NAMED_COMMAND_RETRANSFER)) {
|
||||
result = named_server_retransfercommand(named_g_server,
|
||||
lex, text);
|
||||
result = named_server_retransfercommand(named_g_server, lex,
|
||||
text);
|
||||
} else if (command_compare(command, NAMED_COMMAND_SCAN)) {
|
||||
named_server_scan_interfaces(named_g_server);
|
||||
result = ISC_R_SUCCESS;
|
||||
|
|
@ -286,12 +283,11 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
|
|||
} else {
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_CONTROL, ISC_LOG_WARNING,
|
||||
"unknown control channel command '%s'",
|
||||
command);
|
||||
"unknown control channel command '%s'", command);
|
||||
result = DNS_R_UNKNOWNCOMMAND;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (lex != NULL)
|
||||
isc_lex_destroy(&lex);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@
|
|||
#include <isc/timer.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/result.h>
|
||||
|
||||
#include <isccfg/namedconf.h>
|
||||
|
||||
#include <bind9/check.h>
|
||||
|
||||
#include <isccc/alist.h>
|
||||
#include <isccc/cc.h>
|
||||
#include <isccc/ccmsg.h>
|
||||
|
|
@ -41,9 +42,6 @@
|
|||
#include <isccc/sexpr.h>
|
||||
#include <isccc/symtab.h>
|
||||
#include <isccc/util.h>
|
||||
|
||||
#include <dns/result.h>
|
||||
|
||||
#include <named/config.h>
|
||||
#include <named/control.h>
|
||||
#include <named/log.h>
|
||||
|
|
@ -65,57 +63,60 @@ typedef struct controllistener controllistener_t;
|
|||
typedef ISC_LIST(controllistener_t) controllistenerlist_t;
|
||||
|
||||
struct controlkey {
|
||||
char * keyname;
|
||||
uint32_t algorithm;
|
||||
isc_region_t secret;
|
||||
ISC_LINK(controlkey_t) link;
|
||||
char * keyname;
|
||||
uint32_t algorithm;
|
||||
isc_region_t secret;
|
||||
ISC_LINK(controlkey_t) link;
|
||||
};
|
||||
|
||||
struct controlconnection {
|
||||
isc_socket_t * sock;
|
||||
isccc_ccmsg_t ccmsg;
|
||||
bool ccmsg_valid;
|
||||
bool sending;
|
||||
isc_timer_t * timer;
|
||||
isc_buffer_t * buffer;
|
||||
controllistener_t * listener;
|
||||
uint32_t nonce;
|
||||
ISC_LINK(controlconnection_t) link;
|
||||
isc_socket_t * sock;
|
||||
isccc_ccmsg_t ccmsg;
|
||||
bool ccmsg_valid;
|
||||
bool sending;
|
||||
isc_timer_t * timer;
|
||||
isc_buffer_t * buffer;
|
||||
controllistener_t *listener;
|
||||
uint32_t nonce;
|
||||
ISC_LINK(controlconnection_t) link;
|
||||
};
|
||||
|
||||
struct controllistener {
|
||||
named_controls_t * controls;
|
||||
isc_mem_t * mctx;
|
||||
isc_task_t * task;
|
||||
isc_sockaddr_t address;
|
||||
isc_socket_t * sock;
|
||||
dns_acl_t * acl;
|
||||
named_controls_t * controls;
|
||||
isc_mem_t * mctx;
|
||||
isc_task_t * task;
|
||||
isc_sockaddr_t address;
|
||||
isc_socket_t * sock;
|
||||
dns_acl_t * acl;
|
||||
bool listening;
|
||||
bool exiting;
|
||||
controlkeylist_t keys;
|
||||
controlconnectionlist_t connections;
|
||||
isc_sockettype_t type;
|
||||
uint32_t perm;
|
||||
uint32_t owner;
|
||||
uint32_t group;
|
||||
controlkeylist_t keys;
|
||||
controlconnectionlist_t connections;
|
||||
isc_sockettype_t type;
|
||||
uint32_t perm;
|
||||
uint32_t owner;
|
||||
uint32_t group;
|
||||
bool readonly;
|
||||
ISC_LINK(controllistener_t) link;
|
||||
ISC_LINK(controllistener_t) link;
|
||||
};
|
||||
|
||||
struct named_controls {
|
||||
named_server_t *server;
|
||||
controllistenerlist_t listeners;
|
||||
bool shuttingdown;
|
||||
isccc_symtab_t *symtab;
|
||||
named_server_t * server;
|
||||
controllistenerlist_t listeners;
|
||||
bool shuttingdown;
|
||||
isccc_symtab_t * symtab;
|
||||
};
|
||||
|
||||
static void control_newconn(isc_task_t *task, isc_event_t *event);
|
||||
static void control_recvmessage(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
control_newconn(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
control_recvmessage(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
#define CLOCKSKEW 300
|
||||
|
||||
static void
|
||||
free_controlkey(controlkey_t *key, isc_mem_t *mctx) {
|
||||
free_controlkey(controlkey_t *key, isc_mem_t *mctx)
|
||||
{
|
||||
if (key->keyname != NULL)
|
||||
isc_mem_free(mctx, key->keyname);
|
||||
if (key->secret.base != NULL)
|
||||
|
|
@ -124,7 +125,8 @@ free_controlkey(controlkey_t *key, isc_mem_t *mctx) {
|
|||
}
|
||||
|
||||
static void
|
||||
free_controlkeylist(controlkeylist_t *keylist, isc_mem_t *mctx) {
|
||||
free_controlkeylist(controlkeylist_t *keylist, isc_mem_t *mctx)
|
||||
{
|
||||
while (!ISC_LIST_EMPTY(*keylist)) {
|
||||
controlkey_t *key = ISC_LIST_HEAD(*keylist);
|
||||
ISC_LIST_UNLINK(*keylist, key, link);
|
||||
|
|
@ -133,7 +135,8 @@ free_controlkeylist(controlkeylist_t *keylist, isc_mem_t *mctx) {
|
|||
}
|
||||
|
||||
static void
|
||||
free_listener(controllistener_t *listener) {
|
||||
free_listener(controllistener_t *listener)
|
||||
{
|
||||
INSIST(listener->exiting);
|
||||
INSIST(!listener->listening);
|
||||
INSIST(ISC_LIST_EMPTY(listener->connections));
|
||||
|
|
@ -150,15 +153,16 @@ free_listener(controllistener_t *listener) {
|
|||
}
|
||||
|
||||
static void
|
||||
maybe_free_listener(controllistener_t *listener) {
|
||||
if (listener->exiting &&
|
||||
!listener->listening &&
|
||||
maybe_free_listener(controllistener_t *listener)
|
||||
{
|
||||
if (listener->exiting && !listener->listening &&
|
||||
ISC_LIST_EMPTY(listener->connections))
|
||||
free_listener(listener);
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_free_connection(controlconnection_t *conn) {
|
||||
maybe_free_connection(controlconnection_t *conn)
|
||||
{
|
||||
controllistener_t *listener = conn->listener;
|
||||
|
||||
if (conn->buffer != NULL)
|
||||
|
|
@ -188,7 +192,8 @@ maybe_free_connection(controlconnection_t *conn) {
|
|||
}
|
||||
|
||||
static void
|
||||
shutdown_listener(controllistener_t *listener) {
|
||||
shutdown_listener(controllistener_t *listener)
|
||||
{
|
||||
controlconnection_t *conn;
|
||||
controlconnection_t *next;
|
||||
|
||||
|
|
@ -207,10 +212,8 @@ shutdown_listener(controllistener_t *listener) {
|
|||
listener->exiting = true;
|
||||
}
|
||||
|
||||
for (conn = ISC_LIST_HEAD(listener->connections);
|
||||
conn != NULL;
|
||||
conn = next)
|
||||
{
|
||||
for (conn = ISC_LIST_HEAD(listener->connections); conn != NULL;
|
||||
conn = next) {
|
||||
next = ISC_LIST_NEXT(conn, link);
|
||||
maybe_free_connection(conn);
|
||||
}
|
||||
|
|
@ -223,12 +226,13 @@ shutdown_listener(controllistener_t *listener) {
|
|||
}
|
||||
|
||||
static bool
|
||||
address_ok(isc_sockaddr_t *sockaddr, dns_acl_t *acl) {
|
||||
address_ok(isc_sockaddr_t *sockaddr, dns_acl_t *acl)
|
||||
{
|
||||
dns_aclenv_t *env =
|
||||
ns_interfacemgr_getaclenv(named_g_server->interfacemgr);
|
||||
isc_netaddr_t netaddr;
|
||||
isc_result_t result;
|
||||
int match;
|
||||
isc_result_t result;
|
||||
int match;
|
||||
|
||||
isc_netaddr_fromsockaddr(&netaddr, sockaddr);
|
||||
|
||||
|
|
@ -237,10 +241,10 @@ address_ok(isc_sockaddr_t *sockaddr, dns_acl_t *acl) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
control_accept(controllistener_t *listener) {
|
||||
control_accept(controllistener_t *listener)
|
||||
{
|
||||
isc_result_t result;
|
||||
result = isc_socket_accept(listener->sock,
|
||||
listener->task,
|
||||
result = isc_socket_accept(listener->sock, listener->task,
|
||||
control_newconn, listener);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
|
|
@ -252,7 +256,8 @@ control_accept(controllistener_t *listener) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
control_listen(controllistener_t *listener) {
|
||||
control_listen(controllistener_t *listener)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_socket_listen(listener->sock, 0);
|
||||
|
|
@ -264,17 +269,19 @@ control_listen(controllistener_t *listener) {
|
|||
}
|
||||
|
||||
static void
|
||||
control_next(controllistener_t *listener) {
|
||||
control_next(controllistener_t *listener)
|
||||
{
|
||||
(void)control_accept(listener);
|
||||
}
|
||||
|
||||
static void
|
||||
control_senddone(isc_task_t *task, isc_event_t *event) {
|
||||
isc_socketevent_t *sevent = (isc_socketevent_t *) event;
|
||||
control_senddone(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socketevent_t * sevent = (isc_socketevent_t *)event;
|
||||
controlconnection_t *conn = event->ev_arg;
|
||||
controllistener_t *listener = conn->listener;
|
||||
isc_socket_t *sock = (isc_socket_t *)sevent->ev_sender;
|
||||
isc_result_t result;
|
||||
controllistener_t * listener = conn->listener;
|
||||
isc_socket_t * sock = (isc_socket_t *)sevent->ev_sender;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(conn->sending);
|
||||
|
||||
|
|
@ -283,9 +290,8 @@ control_senddone(isc_task_t *task, isc_event_t *event) {
|
|||
conn->sending = false;
|
||||
|
||||
if (sevent->result != ISC_R_SUCCESS &&
|
||||
sevent->result != ISC_R_CANCELED)
|
||||
{
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
sevent->result != ISC_R_CANCELED) {
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_sockaddr_t peeraddr;
|
||||
|
||||
(void)isc_socket_getpeername(sock, &peeraddr);
|
||||
|
|
@ -307,38 +313,40 @@ control_senddone(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static inline void
|
||||
log_invalid(isccc_ccmsg_t *ccmsg, isc_result_t result) {
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
log_invalid(isccc_ccmsg_t *ccmsg, isc_result_t result)
|
||||
{
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_sockaddr_t peeraddr;
|
||||
|
||||
(void)isc_socket_getpeername(ccmsg->sock, &peeraddr);
|
||||
isc_sockaddr_format(&peeraddr, socktext, sizeof(socktext));
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_CONTROL, ISC_LOG_ERROR,
|
||||
"invalid command from %s: %s",
|
||||
socktext, isc_result_totext(result));
|
||||
"invalid command from %s: %s", socktext,
|
||||
isc_result_totext(result));
|
||||
}
|
||||
|
||||
static void
|
||||
control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
||||
control_recvmessage(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
controlconnection_t *conn = NULL;
|
||||
controllistener_t *listener = NULL;
|
||||
controlkey_t *key = NULL;
|
||||
isccc_sexpr_t *request = NULL;
|
||||
isccc_sexpr_t *response = NULL;
|
||||
uint32_t algorithm;
|
||||
isccc_region_t secret;
|
||||
isc_stdtime_t now;
|
||||
isc_buffer_t b;
|
||||
isc_region_t r;
|
||||
isc_buffer_t *text;
|
||||
isc_result_t result;
|
||||
isc_result_t eresult;
|
||||
isccc_sexpr_t *_ctrl = NULL;
|
||||
isccc_time_t sent;
|
||||
isccc_time_t exp;
|
||||
uint32_t nonce;
|
||||
isccc_sexpr_t *data = NULL;
|
||||
controllistener_t * listener = NULL;
|
||||
controlkey_t * key = NULL;
|
||||
isccc_sexpr_t * request = NULL;
|
||||
isccc_sexpr_t * response = NULL;
|
||||
uint32_t algorithm;
|
||||
isccc_region_t secret;
|
||||
isc_stdtime_t now;
|
||||
isc_buffer_t b;
|
||||
isc_region_t r;
|
||||
isc_buffer_t * text;
|
||||
isc_result_t result;
|
||||
isc_result_t eresult;
|
||||
isccc_sexpr_t * _ctrl = NULL;
|
||||
isccc_time_t sent;
|
||||
isccc_time_t exp;
|
||||
uint32_t nonce;
|
||||
isccc_sexpr_t * data = NULL;
|
||||
|
||||
REQUIRE(event->ev_type == ISCCC_EVENT_CCMSG);
|
||||
|
||||
|
|
@ -361,21 +369,18 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
|||
|
||||
request = NULL;
|
||||
|
||||
for (key = ISC_LIST_HEAD(listener->keys);
|
||||
key != NULL;
|
||||
key = ISC_LIST_NEXT(key, link))
|
||||
{
|
||||
for (key = ISC_LIST_HEAD(listener->keys); key != NULL;
|
||||
key = ISC_LIST_NEXT(key, link)) {
|
||||
isccc_region_t ccregion;
|
||||
|
||||
ccregion.rstart = isc_buffer_base(&conn->ccmsg.buffer);
|
||||
ccregion.rend = isc_buffer_used(&conn->ccmsg.buffer);
|
||||
secret.rstart = isc_mem_get(listener->mctx,
|
||||
key->secret.length);
|
||||
secret.rstart = isc_mem_get(listener->mctx, key->secret.length);
|
||||
memmove(secret.rstart, key->secret.base, key->secret.length);
|
||||
secret.rend = secret.rstart + key->secret.length;
|
||||
algorithm = key->algorithm;
|
||||
result = isccc_cc_fromwire(&ccregion, &request,
|
||||
algorithm, &secret);
|
||||
result = isccc_cc_fromwire(&ccregion, &request, algorithm,
|
||||
&secret);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
break;
|
||||
isc_mem_put(listener->mctx, secret.rstart, REGION_SIZE(secret));
|
||||
|
|
@ -519,16 +524,16 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
|||
isc_buffer_free(&text);
|
||||
return;
|
||||
|
||||
cleanup_response:
|
||||
cleanup_response:
|
||||
isccc_sexpr_free(&response);
|
||||
|
||||
cleanup_request:
|
||||
cleanup_request:
|
||||
isccc_sexpr_free(&request);
|
||||
isc_mem_put(listener->mctx, secret.rstart, REGION_SIZE(secret));
|
||||
if (text != NULL)
|
||||
isc_buffer_free(&text);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
isc_socket_detach(&conn->sock);
|
||||
isccc_ccmsg_invalidate(&conn->ccmsg);
|
||||
conn->ccmsg_valid = false;
|
||||
|
|
@ -537,7 +542,8 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
control_timeout(isc_task_t *task, isc_event_t *event) {
|
||||
control_timeout(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
controlconnection_t *conn = event->ev_arg;
|
||||
|
||||
UNUSED(task);
|
||||
|
|
@ -549,10 +555,11 @@ control_timeout(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
newconnection(controllistener_t *listener, isc_socket_t *sock) {
|
||||
newconnection(controllistener_t *listener, isc_socket_t *sock)
|
||||
{
|
||||
controlconnection_t *conn;
|
||||
isc_interval_t interval;
|
||||
isc_result_t result;
|
||||
isc_interval_t interval;
|
||||
isc_result_t result;
|
||||
|
||||
conn = isc_mem_get(listener->mctx, sizeof(*conn));
|
||||
|
||||
|
|
@ -567,9 +574,9 @@ newconnection(controllistener_t *listener, isc_socket_t *sock) {
|
|||
conn->buffer = NULL;
|
||||
conn->timer = NULL;
|
||||
isc_interval_set(&interval, 60, 0);
|
||||
result = isc_timer_create(named_g_timermgr, isc_timertype_once,
|
||||
NULL, &interval, listener->task,
|
||||
control_timeout, conn, &conn->timer);
|
||||
result = isc_timer_create(named_g_timermgr, isc_timertype_once, NULL,
|
||||
&interval, listener->task, control_timeout,
|
||||
conn, &conn->timer);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
|
|
@ -585,7 +592,7 @@ newconnection(controllistener_t *listener, isc_socket_t *sock) {
|
|||
ISC_LIST_APPEND(listener->connections, conn, link);
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (conn->buffer != NULL)
|
||||
isc_buffer_free(&conn->buffer);
|
||||
isccc_ccmsg_invalidate(&conn->ccmsg);
|
||||
|
|
@ -601,12 +608,13 @@ newconnection(controllistener_t *listener, isc_socket_t *sock) {
|
|||
}
|
||||
|
||||
static void
|
||||
control_newconn(isc_task_t *task, isc_event_t *event) {
|
||||
control_newconn(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socket_newconnev_t *nevent = (isc_socket_newconnev_t *)event;
|
||||
controllistener_t *listener = event->ev_arg;
|
||||
isc_socket_t *sock;
|
||||
isc_sockaddr_t peeraddr;
|
||||
isc_result_t result;
|
||||
controllistener_t * listener = event->ev_arg;
|
||||
isc_socket_t * sock;
|
||||
isc_sockaddr_t peeraddr;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
|
|
@ -641,27 +649,26 @@ control_newconn(isc_task_t *task, isc_event_t *event) {
|
|||
isc_sockaddr_format(&peeraddr, socktext, sizeof(socktext));
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_CONTROL, ISC_LOG_WARNING,
|
||||
"dropped command channel from %s: %s",
|
||||
socktext, isc_result_totext(result));
|
||||
"dropped command channel from %s: %s", socktext,
|
||||
isc_result_totext(result));
|
||||
isc_socket_detach(&sock);
|
||||
goto restart;
|
||||
}
|
||||
|
||||
restart:
|
||||
restart:
|
||||
control_next(listener);
|
||||
cleanup:
|
||||
cleanup:
|
||||
isc_event_free(&event);
|
||||
}
|
||||
|
||||
static void
|
||||
controls_shutdown(named_controls_t *controls) {
|
||||
controls_shutdown(named_controls_t *controls)
|
||||
{
|
||||
controllistener_t *listener;
|
||||
controllistener_t *next;
|
||||
|
||||
for (listener = ISC_LIST_HEAD(controls->listeners);
|
||||
listener != NULL;
|
||||
listener = next)
|
||||
{
|
||||
for (listener = ISC_LIST_HEAD(controls->listeners); listener != NULL;
|
||||
listener = next) {
|
||||
/*
|
||||
* This is asynchronous. As listeners shut down, they will
|
||||
* call their callbacks.
|
||||
|
|
@ -672,7 +679,8 @@ controls_shutdown(named_controls_t *controls) {
|
|||
}
|
||||
|
||||
void
|
||||
named_controls_shutdown(named_controls_t *controls) {
|
||||
named_controls_shutdown(named_controls_t *controls)
|
||||
{
|
||||
controls_shutdown(controls);
|
||||
controls->shuttingdown = true;
|
||||
}
|
||||
|
|
@ -682,13 +690,11 @@ cfgkeylist_find(const cfg_obj_t *keylist, const char *keyname,
|
|||
const cfg_obj_t **objp)
|
||||
{
|
||||
const cfg_listelt_t *element;
|
||||
const char *str;
|
||||
const cfg_obj_t *obj;
|
||||
const char * str;
|
||||
const cfg_obj_t * obj;
|
||||
|
||||
for (element = cfg_list_first(keylist);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
for (element = cfg_list_first(keylist); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
obj = cfg_listelt_value(element);
|
||||
str = cfg_obj_asstring(cfg_map_getname(obj));
|
||||
if (strcasecmp(str, keyname) == 0)
|
||||
|
|
@ -706,15 +712,13 @@ controlkeylist_fromcfg(const cfg_obj_t *keylist, isc_mem_t *mctx,
|
|||
controlkeylist_t *keyids)
|
||||
{
|
||||
const cfg_listelt_t *element;
|
||||
char *newstr = NULL;
|
||||
const char *str;
|
||||
const cfg_obj_t *obj;
|
||||
controlkey_t *key;
|
||||
char * newstr = NULL;
|
||||
const char * str;
|
||||
const cfg_obj_t * obj;
|
||||
controlkey_t * key;
|
||||
|
||||
for (element = cfg_list_first(keylist);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
for (element = cfg_list_first(keylist); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
obj = cfg_listelt_value(element);
|
||||
str = cfg_obj_asstring(obj);
|
||||
newstr = isc_mem_strdup(mctx, str);
|
||||
|
|
@ -733,11 +737,11 @@ static void
|
|||
register_keys(const cfg_obj_t *control, const cfg_obj_t *keylist,
|
||||
controlkeylist_t *keyids, isc_mem_t *mctx, const char *socktext)
|
||||
{
|
||||
controlkey_t *keyid, *next;
|
||||
controlkey_t * keyid, *next;
|
||||
const cfg_obj_t *keydef;
|
||||
char secret[1024];
|
||||
isc_buffer_t b;
|
||||
isc_result_t result;
|
||||
char secret[1024];
|
||||
isc_buffer_t b;
|
||||
isc_result_t result;
|
||||
|
||||
/*
|
||||
* Find the keys corresponding to the keyids used by this listener.
|
||||
|
|
@ -756,9 +760,9 @@ register_keys(const cfg_obj_t *control, const cfg_obj_t *keylist,
|
|||
} else {
|
||||
const cfg_obj_t *algobj = NULL;
|
||||
const cfg_obj_t *secretobj = NULL;
|
||||
const char *algstr = NULL;
|
||||
const char *secretstr = NULL;
|
||||
unsigned int algtype;
|
||||
const char * algstr = NULL;
|
||||
const char * secretstr = NULL;
|
||||
unsigned int algtype;
|
||||
|
||||
(void)cfg_map_get(keydef, "algorithm", &algobj);
|
||||
(void)cfg_map_get(keydef, "secret", &secretobj);
|
||||
|
|
@ -768,8 +772,8 @@ register_keys(const cfg_obj_t *control, const cfg_obj_t *keylist,
|
|||
secretstr = cfg_obj_asstring(secretobj);
|
||||
|
||||
if (named_config_getkeyalgorithm2(algstr, NULL,
|
||||
&algtype, NULL) != ISC_R_SUCCESS)
|
||||
{
|
||||
&algtype, NULL) !=
|
||||
ISC_R_SUCCESS) {
|
||||
cfg_obj_log(control, named_g_lctx,
|
||||
ISC_LOG_WARNING,
|
||||
"unsupported algorithm '%s' in "
|
||||
|
|
@ -798,50 +802,51 @@ register_keys(const cfg_obj_t *control, const cfg_obj_t *keylist,
|
|||
}
|
||||
|
||||
keyid->secret.length = isc_buffer_usedlength(&b);
|
||||
keyid->secret.base = isc_mem_get(mctx,
|
||||
keyid->secret.length);
|
||||
keyid->secret.base =
|
||||
isc_mem_get(mctx, keyid->secret.length);
|
||||
memmove(keyid->secret.base, isc_buffer_base(&b),
|
||||
keyid->secret.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define CHECK(x) \
|
||||
do { \
|
||||
result = (x); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto cleanup; \
|
||||
#define CHECK(x) \
|
||||
do { \
|
||||
result = (x); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
static isc_result_t
|
||||
get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) {
|
||||
isc_result_t result;
|
||||
cfg_parser_t *pctx = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids)
|
||||
{
|
||||
isc_result_t result;
|
||||
cfg_parser_t * pctx = NULL;
|
||||
cfg_obj_t * config = NULL;
|
||||
const cfg_obj_t *key = NULL;
|
||||
const cfg_obj_t *algobj = NULL;
|
||||
const cfg_obj_t *secretobj = NULL;
|
||||
const char *algstr = NULL;
|
||||
const char *secretstr = NULL;
|
||||
controlkey_t *keyid = NULL;
|
||||
char secret[1024];
|
||||
unsigned int algtype;
|
||||
isc_buffer_t b;
|
||||
const char * algstr = NULL;
|
||||
const char * secretstr = NULL;
|
||||
controlkey_t * keyid = NULL;
|
||||
char secret[1024];
|
||||
unsigned int algtype;
|
||||
isc_buffer_t b;
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_CONTROL, ISC_LOG_INFO,
|
||||
"configuring command channel from '%s'",
|
||||
named_g_keyfile);
|
||||
if (! isc_file_exists(named_g_keyfile))
|
||||
"configuring command channel from '%s'", named_g_keyfile);
|
||||
if (!isc_file_exists(named_g_keyfile))
|
||||
return (ISC_R_FILENOTFOUND);
|
||||
|
||||
CHECK(cfg_parser_create(mctx, named_g_lctx, &pctx));
|
||||
CHECK(cfg_parse_file(pctx, named_g_keyfile, &cfg_type_rndckey, &config));
|
||||
CHECK(cfg_parse_file(pctx, named_g_keyfile, &cfg_type_rndckey,
|
||||
&config));
|
||||
CHECK(cfg_map_get(config, "key", &key));
|
||||
|
||||
keyid = isc_mem_get(mctx, sizeof(*keyid));
|
||||
keyid->keyname = isc_mem_strdup(mctx,
|
||||
cfg_obj_asstring(cfg_map_getname(key)));
|
||||
keyid->keyname =
|
||||
isc_mem_strdup(mctx, cfg_obj_asstring(cfg_map_getname(key)));
|
||||
keyid->secret.base = NULL;
|
||||
keyid->secret.length = 0;
|
||||
keyid->algorithm = DST_ALG_UNKNOWN;
|
||||
|
|
@ -858,10 +863,9 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) {
|
|||
algstr = cfg_obj_asstring(algobj);
|
||||
secretstr = cfg_obj_asstring(secretobj);
|
||||
|
||||
if (named_config_getkeyalgorithm2(algstr, NULL,
|
||||
&algtype, NULL) != ISC_R_SUCCESS) {
|
||||
cfg_obj_log(key, named_g_lctx,
|
||||
ISC_LOG_WARNING,
|
||||
if (named_config_getkeyalgorithm2(algstr, NULL, &algtype, NULL) !=
|
||||
ISC_R_SUCCESS) {
|
||||
cfg_obj_log(key, named_g_lctx, ISC_LOG_WARNING,
|
||||
"unsupported algorithm '%s' in "
|
||||
"key '%s' for use with command "
|
||||
"channel",
|
||||
|
|
@ -882,13 +886,12 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) {
|
|||
|
||||
keyid->secret.length = isc_buffer_usedlength(&b);
|
||||
keyid->secret.base = isc_mem_get(mctx, keyid->secret.length);
|
||||
memmove(keyid->secret.base, isc_buffer_base(&b),
|
||||
keyid->secret.length);
|
||||
memmove(keyid->secret.base, isc_buffer_base(&b), keyid->secret.length);
|
||||
ISC_LIST_APPEND(*keyids, keyid, link);
|
||||
keyid = NULL;
|
||||
result = ISC_R_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (keyid != NULL)
|
||||
free_controlkey(keyid, mctx);
|
||||
if (config != NULL)
|
||||
|
|
@ -907,7 +910,7 @@ get_key_info(const cfg_obj_t *config, const cfg_obj_t *control,
|
|||
const cfg_obj_t **global_keylistp,
|
||||
const cfg_obj_t **control_keylistp)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
const cfg_obj_t *control_keylist = NULL;
|
||||
const cfg_obj_t *global_keylist = NULL;
|
||||
|
||||
|
|
@ -934,15 +937,14 @@ update_listener(named_controls_t *cp, controllistener_t **listenerp,
|
|||
const char *socktext, isc_sockettype_t type)
|
||||
{
|
||||
controllistener_t *listener;
|
||||
const cfg_obj_t *allow;
|
||||
const cfg_obj_t *global_keylist = NULL;
|
||||
const cfg_obj_t *control_keylist = NULL;
|
||||
dns_acl_t *new_acl = NULL;
|
||||
controlkeylist_t keys;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
const cfg_obj_t * allow;
|
||||
const cfg_obj_t * global_keylist = NULL;
|
||||
const cfg_obj_t * control_keylist = NULL;
|
||||
dns_acl_t * new_acl = NULL;
|
||||
controlkeylist_t keys;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
for (listener = ISC_LIST_HEAD(cp->listeners);
|
||||
listener != NULL;
|
||||
for (listener = ISC_LIST_HEAD(cp->listeners); listener != NULL;
|
||||
listener = ISC_LIST_NEXT(listener, link))
|
||||
if (isc_sockaddr_equal(addr, &listener->address))
|
||||
break;
|
||||
|
|
@ -1049,7 +1051,7 @@ update_listener(named_controls_t *cp, controllistener_t **listenerp,
|
|||
|
||||
if (result == ISC_R_SUCCESS && type == isc_sockettype_unix) {
|
||||
uint32_t perm, owner, group;
|
||||
perm = cfg_obj_asuint32(cfg_tuple_get(control, "perm"));
|
||||
perm = cfg_obj_asuint32(cfg_tuple_get(control, "perm"));
|
||||
owner = cfg_obj_asuint32(cfg_tuple_get(control, "owner"));
|
||||
group = cfg_obj_asuint32(cfg_tuple_get(control, "group"));
|
||||
result = ISC_R_SUCCESS;
|
||||
|
|
@ -1064,7 +1066,8 @@ update_listener(named_controls_t *cp, controllistener_t **listenerp,
|
|||
} else if (control != NULL)
|
||||
cfg_obj_log(control, named_g_lctx, ISC_LOG_WARNING,
|
||||
"couldn't update ownership/permission for "
|
||||
"command channel %s", socktext);
|
||||
"command channel %s",
|
||||
socktext);
|
||||
}
|
||||
|
||||
*listenerp = listener;
|
||||
|
|
@ -1076,13 +1079,13 @@ add_listener(named_controls_t *cp, controllistener_t **listenerp,
|
|||
isc_sockaddr_t *addr, cfg_aclconfctx_t *aclconfctx,
|
||||
const char *socktext, isc_sockettype_t type)
|
||||
{
|
||||
isc_mem_t *mctx = cp->server->mctx;
|
||||
isc_mem_t * mctx = cp->server->mctx;
|
||||
controllistener_t *listener;
|
||||
const cfg_obj_t *allow;
|
||||
const cfg_obj_t *global_keylist = NULL;
|
||||
const cfg_obj_t *control_keylist = NULL;
|
||||
dns_acl_t *new_acl = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
const cfg_obj_t * allow;
|
||||
const cfg_obj_t * global_keylist = NULL;
|
||||
const cfg_obj_t * control_keylist = NULL;
|
||||
dns_acl_t * new_acl = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
listener = isc_mem_get(mctx, sizeof(*listener));
|
||||
|
||||
|
|
@ -1136,7 +1139,7 @@ add_listener(named_controls_t *cp, controllistener_t **listenerp,
|
|||
|
||||
if (control_keylist != NULL) {
|
||||
controlkeylist_fromcfg(control_keylist, listener->mctx,
|
||||
&listener->keys);
|
||||
&listener->keys);
|
||||
register_keys(control, global_keylist, &listener->keys,
|
||||
listener->mctx, socktext);
|
||||
} else {
|
||||
|
|
@ -1180,12 +1183,12 @@ add_listener(named_controls_t *cp, controllistener_t **listenerp,
|
|||
ISC_SOCKET_REUSEADDRESS);
|
||||
|
||||
if (result == ISC_R_SUCCESS && type == isc_sockettype_unix) {
|
||||
listener->perm = cfg_obj_asuint32(cfg_tuple_get(control,
|
||||
"perm"));
|
||||
listener->owner = cfg_obj_asuint32(cfg_tuple_get(control,
|
||||
"owner"));
|
||||
listener->group = cfg_obj_asuint32(cfg_tuple_get(control,
|
||||
"group"));
|
||||
listener->perm = cfg_obj_asuint32(cfg_tuple_get(control, "per"
|
||||
"m"));
|
||||
listener->owner = cfg_obj_asuint32(cfg_tuple_get(control, "owne"
|
||||
"r"));
|
||||
listener->group = cfg_obj_asuint32(cfg_tuple_get(control, "grou"
|
||||
"p"));
|
||||
result = isc_socket_permunix(&listener->address, listener->perm,
|
||||
listener->owner, listener->group);
|
||||
}
|
||||
|
|
@ -1227,11 +1230,11 @@ isc_result_t
|
|||
named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
||||
cfg_aclconfctx_t *aclconfctx)
|
||||
{
|
||||
controllistener_t *listener;
|
||||
controllistener_t * listener;
|
||||
controllistenerlist_t new_listeners;
|
||||
const cfg_obj_t *controlslist = NULL;
|
||||
const cfg_listelt_t *element, *element2;
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
const cfg_obj_t * controlslist = NULL;
|
||||
const cfg_listelt_t * element, *element2;
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
|
||||
ISC_LIST_INIT(new_listeners);
|
||||
|
||||
|
|
@ -1249,8 +1252,7 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
* address-in-use error.
|
||||
*/
|
||||
if (controlslist != NULL) {
|
||||
for (element = cfg_list_first(controlslist);
|
||||
element != NULL;
|
||||
for (element = cfg_list_first(controlslist); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
const cfg_obj_t *controls;
|
||||
const cfg_obj_t *inetcontrols = NULL;
|
||||
|
|
@ -1265,7 +1267,7 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
element2 = cfg_list_next(element2)) {
|
||||
const cfg_obj_t *control;
|
||||
const cfg_obj_t *obj;
|
||||
isc_sockaddr_t addr;
|
||||
isc_sockaddr_t addr;
|
||||
|
||||
/*
|
||||
* The parser handles BIND 8 configuration file
|
||||
|
|
@ -1277,8 +1279,8 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
obj = cfg_tuple_get(control, "address");
|
||||
addr = *cfg_obj_assockaddr(obj);
|
||||
if (isc_sockaddr_getport(&addr) == 0)
|
||||
isc_sockaddr_setport(&addr,
|
||||
NAMED_CONTROL_PORT);
|
||||
isc_sockaddr_setport(
|
||||
&addr, NAMED_CONTROL_PORT);
|
||||
|
||||
isc_sockaddr_format(&addr, socktext,
|
||||
sizeof(socktext));
|
||||
|
|
@ -1299,8 +1301,8 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
* Remove the listener from the old
|
||||
* list, so it won't be shut down.
|
||||
*/
|
||||
ISC_LIST_UNLINK(cp->listeners,
|
||||
listener, link);
|
||||
ISC_LIST_UNLINK(cp->listeners, listener,
|
||||
link);
|
||||
else
|
||||
/*
|
||||
* This is a new listener.
|
||||
|
|
@ -1311,12 +1313,11 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
isc_sockettype_tcp);
|
||||
|
||||
if (listener != NULL)
|
||||
ISC_LIST_APPEND(new_listeners,
|
||||
listener, link);
|
||||
ISC_LIST_APPEND(new_listeners, listener,
|
||||
link);
|
||||
}
|
||||
}
|
||||
for (element = cfg_list_first(controlslist);
|
||||
element != NULL;
|
||||
for (element = cfg_list_first(controlslist); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
const cfg_obj_t *controls;
|
||||
const cfg_obj_t *unixcontrols = NULL;
|
||||
|
|
@ -1331,8 +1332,8 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
element2 = cfg_list_next(element2)) {
|
||||
const cfg_obj_t *control;
|
||||
const cfg_obj_t *path;
|
||||
isc_sockaddr_t addr;
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t addr;
|
||||
isc_result_t result;
|
||||
|
||||
/*
|
||||
* The parser handles BIND 8 configuration file
|
||||
|
|
@ -1342,16 +1343,17 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
control = cfg_listelt_value(element2);
|
||||
|
||||
path = cfg_tuple_get(control, "path");
|
||||
result = isc_sockaddr_frompath(&addr,
|
||||
cfg_obj_asstring(path));
|
||||
result = isc_sockaddr_frompath(
|
||||
&addr, cfg_obj_asstring(path));
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(named_g_lctx,
|
||||
NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_CONTROL,
|
||||
ISC_LOG_DEBUG(9),
|
||||
"control channel '%s': %s",
|
||||
cfg_obj_asstring(path),
|
||||
isc_result_totext(result));
|
||||
isc_log_write(
|
||||
named_g_lctx,
|
||||
NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_CONTROL,
|
||||
ISC_LOG_DEBUG(9),
|
||||
"control channel '%s': %s",
|
||||
cfg_obj_asstring(path),
|
||||
isc_result_totext(result));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1372,8 +1374,8 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
* Remove the listener from the old
|
||||
* list, so it won't be shut down.
|
||||
*/
|
||||
ISC_LIST_UNLINK(cp->listeners,
|
||||
listener, link);
|
||||
ISC_LIST_UNLINK(cp->listeners, listener,
|
||||
link);
|
||||
else
|
||||
/*
|
||||
* This is a new listener.
|
||||
|
|
@ -1384,8 +1386,8 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
isc_sockettype_unix);
|
||||
|
||||
if (listener != NULL)
|
||||
ISC_LIST_APPEND(new_listeners,
|
||||
listener, link);
|
||||
ISC_LIST_APPEND(new_listeners, listener,
|
||||
link);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1404,35 +1406,32 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
} else {
|
||||
if (isc_net_probeipv6() != ISC_R_SUCCESS)
|
||||
continue;
|
||||
isc_sockaddr_fromin6(&addr,
|
||||
&in6addr_loopback, 0);
|
||||
isc_sockaddr_fromin6(&addr, &in6addr_loopback,
|
||||
0);
|
||||
}
|
||||
isc_sockaddr_setport(&addr, NAMED_CONTROL_PORT);
|
||||
|
||||
isc_sockaddr_format(&addr, socktext, sizeof(socktext));
|
||||
|
||||
update_listener(cp, &listener, NULL, NULL,
|
||||
&addr, NULL, socktext,
|
||||
isc_sockettype_tcp);
|
||||
update_listener(cp, &listener, NULL, NULL, &addr, NULL,
|
||||
socktext, isc_sockettype_tcp);
|
||||
|
||||
if (listener != NULL)
|
||||
/*
|
||||
* Remove the listener from the old
|
||||
* list, so it won't be shut down.
|
||||
*/
|
||||
ISC_LIST_UNLINK(cp->listeners,
|
||||
listener, link);
|
||||
ISC_LIST_UNLINK(cp->listeners, listener, link);
|
||||
else
|
||||
/*
|
||||
* This is a new listener.
|
||||
*/
|
||||
add_listener(cp, &listener, NULL, NULL,
|
||||
&addr, NULL, socktext,
|
||||
add_listener(cp, &listener, NULL, NULL, &addr,
|
||||
NULL, socktext,
|
||||
isc_sockettype_tcp);
|
||||
|
||||
if (listener != NULL)
|
||||
ISC_LIST_APPEND(new_listeners,
|
||||
listener, link);
|
||||
ISC_LIST_APPEND(new_listeners, listener, link);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1454,9 +1453,10 @@ named_controls_configure(named_controls_t *cp, const cfg_obj_t *config,
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
named_controls_create(named_server_t *server, named_controls_t **ctrlsp) {
|
||||
isc_mem_t *mctx = server->mctx;
|
||||
isc_result_t result;
|
||||
named_controls_create(named_server_t *server, named_controls_t **ctrlsp)
|
||||
{
|
||||
isc_mem_t * mctx = server->mctx;
|
||||
isc_result_t result;
|
||||
named_controls_t *controls = isc_mem_get(mctx, sizeof(*controls));
|
||||
|
||||
if (controls == NULL)
|
||||
|
|
@ -1475,7 +1475,8 @@ named_controls_create(named_server_t *server, named_controls_t **ctrlsp) {
|
|||
}
|
||||
|
||||
void
|
||||
named_controls_destroy(named_controls_t **ctrlsp) {
|
||||
named_controls_destroy(named_controls_t **ctrlsp)
|
||||
{
|
||||
named_controls_t *controls = *ctrlsp;
|
||||
*ctrlsp = NULL;
|
||||
|
||||
|
|
|
|||
292
bin/named/fuzz.c
292
bin/named/fuzz.c
|
|
@ -15,33 +15,34 @@
|
|||
#include <named/fuzz.h>
|
||||
|
||||
#ifdef ENABLE_AFL
|
||||
#include <named/globals.h>
|
||||
#include <named/server.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/app.h>
|
||||
#include <isc/condition.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/thread.h>
|
||||
#include <isc/util.h>
|
||||
#include <named/log.h>
|
||||
|
||||
#include <dns/log.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <named/globals.h>
|
||||
#include <named/log.h>
|
||||
#include <named/server.h>
|
||||
|
||||
/*
|
||||
* We are using pthreads directly because we might be using it with
|
||||
* unthreaded version of BIND, where all thread functions are
|
||||
* mocks. Since AFL for now only works on Linux it's not a problem.
|
||||
*/
|
||||
static pthread_cond_t cond;
|
||||
static pthread_cond_t cond;
|
||||
static pthread_mutex_t mutex;
|
||||
static bool ready;
|
||||
static bool ready;
|
||||
|
||||
/*
|
||||
* In "client:" mode, this thread reads fuzzed query messages from AFL
|
||||
|
|
@ -50,12 +51,13 @@ static bool ready;
|
|||
* test named from the client side.
|
||||
*/
|
||||
static void *
|
||||
fuzz_thread_client(void *arg) {
|
||||
char *host;
|
||||
char *port;
|
||||
fuzz_thread_client(void *arg)
|
||||
{
|
||||
char * host;
|
||||
char * port;
|
||||
struct sockaddr_in servaddr;
|
||||
int sockfd;
|
||||
void *buf;
|
||||
int sockfd;
|
||||
void * buf;
|
||||
|
||||
UNUSED(arg);
|
||||
|
||||
|
|
@ -71,7 +73,7 @@ fuzz_thread_client(void *arg) {
|
|||
*port = 0;
|
||||
++port;
|
||||
|
||||
memset(&servaddr, 0, sizeof (servaddr));
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
RUNTIME_CHECK(inet_pton(AF_INET, host, &servaddr.sin_addr) == 1);
|
||||
servaddr.sin_port = htons(atoi(port));
|
||||
|
|
@ -135,7 +137,7 @@ fuzz_thread_client(void *arg) {
|
|||
ready = false;
|
||||
|
||||
sent = sendto(sockfd, buf, length, 0,
|
||||
(struct sockaddr *) &servaddr, sizeof(servaddr));
|
||||
(struct sockaddr *)&servaddr, sizeof(servaddr));
|
||||
RUNTIME_CHECK(sent == length);
|
||||
|
||||
/*
|
||||
|
|
@ -148,7 +150,7 @@ fuzz_thread_client(void *arg) {
|
|||
pthread_cond_wait(&cond, &mutex);
|
||||
|
||||
RUNTIME_CHECK(pthread_mutex_unlock(&mutex) == 0);
|
||||
next: ;
|
||||
next:;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
|
@ -177,22 +179,21 @@ fuzz_thread_client(void *arg) {
|
|||
* named(resolver) when being fuzzed will not cache answers.
|
||||
*/
|
||||
static void *
|
||||
fuzz_thread_resolver(void *arg) {
|
||||
char *sqtype, *shost, *sport, *rhost, *rport;
|
||||
fuzz_thread_resolver(void *arg)
|
||||
{
|
||||
char * sqtype, *shost, *sport, *rhost, *rport;
|
||||
struct sockaddr_in servaddr, recaddr, recvaddr;
|
||||
/*
|
||||
* Query for aaaaaaaaaa.example./A in wire format with RD=1,
|
||||
* EDNS and DO=1. 0x88, 0x0c at the start is the ID field which
|
||||
* will be updated for each query.
|
||||
*/
|
||||
char respacket[] = {
|
||||
0x88, 0x0c, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x0a, 0x61, 0x61, 0x61,
|
||||
0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x07,
|
||||
0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00,
|
||||
0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10,
|
||||
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00
|
||||
};
|
||||
char respacket[] = { 0x88, 0x0c, 0x01, 0x20, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x0a, 0x61, 0x61, 0x61,
|
||||
0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x07,
|
||||
0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00,
|
||||
0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x29, 0x10,
|
||||
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 };
|
||||
/*
|
||||
* Response for example./DNSKEY in wire format. Note that RRSIGs
|
||||
* were generated with this DNSKEY that are used as seeds for
|
||||
|
|
@ -202,93 +203,78 @@ fuzz_thread_resolver(void *arg) {
|
|||
* which will be made to match the query.
|
||||
*/
|
||||
const uint8_t dnskey_wf[] = {
|
||||
0x8d, 0xf6, 0x84, 0x00, 0x00, 0x01, 0x00, 0x02,
|
||||
0x00, 0x00, 0x00, 0x01, 0x07, 0x65, 0x78, 0x61,
|
||||
0x6d, 0x70, 0x6c, 0x65, 0x00, 0x00, 0x30, 0x00,
|
||||
0x01, 0xc0, 0x0c, 0x00, 0x30, 0x00, 0x01, 0x00,
|
||||
0x00, 0x01, 0x2c, 0x01, 0x08, 0x01, 0x00, 0x03,
|
||||
0x08, 0x03, 0x01, 0x00, 0x01, 0xbd, 0x81, 0xdc,
|
||||
0x7f, 0x16, 0xd4, 0x81, 0x7c, 0x1f, 0x9f, 0x6a,
|
||||
0x68, 0xdd, 0xd4, 0xda, 0x48, 0xd9, 0x1c, 0xbd,
|
||||
0xa6, 0x46, 0x1a, 0xf0, 0xb4, 0xb9, 0xec, 0x3d,
|
||||
0x6c, 0x0b, 0x57, 0xc7, 0xd6, 0x54, 0x66, 0xe6,
|
||||
0x6c, 0xd5, 0x90, 0x3a, 0x78, 0x7d, 0x7f, 0x78,
|
||||
0x80, 0xa2, 0x89, 0x61, 0x6d, 0x8a, 0x2b, 0xcd,
|
||||
0x0a, 0x77, 0x7a, 0xad, 0xc9, 0x61, 0x53, 0x53,
|
||||
0x8c, 0x99, 0x72, 0x86, 0x14, 0x74, 0x9c, 0x49,
|
||||
0x2a, 0x47, 0x23, 0xf7, 0x02, 0x07, 0x73, 0x1c,
|
||||
0x5c, 0x2e, 0xb4, 0x9a, 0xa4, 0xd7, 0x98, 0x42,
|
||||
0xc3, 0xd2, 0xfe, 0xbf, 0xf3, 0xb3, 0x6a, 0x52,
|
||||
0x92, 0xd5, 0xfa, 0x47, 0x00, 0xe3, 0xd9, 0x59,
|
||||
0x31, 0x95, 0x48, 0x40, 0xfc, 0x06, 0x73, 0x90,
|
||||
0xc6, 0x73, 0x96, 0xba, 0x29, 0x91, 0xe2, 0xac,
|
||||
0xa3, 0xa5, 0x6d, 0x91, 0x6d, 0x52, 0xb9, 0x34,
|
||||
0xba, 0x68, 0x4f, 0xad, 0xf0, 0xc3, 0xf3, 0x1d,
|
||||
0x6d, 0x61, 0x76, 0xe5, 0x3d, 0xa3, 0x9b, 0x2a,
|
||||
0x0c, 0x92, 0xb3, 0x78, 0x6b, 0xf1, 0x20, 0xd6,
|
||||
0x90, 0xb7, 0xac, 0xe2, 0xf8, 0x2b, 0x94, 0x10,
|
||||
0x79, 0xce, 0xa8, 0x60, 0x42, 0xea, 0x6a, 0x18,
|
||||
0x2f, 0xc0, 0xd8, 0x05, 0x0a, 0x3b, 0x06, 0x0f,
|
||||
0x02, 0x7e, 0xff, 0x33, 0x46, 0xee, 0xb6, 0x21,
|
||||
0x25, 0x90, 0x63, 0x4b, 0x3b, 0x5e, 0xb2, 0x72,
|
||||
0x3a, 0xcb, 0x91, 0x41, 0xf4, 0x20, 0x50, 0x78,
|
||||
0x1c, 0x93, 0x95, 0xda, 0xfa, 0xae, 0x85, 0xc5,
|
||||
0xd7, 0x6b, 0x92, 0x0c, 0x70, 0x6b, 0xe4, 0xb7,
|
||||
0x29, 0x3a, 0x2e, 0x18, 0x88, 0x82, 0x33, 0x7c,
|
||||
0xa8, 0xea, 0xb8, 0x31, 0x8f, 0xaf, 0x50, 0xc5,
|
||||
0x9c, 0x08, 0x56, 0x8f, 0x09, 0x76, 0x4e, 0xdf,
|
||||
0x97, 0x75, 0x9d, 0x00, 0x52, 0x7f, 0xdb, 0xec,
|
||||
0x30, 0xcb, 0x1c, 0x4c, 0x2a, 0x21, 0x93, 0xc4,
|
||||
0x6d, 0x85, 0xa9, 0x40, 0x3b, 0xc0, 0x0c, 0x00,
|
||||
0x2e, 0x00, 0x01, 0x00, 0x00, 0x01, 0x2c, 0x01,
|
||||
0x1b, 0x00, 0x30, 0x08, 0x01, 0x00, 0x00, 0x01,
|
||||
0x2c, 0x67, 0x74, 0x85, 0x80, 0x58, 0xb3, 0xc5,
|
||||
0x17, 0x36, 0x90, 0x07, 0x65, 0x78, 0x61, 0x6d,
|
||||
0x70, 0x6c, 0x65, 0x00, 0x45, 0xac, 0xd3, 0x82,
|
||||
0x69, 0xf3, 0x10, 0x3a, 0x97, 0x2c, 0x6a, 0xa9,
|
||||
0x78, 0x99, 0xea, 0xb0, 0xcc, 0xf7, 0xaf, 0x33,
|
||||
0x51, 0x5b, 0xdf, 0x77, 0x04, 0x18, 0x14, 0x99,
|
||||
0x61, 0xeb, 0x8d, 0x76, 0x3f, 0xd1, 0x71, 0x14,
|
||||
0x43, 0x80, 0x53, 0xc2, 0x3b, 0x9f, 0x09, 0x4f,
|
||||
0xb3, 0x51, 0x04, 0x89, 0x0e, 0xc8, 0x54, 0x12,
|
||||
0xcd, 0x07, 0x20, 0xbe, 0x94, 0xc2, 0xda, 0x99,
|
||||
0xdd, 0x1e, 0xf8, 0xb0, 0x84, 0x2e, 0xf9, 0x19,
|
||||
0x35, 0x36, 0xf5, 0xd0, 0x5d, 0x82, 0x18, 0x74,
|
||||
0xa0, 0x00, 0xb6, 0x15, 0x57, 0x40, 0x5f, 0x78,
|
||||
0x2d, 0x27, 0xac, 0xc7, 0x8a, 0x29, 0x55, 0xa9,
|
||||
0xcd, 0xbc, 0xf7, 0x3e, 0xff, 0xae, 0x1a, 0x5a,
|
||||
0x1d, 0xac, 0x0d, 0x78, 0x0e, 0x08, 0x33, 0x6c,
|
||||
0x59, 0x70, 0x40, 0xb9, 0x65, 0xbd, 0x35, 0xbb,
|
||||
0x9a, 0x70, 0xdc, 0x93, 0x66, 0xb0, 0xef, 0xfe,
|
||||
0xf0, 0x32, 0xa6, 0xee, 0xb7, 0x03, 0x89, 0xa2,
|
||||
0x4d, 0xe0, 0xf1, 0x20, 0xdf, 0x39, 0xe8, 0xe3,
|
||||
0xcc, 0x95, 0xe9, 0x9a, 0xad, 0xbf, 0xbd, 0x7c,
|
||||
0xf7, 0xd7, 0xde, 0x47, 0x9e, 0xf6, 0x17, 0xbb,
|
||||
0x84, 0xa9, 0xed, 0xf2, 0x45, 0x61, 0x6d, 0x13,
|
||||
0x0b, 0x06, 0x29, 0x50, 0xde, 0xfd, 0x42, 0xb0,
|
||||
0x66, 0x2c, 0x1c, 0x2b, 0x63, 0xcb, 0x4e, 0xb9,
|
||||
0x31, 0xc4, 0xea, 0xd2, 0x07, 0x3a, 0x08, 0x79,
|
||||
0x19, 0x4b, 0x4c, 0x50, 0x97, 0x02, 0xd7, 0x26,
|
||||
0x41, 0x2f, 0xdd, 0x57, 0xaa, 0xb0, 0xa0, 0x21,
|
||||
0x4e, 0x74, 0xb6, 0x97, 0x4b, 0x8b, 0x09, 0x9c,
|
||||
0x3d, 0x29, 0xfb, 0x12, 0x27, 0x47, 0x8f, 0xb8,
|
||||
0xc5, 0x8e, 0x65, 0xcd, 0xca, 0x2f, 0xba, 0xf5,
|
||||
0x3e, 0xec, 0x56, 0xc3, 0xc9, 0xa1, 0x62, 0x7d,
|
||||
0xf2, 0x9f, 0x90, 0x16, 0x1d, 0xbf, 0x97, 0x28,
|
||||
0xe1, 0x92, 0xb1, 0x53, 0xab, 0xc4, 0xe0, 0x99,
|
||||
0xbb, 0x19, 0x90, 0x7c, 0x00, 0x00, 0x29, 0x10,
|
||||
0x8d, 0xf6, 0x84, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00,
|
||||
0x00, 0x01, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65,
|
||||
0x00, 0x00, 0x30, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x30, 0x00,
|
||||
0x01, 0x00, 0x00, 0x01, 0x2c, 0x01, 0x08, 0x01, 0x00, 0x03,
|
||||
0x08, 0x03, 0x01, 0x00, 0x01, 0xbd, 0x81, 0xdc, 0x7f, 0x16,
|
||||
0xd4, 0x81, 0x7c, 0x1f, 0x9f, 0x6a, 0x68, 0xdd, 0xd4, 0xda,
|
||||
0x48, 0xd9, 0x1c, 0xbd, 0xa6, 0x46, 0x1a, 0xf0, 0xb4, 0xb9,
|
||||
0xec, 0x3d, 0x6c, 0x0b, 0x57, 0xc7, 0xd6, 0x54, 0x66, 0xe6,
|
||||
0x6c, 0xd5, 0x90, 0x3a, 0x78, 0x7d, 0x7f, 0x78, 0x80, 0xa2,
|
||||
0x89, 0x61, 0x6d, 0x8a, 0x2b, 0xcd, 0x0a, 0x77, 0x7a, 0xad,
|
||||
0xc9, 0x61, 0x53, 0x53, 0x8c, 0x99, 0x72, 0x86, 0x14, 0x74,
|
||||
0x9c, 0x49, 0x2a, 0x47, 0x23, 0xf7, 0x02, 0x07, 0x73, 0x1c,
|
||||
0x5c, 0x2e, 0xb4, 0x9a, 0xa4, 0xd7, 0x98, 0x42, 0xc3, 0xd2,
|
||||
0xfe, 0xbf, 0xf3, 0xb3, 0x6a, 0x52, 0x92, 0xd5, 0xfa, 0x47,
|
||||
0x00, 0xe3, 0xd9, 0x59, 0x31, 0x95, 0x48, 0x40, 0xfc, 0x06,
|
||||
0x73, 0x90, 0xc6, 0x73, 0x96, 0xba, 0x29, 0x91, 0xe2, 0xac,
|
||||
0xa3, 0xa5, 0x6d, 0x91, 0x6d, 0x52, 0xb9, 0x34, 0xba, 0x68,
|
||||
0x4f, 0xad, 0xf0, 0xc3, 0xf3, 0x1d, 0x6d, 0x61, 0x76, 0xe5,
|
||||
0x3d, 0xa3, 0x9b, 0x2a, 0x0c, 0x92, 0xb3, 0x78, 0x6b, 0xf1,
|
||||
0x20, 0xd6, 0x90, 0xb7, 0xac, 0xe2, 0xf8, 0x2b, 0x94, 0x10,
|
||||
0x79, 0xce, 0xa8, 0x60, 0x42, 0xea, 0x6a, 0x18, 0x2f, 0xc0,
|
||||
0xd8, 0x05, 0x0a, 0x3b, 0x06, 0x0f, 0x02, 0x7e, 0xff, 0x33,
|
||||
0x46, 0xee, 0xb6, 0x21, 0x25, 0x90, 0x63, 0x4b, 0x3b, 0x5e,
|
||||
0xb2, 0x72, 0x3a, 0xcb, 0x91, 0x41, 0xf4, 0x20, 0x50, 0x78,
|
||||
0x1c, 0x93, 0x95, 0xda, 0xfa, 0xae, 0x85, 0xc5, 0xd7, 0x6b,
|
||||
0x92, 0x0c, 0x70, 0x6b, 0xe4, 0xb7, 0x29, 0x3a, 0x2e, 0x18,
|
||||
0x88, 0x82, 0x33, 0x7c, 0xa8, 0xea, 0xb8, 0x31, 0x8f, 0xaf,
|
||||
0x50, 0xc5, 0x9c, 0x08, 0x56, 0x8f, 0x09, 0x76, 0x4e, 0xdf,
|
||||
0x97, 0x75, 0x9d, 0x00, 0x52, 0x7f, 0xdb, 0xec, 0x30, 0xcb,
|
||||
0x1c, 0x4c, 0x2a, 0x21, 0x93, 0xc4, 0x6d, 0x85, 0xa9, 0x40,
|
||||
0x3b, 0xc0, 0x0c, 0x00, 0x2e, 0x00, 0x01, 0x00, 0x00, 0x01,
|
||||
0x2c, 0x01, 0x1b, 0x00, 0x30, 0x08, 0x01, 0x00, 0x00, 0x01,
|
||||
0x2c, 0x67, 0x74, 0x85, 0x80, 0x58, 0xb3, 0xc5, 0x17, 0x36,
|
||||
0x90, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x00,
|
||||
0x45, 0xac, 0xd3, 0x82, 0x69, 0xf3, 0x10, 0x3a, 0x97, 0x2c,
|
||||
0x6a, 0xa9, 0x78, 0x99, 0xea, 0xb0, 0xcc, 0xf7, 0xaf, 0x33,
|
||||
0x51, 0x5b, 0xdf, 0x77, 0x04, 0x18, 0x14, 0x99, 0x61, 0xeb,
|
||||
0x8d, 0x76, 0x3f, 0xd1, 0x71, 0x14, 0x43, 0x80, 0x53, 0xc2,
|
||||
0x3b, 0x9f, 0x09, 0x4f, 0xb3, 0x51, 0x04, 0x89, 0x0e, 0xc8,
|
||||
0x54, 0x12, 0xcd, 0x07, 0x20, 0xbe, 0x94, 0xc2, 0xda, 0x99,
|
||||
0xdd, 0x1e, 0xf8, 0xb0, 0x84, 0x2e, 0xf9, 0x19, 0x35, 0x36,
|
||||
0xf5, 0xd0, 0x5d, 0x82, 0x18, 0x74, 0xa0, 0x00, 0xb6, 0x15,
|
||||
0x57, 0x40, 0x5f, 0x78, 0x2d, 0x27, 0xac, 0xc7, 0x8a, 0x29,
|
||||
0x55, 0xa9, 0xcd, 0xbc, 0xf7, 0x3e, 0xff, 0xae, 0x1a, 0x5a,
|
||||
0x1d, 0xac, 0x0d, 0x78, 0x0e, 0x08, 0x33, 0x6c, 0x59, 0x70,
|
||||
0x40, 0xb9, 0x65, 0xbd, 0x35, 0xbb, 0x9a, 0x70, 0xdc, 0x93,
|
||||
0x66, 0xb0, 0xef, 0xfe, 0xf0, 0x32, 0xa6, 0xee, 0xb7, 0x03,
|
||||
0x89, 0xa2, 0x4d, 0xe0, 0xf1, 0x20, 0xdf, 0x39, 0xe8, 0xe3,
|
||||
0xcc, 0x95, 0xe9, 0x9a, 0xad, 0xbf, 0xbd, 0x7c, 0xf7, 0xd7,
|
||||
0xde, 0x47, 0x9e, 0xf6, 0x17, 0xbb, 0x84, 0xa9, 0xed, 0xf2,
|
||||
0x45, 0x61, 0x6d, 0x13, 0x0b, 0x06, 0x29, 0x50, 0xde, 0xfd,
|
||||
0x42, 0xb0, 0x66, 0x2c, 0x1c, 0x2b, 0x63, 0xcb, 0x4e, 0xb9,
|
||||
0x31, 0xc4, 0xea, 0xd2, 0x07, 0x3a, 0x08, 0x79, 0x19, 0x4b,
|
||||
0x4c, 0x50, 0x97, 0x02, 0xd7, 0x26, 0x41, 0x2f, 0xdd, 0x57,
|
||||
0xaa, 0xb0, 0xa0, 0x21, 0x4e, 0x74, 0xb6, 0x97, 0x4b, 0x8b,
|
||||
0x09, 0x9c, 0x3d, 0x29, 0xfb, 0x12, 0x27, 0x47, 0x8f, 0xb8,
|
||||
0xc5, 0x8e, 0x65, 0xcd, 0xca, 0x2f, 0xba, 0xf5, 0x3e, 0xec,
|
||||
0x56, 0xc3, 0xc9, 0xa1, 0x62, 0x7d, 0xf2, 0x9f, 0x90, 0x16,
|
||||
0x1d, 0xbf, 0x97, 0x28, 0xe1, 0x92, 0xb1, 0x53, 0xab, 0xc4,
|
||||
0xe0, 0x99, 0xbb, 0x19, 0x90, 0x7c, 0x00, 0x00, 0x29, 0x10,
|
||||
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
int sockfd;
|
||||
int listenfd;
|
||||
int loop;
|
||||
uint16_t qtype;
|
||||
char *buf, *rbuf;
|
||||
char *nameptr;
|
||||
int sockfd;
|
||||
int listenfd;
|
||||
int loop;
|
||||
uint16_t qtype;
|
||||
char * buf, *rbuf;
|
||||
char * nameptr;
|
||||
unsigned int i;
|
||||
uint8_t llen;
|
||||
uint64_t seed;
|
||||
uint8_t llen;
|
||||
uint64_t seed;
|
||||
|
||||
UNUSED(arg);
|
||||
|
||||
|
|
@ -326,12 +312,12 @@ fuzz_thread_resolver(void *arg) {
|
|||
respacket[32] = (qtype >> 8) & 0xff;
|
||||
respacket[33] = qtype & 0xff;
|
||||
|
||||
memset(&servaddr, 0, sizeof (servaddr));
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
RUNTIME_CHECK(inet_pton(AF_INET, shost, &servaddr.sin_addr) == 1);
|
||||
servaddr.sin_port = htons(atoi(sport));
|
||||
|
||||
memset(&recaddr, 0, sizeof (recaddr));
|
||||
memset(&recaddr, 0, sizeof(recaddr));
|
||||
recaddr.sin_family = AF_INET;
|
||||
RUNTIME_CHECK(inet_pton(AF_INET, rhost, &recaddr.sin_addr) == 1);
|
||||
recaddr.sin_port = htons(atoi(rport));
|
||||
|
|
@ -367,10 +353,10 @@ fuzz_thread_resolver(void *arg) {
|
|||
* the app.
|
||||
*/
|
||||
for (loop = 0; loop < 100000; loop++) {
|
||||
ssize_t length;
|
||||
ssize_t sent;
|
||||
ssize_t length;
|
||||
ssize_t sent;
|
||||
unsigned short id;
|
||||
socklen_t socklen;
|
||||
socklen_t socklen;
|
||||
|
||||
memset(buf, 0, 12);
|
||||
length = read(0, buf, 65536);
|
||||
|
|
@ -395,7 +381,7 @@ fuzz_thread_resolver(void *arg) {
|
|||
}
|
||||
|
||||
if (length < 12) {
|
||||
length = 12;
|
||||
length = 12;
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(pthread_mutex_lock(&mutex) == 0);
|
||||
|
|
@ -413,7 +399,7 @@ fuzz_thread_resolver(void *arg) {
|
|||
*/
|
||||
socklen = sizeof(recvaddr);
|
||||
(void)recvfrom(listenfd, rbuf, 65536, MSG_DONTWAIT,
|
||||
(struct sockaddr *) &recvaddr, &socklen);
|
||||
(struct sockaddr *)&recvaddr, &socklen);
|
||||
|
||||
/*
|
||||
* Send a fixed client query to named(resolver) of
|
||||
|
|
@ -421,7 +407,7 @@ fuzz_thread_resolver(void *arg) {
|
|||
* driver.
|
||||
*/
|
||||
sent = sendto(sockfd, respacket, sizeof(respacket), 0,
|
||||
(struct sockaddr *) &servaddr, sizeof(servaddr));
|
||||
(struct sockaddr *)&servaddr, sizeof(servaddr));
|
||||
RUNTIME_CHECK(sent == sizeof(respacket));
|
||||
|
||||
/*
|
||||
|
|
@ -432,7 +418,7 @@ fuzz_thread_resolver(void *arg) {
|
|||
*/
|
||||
socklen = sizeof(recvaddr);
|
||||
sent = recvfrom(listenfd, rbuf, 65536, 0,
|
||||
(struct sockaddr *) &recvaddr, &socklen);
|
||||
(struct sockaddr *)&recvaddr, &socklen);
|
||||
RUNTIME_CHECK(sent > 0);
|
||||
|
||||
/*
|
||||
|
|
@ -462,8 +448,7 @@ fuzz_thread_resolver(void *arg) {
|
|||
|
||||
/* Skip the name to get to the qtype */
|
||||
i = 0;
|
||||
while (((llen = nameptr[i]) != 0) &&
|
||||
(i < 255) &&
|
||||
while (((llen = nameptr[i]) != 0) && (i < 255) &&
|
||||
(((nameptr + i + 1 + llen) - buf) < length))
|
||||
i += 1 + llen;
|
||||
|
||||
|
|
@ -485,22 +470,22 @@ fuzz_thread_resolver(void *arg) {
|
|||
* Send the reply to named(resolver).
|
||||
*/
|
||||
sent = sendto(listenfd, buf, length, 0,
|
||||
(struct sockaddr *) &recvaddr, sizeof(recvaddr));
|
||||
(struct sockaddr *)&recvaddr, sizeof(recvaddr));
|
||||
RUNTIME_CHECK(sent == length);
|
||||
|
||||
/* We might get additional questions here (e.g. for CNAME). */
|
||||
for (;;) {
|
||||
fd_set fds;
|
||||
fd_set fds;
|
||||
struct timeval tv;
|
||||
int rv;
|
||||
int max;
|
||||
int rv;
|
||||
int max;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(listenfd, &fds);
|
||||
FD_SET(sockfd, &fds);
|
||||
tv.tv_sec = 10;
|
||||
tv.tv_usec = 0;
|
||||
max = (listenfd > sockfd ? listenfd : sockfd)+1;
|
||||
max = (listenfd > sockfd ? listenfd : sockfd) + 1;
|
||||
|
||||
rv = select(max, &fds, NULL, NULL, &tv);
|
||||
RUNTIME_CHECK(rv > 0);
|
||||
|
|
@ -522,7 +507,8 @@ fuzz_thread_resolver(void *arg) {
|
|||
* NOERROR rcode and sending it back.
|
||||
*/
|
||||
length = recvfrom(listenfd, buf, 65536, 0,
|
||||
(struct sockaddr *) &recvaddr, &socklen);
|
||||
(struct sockaddr *)&recvaddr,
|
||||
&socklen);
|
||||
|
||||
/*
|
||||
* If this is a DNSKEY query, send the DNSKEY,
|
||||
|
|
@ -534,8 +520,7 @@ fuzz_thread_resolver(void *arg) {
|
|||
|
||||
/* Skip the name to get to the qtype */
|
||||
i = 0;
|
||||
while (((llen = nameptr[i]) != 0) &&
|
||||
(i < 255) &&
|
||||
while (((llen = nameptr[i]) != 0) && (i < 255) &&
|
||||
(((nameptr + i + 1 + llen) - buf) < length))
|
||||
i += 1 + llen;
|
||||
|
||||
|
|
@ -558,8 +543,8 @@ fuzz_thread_resolver(void *arg) {
|
|||
|
||||
if (qtype == 48) {
|
||||
memmove(buf + 2, dnskey_wf + 2,
|
||||
sizeof (dnskey_wf) - 2);
|
||||
length = sizeof (dnskey_wf);
|
||||
sizeof(dnskey_wf) - 2);
|
||||
length = sizeof(dnskey_wf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -567,7 +552,7 @@ fuzz_thread_resolver(void *arg) {
|
|||
buf[2] |= 0x80;
|
||||
buf[3] &= 0xF0;
|
||||
sent = sendto(listenfd, buf, length, 0,
|
||||
(struct sockaddr *) &recvaddr,
|
||||
(struct sockaddr *)&recvaddr,
|
||||
sizeof(recvaddr));
|
||||
RUNTIME_CHECK(sent == length);
|
||||
}
|
||||
|
|
@ -608,13 +593,14 @@ fuzz_thread_resolver(void *arg) {
|
|||
* client side.
|
||||
*/
|
||||
static void *
|
||||
fuzz_thread_tcp(void *arg) {
|
||||
char *host;
|
||||
char *port;
|
||||
fuzz_thread_tcp(void *arg)
|
||||
{
|
||||
char * host;
|
||||
char * port;
|
||||
struct sockaddr_in servaddr;
|
||||
int sockfd;
|
||||
char *buf;
|
||||
int loop;
|
||||
int sockfd;
|
||||
char * buf;
|
||||
int loop;
|
||||
|
||||
UNUSED(arg);
|
||||
|
||||
|
|
@ -630,7 +616,7 @@ fuzz_thread_tcp(void *arg) {
|
|||
*port = 0;
|
||||
++port;
|
||||
|
||||
memset(&servaddr, 0, sizeof (servaddr));
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
RUNTIME_CHECK(inet_pton(AF_INET, host, &servaddr.sin_addr) == 1);
|
||||
servaddr.sin_port = htons(atoi(port));
|
||||
|
|
@ -655,15 +641,15 @@ fuzz_thread_tcp(void *arg) {
|
|||
for (loop = 0; loop < 100000; loop++) {
|
||||
ssize_t length;
|
||||
ssize_t sent;
|
||||
int yes;
|
||||
int r;
|
||||
int yes;
|
||||
int r;
|
||||
|
||||
if (named_g_fuzz_type == isc_fuzz_tcpclient) {
|
||||
/*
|
||||
* To fuzz DNS TCP client we have to put 16-bit
|
||||
* message length preceding the start of packet.
|
||||
*/
|
||||
length = read(0, buf+2, 65535);
|
||||
length = read(0, buf + 2, 65535);
|
||||
buf[0] = (length >> 8) & 0xff;
|
||||
buf[1] = length & 0xff;
|
||||
length += 2;
|
||||
|
|
@ -683,10 +669,10 @@ fuzz_thread_tcp(void *arg) {
|
|||
* processed.
|
||||
*/
|
||||
INSIST(length <= 65535);
|
||||
buf[length++]='\r';
|
||||
buf[length++]='\n';
|
||||
buf[length++]='\r';
|
||||
buf[length++]='\n';
|
||||
buf[length++] = '\r';
|
||||
buf[length++] = '\n';
|
||||
buf[length++] = '\r';
|
||||
buf[length++] = '\n';
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(pthread_mutex_lock(&mutex) == 0);
|
||||
|
|
@ -696,11 +682,11 @@ fuzz_thread_tcp(void *arg) {
|
|||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
RUNTIME_CHECK(sockfd != -1);
|
||||
RUNTIME_CHECK(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
|
||||
&yes, sizeof(int)) == 0);
|
||||
RUNTIME_CHECK(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes,
|
||||
sizeof(int)) == 0);
|
||||
|
||||
do {
|
||||
r = connect(sockfd, (struct sockaddr*)&servaddr,
|
||||
r = connect(sockfd, (struct sockaddr *)&servaddr,
|
||||
sizeof(servaddr));
|
||||
if (r != 0)
|
||||
usleep(10000);
|
||||
|
|
@ -736,7 +722,8 @@ fuzz_thread_tcp(void *arg) {
|
|||
* and process the next item from AFL.
|
||||
*/
|
||||
void
|
||||
named_fuzz_notify(void) {
|
||||
named_fuzz_notify(void)
|
||||
{
|
||||
#ifdef ENABLE_AFL
|
||||
if (getenv("AFL_CMIN")) {
|
||||
named_server_flushonshutdown(named_g_server, false);
|
||||
|
|
@ -756,7 +743,8 @@ named_fuzz_notify(void) {
|
|||
}
|
||||
|
||||
void
|
||||
named_fuzz_setup(void) {
|
||||
named_fuzz_setup(void)
|
||||
{
|
||||
#ifdef ENABLE_AFL
|
||||
if (getenv("__AFL_PERSISTENT") || getenv("AFL_CMIN")) {
|
||||
pthread_t thread;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
#include <dns/geoip.h>
|
||||
|
||||
#include <named/log.h>
|
||||
#include <named/geoip.h>
|
||||
#include <named/log.h>
|
||||
|
||||
static dns_geoip_databases_t geoip_table;
|
||||
|
||||
|
|
@ -30,17 +30,18 @@ static dns_geoip_databases_t geoip_table;
|
|||
static MMDB_s geoip_country, geoip_city, geoip_as, geoip_isp, geoip_domain;
|
||||
|
||||
static MMDB_s *
|
||||
open_geoip2(const char *dir, const char *dbfile, MMDB_s *mmdb) {
|
||||
char pathbuf[PATH_MAX];
|
||||
open_geoip2(const char *dir, const char *dbfile, MMDB_s *mmdb)
|
||||
{
|
||||
char pathbuf[PATH_MAX];
|
||||
unsigned int n;
|
||||
int ret;
|
||||
int ret;
|
||||
|
||||
n = snprintf(pathbuf, sizeof(pathbuf), "%s/%s", dir, dbfile);
|
||||
if (n >= sizeof(pathbuf)) {
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
||||
"GeoIP2 database '%s/%s': path too long",
|
||||
dir, dbfile);
|
||||
"GeoIP2 database '%s/%s': path too long", dir,
|
||||
dbfile);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
@ -61,9 +62,9 @@ open_geoip2(const char *dir, const char *dbfile, MMDB_s *mmdb) {
|
|||
}
|
||||
#endif /* HAVE_GEOIP2 */
|
||||
|
||||
|
||||
void
|
||||
named_geoip_init(void) {
|
||||
named_geoip_init(void)
|
||||
{
|
||||
#if defined(HAVE_GEOIP2)
|
||||
if (named_g_geoip == NULL) {
|
||||
named_g_geoip = &geoip_table;
|
||||
|
|
@ -74,7 +75,8 @@ named_geoip_init(void) {
|
|||
}
|
||||
|
||||
void
|
||||
named_geoip_load(char *dir) {
|
||||
named_geoip_load(char *dir)
|
||||
{
|
||||
#if defined(HAVE_GEOIP2)
|
||||
REQUIRE(dir != NULL);
|
||||
|
||||
|
|
@ -82,30 +84,28 @@ named_geoip_load(char *dir) {
|
|||
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
||||
"looking for GeoIP2 databases in '%s'", dir);
|
||||
|
||||
named_g_geoip->country = open_geoip2(dir, "GeoIP2-Country.mmdb",
|
||||
&geoip_country);
|
||||
named_g_geoip->country =
|
||||
open_geoip2(dir, "GeoIP2-Country.mmdb", &geoip_country);
|
||||
if (named_g_geoip->country == NULL) {
|
||||
named_g_geoip->country = open_geoip2(dir,
|
||||
"GeoLite2-Country.mmdb",
|
||||
&geoip_country);
|
||||
named_g_geoip->country = open_geoip2(
|
||||
dir, "GeoLite2-Country.mmdb", &geoip_country);
|
||||
}
|
||||
|
||||
named_g_geoip->city = open_geoip2(dir, "GeoIP2-City.mmdb",
|
||||
&geoip_city);
|
||||
named_g_geoip->city = open_geoip2(dir, "GeoIP2-City.mmdb", &geoip_city);
|
||||
if (named_g_geoip->city == NULL) {
|
||||
named_g_geoip->city = open_geoip2(dir, "GeoLite2-City.mmdb",
|
||||
&geoip_city);
|
||||
named_g_geoip->city =
|
||||
open_geoip2(dir, "GeoLite2-City.mmdb", &geoip_city);
|
||||
}
|
||||
|
||||
named_g_geoip->as = open_geoip2(dir, "GeoIP2-ASN.mmdb", &geoip_as);
|
||||
if (named_g_geoip->as == NULL) {
|
||||
named_g_geoip->as = open_geoip2(dir, "GeoLite2-ASN.mmdb",
|
||||
&geoip_as);
|
||||
named_g_geoip->as =
|
||||
open_geoip2(dir, "GeoLite2-ASN.mmdb", &geoip_as);
|
||||
}
|
||||
|
||||
named_g_geoip->isp = open_geoip2(dir, "GeoIP2-ISP.mmdb", &geoip_isp);
|
||||
named_g_geoip->domain = open_geoip2(dir, "GeoIP2-Domain.mmdb",
|
||||
&geoip_domain);
|
||||
named_g_geoip->domain =
|
||||
open_geoip2(dir, "GeoIP2-Domain.mmdb", &geoip_domain);
|
||||
#else
|
||||
UNUSED(dir);
|
||||
|
||||
|
|
@ -113,7 +113,9 @@ named_geoip_load(char *dir) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void named_geoip_unload(void) {
|
||||
void
|
||||
named_geoip_unload(void)
|
||||
{
|
||||
#ifdef HAVE_GEOIP2
|
||||
if (named_g_geoip->country != NULL) {
|
||||
MMDB_close(named_g_geoip->country);
|
||||
|
|
@ -139,7 +141,8 @@ void named_geoip_unload(void) {
|
|||
}
|
||||
|
||||
void
|
||||
named_geoip_shutdown(void) {
|
||||
named_geoip_shutdown(void)
|
||||
{
|
||||
#ifdef HAVE_GEOIP2
|
||||
named_geoip_unload();
|
||||
#endif /* HAVE_GEOIP2 */
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DLZ_DLOPEN_DRIVER_H
|
||||
#define DLZ_DLOPEN_DRIVER_H
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
#include <isc/types.h>
|
||||
|
||||
isc_result_t named_builtin_init(void);
|
||||
isc_result_t
|
||||
named_builtin_init(void);
|
||||
|
||||
void named_builtin_deinit(void);
|
||||
void
|
||||
named_builtin_deinit(void);
|
||||
|
||||
#endif /* NAMED_BUILTIN_H */
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NAMED_CONFIG_H
|
||||
#define NAMED_CONFIG_H 1
|
||||
|
||||
|
|
@ -17,47 +16,47 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <isccfg/cfg.h>
|
||||
|
||||
#include <dns/types.h>
|
||||
#include <dns/zone.h>
|
||||
|
||||
#include <isccfg/cfg.h>
|
||||
|
||||
#define DEFAULT_IANA_ROOT_ZONE_MASTERS "_default_iana_root_zone_masters"
|
||||
|
||||
isc_result_t
|
||||
named_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf);
|
||||
|
||||
isc_result_t
|
||||
named_config_get(cfg_obj_t const * const *maps, const char *name,
|
||||
const cfg_obj_t **obj);
|
||||
named_config_get(cfg_obj_t const *const *maps, const char *name,
|
||||
const cfg_obj_t **obj);
|
||||
|
||||
isc_result_t
|
||||
named_checknames_get(const cfg_obj_t **maps, const char *name,
|
||||
const cfg_obj_t **obj);
|
||||
const cfg_obj_t **obj);
|
||||
|
||||
int
|
||||
named_config_listcount(const cfg_obj_t *list);
|
||||
|
||||
isc_result_t
|
||||
named_config_getclass(const cfg_obj_t *classobj, dns_rdataclass_t defclass,
|
||||
dns_rdataclass_t *classp);
|
||||
dns_rdataclass_t *classp);
|
||||
|
||||
isc_result_t
|
||||
named_config_gettype(const cfg_obj_t *typeobj, dns_rdatatype_t deftype,
|
||||
dns_rdatatype_t *typep);
|
||||
dns_rdatatype_t *typep);
|
||||
|
||||
dns_zonetype_t
|
||||
named_config_getzonetype(const cfg_obj_t *zonetypeobj);
|
||||
|
||||
isc_result_t
|
||||
named_config_getiplist(const cfg_obj_t *config, const cfg_obj_t *list,
|
||||
in_port_t defport, isc_mem_t *mctx,
|
||||
isc_sockaddr_t **addrsp, isc_dscp_t **dscpsp,
|
||||
uint32_t *countp);
|
||||
in_port_t defport, isc_mem_t *mctx,
|
||||
isc_sockaddr_t **addrsp, isc_dscp_t **dscpsp,
|
||||
uint32_t *countp);
|
||||
|
||||
void
|
||||
named_config_putiplist(isc_mem_t *mctx, isc_sockaddr_t **addrsp,
|
||||
isc_dscp_t **dscpsp, uint32_t count);
|
||||
isc_dscp_t **dscpsp, uint32_t count);
|
||||
|
||||
isc_result_t
|
||||
named_config_getmastersdef(const cfg_obj_t *cctx, const char *name,
|
||||
|
|
@ -65,17 +64,17 @@ named_config_getmastersdef(const cfg_obj_t *cctx, const char *name,
|
|||
|
||||
isc_result_t
|
||||
named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list,
|
||||
isc_mem_t *mctx, dns_ipkeylist_t *ipkl);
|
||||
isc_mem_t *mctx, dns_ipkeylist_t *ipkl);
|
||||
|
||||
isc_result_t
|
||||
named_config_getport(const cfg_obj_t *config, in_port_t *portp);
|
||||
|
||||
isc_result_t
|
||||
named_config_getkeyalgorithm(const char *str, const dns_name_t **name,
|
||||
uint16_t *digestbits);
|
||||
uint16_t *digestbits);
|
||||
isc_result_t
|
||||
named_config_getkeyalgorithm2(const char *str, const dns_name_t **name,
|
||||
unsigned int *typep, uint16_t *digestbits);
|
||||
unsigned int *typep, uint16_t *digestbits);
|
||||
|
||||
isc_result_t
|
||||
named_config_getdscp(const cfg_obj_t *config, isc_dscp_t *dscpp);
|
||||
|
|
|
|||
|
|
@ -19,57 +19,56 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <isccc/types.h>
|
||||
|
||||
#include <isccfg/aclconf.h>
|
||||
|
||||
#include <isccc/types.h>
|
||||
#include <named/types.h>
|
||||
|
||||
#define NAMED_CONTROL_PORT 953
|
||||
#define NAMED_CONTROL_PORT 953
|
||||
|
||||
#define NAMED_COMMAND_STOP "stop"
|
||||
#define NAMED_COMMAND_HALT "halt"
|
||||
#define NAMED_COMMAND_RELOAD "reload"
|
||||
#define NAMED_COMMAND_RECONFIG "reconfig"
|
||||
#define NAMED_COMMAND_REFRESH "refresh"
|
||||
#define NAMED_COMMAND_RETRANSFER "retransfer"
|
||||
#define NAMED_COMMAND_DUMPSTATS "stats"
|
||||
#define NAMED_COMMAND_QUERYLOG "querylog"
|
||||
#define NAMED_COMMAND_DUMPDB "dumpdb"
|
||||
#define NAMED_COMMAND_SECROOTS "secroots"
|
||||
#define NAMED_COMMAND_TRACE "trace"
|
||||
#define NAMED_COMMAND_NOTRACE "notrace"
|
||||
#define NAMED_COMMAND_FLUSH "flush"
|
||||
#define NAMED_COMMAND_FLUSHNAME "flushname"
|
||||
#define NAMED_COMMAND_FLUSHTREE "flushtree"
|
||||
#define NAMED_COMMAND_STATUS "status"
|
||||
#define NAMED_COMMAND_TSIGLIST "tsig-list"
|
||||
#define NAMED_COMMAND_TSIGDELETE "tsig-delete"
|
||||
#define NAMED_COMMAND_FREEZE "freeze"
|
||||
#define NAMED_COMMAND_UNFREEZE "unfreeze"
|
||||
#define NAMED_COMMAND_THAW "thaw"
|
||||
#define NAMED_COMMAND_TIMERPOKE "timerpoke"
|
||||
#define NAMED_COMMAND_RECURSING "recursing"
|
||||
#define NAMED_COMMAND_NULL "null"
|
||||
#define NAMED_COMMAND_NOTIFY "notify"
|
||||
#define NAMED_COMMAND_VALIDATION "validation"
|
||||
#define NAMED_COMMAND_SCAN "scan"
|
||||
#define NAMED_COMMAND_SIGN "sign"
|
||||
#define NAMED_COMMAND_LOADKEYS "loadkeys"
|
||||
#define NAMED_COMMAND_ADDZONE "addzone"
|
||||
#define NAMED_COMMAND_MODZONE "modzone"
|
||||
#define NAMED_COMMAND_DELZONE "delzone"
|
||||
#define NAMED_COMMAND_SHOWZONE "showzone"
|
||||
#define NAMED_COMMAND_SYNC "sync"
|
||||
#define NAMED_COMMAND_SIGNING "signing"
|
||||
#define NAMED_COMMAND_ZONESTATUS "zonestatus"
|
||||
#define NAMED_COMMAND_NTA "nta"
|
||||
#define NAMED_COMMAND_TESTGEN "testgen"
|
||||
#define NAMED_COMMAND_MKEYS "managed-keys"
|
||||
#define NAMED_COMMAND_DNSTAPREOPEN "dnstap-reopen"
|
||||
#define NAMED_COMMAND_DNSTAP "dnstap"
|
||||
#define NAMED_COMMAND_TCPTIMEOUTS "tcp-timeouts"
|
||||
#define NAMED_COMMAND_SERVESTALE "serve-stale"
|
||||
#define NAMED_COMMAND_STOP "stop"
|
||||
#define NAMED_COMMAND_HALT "halt"
|
||||
#define NAMED_COMMAND_RELOAD "reload"
|
||||
#define NAMED_COMMAND_RECONFIG "reconfig"
|
||||
#define NAMED_COMMAND_REFRESH "refresh"
|
||||
#define NAMED_COMMAND_RETRANSFER "retransfer"
|
||||
#define NAMED_COMMAND_DUMPSTATS "stats"
|
||||
#define NAMED_COMMAND_QUERYLOG "querylog"
|
||||
#define NAMED_COMMAND_DUMPDB "dumpdb"
|
||||
#define NAMED_COMMAND_SECROOTS "secroots"
|
||||
#define NAMED_COMMAND_TRACE "trace"
|
||||
#define NAMED_COMMAND_NOTRACE "notrace"
|
||||
#define NAMED_COMMAND_FLUSH "flush"
|
||||
#define NAMED_COMMAND_FLUSHNAME "flushname"
|
||||
#define NAMED_COMMAND_FLUSHTREE "flushtree"
|
||||
#define NAMED_COMMAND_STATUS "status"
|
||||
#define NAMED_COMMAND_TSIGLIST "tsig-list"
|
||||
#define NAMED_COMMAND_TSIGDELETE "tsig-delete"
|
||||
#define NAMED_COMMAND_FREEZE "freeze"
|
||||
#define NAMED_COMMAND_UNFREEZE "unfreeze"
|
||||
#define NAMED_COMMAND_THAW "thaw"
|
||||
#define NAMED_COMMAND_TIMERPOKE "timerpoke"
|
||||
#define NAMED_COMMAND_RECURSING "recursing"
|
||||
#define NAMED_COMMAND_NULL "null"
|
||||
#define NAMED_COMMAND_NOTIFY "notify"
|
||||
#define NAMED_COMMAND_VALIDATION "validation"
|
||||
#define NAMED_COMMAND_SCAN "scan"
|
||||
#define NAMED_COMMAND_SIGN "sign"
|
||||
#define NAMED_COMMAND_LOADKEYS "loadkeys"
|
||||
#define NAMED_COMMAND_ADDZONE "addzone"
|
||||
#define NAMED_COMMAND_MODZONE "modzone"
|
||||
#define NAMED_COMMAND_DELZONE "delzone"
|
||||
#define NAMED_COMMAND_SHOWZONE "showzone"
|
||||
#define NAMED_COMMAND_SYNC "sync"
|
||||
#define NAMED_COMMAND_SIGNING "signing"
|
||||
#define NAMED_COMMAND_ZONESTATUS "zonestatus"
|
||||
#define NAMED_COMMAND_NTA "nta"
|
||||
#define NAMED_COMMAND_TESTGEN "testgen"
|
||||
#define NAMED_COMMAND_MKEYS "managed-keys"
|
||||
#define NAMED_COMMAND_DNSTAPREOPEN "dnstap-reopen"
|
||||
#define NAMED_COMMAND_DNSTAP "dnstap"
|
||||
#define NAMED_COMMAND_TCPTIMEOUTS "tcp-timeouts"
|
||||
#define NAMED_COMMAND_SERVESTALE "serve-stale"
|
||||
|
||||
isc_result_t
|
||||
named_controls_create(named_server_t *server, named_controls_t **ctrlsp);
|
||||
|
|
|
|||
|
|
@ -16,27 +16,26 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <isc/rwlock.h>
|
||||
#include <isc/log.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/netmgr.h>
|
||||
|
||||
#include <isccfg/aclconf.h>
|
||||
#include <isccfg/cfg.h>
|
||||
#include <isc/rwlock.h>
|
||||
|
||||
#include <dns/acl.h>
|
||||
#include <dns/zone.h>
|
||||
|
||||
#include <dst/dst.h>
|
||||
#include <isccfg/aclconf.h>
|
||||
#include <isccfg/cfg.h>
|
||||
|
||||
#include <named/types.h>
|
||||
#include <dst/dst.h>
|
||||
#include <named/fuzz.h>
|
||||
#include <named/types.h>
|
||||
|
||||
#undef EXTERN
|
||||
#undef INIT
|
||||
#ifdef NAMED_MAIN
|
||||
#define EXTERN
|
||||
#define INIT(v) = (v)
|
||||
#define INIT(v) = (v)
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#define INIT(v)
|
||||
|
|
@ -46,116 +45,113 @@
|
|||
#define NAMED_RUN_PID_DIR 1
|
||||
#endif
|
||||
|
||||
EXTERN isc_mem_t * named_g_mctx INIT(NULL);
|
||||
EXTERN unsigned int named_g_cpus INIT(0);
|
||||
EXTERN unsigned int named_g_udpdisp INIT(0);
|
||||
EXTERN isc_taskmgr_t * named_g_taskmgr INIT(NULL);
|
||||
EXTERN dns_dispatchmgr_t * named_g_dispatchmgr INIT(NULL);
|
||||
EXTERN unsigned int named_g_cpus_detected INIT(1);
|
||||
EXTERN isc_mem_t *named_g_mctx INIT(NULL);
|
||||
EXTERN unsigned int named_g_cpus INIT(0);
|
||||
EXTERN unsigned int named_g_udpdisp INIT(0);
|
||||
EXTERN isc_taskmgr_t *named_g_taskmgr INIT(NULL);
|
||||
EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL);
|
||||
EXTERN unsigned int named_g_cpus_detected INIT(1);
|
||||
|
||||
#ifdef ENABLE_AFL
|
||||
EXTERN bool named_g_run_done INIT(false);
|
||||
EXTERN bool named_g_run_done INIT(false);
|
||||
#endif
|
||||
/*
|
||||
* XXXRTH We're going to want multiple timer managers eventually. One
|
||||
* for really short timers, another for client timers, and one
|
||||
* for zone timers.
|
||||
*/
|
||||
EXTERN isc_timermgr_t * named_g_timermgr INIT(NULL);
|
||||
EXTERN isc_socketmgr_t * named_g_socketmgr INIT(NULL);
|
||||
EXTERN isc_nm_t * named_g_nm INIT(NULL);
|
||||
EXTERN cfg_parser_t * named_g_parser INIT(NULL);
|
||||
EXTERN cfg_parser_t * named_g_addparser INIT(NULL);
|
||||
EXTERN const char * named_g_version INIT(VERSION);
|
||||
EXTERN const char * named_g_product INIT(PRODUCT);
|
||||
EXTERN const char * named_g_description INIT(DESCRIPTION);
|
||||
EXTERN const char * named_g_srcid INIT(SRCID);
|
||||
EXTERN const char * named_g_configargs INIT(CONFIGARGS);
|
||||
EXTERN const char * named_g_builder INIT(BUILDER);
|
||||
EXTERN in_port_t named_g_port INIT(0);
|
||||
EXTERN isc_dscp_t named_g_dscp INIT(-1);
|
||||
EXTERN isc_timermgr_t *named_g_timermgr INIT(NULL);
|
||||
EXTERN isc_socketmgr_t *named_g_socketmgr INIT(NULL);
|
||||
EXTERN isc_nm_t *named_g_nm INIT(NULL);
|
||||
EXTERN cfg_parser_t *named_g_parser INIT(NULL);
|
||||
EXTERN cfg_parser_t *named_g_addparser INIT(NULL);
|
||||
EXTERN const char *named_g_version INIT(VERSION);
|
||||
EXTERN const char *named_g_product INIT(PRODUCT);
|
||||
EXTERN const char *named_g_description INIT(DESCRIPTION);
|
||||
EXTERN const char *named_g_srcid INIT(SRCID);
|
||||
EXTERN const char *named_g_configargs INIT(CONFIGARGS);
|
||||
EXTERN const char *named_g_builder INIT(BUILDER);
|
||||
EXTERN in_port_t named_g_port INIT(0);
|
||||
EXTERN isc_dscp_t named_g_dscp INIT(-1);
|
||||
|
||||
EXTERN named_server_t * named_g_server INIT(NULL);
|
||||
EXTERN named_server_t *named_g_server INIT(NULL);
|
||||
|
||||
/*
|
||||
* Logging.
|
||||
*/
|
||||
EXTERN isc_log_t * named_g_lctx INIT(NULL);
|
||||
EXTERN isc_logcategory_t * named_g_categories INIT(NULL);
|
||||
EXTERN isc_logmodule_t * named_g_modules INIT(NULL);
|
||||
EXTERN unsigned int named_g_debuglevel INIT(0);
|
||||
EXTERN isc_log_t *named_g_lctx INIT(NULL);
|
||||
EXTERN isc_logcategory_t *named_g_categories INIT(NULL);
|
||||
EXTERN isc_logmodule_t *named_g_modules INIT(NULL);
|
||||
EXTERN unsigned int named_g_debuglevel INIT(0);
|
||||
|
||||
/*
|
||||
* Current configuration information.
|
||||
*/
|
||||
EXTERN cfg_obj_t * named_g_config INIT(NULL);
|
||||
EXTERN const cfg_obj_t * named_g_defaults INIT(NULL);
|
||||
EXTERN const char * named_g_conffile INIT(NAMED_SYSCONFDIR
|
||||
"/named.conf");
|
||||
EXTERN const char * named_g_defaultbindkeys INIT(NAMED_SYSCONFDIR
|
||||
"/bind.keys");
|
||||
EXTERN const char * named_g_keyfile INIT(NAMED_SYSCONFDIR
|
||||
"/rndc.key");
|
||||
EXTERN cfg_obj_t *named_g_config INIT(NULL);
|
||||
EXTERN const cfg_obj_t *named_g_defaults INIT(NULL);
|
||||
EXTERN const char *named_g_conffile INIT(NAMED_SYSCONFDIR "/named.conf");
|
||||
EXTERN const char *named_g_defaultbindkeys INIT(NAMED_SYSCONFDIR "/bind.keys");
|
||||
EXTERN const char *named_g_keyfile INIT(NAMED_SYSCONFDIR "/rndc.key");
|
||||
|
||||
EXTERN dns_tsigkey_t * named_g_sessionkey INIT(NULL);
|
||||
EXTERN dns_name_t named_g_sessionkeyname;
|
||||
EXTERN bool named_g_conffileset INIT(false);
|
||||
EXTERN cfg_aclconfctx_t * named_g_aclconfctx INIT(NULL);
|
||||
EXTERN dns_tsigkey_t *named_g_sessionkey INIT(NULL);
|
||||
EXTERN dns_name_t named_g_sessionkeyname;
|
||||
EXTERN bool named_g_conffileset INIT(false);
|
||||
EXTERN cfg_aclconfctx_t *named_g_aclconfctx INIT(NULL);
|
||||
|
||||
/*
|
||||
* Initial resource limits.
|
||||
*/
|
||||
EXTERN isc_resourcevalue_t named_g_initstacksize INIT(0);
|
||||
EXTERN isc_resourcevalue_t named_g_initdatasize INIT(0);
|
||||
EXTERN isc_resourcevalue_t named_g_initcoresize INIT(0);
|
||||
EXTERN isc_resourcevalue_t named_g_initopenfiles INIT(0);
|
||||
EXTERN isc_resourcevalue_t named_g_initstacksize INIT(0);
|
||||
EXTERN isc_resourcevalue_t named_g_initdatasize INIT(0);
|
||||
EXTERN isc_resourcevalue_t named_g_initcoresize INIT(0);
|
||||
EXTERN isc_resourcevalue_t named_g_initopenfiles INIT(0);
|
||||
|
||||
/*
|
||||
* Misc.
|
||||
*/
|
||||
EXTERN bool named_g_coreok INIT(true);
|
||||
EXTERN const char * named_g_chrootdir INIT(NULL);
|
||||
EXTERN bool named_g_foreground INIT(false);
|
||||
EXTERN bool named_g_logstderr INIT(false);
|
||||
EXTERN bool named_g_nosyslog INIT(false);
|
||||
EXTERN const char * named_g_logfile INIT(NULL);
|
||||
EXTERN bool named_g_coreok INIT(true);
|
||||
EXTERN const char *named_g_chrootdir INIT(NULL);
|
||||
EXTERN bool named_g_foreground INIT(false);
|
||||
EXTERN bool named_g_logstderr INIT(false);
|
||||
EXTERN bool named_g_nosyslog INIT(false);
|
||||
EXTERN const char *named_g_logfile INIT(NULL);
|
||||
|
||||
EXTERN const char * named_g_defaultsessionkeyfile
|
||||
INIT(NAMED_LOCALSTATEDIR "/run/named/"
|
||||
"session.key");
|
||||
EXTERN const char * named_g_defaultlockfile INIT(NAMED_LOCALSTATEDIR
|
||||
"/run/named/"
|
||||
"named.lock");
|
||||
EXTERN bool named_g_forcelock INIT(false);
|
||||
EXTERN const char *named_g_defaultsessionkeyfile INIT(NAMED_LOCALSTATEDIR
|
||||
"/run/named/"
|
||||
"session.key");
|
||||
EXTERN const char *named_g_defaultlockfile INIT(NAMED_LOCALSTATEDIR "/run/"
|
||||
"named/"
|
||||
"named."
|
||||
"lock");
|
||||
EXTERN bool named_g_forcelock INIT(false);
|
||||
|
||||
#if NAMED_RUN_PID_DIR
|
||||
EXTERN const char * named_g_defaultpidfile INIT(NAMED_LOCALSTATEDIR
|
||||
"/run/named/"
|
||||
"named.pid");
|
||||
EXTERN const char *named_g_defaultpidfile INIT(NAMED_LOCALSTATEDIR "/run/named/"
|
||||
"named.pid");
|
||||
#else
|
||||
EXTERN const char * named_g_defaultpidfile INIT(NAMED_LOCALSTATEDIR
|
||||
"/run/named.pid");
|
||||
EXTERN const char *named_g_defaultpidfile INIT(NAMED_LOCALSTATEDIR "/run/"
|
||||
"named.pid");
|
||||
#endif
|
||||
|
||||
EXTERN const char * named_g_username INIT(NULL);
|
||||
EXTERN const char *named_g_username INIT(NULL);
|
||||
|
||||
EXTERN const char * named_g_engine INIT(NULL);
|
||||
EXTERN const char *named_g_engine INIT(NULL);
|
||||
|
||||
EXTERN isc_time_t named_g_boottime;
|
||||
EXTERN isc_time_t named_g_configtime;
|
||||
EXTERN bool named_g_memstatistics INIT(false);
|
||||
EXTERN bool named_g_keepstderr INIT(false);
|
||||
EXTERN isc_time_t named_g_boottime;
|
||||
EXTERN isc_time_t named_g_configtime;
|
||||
EXTERN bool named_g_memstatistics INIT(false);
|
||||
EXTERN bool named_g_keepstderr INIT(false);
|
||||
|
||||
EXTERN unsigned int named_g_tat_interval INIT(24*3600);
|
||||
EXTERN unsigned int named_g_tat_interval INIT(24 * 3600);
|
||||
|
||||
#if defined(HAVE_GEOIP2)
|
||||
EXTERN dns_geoip_databases_t *named_g_geoip INIT(NULL);
|
||||
EXTERN dns_geoip_databases_t *named_g_geoip INIT(NULL);
|
||||
#endif
|
||||
|
||||
EXTERN const char * named_g_fuzz_addr INIT(NULL);
|
||||
EXTERN isc_fuzztype_t named_g_fuzz_type INIT(isc_fuzz_none);
|
||||
EXTERN const char *named_g_fuzz_addr INIT(NULL);
|
||||
EXTERN isc_fuzztype_t named_g_fuzz_type INIT(isc_fuzz_none);
|
||||
|
||||
EXTERN dns_acl_t * named_g_mapped INIT(NULL);
|
||||
EXTERN dns_acl_t *named_g_mapped INIT(NULL);
|
||||
|
||||
#undef EXTERN
|
||||
#undef INIT
|
||||
|
|
|
|||
|
|
@ -19,19 +19,19 @@
|
|||
|
||||
#include <dns/log.h>
|
||||
|
||||
#include <named/globals.h> /* Required for named_g_(categories|modules). */
|
||||
#include <named/globals.h> /* Required for named_g_(categories|modules). */
|
||||
|
||||
/* Unused slot 0. */
|
||||
#define NAMED_LOGCATEGORY_UNMATCHED (&named_g_categories[1])
|
||||
#define NAMED_LOGCATEGORY_UNMATCHED (&named_g_categories[1])
|
||||
|
||||
/*
|
||||
* Backwards compatibility.
|
||||
*/
|
||||
#define NAMED_LOGCATEGORY_GENERAL ISC_LOGCATEGORY_GENERAL
|
||||
#define NAMED_LOGCATEGORY_GENERAL ISC_LOGCATEGORY_GENERAL
|
||||
|
||||
#define NAMED_LOGMODULE_MAIN (&named_g_modules[0])
|
||||
#define NAMED_LOGMODULE_SERVER (&named_g_modules[1])
|
||||
#define NAMED_LOGMODULE_CONTROL (&named_g_modules[2])
|
||||
#define NAMED_LOGMODULE_MAIN (&named_g_modules[0])
|
||||
#define NAMED_LOGMODULE_SERVER (&named_g_modules[1])
|
||||
#define NAMED_LOGMODULE_CONTROL (&named_g_modules[2])
|
||||
|
||||
isc_result_t
|
||||
named_log_init(bool safe);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NAMED_LOGCONF_H
|
||||
#define NAMED_LOGCONF_H 1
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
ISC_PLATFORM_NORETURN_PRE void
|
||||
named_main_earlyfatal(const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
void
|
||||
named_main_earlywarning(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||
|
|
|
|||
|
|
@ -35,80 +35,80 @@
|
|||
|
||||
#include <named/types.h>
|
||||
|
||||
#define NAMED_EVENTCLASS ISC_EVENTCLASS(0x4E43)
|
||||
#define NAMED_EVENT_RELOAD (NAMED_EVENTCLASS + 0)
|
||||
#define NAMED_EVENT_DELZONE (NAMED_EVENTCLASS + 1)
|
||||
#define NAMED_EVENTCLASS ISC_EVENTCLASS(0x4E43)
|
||||
#define NAMED_EVENT_RELOAD (NAMED_EVENTCLASS + 0)
|
||||
#define NAMED_EVENT_DELZONE (NAMED_EVENTCLASS + 1)
|
||||
|
||||
/*%
|
||||
* Name server state. Better here than in lots of separate global variables.
|
||||
*/
|
||||
struct named_server {
|
||||
unsigned int magic;
|
||||
isc_mem_t * mctx;
|
||||
unsigned int magic;
|
||||
isc_mem_t * mctx;
|
||||
|
||||
ns_server_t * sctx;
|
||||
ns_server_t *sctx;
|
||||
|
||||
isc_task_t * task;
|
||||
isc_task_t *task;
|
||||
|
||||
char * statsfile; /*%< Statistics file name */
|
||||
char * dumpfile; /*%< Dump file name */
|
||||
char * secrootsfile; /*%< Secroots file name */
|
||||
char * bindkeysfile; /*%< bind.keys file name */
|
||||
char * recfile; /*%< Recursive file name */
|
||||
bool version_set; /*%< User has set version */
|
||||
char * version; /*%< User-specified version */
|
||||
bool hostname_set; /*%< User has set hostname */
|
||||
char * hostname; /*%< User-specified hostname */
|
||||
char *statsfile; /*%< Statistics file name */
|
||||
char *dumpfile; /*%< Dump file name */
|
||||
char *secrootsfile; /*%< Secroots file name */
|
||||
char *bindkeysfile; /*%< bind.keys file name */
|
||||
char *recfile; /*%< Recursive file name */
|
||||
bool version_set; /*%< User has set version */
|
||||
char *version; /*%< User-specified version */
|
||||
bool hostname_set; /*%< User has set hostname */
|
||||
char *hostname; /*%< User-specified hostname */
|
||||
|
||||
/* Server data structures. */
|
||||
dns_loadmgr_t * loadmgr;
|
||||
dns_zonemgr_t * zonemgr;
|
||||
dns_viewlist_t viewlist;
|
||||
dns_kasplist_t kasplist;
|
||||
ns_interfacemgr_t * interfacemgr;
|
||||
dns_db_t * in_roothints;
|
||||
dns_loadmgr_t * loadmgr;
|
||||
dns_zonemgr_t * zonemgr;
|
||||
dns_viewlist_t viewlist;
|
||||
dns_kasplist_t kasplist;
|
||||
ns_interfacemgr_t *interfacemgr;
|
||||
dns_db_t * in_roothints;
|
||||
|
||||
isc_timer_t * interface_timer;
|
||||
isc_timer_t * heartbeat_timer;
|
||||
isc_timer_t * pps_timer;
|
||||
isc_timer_t * tat_timer;
|
||||
isc_timer_t *interface_timer;
|
||||
isc_timer_t *heartbeat_timer;
|
||||
isc_timer_t *pps_timer;
|
||||
isc_timer_t *tat_timer;
|
||||
|
||||
uint32_t interface_interval;
|
||||
uint32_t heartbeat_interval;
|
||||
uint32_t interface_interval;
|
||||
uint32_t heartbeat_interval;
|
||||
|
||||
isc_mutex_t reload_event_lock;
|
||||
isc_event_t * reload_event;
|
||||
named_reload_t reload_status;
|
||||
isc_mutex_t reload_event_lock;
|
||||
isc_event_t * reload_event;
|
||||
named_reload_t reload_status;
|
||||
|
||||
bool flushonshutdown;
|
||||
bool flushonshutdown;
|
||||
|
||||
named_cachelist_t cachelist; /*%< Possibly shared caches */
|
||||
isc_stats_t * zonestats; /*% Zone management stats */
|
||||
isc_stats_t * resolverstats; /*% Resolver stats */
|
||||
isc_stats_t * sockstats; /*%< Socket stats */
|
||||
named_cachelist_t cachelist; /*%< Possibly shared caches */
|
||||
isc_stats_t * zonestats; /*% Zone management stats */
|
||||
isc_stats_t * resolverstats; /*% Resolver stats */
|
||||
isc_stats_t * sockstats; /*%< Socket stats */
|
||||
|
||||
named_controls_t * controls; /*%< Control channels */
|
||||
unsigned int dispatchgen;
|
||||
named_dispatchlist_t dispatches;
|
||||
named_controls_t * controls; /*%< Control channels */
|
||||
unsigned int dispatchgen;
|
||||
named_dispatchlist_t dispatches;
|
||||
|
||||
named_statschannellist_t statschannels;
|
||||
|
||||
dns_tsigkey_t *sessionkey;
|
||||
char *session_keyfile;
|
||||
dns_name_t *session_keyname;
|
||||
unsigned int session_keyalg;
|
||||
uint16_t session_keybits;
|
||||
bool interface_auto;
|
||||
unsigned char secret[32]; /*%< Server Cookie Secret */
|
||||
ns_cookiealg_t cookiealg;
|
||||
dns_tsigkey_t *sessionkey;
|
||||
char * session_keyfile;
|
||||
dns_name_t * session_keyname;
|
||||
unsigned int session_keyalg;
|
||||
uint16_t session_keybits;
|
||||
bool interface_auto;
|
||||
unsigned char secret[32]; /*%< Server Cookie Secret */
|
||||
ns_cookiealg_t cookiealg;
|
||||
|
||||
dns_dtenv_t *dtenv; /*%< Dnstap environment */
|
||||
dns_dtenv_t *dtenv; /*%< Dnstap environment */
|
||||
|
||||
char * lockfile;
|
||||
char *lockfile;
|
||||
};
|
||||
|
||||
#define NAMED_SERVER_MAGIC ISC_MAGIC('S','V','E','R')
|
||||
#define NAMED_SERVER_VALID(s) ISC_MAGIC_VALID(s, NAMED_SERVER_MAGIC)
|
||||
#define NAMED_SERVER_MAGIC ISC_MAGIC('S', 'V', 'E', 'R')
|
||||
#define NAMED_SERVER_VALID(s) ISC_MAGIC_VALID(s, NAMED_SERVER_MAGIC)
|
||||
|
||||
void
|
||||
named_server_create(isc_mem_t *mctx, named_server_t **serverp);
|
||||
|
|
@ -148,7 +148,7 @@ named_server_flushonshutdown(named_server_t *server, bool flush);
|
|||
|
||||
isc_result_t
|
||||
named_server_reloadcommand(named_server_t *server, isc_lex_t *lex,
|
||||
isc_buffer_t **text);
|
||||
isc_buffer_t **text);
|
||||
/*%<
|
||||
* Act on a "reload" command from the command channel.
|
||||
*/
|
||||
|
|
@ -161,21 +161,21 @@ named_server_reconfigcommand(named_server_t *server);
|
|||
|
||||
isc_result_t
|
||||
named_server_notifycommand(named_server_t *server, isc_lex_t *lex,
|
||||
isc_buffer_t **text);
|
||||
isc_buffer_t **text);
|
||||
/*%<
|
||||
* Act on a "notify" command from the command channel.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
named_server_refreshcommand(named_server_t *server, isc_lex_t *lex,
|
||||
isc_buffer_t **text);
|
||||
isc_buffer_t **text);
|
||||
/*%<
|
||||
* Act on a "refresh" command from the command channel.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
named_server_retransfercommand(named_server_t *server, isc_lex_t *lex,
|
||||
isc_buffer_t **text);
|
||||
isc_buffer_t **text);
|
||||
/*%<
|
||||
* Act on a "retransfer" command from the command channel.
|
||||
*/
|
||||
|
|
@ -217,7 +217,7 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
|
|||
*/
|
||||
isc_result_t
|
||||
named_server_dumpsecroots(named_server_t *server, isc_lex_t *lex,
|
||||
isc_buffer_t **text);
|
||||
isc_buffer_t **text);
|
||||
|
||||
/*%
|
||||
* Change or increment the server debug level.
|
||||
|
|
@ -237,8 +237,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex);
|
|||
* flush all the names under the specified name.
|
||||
*/
|
||||
isc_result_t
|
||||
named_server_flushnode(named_server_t *server, isc_lex_t *lex,
|
||||
bool tree);
|
||||
named_server_flushnode(named_server_t *server, isc_lex_t *lex, bool tree);
|
||||
|
||||
/*%
|
||||
* Report the server's status.
|
||||
|
|
@ -257,14 +256,14 @@ named_server_tsiglist(named_server_t *server, isc_buffer_t **text);
|
|||
*/
|
||||
isc_result_t
|
||||
named_server_tsigdelete(named_server_t *server, isc_lex_t *lex,
|
||||
isc_buffer_t **text);
|
||||
isc_buffer_t **text);
|
||||
|
||||
/*%
|
||||
* Enable or disable updates for a zone.
|
||||
*/
|
||||
isc_result_t
|
||||
named_server_freeze(named_server_t *server, bool freeze,
|
||||
isc_lex_t *lex, isc_buffer_t **text);
|
||||
named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
|
||||
isc_buffer_t **text);
|
||||
|
||||
/*%
|
||||
* Dump zone updates to disk, optionally removing the journal file
|
||||
|
|
@ -342,8 +341,8 @@ named_server_zonestatus(named_server_t *server, isc_lex_t *lex,
|
|||
* duration, in a particular view if specified, or in all views.
|
||||
*/
|
||||
isc_result_t
|
||||
named_server_nta(named_server_t *server, isc_lex_t *lex,
|
||||
bool readonly, isc_buffer_t **text);
|
||||
named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly,
|
||||
isc_buffer_t **text);
|
||||
|
||||
/*%
|
||||
* Generates a test sequence that is only for use in system tests. The
|
||||
|
|
|
|||
|
|
@ -24,12 +24,14 @@
|
|||
#define INIT(v)
|
||||
#endif
|
||||
|
||||
EXTERN unsigned int named_smf_got_instance INIT(0);
|
||||
EXTERN unsigned int named_smf_chroot INIT(0);
|
||||
EXTERN unsigned int named_smf_want_disable INIT(0);
|
||||
EXTERN unsigned int named_smf_got_instance INIT(0);
|
||||
EXTERN unsigned int named_smf_chroot INIT(0);
|
||||
EXTERN unsigned int named_smf_want_disable INIT(0);
|
||||
|
||||
isc_result_t named_smf_add_message(isc_buffer_t **text);
|
||||
isc_result_t named_smf_get_instance(char **name, int debug, isc_mem_t *mctx);
|
||||
isc_result_t
|
||||
named_smf_add_message(isc_buffer_t **text);
|
||||
isc_result_t
|
||||
named_smf_get_instance(char **name, int debug, isc_mem_t *mctx);
|
||||
|
||||
#undef EXTERN
|
||||
#undef INIT
|
||||
|
|
|
|||
|
|
@ -17,13 +17,12 @@
|
|||
* The statistics channels built-in the name server.
|
||||
*/
|
||||
|
||||
#include <isccc/types.h>
|
||||
|
||||
#include <isccfg/aclconf.h>
|
||||
|
||||
#include <isccc/types.h>
|
||||
#include <named/types.h>
|
||||
|
||||
#define NAMED_STATSCHANNEL_HTTPPORT 80
|
||||
#define NAMED_STATSCHANNEL_HTTPPORT 80
|
||||
|
||||
isc_result_t
|
||||
named_statschannels_configure(named_server_t *server, const cfg_obj_t *config,
|
||||
|
|
@ -38,7 +37,6 @@ named_statschannels_configure(named_server_t *server, const cfg_obj_t *config,
|
|||
* and create a new one.
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
named_statschannels_shutdown(named_server_t *server);
|
||||
/*%<
|
||||
|
|
@ -51,4 +49,4 @@ named_stats_dump(named_server_t *server, FILE *fp);
|
|||
* Dump statistics counters managed by the server to the file fp.
|
||||
*/
|
||||
|
||||
#endif /* NAMED_STATSCHANNEL_H */
|
||||
#endif /* NAMED_STATSCHANNEL_H */
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#include <isccfg/cfg.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@
|
|||
|
||||
#include <dns/types.h>
|
||||
|
||||
typedef struct named_cache named_cache_t;
|
||||
typedef ISC_LIST(named_cache_t) named_cachelist_t;
|
||||
typedef struct named_server named_server_t;
|
||||
typedef struct named_xmld named_xmld_t;
|
||||
typedef struct named_xmldmgr named_xmldmgr_t;
|
||||
typedef struct named_controls named_controls_t;
|
||||
typedef struct named_dispatch named_dispatch_t;
|
||||
typedef ISC_LIST(named_dispatch_t) named_dispatchlist_t;
|
||||
typedef struct named_statschannel named_statschannel_t;
|
||||
typedef ISC_LIST(named_statschannel_t) named_statschannellist_t;
|
||||
typedef struct named_cache named_cache_t;
|
||||
typedef ISC_LIST(named_cache_t) named_cachelist_t;
|
||||
typedef struct named_server named_server_t;
|
||||
typedef struct named_xmld named_xmld_t;
|
||||
typedef struct named_xmldmgr named_xmldmgr_t;
|
||||
typedef struct named_controls named_controls_t;
|
||||
typedef struct named_dispatch named_dispatch_t;
|
||||
typedef ISC_LIST(named_dispatch_t) named_dispatchlist_t;
|
||||
typedef struct named_statschannel named_statschannel_t;
|
||||
typedef ISC_LIST(named_statschannel_t) named_statschannellist_t;
|
||||
|
||||
/*%
|
||||
* Used for server->reload_status as printed by `rndc status`
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ ISC_LANG_BEGINDECLS
|
|||
isc_result_t
|
||||
named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
||||
const cfg_obj_t *zconfig, cfg_aclconfctx_t *ac,
|
||||
dns_kasplist_t* kasplist, dns_zone_t *zone,
|
||||
dns_kasplist_t *kasplist, dns_zone_t *zone,
|
||||
dns_zone_t *raw);
|
||||
/*%<
|
||||
* Configure or reconfigure a zone according to the named.conf
|
||||
|
|
@ -52,10 +52,8 @@ named_zone_reusable(dns_zone_t *zone, const cfg_obj_t *zconfig);
|
|||
*/
|
||||
|
||||
isc_result_t
|
||||
named_zone_configure_writeable_dlz(dns_dlzdb_t *dlzdatabase,
|
||||
dns_zone_t *zone,
|
||||
dns_rdataclass_t rdclass,
|
||||
dns_name_t *name);
|
||||
named_zone_configure_writeable_dlz(dns_dlzdb_t *dlzdatabase, dns_zone_t *zone,
|
||||
dns_rdataclass_t rdclass, dns_name_t *name);
|
||||
/*%>
|
||||
* configure a DLZ zone, setting up the database methods and calling
|
||||
* postload to load the origin values
|
||||
|
|
|
|||
107
bin/named/log.c
107
bin/named/log.c
|
|
@ -15,10 +15,10 @@
|
|||
|
||||
#include <dns/log.h>
|
||||
|
||||
#include <ns/log.h>
|
||||
|
||||
#include <isccfg/log.h>
|
||||
|
||||
#include <ns/log.h>
|
||||
|
||||
#include <named/log.h>
|
||||
|
||||
#ifndef ISC_FACILITY
|
||||
|
|
@ -30,26 +30,22 @@
|
|||
* \#define to <named/log.h> and to update the list in
|
||||
* bin/check/check-tool.c.
|
||||
*/
|
||||
static isc_logcategory_t categories[] = {
|
||||
{ "", 0 },
|
||||
{ "unmatched", 0 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
static isc_logcategory_t categories[] = { { "", 0 },
|
||||
{ "unmatched", 0 },
|
||||
{ NULL, 0 } };
|
||||
|
||||
/*%
|
||||
* When adding a new module, be sure to add the appropriate
|
||||
* \#define to <dns/log.h>.
|
||||
*/
|
||||
static isc_logmodule_t modules[] = {
|
||||
{ "main", 0 },
|
||||
{ "server", 0 },
|
||||
{ "control", 0 },
|
||||
{ NULL, 0 }
|
||||
{ "main", 0 }, { "server", 0 }, { "control", 0 }, { NULL, 0 }
|
||||
};
|
||||
|
||||
isc_result_t
|
||||
named_log_init(bool safe) {
|
||||
isc_result_t result;
|
||||
named_log_init(bool safe)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_logconfig_t *lcfg = NULL;
|
||||
|
||||
named_g_categories = categories;
|
||||
|
|
@ -87,7 +83,7 @@ named_log_init(bool safe) {
|
|||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
isc_log_destroy(&named_g_lctx);
|
||||
isc_log_setcontext(NULL);
|
||||
dns_log_setcontext(NULL);
|
||||
|
|
@ -96,8 +92,9 @@ named_log_init(bool safe) {
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
named_log_setdefaultchannels(isc_logconfig_t *lcfg) {
|
||||
isc_result_t result;
|
||||
named_log_setdefaultchannels(isc_logconfig_t *lcfg)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_logdestination_t destination;
|
||||
|
||||
/*
|
||||
|
|
@ -105,17 +102,14 @@ named_log_setdefaultchannels(isc_logconfig_t *lcfg) {
|
|||
* stderr. In BIND, we want to override this and log to named.run
|
||||
* instead, unless the -g option was given.
|
||||
*/
|
||||
if (! named_g_logstderr) {
|
||||
if (!named_g_logstderr) {
|
||||
destination.file.stream = NULL;
|
||||
destination.file.name = "named.run";
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
result = isc_log_createchannel(lcfg, "default_debug",
|
||||
ISC_LOG_TOFILE,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination,
|
||||
ISC_LOG_PRINTTIME|
|
||||
ISC_LOG_DEBUGONLY);
|
||||
result = isc_log_createchannel(
|
||||
lcfg, "default_debug", ISC_LOG_TOFILE, ISC_LOG_DYNAMIC,
|
||||
&destination, ISC_LOG_PRINTTIME | ISC_LOG_DEBUGONLY);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
@ -125,22 +119,19 @@ named_log_setdefaultchannels(isc_logconfig_t *lcfg) {
|
|||
destination.file.name = named_g_logfile;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
result = isc_log_createchannel(lcfg, "default_logfile",
|
||||
ISC_LOG_TOFILE,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination,
|
||||
ISC_LOG_PRINTTIME|
|
||||
ISC_LOG_PRINTCATEGORY|
|
||||
ISC_LOG_PRINTLEVEL);
|
||||
result = isc_log_createchannel(
|
||||
lcfg, "default_logfile", ISC_LOG_TOFILE,
|
||||
ISC_LOG_DYNAMIC, &destination,
|
||||
ISC_LOG_PRINTTIME | ISC_LOG_PRINTCATEGORY |
|
||||
ISC_LOG_PRINTLEVEL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
#if ISC_FACILITY != LOG_DAEMON
|
||||
destination.facility = ISC_FACILITY;
|
||||
result = isc_log_createchannel(lcfg, "default_syslog",
|
||||
ISC_LOG_TOSYSLOG, ISC_LOG_INFO,
|
||||
&destination, 0);
|
||||
result = isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG,
|
||||
ISC_LOG_INFO, &destination, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
#endif
|
||||
|
|
@ -152,19 +143,19 @@ named_log_setdefaultchannels(isc_logconfig_t *lcfg) {
|
|||
|
||||
result = ISC_R_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
named_log_setsafechannels(isc_logconfig_t *lcfg) {
|
||||
isc_result_t result;
|
||||
named_log_setsafechannels(isc_logconfig_t *lcfg)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_logdestination_t destination;
|
||||
|
||||
if (! named_g_logstderr) {
|
||||
if (!named_g_logstderr) {
|
||||
result = isc_log_createchannel(lcfg, "default_debug",
|
||||
ISC_LOG_TONULL,
|
||||
ISC_LOG_DYNAMIC,
|
||||
ISC_LOG_TONULL, ISC_LOG_DYNAMIC,
|
||||
NULL, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
|
@ -183,34 +174,32 @@ named_log_setsafechannels(isc_logconfig_t *lcfg) {
|
|||
destination.file.name = named_g_logfile;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
result = isc_log_createchannel(lcfg, "default_logfile",
|
||||
ISC_LOG_TOFILE,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination,
|
||||
ISC_LOG_PRINTTIME|
|
||||
ISC_LOG_PRINTCATEGORY|
|
||||
ISC_LOG_PRINTLEVEL);
|
||||
result = isc_log_createchannel(
|
||||
lcfg, "default_logfile", ISC_LOG_TOFILE,
|
||||
ISC_LOG_DYNAMIC, &destination,
|
||||
ISC_LOG_PRINTTIME | ISC_LOG_PRINTCATEGORY |
|
||||
ISC_LOG_PRINTLEVEL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
#if ISC_FACILITY != LOG_DAEMON
|
||||
destination.facility = ISC_FACILITY;
|
||||
result = isc_log_createchannel(lcfg, "default_syslog",
|
||||
ISC_LOG_TOSYSLOG, ISC_LOG_INFO,
|
||||
&destination, 0);
|
||||
result = isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG,
|
||||
ISC_LOG_INFO, &destination, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
#endif
|
||||
|
||||
result = ISC_R_SUCCESS;
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
named_log_setdefaultcategory(isc_logconfig_t *lcfg) {
|
||||
named_log_setdefaultcategory(isc_logconfig_t *lcfg)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
result = isc_log_usechannel(lcfg, "default_debug",
|
||||
|
|
@ -218,32 +207,34 @@ named_log_setdefaultcategory(isc_logconfig_t *lcfg) {
|
|||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
if (! named_g_logstderr) {
|
||||
if (!named_g_logstderr) {
|
||||
if (named_g_logfile != NULL)
|
||||
result = isc_log_usechannel(lcfg, "default_logfile",
|
||||
ISC_LOGCATEGORY_DEFAULT,
|
||||
NULL);
|
||||
else if (! named_g_nosyslog)
|
||||
else if (!named_g_nosyslog)
|
||||
result = isc_log_usechannel(lcfg, "default_syslog",
|
||||
ISC_LOGCATEGORY_DEFAULT,
|
||||
NULL);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
named_log_setunmatchedcategory(isc_logconfig_t *lcfg) {
|
||||
named_log_setunmatchedcategory(isc_logconfig_t *lcfg)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_log_usechannel(lcfg, "null",
|
||||
NAMED_LOGCATEGORY_UNMATCHED, NULL);
|
||||
result = isc_log_usechannel(lcfg, "null", NAMED_LOGCATEGORY_UNMATCHED,
|
||||
NULL);
|
||||
return (result);
|
||||
}
|
||||
|
||||
void
|
||||
named_log_shutdown(void) {
|
||||
named_log_shutdown(void)
|
||||
{
|
||||
isc_log_destroy(&named_g_lctx);
|
||||
isc_log_setcontext(NULL);
|
||||
dns_log_setcontext(NULL);
|
||||
|
|
|
|||
|
|
@ -29,9 +29,11 @@
|
|||
#include <named/log.h>
|
||||
#include <named/logconf.h>
|
||||
|
||||
#define CHECK(op) \
|
||||
do { result = (op); \
|
||||
if (result != ISC_R_SUCCESS) goto cleanup; \
|
||||
#define CHECK(op) \
|
||||
do { \
|
||||
result = (op); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
/*%
|
||||
|
|
@ -39,20 +41,20 @@
|
|||
* in 'ccat' and add it to 'logconfig'.
|
||||
*/
|
||||
static isc_result_t
|
||||
category_fromconf(const cfg_obj_t *ccat, isc_logconfig_t *logconfig) {
|
||||
isc_result_t result;
|
||||
const char *catname;
|
||||
isc_logcategory_t *category;
|
||||
isc_logmodule_t *module;
|
||||
const cfg_obj_t *destinations = NULL;
|
||||
category_fromconf(const cfg_obj_t *ccat, isc_logconfig_t *logconfig)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char * catname;
|
||||
isc_logcategory_t * category;
|
||||
isc_logmodule_t * module;
|
||||
const cfg_obj_t * destinations = NULL;
|
||||
const cfg_listelt_t *element = NULL;
|
||||
|
||||
catname = cfg_obj_asstring(cfg_tuple_get(ccat, "name"));
|
||||
category = isc_log_categorybyname(named_g_lctx, catname);
|
||||
if (category == NULL) {
|
||||
cfg_obj_log(ccat, named_g_lctx, ISC_LOG_ERROR,
|
||||
"unknown logging category '%s' ignored",
|
||||
catname);
|
||||
"unknown logging category '%s' ignored", catname);
|
||||
/*
|
||||
* Allow further processing by returning success.
|
||||
*/
|
||||
|
|
@ -65,12 +67,10 @@ category_fromconf(const cfg_obj_t *ccat, isc_logconfig_t *logconfig) {
|
|||
module = NULL;
|
||||
|
||||
destinations = cfg_tuple_get(ccat, "destinations");
|
||||
for (element = cfg_list_first(destinations);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
for (element = cfg_list_first(destinations); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
const cfg_obj_t *channel = cfg_listelt_value(element);
|
||||
const char *channelname = cfg_obj_asstring(channel);
|
||||
const char * channelname = cfg_obj_asstring(channel);
|
||||
|
||||
result = isc_log_usechannel(logconfig, channelname, category,
|
||||
module);
|
||||
|
|
@ -90,19 +90,20 @@ category_fromconf(const cfg_obj_t *ccat, isc_logconfig_t *logconfig) {
|
|||
* in 'cchan' and add it to 'logconfig'.
|
||||
*/
|
||||
static isc_result_t
|
||||
channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
||||
isc_result_t result;
|
||||
channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_logdestination_t dest;
|
||||
unsigned int type;
|
||||
unsigned int flags = 0;
|
||||
int level;
|
||||
const char *channelname;
|
||||
const cfg_obj_t *fileobj = NULL;
|
||||
const cfg_obj_t *syslogobj = NULL;
|
||||
const cfg_obj_t *nullobj = NULL;
|
||||
const cfg_obj_t *stderrobj = NULL;
|
||||
const cfg_obj_t *severity = NULL;
|
||||
int i;
|
||||
unsigned int type;
|
||||
unsigned int flags = 0;
|
||||
int level;
|
||||
const char * channelname;
|
||||
const cfg_obj_t * fileobj = NULL;
|
||||
const cfg_obj_t * syslogobj = NULL;
|
||||
const cfg_obj_t * nullobj = NULL;
|
||||
const cfg_obj_t * stderrobj = NULL;
|
||||
const cfg_obj_t * severity = NULL;
|
||||
int i;
|
||||
|
||||
channelname = cfg_obj_asstring(cfg_map_getname(channel));
|
||||
|
||||
|
|
@ -123,8 +124,9 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
|||
|
||||
if (i != 1) {
|
||||
cfg_obj_log(channel, named_g_lctx, ISC_LOG_ERROR,
|
||||
"channel '%s': exactly one of file, syslog, "
|
||||
"null, and stderr must be present", channelname);
|
||||
"channel '%s': exactly one of file, syslog, "
|
||||
"null, and stderr must be present",
|
||||
channelname);
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -133,14 +135,13 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
|||
if (fileobj != NULL) {
|
||||
const cfg_obj_t *pathobj = cfg_tuple_get(fileobj, "file");
|
||||
const cfg_obj_t *sizeobj = cfg_tuple_get(fileobj, "size");
|
||||
const cfg_obj_t *versionsobj =
|
||||
cfg_tuple_get(fileobj, "versions");
|
||||
const cfg_obj_t *suffixobj =
|
||||
cfg_tuple_get(fileobj, "suffix");
|
||||
int32_t versions = ISC_LOG_ROLLNEVER;
|
||||
const cfg_obj_t *versionsobj = cfg_tuple_get(fileobj, "version"
|
||||
"s");
|
||||
const cfg_obj_t *suffixobj = cfg_tuple_get(fileobj, "suffix");
|
||||
int32_t versions = ISC_LOG_ROLLNEVER;
|
||||
isc_log_rollsuffix_t suffix = isc_log_rollsuffix_increment;
|
||||
isc_offset_t size = 0;
|
||||
uint64_t maxoffset;
|
||||
isc_offset_t size = 0;
|
||||
uint64_t maxoffset;
|
||||
|
||||
/*
|
||||
* isc_offset_t is a signed integer type, so the maximum
|
||||
|
|
@ -163,10 +164,10 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
|||
if (versionsobj != NULL && cfg_obj_isuint32(versionsobj))
|
||||
versions = cfg_obj_asuint32(versionsobj);
|
||||
else if (versionsobj != NULL && cfg_obj_isstring(versionsobj) &&
|
||||
strcasecmp(cfg_obj_asstring(versionsobj), "unlimited") == 0)
|
||||
strcasecmp(cfg_obj_asstring(versionsobj), "unlimite"
|
||||
"d") == 0)
|
||||
versions = ISC_LOG_ROLLINFINITE;
|
||||
if (sizeobj != NULL &&
|
||||
cfg_obj_isuint64(sizeobj) &&
|
||||
if (sizeobj != NULL && cfg_obj_isuint64(sizeobj) &&
|
||||
cfg_obj_asuint64(sizeobj) < maxoffset)
|
||||
size = (isc_offset_t)cfg_obj_asuint64(sizeobj);
|
||||
if (suffixobj != NULL && cfg_obj_isstring(suffixobj) &&
|
||||
|
|
@ -221,7 +222,7 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
|||
if (printtime != NULL && cfg_obj_isboolean(printtime)) {
|
||||
if (cfg_obj_asboolean(printtime))
|
||||
flags |= ISC_LOG_PRINTTIME;
|
||||
} else if (printtime != NULL) { /* local/iso8601/iso8601-utc */
|
||||
} else if (printtime != NULL) { /* local/iso8601/iso8601-utc */
|
||||
const char *s = cfg_obj_asstring(printtime);
|
||||
flags |= ISC_LOG_PRINTTIME;
|
||||
if (strcasecmp(s, "iso8601") == 0)
|
||||
|
|
@ -255,8 +256,8 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
|||
if (logconfig == NULL)
|
||||
result = ISC_R_SUCCESS;
|
||||
else
|
||||
result = isc_log_createchannel(logconfig, channelname,
|
||||
type, level, &dest, flags);
|
||||
result = isc_log_createchannel(logconfig, channelname, type,
|
||||
level, &dest, flags);
|
||||
|
||||
if (result == ISC_R_SUCCESS && type == ISC_LOG_TOFILE) {
|
||||
FILE *fp;
|
||||
|
|
@ -264,7 +265,7 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
|||
/*
|
||||
* Test to make sure that file is a plain file.
|
||||
* Fix defect #22771
|
||||
*/
|
||||
*/
|
||||
result = isc_file_isplainfile(dest.file.name);
|
||||
if (result == ISC_R_SUCCESS || result == ISC_R_FILENOTFOUND) {
|
||||
/*
|
||||
|
|
@ -276,9 +277,10 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
|||
if (result != ISC_R_SUCCESS) {
|
||||
if (logconfig != NULL && !named_g_nosyslog)
|
||||
syslog(LOG_ERR,
|
||||
"isc_stdio_open '%s' failed: "
|
||||
"%s", dest.file.name,
|
||||
isc_result_totext(result));
|
||||
"isc_stdio_open '%s' failed: "
|
||||
"%s",
|
||||
dest.file.name,
|
||||
isc_result_totext(result));
|
||||
fprintf(stderr,
|
||||
"isc_stdio_open '%s' failed: %s\n",
|
||||
dest.file.name,
|
||||
|
|
@ -294,37 +296,34 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
|
|||
dest.file.name, isc_result_totext(result));
|
||||
}
|
||||
|
||||
done:
|
||||
done:
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
named_logconfig(isc_logconfig_t *logconfig, const cfg_obj_t *logstmt) {
|
||||
isc_result_t result;
|
||||
const cfg_obj_t *channels = NULL;
|
||||
const cfg_obj_t *categories = NULL;
|
||||
named_logconfig(isc_logconfig_t *logconfig, const cfg_obj_t *logstmt)
|
||||
{
|
||||
isc_result_t result;
|
||||
const cfg_obj_t * channels = NULL;
|
||||
const cfg_obj_t * categories = NULL;
|
||||
const cfg_listelt_t *element;
|
||||
bool default_set = false;
|
||||
bool unmatched_set = false;
|
||||
const cfg_obj_t *catname;
|
||||
bool default_set = false;
|
||||
bool unmatched_set = false;
|
||||
const cfg_obj_t * catname;
|
||||
|
||||
if (logconfig != NULL)
|
||||
CHECK(named_log_setdefaultchannels(logconfig));
|
||||
|
||||
(void)cfg_map_get(logstmt, "channel", &channels);
|
||||
for (element = cfg_list_first(channels);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
for (element = cfg_list_first(channels); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
const cfg_obj_t *channel = cfg_listelt_value(element);
|
||||
CHECK(channel_fromconf(channel, logconfig));
|
||||
}
|
||||
|
||||
(void)cfg_map_get(logstmt, "category", &categories);
|
||||
for (element = cfg_list_first(categories);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
for (element = cfg_list_first(categories); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
const cfg_obj_t *category = cfg_listelt_value(element);
|
||||
CHECK(category_fromconf(category, logconfig));
|
||||
if (!default_set) {
|
||||
|
|
@ -347,6 +346,6 @@ named_logconfig(isc_logconfig_t *logconfig, const cfg_obj_t *logstmt) {
|
|||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
|
|
|||
404
bin/named/main.c
404
bin/named/main.c
|
|
@ -36,16 +36,15 @@
|
|||
#include <isc/timer.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <isccc/result.h>
|
||||
|
||||
#include <dns/dispatch.h>
|
||||
#include <dns/dyndb.h>
|
||||
#include <dns/name.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/resolver.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/view.h>
|
||||
|
||||
#include <dst/result.h>
|
||||
#include <isccc/result.h>
|
||||
#if USE_PKCS11
|
||||
#include <pk11/result.h>
|
||||
#endif
|
||||
|
|
@ -76,20 +75,20 @@
|
|||
#include <named/config.h>
|
||||
#include <named/control.h>
|
||||
#include <named/fuzz.h>
|
||||
#include <named/globals.h> /* Explicit, though named/log.h includes it. */
|
||||
#include <named/globals.h> /* Explicit, though named/log.h includes it. */
|
||||
#include <named/log.h>
|
||||
#include <named/main.h>
|
||||
#include <named/os.h>
|
||||
#include <named/server.h>
|
||||
#include <named/main.h>
|
||||
#ifdef HAVE_LIBSCF
|
||||
#include <named/smf_globals.h>
|
||||
#endif
|
||||
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#ifdef HAVE_LIBXML2
|
||||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlversion.h>
|
||||
#endif
|
||||
#ifdef HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
|
|
@ -113,19 +112,19 @@
|
|||
#define BACKTRACE_MAXFRAME 128
|
||||
#endif
|
||||
|
||||
LIBISC_EXTERNAL_DATA extern int isc_dscp_check_value;
|
||||
LIBISC_EXTERNAL_DATA extern int isc_dscp_check_value;
|
||||
LIBDNS_EXTERNAL_DATA extern unsigned int dns_zone_mkey_hour;
|
||||
LIBDNS_EXTERNAL_DATA extern unsigned int dns_zone_mkey_day;
|
||||
LIBDNS_EXTERNAL_DATA extern unsigned int dns_zone_mkey_month;
|
||||
|
||||
static bool want_stats = false;
|
||||
static char program_name[NAME_MAX] = "named";
|
||||
static char absolute_conffile[PATH_MAX];
|
||||
static char saved_command_line[4096] = { 0 };
|
||||
static char ellipsis[5] = { 0 };
|
||||
static char version[512];
|
||||
static unsigned int maxsocks = 0;
|
||||
static int maxudp = 0;
|
||||
static bool want_stats = false;
|
||||
static char program_name[NAME_MAX] = "named";
|
||||
static char absolute_conffile[PATH_MAX];
|
||||
static char saved_command_line[4096] = { 0 };
|
||||
static char ellipsis[5] = { 0 };
|
||||
static char version[512];
|
||||
static unsigned int maxsocks = 0;
|
||||
static int maxudp = 0;
|
||||
|
||||
/*
|
||||
* -T options:
|
||||
|
|
@ -149,14 +148,15 @@ static bool disable6 = false;
|
|||
static bool disable4 = false;
|
||||
|
||||
void
|
||||
named_main_earlywarning(const char *format, ...) {
|
||||
named_main_earlywarning(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
if (named_g_lctx != NULL) {
|
||||
isc_log_vwrite(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_WARNING,
|
||||
format, args);
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_WARNING, format,
|
||||
args);
|
||||
} else {
|
||||
fprintf(stderr, "%s: ", program_name);
|
||||
vfprintf(stderr, format, args);
|
||||
|
|
@ -167,17 +167,18 @@ named_main_earlywarning(const char *format, ...) {
|
|||
}
|
||||
|
||||
void
|
||||
named_main_earlyfatal(const char *format, ...) {
|
||||
named_main_earlyfatal(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
if (named_g_lctx != NULL) {
|
||||
isc_log_vwrite(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
format, args);
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL, format,
|
||||
args);
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
"exiting (due to early fatal error)");
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
"exiting (due to early fatal error)");
|
||||
} else {
|
||||
fprintf(stderr, "%s: ", program_name);
|
||||
vfprintf(stderr, format, args);
|
||||
|
|
@ -197,11 +198,11 @@ static void
|
|||
assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
||||
const char *cond)
|
||||
{
|
||||
void *tracebuf[BACKTRACE_MAXFRAME];
|
||||
int i, nframes;
|
||||
void * tracebuf[BACKTRACE_MAXFRAME];
|
||||
int i, nframes;
|
||||
isc_result_t result;
|
||||
const char *logsuffix = "";
|
||||
const char *fname;
|
||||
const char * logsuffix = "";
|
||||
const char * fname;
|
||||
|
||||
/*
|
||||
* Handle assertion failures.
|
||||
|
|
@ -227,9 +228,8 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
|||
unsigned long offset;
|
||||
|
||||
fname = NULL;
|
||||
result = isc_backtrace_getsymbol(tracebuf[i],
|
||||
&fname,
|
||||
&offset);
|
||||
result = isc_backtrace_getsymbol(
|
||||
tracebuf[i], &fname, &offset);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_log_write(named_g_lctx,
|
||||
NAMED_LOGCATEGORY_GENERAL,
|
||||
|
|
@ -252,8 +252,8 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
|||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
"exiting (due to assertion failure)");
|
||||
} else {
|
||||
fprintf(stderr, "%s:%d: %s(%s) failed\n",
|
||||
file, line, isc_assertion_typetotext(type), cond);
|
||||
fprintf(stderr, "%s:%d: %s(%s) failed\n", file, line,
|
||||
isc_assertion_typetotext(type), cond);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type,
|
|||
ISC_PLATFORM_NORETURN_PRE static void
|
||||
library_fatal_error(const char *file, int line, const char *format,
|
||||
va_list args)
|
||||
ISC_FORMAT_PRINTF(3, 0) ISC_PLATFORM_NORETURN_POST;
|
||||
ISC_FORMAT_PRINTF(3, 0) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
library_fatal_error(const char *file, int line, const char *format,
|
||||
|
|
@ -286,8 +286,8 @@ library_fatal_error(const char *file, int line, const char *format,
|
|||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
"%s:%d: fatal error:", file, line);
|
||||
isc_log_vwrite(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
format, args);
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL, format,
|
||||
args);
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL,
|
||||
"exiting (due to fatal error in library)");
|
||||
|
|
@ -320,8 +320,8 @@ library_unexpected_error(const char *file, int line, const char *format,
|
|||
NAMED_LOGMODULE_MAIN, ISC_LOG_ERROR,
|
||||
"%s:%d: unexpected error:", file, line);
|
||||
isc_log_vwrite(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_ERROR,
|
||||
format, args);
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_ERROR, format,
|
||||
args);
|
||||
} else {
|
||||
fprintf(stderr, "%s:%d: fatal error: ", file, line);
|
||||
vfprintf(stderr, format, args);
|
||||
|
|
@ -331,36 +331,35 @@ library_unexpected_error(const char *file, int line, const char *format,
|
|||
}
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
fprintf(stderr,
|
||||
"usage: named [-4|-6] [-c conffile] [-d debuglevel] "
|
||||
"[-E engine] [-f|-g]\n"
|
||||
" [-n number_of_cpus] [-p port] [-s] "
|
||||
"[-S sockets] [-t chrootdir]\n"
|
||||
" [-u username] [-U listeners] "
|
||||
"[-m {usage|trace|record|size|mctx}]\n"
|
||||
"usage: named [-v|-V]\n");
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: named [-4|-6] [-c conffile] [-d debuglevel] "
|
||||
"[-E engine] [-f|-g]\n"
|
||||
" [-n number_of_cpus] [-p port] [-s] "
|
||||
"[-S sockets] [-t chrootdir]\n"
|
||||
" [-u username] [-U listeners] "
|
||||
"[-m {usage|trace|record|size|mctx}]\n"
|
||||
"usage: named [-v|-V]\n");
|
||||
}
|
||||
|
||||
static void
|
||||
save_command_line(int argc, char *argv[]) {
|
||||
int i;
|
||||
save_command_line(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char *dst = saved_command_line;
|
||||
char *eob = saved_command_line + sizeof(saved_command_line) - 1;
|
||||
char *rollback = dst;
|
||||
|
||||
for (i = 1; i < argc && dst < eob; i++) {
|
||||
char *src = argv[i];
|
||||
bool quoted = false;
|
||||
bool quoted = false;
|
||||
|
||||
rollback = dst;
|
||||
*dst++ = ' ';
|
||||
|
||||
while (*src != '\0' && dst < eob) {
|
||||
if (isalnum(*src) || *src == ',' ||
|
||||
*src == '-' || *src == '_' ||
|
||||
*src == '.' || *src == '/')
|
||||
{
|
||||
if (isalnum(*src) || *src == ',' || *src == '-' ||
|
||||
*src == '_' || *src == '.' || *src == '/') {
|
||||
*dst++ = *src++;
|
||||
} else if (isprint(*src)) {
|
||||
if (dst + 2 >= eob) {
|
||||
|
|
@ -389,8 +388,8 @@ save_command_line(int argc, char *argv[]) {
|
|||
continue;
|
||||
} else {
|
||||
char tmp[5];
|
||||
int c = snprintf(tmp, sizeof(tmp),
|
||||
"\\%03o", *src++);
|
||||
int c = snprintf(tmp, sizeof(tmp),
|
||||
"\\%03o", *src++);
|
||||
if (dst + c >= eob) {
|
||||
goto add_ellipsis;
|
||||
}
|
||||
|
|
@ -405,7 +404,6 @@ save_command_line(int argc, char *argv[]) {
|
|||
}
|
||||
*dst++ = '\'';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (dst < eob) {
|
||||
|
|
@ -418,13 +416,14 @@ add_ellipsis:
|
|||
}
|
||||
|
||||
static int
|
||||
parse_int(char *arg, const char *desc) {
|
||||
char *endp;
|
||||
int tmp;
|
||||
parse_int(char *arg, const char *desc)
|
||||
{
|
||||
char * endp;
|
||||
int tmp;
|
||||
long int ltmp;
|
||||
|
||||
ltmp = strtol(arg, &endp, 10);
|
||||
tmp = (int) ltmp;
|
||||
tmp = (int)ltmp;
|
||||
if (*endp != '\0')
|
||||
named_main_earlyfatal("%s '%s' must be numeric", desc, arg);
|
||||
if (tmp < 0 || tmp != ltmp)
|
||||
|
|
@ -433,32 +432,30 @@ parse_int(char *arg, const char *desc) {
|
|||
}
|
||||
|
||||
static struct flag_def {
|
||||
const char *name;
|
||||
const char * name;
|
||||
unsigned int value;
|
||||
bool negate;
|
||||
} mem_debug_flags[] = {
|
||||
{ "none", 0, false },
|
||||
{ "trace", ISC_MEM_DEBUGTRACE, false },
|
||||
{ "record", ISC_MEM_DEBUGRECORD, false },
|
||||
{ "usage", ISC_MEM_DEBUGUSAGE, false },
|
||||
{ "size", ISC_MEM_DEBUGSIZE, false },
|
||||
{ "mctx", ISC_MEM_DEBUGCTX, false },
|
||||
{ NULL, 0, false }
|
||||
}, mem_context_flags[] = {
|
||||
{ "external", ISC_MEMFLAG_INTERNAL, true },
|
||||
{ "fill", ISC_MEMFLAG_FILL, false },
|
||||
{ "nofill", ISC_MEMFLAG_FILL, true },
|
||||
{ NULL, 0, false }
|
||||
};
|
||||
bool negate;
|
||||
} mem_debug_flags[] = { { "none", 0, false },
|
||||
{ "trace", ISC_MEM_DEBUGTRACE, false },
|
||||
{ "record", ISC_MEM_DEBUGRECORD, false },
|
||||
{ "usage", ISC_MEM_DEBUGUSAGE, false },
|
||||
{ "size", ISC_MEM_DEBUGSIZE, false },
|
||||
{ "mctx", ISC_MEM_DEBUGCTX, false },
|
||||
{ NULL, 0, false } },
|
||||
mem_context_flags[] = { { "external", ISC_MEMFLAG_INTERNAL, true },
|
||||
{ "fill", ISC_MEMFLAG_FILL, false },
|
||||
{ "nofill", ISC_MEMFLAG_FILL, true },
|
||||
{ NULL, 0, false } };
|
||||
|
||||
static void
|
||||
set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) {
|
||||
set_flags(const char *arg, struct flag_def *defs, unsigned int *ret)
|
||||
{
|
||||
bool clear = false;
|
||||
|
||||
for (;;) {
|
||||
const struct flag_def *def;
|
||||
const char *end = strchr(arg, ',');
|
||||
int arglen;
|
||||
const char * end = strchr(arg, ',');
|
||||
int arglen;
|
||||
if (end == NULL)
|
||||
end = arg + strlen(arg);
|
||||
arglen = (int)(end - arg);
|
||||
|
|
@ -475,7 +472,7 @@ set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) {
|
|||
}
|
||||
}
|
||||
named_main_earlyfatal("unrecognized flag '%.*s'", arglen, arg);
|
||||
found:
|
||||
found:
|
||||
if (clear || (*end == '\0'))
|
||||
break;
|
||||
arg = end + 1;
|
||||
|
|
@ -486,27 +483,26 @@ set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) {
|
|||
}
|
||||
|
||||
static void
|
||||
printversion(bool verbose) {
|
||||
printversion(bool verbose)
|
||||
{
|
||||
char rndcconf[PATH_MAX], *dot = NULL;
|
||||
#if defined(HAVE_GEOIP2)
|
||||
isc_mem_t *mctx = NULL;
|
||||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
isc_mem_t * mctx = NULL;
|
||||
cfg_parser_t * parser = NULL;
|
||||
cfg_obj_t * config = NULL;
|
||||
const cfg_obj_t *defaults = NULL, *obj = NULL;
|
||||
#endif
|
||||
|
||||
printf("%s %s%s%s <id:%s>\n",
|
||||
named_g_product, named_g_version,
|
||||
(*named_g_description != '\0') ? " " : "",
|
||||
named_g_description, named_g_srcid);
|
||||
printf("%s %s%s%s <id:%s>\n", named_g_product, named_g_version,
|
||||
(*named_g_description != '\0') ? " " : "", named_g_description,
|
||||
named_g_srcid);
|
||||
|
||||
if (!verbose) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf("running on %s\n", named_os_uname());
|
||||
printf("built by %s with %s\n",
|
||||
named_g_builder, named_g_configargs);
|
||||
printf("built by %s with %s\n", named_g_builder, named_g_configargs);
|
||||
#ifdef __clang__
|
||||
printf("compiled by CLANG %s\n", __VERSION__);
|
||||
#else
|
||||
|
|
@ -524,10 +520,9 @@ printversion(bool verbose) {
|
|||
#ifdef __SUNPRO_C
|
||||
printf("compiled by Solaris Studio %x\n", __SUNPRO_C);
|
||||
#endif
|
||||
printf("compiled with OpenSSL version: %s\n",
|
||||
OPENSSL_VERSION_TEXT);
|
||||
printf("compiled with OpenSSL version: %s\n", OPENSSL_VERSION_TEXT);
|
||||
#if !defined(LIBRESSL_VERSION_NUMBER) && \
|
||||
OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */
|
||||
OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */
|
||||
printf("linked to OpenSSL version: %s\n",
|
||||
OpenSSL_version(OPENSSL_VERSION));
|
||||
|
||||
|
|
@ -536,37 +531,27 @@ OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */
|
|||
SSLeay_version(SSLEAY_VERSION));
|
||||
#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
|
||||
#ifdef HAVE_LIBXML2
|
||||
printf("compiled with libxml2 version: %s\n",
|
||||
LIBXML_DOTTED_VERSION);
|
||||
printf("linked to libxml2 version: %s\n",
|
||||
xmlParserVersion);
|
||||
printf("compiled with libxml2 version: %s\n", LIBXML_DOTTED_VERSION);
|
||||
printf("linked to libxml2 version: %s\n", xmlParserVersion);
|
||||
#endif
|
||||
#if defined(HAVE_JSON_C)
|
||||
printf("compiled with json-c version: %s\n",
|
||||
JSON_C_VERSION);
|
||||
printf("linked to json-c version: %s\n",
|
||||
json_c_version());
|
||||
printf("compiled with json-c version: %s\n", JSON_C_VERSION);
|
||||
printf("linked to json-c version: %s\n", json_c_version());
|
||||
#endif
|
||||
#if defined(HAVE_ZLIB) && defined(ZLIB_VERSION)
|
||||
printf("compiled with zlib version: %s\n",
|
||||
ZLIB_VERSION);
|
||||
printf("linked to zlib version: %s\n",
|
||||
zlibVersion());
|
||||
printf("compiled with zlib version: %s\n", ZLIB_VERSION);
|
||||
printf("linked to zlib version: %s\n", zlibVersion());
|
||||
#endif
|
||||
#if defined(HAVE_GEOIP2)
|
||||
/* Unfortunately, no version define on link time */
|
||||
printf("linked to maxminddb version: %s\n",
|
||||
MMDB_lib_version());
|
||||
printf("linked to maxminddb version: %s\n", MMDB_lib_version());
|
||||
#endif
|
||||
#if defined(HAVE_DNSTAP)
|
||||
printf("compiled with protobuf-c version: %s\n",
|
||||
PROTOBUF_C_VERSION);
|
||||
printf("linked to protobuf-c version: %s\n",
|
||||
protobuf_c_version());
|
||||
printf("compiled with protobuf-c version: %s\n", PROTOBUF_C_VERSION);
|
||||
printf("linked to protobuf-c version: %s\n", protobuf_c_version());
|
||||
#endif
|
||||
printf("threads support is enabled\n\n");
|
||||
|
||||
|
||||
/*
|
||||
* The default rndc.conf and rndc.key paths are in the same
|
||||
* directory, but named only has rndc.key defined internally.
|
||||
|
|
@ -608,7 +593,8 @@ OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */
|
|||
}
|
||||
|
||||
static void
|
||||
parse_fuzz_arg(void) {
|
||||
parse_fuzz_arg(void)
|
||||
{
|
||||
if (!strncmp(isc_commandline_argument, "client:", 7)) {
|
||||
named_g_fuzz_addr = isc_commandline_argument + 7;
|
||||
named_g_fuzz_type = isc_fuzz_client;
|
||||
|
|
@ -626,14 +612,15 @@ parse_fuzz_arg(void) {
|
|||
named_g_fuzz_type = isc_fuzz_rndc;
|
||||
} else {
|
||||
named_main_earlyfatal("unknown fuzzing type '%s'",
|
||||
isc_commandline_argument);
|
||||
isc_commandline_argument);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
parse_T_opt(char *option) {
|
||||
parse_T_opt(char *option)
|
||||
{
|
||||
const char *p;
|
||||
char *last = NULL;
|
||||
char * last = NULL;
|
||||
/*
|
||||
* force the server to behave (or misbehave) in
|
||||
* specified ways for testing purposes.
|
||||
|
|
@ -717,9 +704,10 @@ parse_T_opt(char *option) {
|
|||
}
|
||||
|
||||
static void
|
||||
parse_command_line(int argc, char *argv[]) {
|
||||
int ch;
|
||||
int port;
|
||||
parse_command_line(int argc, char *argv[])
|
||||
{
|
||||
int ch;
|
||||
int port;
|
||||
const char *p;
|
||||
|
||||
save_command_line(argc, argv);
|
||||
|
|
@ -729,9 +717,8 @@ parse_command_line(int argc, char *argv[]) {
|
|||
* both by named and by ntservice hooks.
|
||||
*/
|
||||
isc_commandline_errprint = false;
|
||||
while ((ch = isc_commandline_parse(argc, argv,
|
||||
NAMED_MAIN_ARGS)) != -1)
|
||||
{
|
||||
while ((ch = isc_commandline_parse(argc, argv, NAMED_MAIN_ARGS)) !=
|
||||
-1) {
|
||||
switch (ch) {
|
||||
case '4':
|
||||
if (disable4)
|
||||
|
|
@ -762,7 +749,8 @@ parse_command_line(int argc, char *argv[]) {
|
|||
break;
|
||||
case 'd':
|
||||
named_g_debuglevel = parse_int(isc_commandline_argument,
|
||||
"debug level");
|
||||
"debug "
|
||||
"level");
|
||||
break;
|
||||
case 'D':
|
||||
/* Descriptive comment for 'ps'. */
|
||||
|
|
@ -790,8 +778,12 @@ parse_command_line(int argc, char *argv[]) {
|
|||
break;
|
||||
case 'N': /* Deprecated. */
|
||||
case 'n':
|
||||
named_g_cpus = parse_int(isc_commandline_argument,
|
||||
"number of cpus");
|
||||
named_g_cpus = parse_int(isc_commandline_argument, "num"
|
||||
"ber"
|
||||
" of"
|
||||
" cp"
|
||||
"u"
|
||||
"s");
|
||||
if (named_g_cpus == 0)
|
||||
named_g_cpus = 1;
|
||||
break;
|
||||
|
|
@ -799,7 +791,7 @@ parse_command_line(int argc, char *argv[]) {
|
|||
port = parse_int(isc_commandline_argument, "port");
|
||||
if (port < 1 || port > 65535)
|
||||
named_main_earlyfatal("port '%s' out of range",
|
||||
isc_commandline_argument);
|
||||
isc_commandline_argument);
|
||||
named_g_port = port;
|
||||
break;
|
||||
case 's':
|
||||
|
|
@ -807,14 +799,17 @@ parse_command_line(int argc, char *argv[]) {
|
|||
want_stats = true;
|
||||
break;
|
||||
case 'S':
|
||||
maxsocks = parse_int(isc_commandline_argument,
|
||||
"max number of sockets");
|
||||
maxsocks = parse_int(isc_commandline_argument, "max "
|
||||
"number "
|
||||
"of "
|
||||
"socket"
|
||||
"s");
|
||||
break;
|
||||
case 't':
|
||||
/* XXXJAB should we make a copy? */
|
||||
named_g_chrootdir = isc_commandline_argument;
|
||||
break;
|
||||
case 'T': /* NOT DOCUMENTED */
|
||||
case 'T': /* NOT DOCUMENTED */
|
||||
parse_T_opt(isc_commandline_argument);
|
||||
break;
|
||||
case 'U':
|
||||
|
|
@ -852,11 +847,11 @@ parse_command_line(int argc, char *argv[]) {
|
|||
p = strchr(NAMED_MAIN_ARGS, isc_commandline_option);
|
||||
if (p == NULL || *++p != ':')
|
||||
named_main_earlyfatal("unknown option '-%c'",
|
||||
isc_commandline_option);
|
||||
isc_commandline_option);
|
||||
else
|
||||
named_main_earlyfatal("option '-%c' requires "
|
||||
"an argument",
|
||||
isc_commandline_option);
|
||||
"an argument",
|
||||
isc_commandline_option);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
named_main_earlyfatal("parsing options returned %d",
|
||||
|
|
@ -875,7 +870,8 @@ parse_command_line(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
create_managers(void) {
|
||||
create_managers(void)
|
||||
{
|
||||
isc_result_t result;
|
||||
unsigned int socks;
|
||||
|
||||
|
|
@ -883,12 +879,11 @@ create_managers(void) {
|
|||
|
||||
if (named_g_cpus == 0)
|
||||
named_g_cpus = named_g_cpus_detected;
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
||||
"found %u CPU%s, using %u worker thread%s",
|
||||
named_g_cpus_detected,
|
||||
named_g_cpus_detected == 1 ? "" : "s",
|
||||
named_g_cpus, named_g_cpus == 1 ? "" : "s");
|
||||
isc_log_write(
|
||||
named_g_lctx, NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
|
||||
ISC_LOG_INFO, "found %u CPU%s, using %u worker thread%s",
|
||||
named_g_cpus_detected, named_g_cpus_detected == 1 ? "" : "s",
|
||||
named_g_cpus, named_g_cpus == 1 ? "" : "s");
|
||||
#ifdef WIN32
|
||||
named_g_udpdisp = 1;
|
||||
#else
|
||||
|
|
@ -900,24 +895,23 @@ create_managers(void) {
|
|||
#endif
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
||||
"using %u UDP listener%s per interface",
|
||||
named_g_udpdisp, named_g_udpdisp == 1 ? "" : "s");
|
||||
"using %u UDP listener%s per interface", named_g_udpdisp,
|
||||
named_g_udpdisp == 1 ? "" : "s");
|
||||
|
||||
/*
|
||||
* We have ncpus network threads, ncpus worker threads, ncpus
|
||||
* old network threads - make it 4x just to be safe. The memory
|
||||
* impact is neglible.
|
||||
*/
|
||||
isc_hp_init(4*named_g_cpus);
|
||||
isc_hp_init(4 * named_g_cpus);
|
||||
named_g_nm = isc_nm_start(named_g_mctx, named_g_cpus);
|
||||
if (named_g_nm == NULL) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_nm_start() failed");
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_nm_start() failed");
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
|
||||
result = isc_taskmgr_create(named_g_mctx, named_g_cpus, 0,
|
||||
named_g_nm, &named_g_taskmgr);
|
||||
result = isc_taskmgr_create(named_g_mctx, named_g_cpus, 0, named_g_nm,
|
||||
&named_g_taskmgr);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_taskmgr_create() failed: %s",
|
||||
|
|
@ -946,15 +940,16 @@ create_managers(void) {
|
|||
result = isc_socketmgr_getmaxsockets(named_g_socketmgr, &socks);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_SERVER,
|
||||
ISC_LOG_INFO, "using up to %u sockets", socks);
|
||||
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
||||
"using up to %u sockets", socks);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_managers(void) {
|
||||
destroy_managers(void)
|
||||
{
|
||||
/*
|
||||
* isc_nm_closedown() closes all active connections, freeing
|
||||
* attached clients and other resources and preventing new
|
||||
|
|
@ -977,11 +972,12 @@ destroy_managers(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
dump_symboltable(void) {
|
||||
int i;
|
||||
dump_symboltable(void)
|
||||
{
|
||||
int i;
|
||||
isc_result_t result;
|
||||
const char *fname;
|
||||
const void *addr;
|
||||
const char * fname;
|
||||
const void * addr;
|
||||
|
||||
if (isc__backtrace_nsymbols == 0)
|
||||
return;
|
||||
|
|
@ -990,8 +986,7 @@ dump_symboltable(void) {
|
|||
return;
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_DEBUG(99),
|
||||
"Symbol table:");
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_DEBUG(99), "Symbol table:");
|
||||
|
||||
for (i = 0, result = ISC_R_SUCCESS; result == ISC_R_SUCCESS; i++) {
|
||||
addr = NULL;
|
||||
|
|
@ -1006,10 +1001,11 @@ dump_symboltable(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
setup(void) {
|
||||
isc_result_t result;
|
||||
setup(void)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_resourcevalue_t old_openfiles;
|
||||
ns_server_t *sctx;
|
||||
ns_server_t * sctx;
|
||||
#ifdef HAVE_LIBSCF
|
||||
char *instance = NULL;
|
||||
#endif
|
||||
|
|
@ -1060,7 +1056,7 @@ setup(void) {
|
|||
result = named_log_init(named_g_username != NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
named_main_earlyfatal("named_log_init() failed: %s",
|
||||
isc_result_totext(result));
|
||||
isc_result_totext(result));
|
||||
|
||||
/*
|
||||
* Now is the time to daemonize (if we're not running in the
|
||||
|
|
@ -1079,27 +1075,26 @@ setup(void) {
|
|||
result = isc_app_start();
|
||||
if (result != ISC_R_SUCCESS)
|
||||
named_main_earlyfatal("isc_app_start() failed: %s",
|
||||
isc_result_totext(result));
|
||||
isc_result_totext(result));
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
|
||||
"starting %s %s%s%s <id:%s>",
|
||||
named_g_product, named_g_version,
|
||||
*named_g_description ? " " : "", named_g_description,
|
||||
named_g_srcid);
|
||||
"starting %s %s%s%s <id:%s>", named_g_product,
|
||||
named_g_version, *named_g_description ? " " : "",
|
||||
named_g_description, named_g_srcid);
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE, "running on %s",
|
||||
named_os_uname());
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE, "built with %s",
|
||||
named_g_configargs);
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
|
||||
"running on %s", named_os_uname());
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
|
||||
"built with %s", named_g_configargs);
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
|
||||
"running as: %s%s%s",
|
||||
program_name, saved_command_line, ellipsis);
|
||||
"running as: %s%s%s", program_name, saved_command_line,
|
||||
ellipsis);
|
||||
#ifdef __clang__
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
|
||||
|
|
@ -1132,7 +1127,7 @@ setup(void) {
|
|||
"compiled with OpenSSL version: %s",
|
||||
OPENSSL_VERSION_TEXT);
|
||||
#if !defined(LIBRESSL_VERSION_NUMBER) && \
|
||||
OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */
|
||||
OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
|
||||
"linked to OpenSSL version: %s",
|
||||
|
|
@ -1194,18 +1189,18 @@ setup(void) {
|
|||
*/
|
||||
#ifndef WIN32
|
||||
RUNTIME_CHECK(isc_resource_getlimit(isc_resource_stacksize,
|
||||
&named_g_initstacksize)
|
||||
== ISC_R_SUCCESS);
|
||||
&named_g_initstacksize) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_resource_getlimit(isc_resource_datasize,
|
||||
&named_g_initdatasize)
|
||||
== ISC_R_SUCCESS);
|
||||
&named_g_initdatasize) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_resource_getlimit(isc_resource_coresize,
|
||||
&named_g_initcoresize)
|
||||
== ISC_R_SUCCESS);
|
||||
&named_g_initcoresize) ==
|
||||
ISC_R_SUCCESS);
|
||||
#endif
|
||||
RUNTIME_CHECK(isc_resource_getlimit(isc_resource_openfiles,
|
||||
&named_g_initopenfiles)
|
||||
== ISC_R_SUCCESS);
|
||||
&named_g_initopenfiles) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* System resources cannot effectively be tuned on some systems.
|
||||
|
|
@ -1214,8 +1209,8 @@ setup(void) {
|
|||
old_openfiles = named_g_initopenfiles;
|
||||
named_os_adjustnofile();
|
||||
RUNTIME_CHECK(isc_resource_getlimit(isc_resource_openfiles,
|
||||
&named_g_initopenfiles)
|
||||
== ISC_R_SUCCESS);
|
||||
&named_g_initopenfiles) ==
|
||||
ISC_R_SUCCESS);
|
||||
if (old_openfiles != named_g_initopenfiles) {
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
|
||||
|
|
@ -1229,7 +1224,7 @@ setup(void) {
|
|||
* If the named configuration filename is relative, prepend the current
|
||||
* directory's name before possibly changing to another directory.
|
||||
*/
|
||||
if (! isc_file_isabsolute(named_g_conffile)) {
|
||||
if (!isc_file_isabsolute(named_g_conffile)) {
|
||||
result = isc_file_absolutepath(named_g_conffile,
|
||||
absolute_conffile,
|
||||
sizeof(absolute_conffile));
|
||||
|
|
@ -1247,12 +1242,12 @@ setup(void) {
|
|||
result = isc_time_now(&named_g_boottime);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
named_main_earlyfatal("isc_time_now() failed: %s",
|
||||
isc_result_totext(result));
|
||||
isc_result_totext(result));
|
||||
|
||||
result = create_managers();
|
||||
if (result != ISC_R_SUCCESS)
|
||||
named_main_earlyfatal("create_managers() failed: %s",
|
||||
isc_result_totext(result));
|
||||
isc_result_totext(result));
|
||||
|
||||
named_builtin_init();
|
||||
|
||||
|
|
@ -1268,7 +1263,7 @@ setup(void) {
|
|||
result = dlz_dlopen_init(named_g_mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
named_main_earlyfatal("dlz_dlopen_init() failed: %s",
|
||||
isc_result_totext(result));
|
||||
isc_result_totext(result));
|
||||
#endif
|
||||
|
||||
#if CONTRIB_DLZ
|
||||
|
|
@ -1278,7 +1273,7 @@ setup(void) {
|
|||
result = dlz_drivers_init();
|
||||
if (result != ISC_R_SUCCESS)
|
||||
named_main_earlyfatal("dlz_drivers_init() failed: %s",
|
||||
isc_result_totext(result));
|
||||
isc_result_totext(result));
|
||||
#endif
|
||||
|
||||
named_server_create(named_g_mctx, &named_g_server);
|
||||
|
|
@ -1293,7 +1288,7 @@ setup(void) {
|
|||
ns_server_setoption(sctx, NS_SERVER_DISABLE6, true);
|
||||
if (dropedns)
|
||||
ns_server_setoption(sctx, NS_SERVER_DROPEDNS, true);
|
||||
if (ednsformerr) /* STD13 server */
|
||||
if (ednsformerr) /* STD13 server */
|
||||
ns_server_setoption(sctx, NS_SERVER_EDNSFORMERR, true);
|
||||
if (ednsnotimp)
|
||||
ns_server_setoption(sctx, NS_SERVER_EDNSNOTIMP, true);
|
||||
|
|
@ -1316,7 +1311,8 @@ setup(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
cleanup(void) {
|
||||
cleanup(void)
|
||||
{
|
||||
destroy_managers();
|
||||
|
||||
if (named_g_mapped != NULL)
|
||||
|
|
@ -1345,15 +1341,15 @@ cleanup(void) {
|
|||
#endif
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
NAMED_LOGMODULE_MAIN,
|
||||
ISC_LOG_NOTICE, "exiting");
|
||||
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE, "exiting");
|
||||
named_log_shutdown();
|
||||
}
|
||||
|
||||
static char *memstats = NULL;
|
||||
|
||||
void
|
||||
named_main_setmemstats(const char *filename) {
|
||||
named_main_setmemstats(const char *filename)
|
||||
{
|
||||
/*
|
||||
* Caller has to ensure locking.
|
||||
*/
|
||||
|
|
@ -1374,10 +1370,11 @@ named_main_setmemstats(const char *filename) {
|
|||
* Get FMRI for the named process.
|
||||
*/
|
||||
isc_result_t
|
||||
named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
|
||||
named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx)
|
||||
{
|
||||
scf_handle_t *h = NULL;
|
||||
int namelen;
|
||||
char *instance;
|
||||
int namelen;
|
||||
char * instance;
|
||||
|
||||
REQUIRE(ins_name != NULL && *ins_name == NULL);
|
||||
|
||||
|
|
@ -1435,14 +1432,15 @@ named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
|
|||
/* main entry point, possibly hooked */
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_result_t result;
|
||||
#ifdef HAVE_LIBSCF
|
||||
char *instance = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GPERFTOOLS_PROFILER
|
||||
(void) ProfilerStart(NULL);
|
||||
(void)ProfilerStart(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
|
@ -1452,7 +1450,7 @@ main(int argc, char *argv[]) {
|
|||
* buffering (_IOFBF) as line buffering (_IOLBF) is unavailable on
|
||||
* Windows and fflush() is called anyway after each log message gets
|
||||
* written to the default stderr logging channels created by libisc.
|
||||
*/
|
||||
*/
|
||||
setvbuf(stderr, NULL, _IOFBF, BUFSIZ);
|
||||
#endif
|
||||
|
||||
|
|
@ -1578,7 +1576,7 @@ main(int argc, char *argv[]) {
|
|||
if (result == ISC_R_SUCCESS) {
|
||||
isc_mem_stats(named_g_mctx, fp);
|
||||
isc_mutex_stats(fp);
|
||||
(void) isc_stdio_close(fp);
|
||||
(void)isc_stdio_close(fp);
|
||||
}
|
||||
}
|
||||
isc_mem_destroy(&named_g_mctx);
|
||||
|
|
|
|||
5098
bin/named/server.c
5098
bin/named/server.c
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -9,53 +9,49 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/string.h> /* Required for HP/UX (and others?) */
|
||||
#include <isc/mem.h>
|
||||
|
||||
#include <isccfg/cfg.h>
|
||||
#include <isc/string.h> /* Required for HP/UX (and others?) */
|
||||
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/keyvalues.h>
|
||||
#include <dns/name.h>
|
||||
#include <dns/tkey.h>
|
||||
|
||||
#include <dst/gssapi.h>
|
||||
#include <isccfg/cfg.h>
|
||||
|
||||
#include <dst/gssapi.h>
|
||||
#include <named/tkeyconf.h>
|
||||
|
||||
#define RETERR(x) do { \
|
||||
result = (x); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto failure; \
|
||||
#define RETERR(x) \
|
||||
do { \
|
||||
result = (x); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto failure; \
|
||||
} while (0)
|
||||
|
||||
#include<named/log.h>
|
||||
#define LOG(msg) \
|
||||
isc_log_write(named_g_lctx, \
|
||||
NAMED_LOGCATEGORY_GENERAL, \
|
||||
NAMED_LOGMODULE_SERVER, \
|
||||
ISC_LOG_ERROR, \
|
||||
"%s", msg)
|
||||
#include <named/log.h>
|
||||
#define LOG(msg) \
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, \
|
||||
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR, "%s", msg)
|
||||
|
||||
isc_result_t
|
||||
named_tkeyctx_fromconfig(const cfg_obj_t *options, isc_mem_t *mctx,
|
||||
dns_tkeyctx_t **tctxp)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_tkeyctx_t *tctx = NULL;
|
||||
const char *s;
|
||||
uint32_t n;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t *name;
|
||||
isc_buffer_t b;
|
||||
isc_result_t result;
|
||||
dns_tkeyctx_t * tctx = NULL;
|
||||
const char * s;
|
||||
uint32_t n;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t * name;
|
||||
isc_buffer_t b;
|
||||
const cfg_obj_t *obj;
|
||||
int type;
|
||||
int type;
|
||||
|
||||
result = dns_tkeyctx_create(mctx, &tctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
|
|
@ -70,8 +66,8 @@ named_tkeyctx_fromconfig(const cfg_obj_t *options, isc_mem_t *mctx,
|
|||
isc_buffer_add(&b, strlen(s));
|
||||
name = dns_fixedname_initname(&fname);
|
||||
RETERR(dns_name_fromtext(name, &b, dns_rootname, 0, NULL));
|
||||
type = DST_TYPE_PUBLIC|DST_TYPE_PRIVATE|DST_TYPE_KEY;
|
||||
RETERR(dst_key_fromfile(name, (dns_keytag_t) n, DNS_KEYALG_DH,
|
||||
type = DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_KEY;
|
||||
RETERR(dst_key_fromfile(name, (dns_keytag_t)n, DNS_KEYALG_DH,
|
||||
type, NULL, mctx, &tctx->dhkey));
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +106,7 @@ named_tkeyctx_fromconfig(const cfg_obj_t *options, isc_mem_t *mctx,
|
|||
*tctxp = tctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
failure:
|
||||
failure:
|
||||
dns_tkeyctx_destroy(&tctx);
|
||||
return (result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <inttypes.h>
|
||||
|
|
@ -20,44 +19,41 @@
|
|||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/result.h>
|
||||
#include <dns/tsig.h>
|
||||
|
||||
#include <isccfg/cfg.h>
|
||||
|
||||
#include <dns/tsig.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
#include <named/log.h>
|
||||
|
||||
#include <named/config.h>
|
||||
#include <named/log.h>
|
||||
#include <named/tsigconf.h>
|
||||
|
||||
static isc_result_t
|
||||
add_initial_keys(const cfg_obj_t *list, dns_tsig_keyring_t *ring,
|
||||
isc_mem_t *mctx)
|
||||
{
|
||||
dns_tsigkey_t *tsigkey = NULL;
|
||||
dns_tsigkey_t * tsigkey = NULL;
|
||||
const cfg_listelt_t *element;
|
||||
const cfg_obj_t *key = NULL;
|
||||
const char *keyid = NULL;
|
||||
unsigned char *secret = NULL;
|
||||
int secretalloc = 0;
|
||||
int secretlen = 0;
|
||||
isc_result_t ret;
|
||||
isc_stdtime_t now;
|
||||
uint16_t bits;
|
||||
const cfg_obj_t * key = NULL;
|
||||
const char * keyid = NULL;
|
||||
unsigned char * secret = NULL;
|
||||
int secretalloc = 0;
|
||||
int secretlen = 0;
|
||||
isc_result_t ret;
|
||||
isc_stdtime_t now;
|
||||
uint16_t bits;
|
||||
|
||||
for (element = cfg_list_first(list);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
const cfg_obj_t *algobj = NULL;
|
||||
const cfg_obj_t *secretobj = NULL;
|
||||
dns_name_t keyname;
|
||||
for (element = cfg_list_first(list); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
const cfg_obj_t * algobj = NULL;
|
||||
const cfg_obj_t * secretobj = NULL;
|
||||
dns_name_t keyname;
|
||||
const dns_name_t *alg;
|
||||
const char *algstr;
|
||||
char keynamedata[1024];
|
||||
isc_buffer_t keynamesrc, keynamebuf;
|
||||
const char *secretstr;
|
||||
isc_buffer_t secretbuf;
|
||||
const char * algstr;
|
||||
char keynamedata[1024];
|
||||
isc_buffer_t keynamesrc, keynamebuf;
|
||||
const char * secretstr;
|
||||
isc_buffer_t secretbuf;
|
||||
|
||||
key = cfg_listelt_value(element);
|
||||
keyid = cfg_obj_asstring(cfg_map_getname(key));
|
||||
|
|
@ -84,8 +80,8 @@ add_initial_keys(const cfg_obj_t *list, dns_tsig_keyring_t *ring,
|
|||
* Create the algorithm.
|
||||
*/
|
||||
algstr = cfg_obj_asstring(algobj);
|
||||
if (named_config_getkeyalgorithm(algstr, &alg, &bits)
|
||||
!= ISC_R_SUCCESS) {
|
||||
if (named_config_getkeyalgorithm(algstr, &alg, &bits) !=
|
||||
ISC_R_SUCCESS) {
|
||||
cfg_obj_log(algobj, named_g_lctx, ISC_LOG_ERROR,
|
||||
"key '%s': has a "
|
||||
"unsupported algorithm '%s'",
|
||||
|
|
@ -105,8 +101,8 @@ add_initial_keys(const cfg_obj_t *list, dns_tsig_keyring_t *ring,
|
|||
|
||||
isc_stdtime_get(&now);
|
||||
ret = dns_tsigkey_create(&keyname, alg, secret, secretlen,
|
||||
false, NULL, now, now,
|
||||
mctx, ring, &tsigkey);
|
||||
false, NULL, now, now, mctx, ring,
|
||||
&tsigkey);
|
||||
isc_mem_put(mctx, secret, secretalloc);
|
||||
secret = NULL;
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
|
|
@ -120,10 +116,9 @@ add_initial_keys(const cfg_obj_t *list, dns_tsig_keyring_t *ring,
|
|||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
failure:
|
||||
failure:
|
||||
cfg_obj_log(key, named_g_lctx, ISC_LOG_ERROR,
|
||||
"configuring key '%s': %s", keyid,
|
||||
isc_result_totext(ret));
|
||||
"configuring key '%s': %s", keyid, isc_result_totext(ret));
|
||||
|
||||
if (secret != NULL)
|
||||
isc_mem_put(mctx, secret, secretalloc);
|
||||
|
|
@ -134,11 +129,11 @@ isc_result_t
|
|||
named_tsigkeyring_fromconfig(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
||||
isc_mem_t *mctx, dns_tsig_keyring_t **ringp)
|
||||
{
|
||||
const cfg_obj_t *maps[3];
|
||||
const cfg_obj_t *keylist;
|
||||
const cfg_obj_t * maps[3];
|
||||
const cfg_obj_t * keylist;
|
||||
dns_tsig_keyring_t *ring = NULL;
|
||||
isc_result_t result;
|
||||
int i;
|
||||
isc_result_t result;
|
||||
int i;
|
||||
|
||||
REQUIRE(ringp != NULL && *ringp == NULL);
|
||||
|
||||
|
|
@ -153,7 +148,7 @@ named_tsigkeyring_fromconfig(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
|||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
for (i = 0; ; i++) {
|
||||
for (i = 0;; i++) {
|
||||
if (maps[i] == NULL)
|
||||
break;
|
||||
keylist = NULL;
|
||||
|
|
@ -168,7 +163,7 @@ named_tsigkeyring_fromconfig(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
|||
*ringp = ring;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
failure:
|
||||
failure:
|
||||
dns_tsigkeyring_detach(&ring);
|
||||
return (result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,85 +9,83 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include <dns/log.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/dlz_dlopen.h>
|
||||
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <named/globals.h>
|
||||
#include <dns/dlz_dlopen.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
#include <dlz/dlz_dlopen_driver.h>
|
||||
#include <named/globals.h>
|
||||
|
||||
#ifdef ISC_DLZ_DLOPEN
|
||||
static dns_sdlzimplementation_t *dlz_dlopen = NULL;
|
||||
|
||||
|
||||
typedef struct dlopen_data {
|
||||
isc_mem_t *mctx;
|
||||
char *dl_path;
|
||||
char *dlzname;
|
||||
void *dl_handle;
|
||||
void *dbdata;
|
||||
isc_mem_t * mctx;
|
||||
char * dl_path;
|
||||
char * dlzname;
|
||||
void * dl_handle;
|
||||
void * dbdata;
|
||||
unsigned int flags;
|
||||
isc_mutex_t lock;
|
||||
int version;
|
||||
bool in_configure;
|
||||
isc_mutex_t lock;
|
||||
int version;
|
||||
bool in_configure;
|
||||
|
||||
dlz_dlopen_version_t *dlz_version;
|
||||
dlz_dlopen_create_t *dlz_create;
|
||||
dlz_dlopen_findzonedb_t *dlz_findzonedb;
|
||||
dlz_dlopen_lookup_t *dlz_lookup;
|
||||
dlz_dlopen_authority_t *dlz_authority;
|
||||
dlz_dlopen_allnodes_t *dlz_allnodes;
|
||||
dlz_dlopen_version_t * dlz_version;
|
||||
dlz_dlopen_create_t * dlz_create;
|
||||
dlz_dlopen_findzonedb_t * dlz_findzonedb;
|
||||
dlz_dlopen_lookup_t * dlz_lookup;
|
||||
dlz_dlopen_authority_t * dlz_authority;
|
||||
dlz_dlopen_allnodes_t * dlz_allnodes;
|
||||
dlz_dlopen_allowzonexfr_t *dlz_allowzonexfr;
|
||||
dlz_dlopen_newversion_t *dlz_newversion;
|
||||
dlz_dlopen_newversion_t * dlz_newversion;
|
||||
dlz_dlopen_closeversion_t *dlz_closeversion;
|
||||
dlz_dlopen_configure_t *dlz_configure;
|
||||
dlz_dlopen_ssumatch_t *dlz_ssumatch;
|
||||
dlz_dlopen_addrdataset_t *dlz_addrdataset;
|
||||
dlz_dlopen_subrdataset_t *dlz_subrdataset;
|
||||
dlz_dlopen_delrdataset_t *dlz_delrdataset;
|
||||
dlz_dlopen_destroy_t *dlz_destroy;
|
||||
dlz_dlopen_configure_t * dlz_configure;
|
||||
dlz_dlopen_ssumatch_t * dlz_ssumatch;
|
||||
dlz_dlopen_addrdataset_t * dlz_addrdataset;
|
||||
dlz_dlopen_subrdataset_t * dlz_subrdataset;
|
||||
dlz_dlopen_delrdataset_t * dlz_delrdataset;
|
||||
dlz_dlopen_destroy_t * dlz_destroy;
|
||||
} dlopen_data_t;
|
||||
|
||||
/* Modules can choose whether they are lock-safe or not. */
|
||||
#define MAYBE_LOCK(cd) \
|
||||
do { \
|
||||
#define MAYBE_LOCK(cd) \
|
||||
do { \
|
||||
if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
|
||||
cd->in_configure == false) \
|
||||
LOCK(&cd->lock); \
|
||||
cd->in_configure == false) \
|
||||
LOCK(&cd->lock); \
|
||||
} while (0)
|
||||
|
||||
#define MAYBE_UNLOCK(cd) \
|
||||
do { \
|
||||
#define MAYBE_UNLOCK(cd) \
|
||||
do { \
|
||||
if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
|
||||
cd->in_configure == false) \
|
||||
UNLOCK(&cd->lock); \
|
||||
cd->in_configure == false) \
|
||||
UNLOCK(&cd->lock); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Log a message at the given level.
|
||||
*/
|
||||
static void dlopen_log(int level, const char *fmt, ...)
|
||||
static void
|
||||
dlopen_log(int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
||||
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(level),
|
||||
fmt, ap);
|
||||
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
|
||||
ISC_LOG_DEBUG(level), fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
|
@ -99,9 +97,8 @@ static isc_result_t
|
|||
dlopen_dlz_allnodes(const char *zone, void *driverarg, void *dbdata,
|
||||
dns_sdlzallnodes_t *allnodes)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -115,17 +112,15 @@ dlopen_dlz_allnodes(const char *zone, void *driverarg, void *dbdata,
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static isc_result_t
|
||||
dlopen_dlz_allowzonexfr(void *driverarg, void *dbdata, const char *name,
|
||||
const char *client)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
||||
if (cd->dlz_allowzonexfr == NULL) {
|
||||
return (ISC_R_NOPERM);
|
||||
}
|
||||
|
|
@ -140,8 +135,8 @@ static isc_result_t
|
|||
dlopen_dlz_authority(const char *zone, void *driverarg, void *dbdata,
|
||||
dns_sdlzlookup_t *lookup)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -158,10 +153,10 @@ dlopen_dlz_authority(const char *zone, void *driverarg, void *dbdata,
|
|||
static isc_result_t
|
||||
dlopen_dlz_findzonedb(void *driverarg, void *dbdata, const char *name,
|
||||
dns_clientinfomethods_t *methods,
|
||||
dns_clientinfo_t *clientinfo)
|
||||
dns_clientinfo_t * clientinfo)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -171,21 +166,20 @@ dlopen_dlz_findzonedb(void *driverarg, void *dbdata, const char *name,
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static isc_result_t
|
||||
dlopen_dlz_lookup(const char *zone, const char *name, void *driverarg,
|
||||
void *dbdata, dns_sdlzlookup_t *lookup,
|
||||
dns_clientinfomethods_t *methods,
|
||||
dns_clientinfo_t *clientinfo)
|
||||
dns_clientinfo_t * clientinfo)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
MAYBE_LOCK(cd);
|
||||
result = cd->dlz_lookup(zone, name, cd->dbdata, lookup,
|
||||
methods, clientinfo);
|
||||
result = cd->dlz_lookup(zone, name, cd->dbdata, lookup, methods,
|
||||
clientinfo);
|
||||
MAYBE_UNLOCK(cd);
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -194,12 +188,14 @@ dlopen_dlz_lookup(const char *zone, const char *name, void *driverarg,
|
|||
* Load a symbol from the library
|
||||
*/
|
||||
static void *
|
||||
dl_load_symbol(dlopen_data_t *cd, const char *symbol, bool mandatory) {
|
||||
dl_load_symbol(dlopen_data_t *cd, const char *symbol, bool mandatory)
|
||||
{
|
||||
void *ptr = dlsym(cd->dl_handle, symbol);
|
||||
if (ptr == NULL && mandatory) {
|
||||
dlopen_log(ISC_LOG_ERROR,
|
||||
"dlz_dlopen: library '%s' is missing "
|
||||
"required symbol '%s'", cd->dl_path, symbol);
|
||||
"required symbol '%s'",
|
||||
cd->dl_path, symbol);
|
||||
}
|
||||
return (ptr);
|
||||
}
|
||||
|
|
@ -212,16 +208,17 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
void *driverarg, void **dbdata)
|
||||
{
|
||||
dlopen_data_t *cd;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_result_t result = ISC_R_FAILURE;
|
||||
int dlopen_flags = 0;
|
||||
isc_mem_t * mctx = NULL;
|
||||
isc_result_t result = ISC_R_FAILURE;
|
||||
int dlopen_flags = 0;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
if (argc < 2) {
|
||||
dlopen_log(ISC_LOG_ERROR,
|
||||
"dlz_dlopen driver for '%s' needs a path to "
|
||||
"the shared library", dlzname);
|
||||
"the shared library",
|
||||
dlzname);
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +237,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
isc_mutex_init(&cd->lock);
|
||||
|
||||
/* Open the library */
|
||||
dlopen_flags = RTLD_NOW|RTLD_GLOBAL;
|
||||
dlopen_flags = RTLD_NOW | RTLD_GLOBAL;
|
||||
|
||||
#if defined(RTLD_DEEPBIND) && !__SANITIZE_ADDRESS__
|
||||
/*
|
||||
|
|
@ -265,55 +262,49 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
}
|
||||
|
||||
/* Find the symbols */
|
||||
cd->dlz_version = (dlz_dlopen_version_t *)
|
||||
dl_load_symbol(cd, "dlz_version", true);
|
||||
cd->dlz_create = (dlz_dlopen_create_t *)
|
||||
dl_load_symbol(cd, "dlz_create", true);
|
||||
cd->dlz_lookup = (dlz_dlopen_lookup_t *)
|
||||
dl_load_symbol(cd, "dlz_lookup", true);
|
||||
cd->dlz_findzonedb = (dlz_dlopen_findzonedb_t *)
|
||||
dl_load_symbol(cd, "dlz_findzonedb", true);
|
||||
cd->dlz_version =
|
||||
(dlz_dlopen_version_t *)dl_load_symbol(cd, "dlz_version", true);
|
||||
cd->dlz_create =
|
||||
(dlz_dlopen_create_t *)dl_load_symbol(cd, "dlz_create", true);
|
||||
cd->dlz_lookup =
|
||||
(dlz_dlopen_lookup_t *)dl_load_symbol(cd, "dlz_lookup", true);
|
||||
cd->dlz_findzonedb = (dlz_dlopen_findzonedb_t *)dl_load_symbol(
|
||||
cd, "dlz_findzonedb", true);
|
||||
|
||||
if (cd->dlz_create == NULL ||
|
||||
cd->dlz_version == NULL ||
|
||||
cd->dlz_lookup == NULL ||
|
||||
cd->dlz_findzonedb == NULL)
|
||||
{
|
||||
if (cd->dlz_create == NULL || cd->dlz_version == NULL ||
|
||||
cd->dlz_lookup == NULL || cd->dlz_findzonedb == NULL) {
|
||||
/* We're missing a required symbol */
|
||||
result = ISC_R_FAILURE;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
cd->dlz_allowzonexfr = (dlz_dlopen_allowzonexfr_t *)
|
||||
dl_load_symbol(cd, "dlz_allowzonexfr", false);
|
||||
cd->dlz_allnodes = (dlz_dlopen_allnodes_t *)
|
||||
dl_load_symbol(cd, "dlz_allnodes",
|
||||
(cd->dlz_allowzonexfr != NULL));
|
||||
cd->dlz_authority = (dlz_dlopen_authority_t *)
|
||||
dl_load_symbol(cd, "dlz_authority", false);
|
||||
cd->dlz_newversion = (dlz_dlopen_newversion_t *)
|
||||
dl_load_symbol(cd, "dlz_newversion", false);
|
||||
cd->dlz_closeversion = (dlz_dlopen_closeversion_t *)
|
||||
dl_load_symbol(cd, "dlz_closeversion",
|
||||
(cd->dlz_newversion != NULL));
|
||||
cd->dlz_configure = (dlz_dlopen_configure_t *)
|
||||
dl_load_symbol(cd, "dlz_configure", false);
|
||||
cd->dlz_ssumatch = (dlz_dlopen_ssumatch_t *)
|
||||
dl_load_symbol(cd, "dlz_ssumatch", false);
|
||||
cd->dlz_addrdataset = (dlz_dlopen_addrdataset_t *)
|
||||
dl_load_symbol(cd, "dlz_addrdataset", false);
|
||||
cd->dlz_subrdataset = (dlz_dlopen_subrdataset_t *)
|
||||
dl_load_symbol(cd, "dlz_subrdataset", false);
|
||||
cd->dlz_delrdataset = (dlz_dlopen_delrdataset_t *)
|
||||
dl_load_symbol(cd, "dlz_delrdataset", false);
|
||||
cd->dlz_destroy = (dlz_dlopen_destroy_t *)
|
||||
dl_load_symbol(cd, "dlz_destroy", false);
|
||||
cd->dlz_allowzonexfr = (dlz_dlopen_allowzonexfr_t *)dl_load_symbol(
|
||||
cd, "dlz_allowzonexfr", false);
|
||||
cd->dlz_allnodes = (dlz_dlopen_allnodes_t *)dl_load_symbol(
|
||||
cd, "dlz_allnodes", (cd->dlz_allowzonexfr != NULL));
|
||||
cd->dlz_authority = (dlz_dlopen_authority_t *)dl_load_symbol(
|
||||
cd, "dlz_authority", false);
|
||||
cd->dlz_newversion = (dlz_dlopen_newversion_t *)dl_load_symbol(
|
||||
cd, "dlz_newversion", false);
|
||||
cd->dlz_closeversion = (dlz_dlopen_closeversion_t *)dl_load_symbol(
|
||||
cd, "dlz_closeversion", (cd->dlz_newversion != NULL));
|
||||
cd->dlz_configure = (dlz_dlopen_configure_t *)dl_load_symbol(
|
||||
cd, "dlz_configure", false);
|
||||
cd->dlz_ssumatch = (dlz_dlopen_ssumatch_t *)dl_load_symbol(
|
||||
cd, "dlz_ssumatch", false);
|
||||
cd->dlz_addrdataset = (dlz_dlopen_addrdataset_t *)dl_load_symbol(
|
||||
cd, "dlz_addrdataset", false);
|
||||
cd->dlz_subrdataset = (dlz_dlopen_subrdataset_t *)dl_load_symbol(
|
||||
cd, "dlz_subrdataset", false);
|
||||
cd->dlz_delrdataset = (dlz_dlopen_delrdataset_t *)dl_load_symbol(
|
||||
cd, "dlz_delrdataset", false);
|
||||
cd->dlz_destroy = (dlz_dlopen_destroy_t *)dl_load_symbol(
|
||||
cd, "dlz_destroy", false);
|
||||
|
||||
/* Check the version of the API is the same */
|
||||
cd->version = cd->dlz_version(&cd->flags);
|
||||
if (cd->version < (DLZ_DLOPEN_VERSION - DLZ_DLOPEN_AGE) ||
|
||||
cd->version > DLZ_DLOPEN_VERSION)
|
||||
{
|
||||
cd->version > DLZ_DLOPEN_VERSION) {
|
||||
dlopen_log(ISC_LOG_ERROR,
|
||||
"dlz_dlopen: %s: incorrect driver API version %d, "
|
||||
"requires %d",
|
||||
|
|
@ -330,13 +321,10 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
* link the BIND9 libraries
|
||||
*/
|
||||
MAYBE_LOCK(cd);
|
||||
result = cd->dlz_create(dlzname, argc-1, argv+1,
|
||||
&cd->dbdata,
|
||||
"log", dlopen_log,
|
||||
"putrr", dns_sdlz_putrr,
|
||||
result = cd->dlz_create(dlzname, argc - 1, argv + 1, &cd->dbdata, "log",
|
||||
dlopen_log, "putrr", dns_sdlz_putrr,
|
||||
"putnamedrr", dns_sdlz_putnamedrr,
|
||||
"writeable_zone", dns_dlz_writeablezone,
|
||||
NULL);
|
||||
"writeable_zone", dns_dlz_writeablezone, NULL);
|
||||
MAYBE_UNLOCK(cd);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto failed;
|
||||
|
|
@ -370,9 +358,10 @@ failed:
|
|||
* Called when bind is shutting down
|
||||
*/
|
||||
static void
|
||||
dlopen_dlz_destroy(void *driverarg, void *dbdata) {
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_mem_t *mctx;
|
||||
dlopen_dlz_destroy(void *driverarg, void *dbdata)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_mem_t * mctx;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -409,8 +398,8 @@ static isc_result_t
|
|||
dlopen_dlz_newversion(const char *zone, void *driverarg, void *dbdata,
|
||||
void **versionp)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -427,10 +416,10 @@ dlopen_dlz_newversion(const char *zone, void *driverarg, void *dbdata,
|
|||
* Called to end a transaction
|
||||
*/
|
||||
static void
|
||||
dlopen_dlz_closeversion(const char *zone, bool commit,
|
||||
void *driverarg, void *dbdata, void **versionp)
|
||||
dlopen_dlz_closeversion(const char *zone, bool commit, void *driverarg,
|
||||
void *dbdata, void **versionp)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -448,11 +437,11 @@ dlopen_dlz_closeversion(const char *zone, bool commit,
|
|||
* Called on startup to configure any writeable zones
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
void *driverarg, void *dbdata)
|
||||
dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *driverarg,
|
||||
void *dbdata)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -468,7 +457,6 @@ dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check for authority to change a name.
|
||||
*/
|
||||
|
|
@ -477,8 +465,8 @@ dlopen_dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
|
|||
const char *type, const char *key, uint32_t keydatalen,
|
||||
unsigned char *keydata, void *driverarg, void *dbdata)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
bool ret;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
bool ret;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -493,16 +481,15 @@ dlopen_dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
|
|||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add an rdataset.
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_addrdataset(const char *name, const char *rdatastr,
|
||||
void *driverarg, void *dbdata, void *version)
|
||||
dlopen_dlz_addrdataset(const char *name, const char *rdatastr, void *driverarg,
|
||||
void *dbdata, void *version)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -520,11 +507,11 @@ dlopen_dlz_addrdataset(const char *name, const char *rdatastr,
|
|||
* Subtract an rdataset.
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_subrdataset(const char *name, const char *rdatastr,
|
||||
void *driverarg, void *dbdata, void *version)
|
||||
dlopen_dlz_subrdataset(const char *name, const char *rdatastr, void *driverarg,
|
||||
void *dbdata, void *version)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -542,11 +529,11 @@ dlopen_dlz_subrdataset(const char *name, const char *rdatastr,
|
|||
* Delete a rdataset.
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_delrdataset(const char *name, const char *type,
|
||||
void *driverarg, void *dbdata, void *version)
|
||||
dlopen_dlz_delrdataset(const char *name, const char *type, void *driverarg,
|
||||
void *dbdata, void *version)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -560,22 +547,12 @@ dlopen_dlz_delrdataset(const char *name, const char *type,
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static dns_sdlzmethods_t dlz_dlopen_methods = {
|
||||
dlopen_dlz_create,
|
||||
dlopen_dlz_destroy,
|
||||
dlopen_dlz_findzonedb,
|
||||
dlopen_dlz_lookup,
|
||||
dlopen_dlz_authority,
|
||||
dlopen_dlz_allnodes,
|
||||
dlopen_dlz_allowzonexfr,
|
||||
dlopen_dlz_newversion,
|
||||
dlopen_dlz_closeversion,
|
||||
dlopen_dlz_configure,
|
||||
dlopen_dlz_ssumatch,
|
||||
dlopen_dlz_addrdataset,
|
||||
dlopen_dlz_subrdataset,
|
||||
dlopen_dlz_delrdataset
|
||||
dlopen_dlz_create, dlopen_dlz_destroy, dlopen_dlz_findzonedb,
|
||||
dlopen_dlz_lookup, dlopen_dlz_authority, dlopen_dlz_allnodes,
|
||||
dlopen_dlz_allowzonexfr, dlopen_dlz_newversion, dlopen_dlz_closeversion,
|
||||
dlopen_dlz_configure, dlopen_dlz_ssumatch, dlopen_dlz_addrdataset,
|
||||
dlopen_dlz_subrdataset, dlopen_dlz_delrdataset
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
@ -583,7 +560,8 @@ static dns_sdlzmethods_t dlz_dlopen_methods = {
|
|||
* Register driver with BIND
|
||||
*/
|
||||
isc_result_t
|
||||
dlz_dlopen_init(isc_mem_t *mctx) {
|
||||
dlz_dlopen_init(isc_mem_t *mctx)
|
||||
{
|
||||
#ifndef ISC_DLZ_DLOPEN
|
||||
UNUSED(mctx);
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
|
|
@ -594,8 +572,8 @@ dlz_dlopen_init(isc_mem_t *mctx) {
|
|||
|
||||
result = dns_sdlzregister("dlopen", &dlz_dlopen_methods, NULL,
|
||||
DNS_SDLZFLAG_RELATIVEOWNER |
|
||||
DNS_SDLZFLAG_RELATIVERDATA |
|
||||
DNS_SDLZFLAG_THREADSAFE,
|
||||
DNS_SDLZFLAG_RELATIVERDATA |
|
||||
DNS_SDLZFLAG_THREADSAFE,
|
||||
mctx, &dlz_dlopen);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -609,12 +587,12 @@ dlz_dlopen_init(isc_mem_t *mctx) {
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Unregister the driver
|
||||
*/
|
||||
void
|
||||
dlz_dlopen_clear(void) {
|
||||
dlz_dlopen_clear(void)
|
||||
{
|
||||
#ifdef ISC_DLZ_DLOPEN
|
||||
dlopen_log(2, "Unregistering DLZ_dlopen driver");
|
||||
if (dlz_dlopen != NULL)
|
||||
|
|
|
|||
|
|
@ -13,20 +13,20 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <sys/types.h> /* dev_t FreeBSD 2.1 */
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h> /* dev_t FreeBSD 2.1 */
|
||||
#ifdef HAVE_UNAME
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <syslog.h>
|
||||
#ifdef HAVE_TZSET
|
||||
#include <time.h>
|
||||
|
|
@ -50,16 +50,16 @@
|
|||
|
||||
static char *pidfile = NULL;
|
||||
static char *lockfile = NULL;
|
||||
static int devnullfd = -1;
|
||||
static int singletonfd = -1;
|
||||
static int devnullfd = -1;
|
||||
static int singletonfd = -1;
|
||||
|
||||
#ifndef ISC_FACILITY
|
||||
#define ISC_FACILITY LOG_DAEMON
|
||||
#endif
|
||||
|
||||
static struct passwd *runas_pw = NULL;
|
||||
static bool done_setuid = false;
|
||||
static int dfd[2] = { -1, -1 };
|
||||
static bool done_setuid = false;
|
||||
static int dfd[2] = { -1, -1 };
|
||||
|
||||
#ifdef HAVE_SYS_CAPABILITY_H
|
||||
|
||||
|
|
@ -70,7 +70,8 @@ static bool non_root_caps = false;
|
|||
#include <sys/prctl.h>
|
||||
|
||||
static void
|
||||
linux_setcaps(cap_t caps) {
|
||||
linux_setcaps(cap_t caps)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
if ((getuid() != 0 && !non_root_caps) || non_root) {
|
||||
|
|
@ -85,51 +86,60 @@ linux_setcaps(cap_t caps) {
|
|||
}
|
||||
}
|
||||
|
||||
#define SET_CAP(flag) \
|
||||
do { \
|
||||
cap_flag_value_t curval; \
|
||||
capval = (flag); \
|
||||
err = cap_get_flag(curcaps, capval, CAP_PERMITTED, &curval); \
|
||||
if (err != -1 && curval) { \
|
||||
err = cap_set_flag(caps, CAP_EFFECTIVE, 1, &capval, CAP_SET); \
|
||||
if (err == -1) { \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_set_proc failed: %s", strbuf); \
|
||||
} \
|
||||
\
|
||||
err = cap_set_flag(caps, CAP_PERMITTED, 1, &capval, CAP_SET); \
|
||||
if (err == -1) { \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_set_proc failed: %s", strbuf); \
|
||||
} \
|
||||
} \
|
||||
#define SET_CAP(flag) \
|
||||
do { \
|
||||
cap_flag_value_t curval; \
|
||||
capval = (flag); \
|
||||
err = cap_get_flag(curcaps, capval, CAP_PERMITTED, &curval); \
|
||||
if (err != -1 && curval) { \
|
||||
err = cap_set_flag(caps, CAP_EFFECTIVE, 1, &capval, \
|
||||
CAP_SET); \
|
||||
if (err == -1) { \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_set_proc failed: " \
|
||||
"%s", \
|
||||
strbuf); \
|
||||
} \
|
||||
\
|
||||
err = cap_set_flag(caps, CAP_PERMITTED, 1, &capval, \
|
||||
CAP_SET); \
|
||||
if (err == -1) { \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_set_proc failed: " \
|
||||
"%s", \
|
||||
strbuf); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#define INIT_CAP \
|
||||
do { \
|
||||
caps = cap_init(); \
|
||||
if (caps == NULL) { \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
#define INIT_CAP \
|
||||
do { \
|
||||
caps = cap_init(); \
|
||||
if (caps == NULL) { \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_init failed: %s", strbuf); \
|
||||
} \
|
||||
curcaps = cap_get_proc(); \
|
||||
if (curcaps == NULL) { \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_get_proc failed: %s", strbuf); \
|
||||
} \
|
||||
} \
|
||||
curcaps = cap_get_proc(); \
|
||||
if (curcaps == NULL) { \
|
||||
strerror_r(errno, strbuf, sizeof(strbuf)); \
|
||||
named_main_earlyfatal("cap_get_proc failed: %s", \
|
||||
strbuf); \
|
||||
} \
|
||||
} while (0)
|
||||
#define FREE_CAP \
|
||||
{ \
|
||||
cap_free(caps); \
|
||||
#define FREE_CAP \
|
||||
{ \
|
||||
cap_free(caps); \
|
||||
cap_free(curcaps); \
|
||||
} while (0)
|
||||
} \
|
||||
while (0)
|
||||
|
||||
static void
|
||||
linux_initialprivs(void) {
|
||||
cap_t caps;
|
||||
cap_t curcaps;
|
||||
linux_initialprivs(void)
|
||||
{
|
||||
cap_t caps;
|
||||
cap_t curcaps;
|
||||
cap_value_t capval;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
int err;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
int err;
|
||||
|
||||
/*%
|
||||
* We don't need most privileges, so we drop them right away.
|
||||
|
|
@ -186,12 +196,13 @@ linux_initialprivs(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
linux_minprivs(void) {
|
||||
cap_t caps;
|
||||
cap_t curcaps;
|
||||
linux_minprivs(void)
|
||||
{
|
||||
cap_t caps;
|
||||
cap_t curcaps;
|
||||
cap_value_t capval;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
int err;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
int err;
|
||||
|
||||
INIT_CAP;
|
||||
/*%
|
||||
|
|
@ -219,7 +230,8 @@ linux_minprivs(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
linux_keepcaps(void) {
|
||||
linux_keepcaps(void)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
/*%
|
||||
* Ask the kernel to allow us to keep our capabilities after we
|
||||
|
|
@ -238,10 +250,11 @@ linux_keepcaps(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#endif /* HAVE_SYS_CAPABILITY_H */
|
||||
#endif /* HAVE_SYS_CAPABILITY_H */
|
||||
|
||||
static void
|
||||
setup_syslog(const char *progname) {
|
||||
setup_syslog(const char *progname)
|
||||
{
|
||||
int options;
|
||||
|
||||
options = LOG_PID;
|
||||
|
|
@ -252,7 +265,8 @@ setup_syslog(const char *progname) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_init(const char *progname) {
|
||||
named_os_init(const char *progname)
|
||||
{
|
||||
setup_syslog(progname);
|
||||
#ifdef HAVE_SYS_CAPABILITY_H
|
||||
linux_initialprivs();
|
||||
|
|
@ -263,9 +277,10 @@ named_os_init(const char *progname) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_daemonize(void) {
|
||||
named_os_daemonize(void)
|
||||
{
|
||||
pid_t pid;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
if (pipe(dfd) == -1) {
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
|
|
@ -331,7 +346,8 @@ named_os_daemonize(void) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_started(void) {
|
||||
named_os_started(void)
|
||||
{
|
||||
char buf = 0;
|
||||
|
||||
/*
|
||||
|
|
@ -348,14 +364,15 @@ named_os_started(void) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_opendevnull(void) {
|
||||
named_os_opendevnull(void)
|
||||
{
|
||||
devnullfd = open("/dev/null", O_RDWR, 0);
|
||||
}
|
||||
|
||||
void
|
||||
named_os_closedevnull(void) {
|
||||
if (devnullfd != STDIN_FILENO &&
|
||||
devnullfd != STDOUT_FILENO &&
|
||||
named_os_closedevnull(void)
|
||||
{
|
||||
if (devnullfd != STDIN_FILENO && devnullfd != STDOUT_FILENO &&
|
||||
devnullfd != STDERR_FILENO) {
|
||||
close(devnullfd);
|
||||
devnullfd = -1;
|
||||
|
|
@ -363,11 +380,12 @@ named_os_closedevnull(void) {
|
|||
}
|
||||
|
||||
static bool
|
||||
all_digits(const char *s) {
|
||||
all_digits(const char *s)
|
||||
{
|
||||
if (*s == '\0')
|
||||
return (false);
|
||||
while (*s != '\0') {
|
||||
if (!isdigit((*s)&0xff))
|
||||
if (!isdigit((*s) & 0xff))
|
||||
return (false);
|
||||
s++;
|
||||
}
|
||||
|
|
@ -375,7 +393,8 @@ all_digits(const char *s) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_chroot(const char *root) {
|
||||
named_os_chroot(const char *root)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
#ifdef HAVE_LIBSCF
|
||||
named_smf_chroot = 0;
|
||||
|
|
@ -401,7 +420,8 @@ named_os_chroot(const char *root) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_inituserinfo(const char *username) {
|
||||
named_os_inituserinfo(const char *username)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
if (username == NULL)
|
||||
return;
|
||||
|
|
@ -421,11 +441,11 @@ named_os_inituserinfo(const char *username) {
|
|||
named_main_earlyfatal("initgroups(): %s", strbuf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
named_os_changeuser(void) {
|
||||
named_os_changeuser(void)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
if (runas_pw == NULL || done_setuid)
|
||||
return;
|
||||
|
|
@ -447,7 +467,7 @@ named_os_changeuser(void) {
|
|||
* Restore the ability of named to drop core after the setuid()
|
||||
* call has disabled it.
|
||||
*/
|
||||
if (prctl(PR_SET_DUMPABLE,1,0,0,0) < 0) {
|
||||
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) {
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("prctl(PR_SET_DUMPABLE) failed: %s",
|
||||
strbuf);
|
||||
|
|
@ -458,16 +478,18 @@ named_os_changeuser(void) {
|
|||
}
|
||||
|
||||
uid_t
|
||||
ns_os_uid(void) {
|
||||
ns_os_uid(void)
|
||||
{
|
||||
if (runas_pw == NULL)
|
||||
return (0);
|
||||
return (runas_pw->pw_uid);
|
||||
}
|
||||
|
||||
void
|
||||
named_os_adjustnofile(void) {
|
||||
named_os_adjustnofile(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
isc_resourcevalue_t newvalue;
|
||||
|
||||
/*
|
||||
|
|
@ -483,7 +505,8 @@ named_os_adjustnofile(void) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_minprivs(void) {
|
||||
named_os_minprivs(void)
|
||||
{
|
||||
#if defined(HAVE_SYS_CAPABILITY_H)
|
||||
linux_keepcaps();
|
||||
named_os_changeuser();
|
||||
|
|
@ -492,8 +515,9 @@ named_os_minprivs(void) {
|
|||
}
|
||||
|
||||
static int
|
||||
safe_open(const char *filename, mode_t mode, bool append) {
|
||||
int fd;
|
||||
safe_open(const char *filename, mode_t mode, bool append)
|
||||
{
|
||||
int fd;
|
||||
struct stat sb;
|
||||
|
||||
if (stat(filename, &sb) == -1) {
|
||||
|
|
@ -505,17 +529,18 @@ safe_open(const char *filename, mode_t mode, bool append) {
|
|||
}
|
||||
|
||||
if (append)
|
||||
fd = open(filename, O_WRONLY|O_CREAT|O_APPEND, mode);
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_APPEND, mode);
|
||||
else {
|
||||
if (unlink(filename) < 0 && errno != ENOENT)
|
||||
return (-1);
|
||||
fd = open(filename, O_WRONLY|O_CREAT|O_EXCL, mode);
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, mode);
|
||||
}
|
||||
return (fd);
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_pidfile(void) {
|
||||
cleanup_pidfile(void)
|
||||
{
|
||||
int n;
|
||||
if (pidfile != NULL) {
|
||||
n = unlink(pidfile);
|
||||
|
|
@ -527,7 +552,8 @@ cleanup_pidfile(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
cleanup_lockfile(void) {
|
||||
cleanup_lockfile(void)
|
||||
{
|
||||
if (singletonfd != -1) {
|
||||
close(singletonfd);
|
||||
singletonfd = -1;
|
||||
|
|
@ -549,9 +575,10 @@ cleanup_lockfile(void) {
|
|||
* nulls. The caller should copy the filename to a fresh buffer first.
|
||||
*/
|
||||
static int
|
||||
mkdirpath(char *filename, void (*report)(const char *, ...)) {
|
||||
char *slash = strrchr(filename, '/');
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
mkdirpath(char *filename, void (*report)(const char *, ...))
|
||||
{
|
||||
char * slash = strrchr(filename, '/');
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
unsigned int mode;
|
||||
|
||||
if (slash != NULL && slash != filename) {
|
||||
|
|
@ -570,15 +597,14 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
|
|||
/*
|
||||
* Handle "//", "/./" and "/../" in path.
|
||||
*/
|
||||
if (!strcmp(slash + 1, "") ||
|
||||
!strcmp(slash + 1, ".") ||
|
||||
if (!strcmp(slash + 1, "") || !strcmp(slash + 1, ".") ||
|
||||
!strcmp(slash + 1, "..")) {
|
||||
*slash = '/';
|
||||
return (0);
|
||||
}
|
||||
mode = S_IRUSR | S_IWUSR | S_IXUSR; /* u=rwx */
|
||||
mode |= S_IRGRP | S_IXGRP; /* g=rx */
|
||||
mode |= S_IROTH | S_IXOTH; /* o=rx */
|
||||
mode = S_IRUSR | S_IWUSR | S_IXUSR; /* u=rwx */
|
||||
mode |= S_IRGRP | S_IXGRP; /* g=rx */
|
||||
mode |= S_IROTH | S_IXOTH; /* o=rx */
|
||||
if (mkdir(filename, mode) == -1) {
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
(*report)("couldn't mkdir '%s': %s", filename,
|
||||
|
|
@ -597,13 +623,14 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
|
|||
}
|
||||
return (0);
|
||||
|
||||
error:
|
||||
error:
|
||||
*slash = '/';
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
setperms(uid_t uid, gid_t gid) {
|
||||
setperms(uid_t uid, gid_t gid)
|
||||
{
|
||||
#if defined(HAVE_SETEGID) || defined(HAVE_SETRESGID)
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
#endif
|
||||
|
|
@ -625,7 +652,8 @@ setperms(uid_t uid, gid_t gid) {
|
|||
if (setresgid(-1, gid, -1) == -1) {
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("unable to set effective "
|
||||
"gid to %d: %s", gid, strbuf);
|
||||
"gid to %d: %s",
|
||||
gid, strbuf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -642,17 +670,19 @@ setperms(uid_t uid, gid_t gid) {
|
|||
if (setresuid(-1, uid, -1) == -1) {
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("unable to set effective "
|
||||
"uid to %d: %s", uid, strbuf);
|
||||
"uid to %d: %s",
|
||||
uid, strbuf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
FILE *
|
||||
named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
|
||||
char strbuf[ISC_STRERRORSIZE], *f;
|
||||
named_os_openfile(const char *filename, mode_t mode, bool switch_user)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE], *f;
|
||||
FILE *fp;
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* Make the containing directory if it doesn't exist.
|
||||
|
|
@ -660,8 +690,8 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
|
|||
f = strdup(filename);
|
||||
if (f == NULL) {
|
||||
strerror_r(errno, strbuf, sizeof(strbuf));
|
||||
named_main_earlywarning("couldn't strdup() '%s': %s",
|
||||
filename, strbuf);
|
||||
named_main_earlywarning("couldn't strdup() '%s': %s", filename,
|
||||
strbuf);
|
||||
return (NULL);
|
||||
}
|
||||
if (mkdirpath(f, named_main_earlywarning) == -1) {
|
||||
|
|
@ -685,10 +715,12 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
|
|||
if (fd != -1) {
|
||||
named_main_earlywarning("Required root "
|
||||
"permissions to open "
|
||||
"'%s'.", filename);
|
||||
"'%s'.",
|
||||
filename);
|
||||
} else {
|
||||
named_main_earlywarning("Could not open "
|
||||
"'%s'.", filename);
|
||||
"'%s'.",
|
||||
filename);
|
||||
}
|
||||
named_main_earlywarning("Please check file and "
|
||||
"directory permissions "
|
||||
|
|
@ -716,10 +748,11 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_writepidfile(const char *filename, bool first_time) {
|
||||
named_os_writepidfile(const char *filename, bool first_time)
|
||||
{
|
||||
FILE *fh;
|
||||
pid_t pid;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
void (*report)(const char *, ...);
|
||||
|
||||
/*
|
||||
|
|
@ -740,7 +773,7 @@ named_os_writepidfile(const char *filename, bool first_time) {
|
|||
return;
|
||||
}
|
||||
|
||||
fh = named_os_openfile(filename, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
|
||||
fh = named_os_openfile(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH,
|
||||
first_time);
|
||||
if (fh == NULL) {
|
||||
cleanup_pidfile();
|
||||
|
|
@ -763,8 +796,9 @@ named_os_writepidfile(const char *filename, bool first_time) {
|
|||
}
|
||||
|
||||
bool
|
||||
named_os_issingleton(const char *filename) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
named_os_issingleton(const char *filename)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
struct flock lock;
|
||||
|
||||
if (singletonfd != -1)
|
||||
|
|
@ -796,7 +830,7 @@ named_os_issingleton(const char *filename) {
|
|||
* files. We can't use that here.
|
||||
*/
|
||||
singletonfd = open(filename, O_WRONLY | O_CREAT,
|
||||
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
if (singletonfd == -1) {
|
||||
cleanup_lockfile();
|
||||
return (false);
|
||||
|
|
@ -819,14 +853,16 @@ named_os_issingleton(const char *filename) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_shutdown(void) {
|
||||
named_os_shutdown(void)
|
||||
{
|
||||
closelog();
|
||||
cleanup_pidfile();
|
||||
cleanup_lockfile();
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
named_os_gethostname(char *buf, size_t len) {
|
||||
named_os_gethostname(char *buf, size_t len)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = gethostname(buf, len);
|
||||
|
|
@ -834,11 +870,11 @@ named_os_gethostname(char *buf, size_t len) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_shutdownmsg(char *command, isc_buffer_t *text) {
|
||||
named_os_shutdownmsg(char *command, isc_buffer_t *text)
|
||||
{
|
||||
char *last, *ptr;
|
||||
pid_t pid;
|
||||
|
||||
|
||||
/* Skip the command name. */
|
||||
if ((ptr = strtok_r(command, " \t", &last)) == NULL) {
|
||||
return;
|
||||
|
|
@ -858,17 +894,19 @@ named_os_shutdownmsg(char *command, isc_buffer_t *text) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_tzset(void) {
|
||||
named_os_tzset(void)
|
||||
{
|
||||
#ifdef HAVE_TZSET
|
||||
tzset();
|
||||
#endif
|
||||
}
|
||||
|
||||
static char unamebuf[BUFSIZ];
|
||||
static char unamebuf[BUFSIZ];
|
||||
static char *unamep = NULL;
|
||||
|
||||
static void
|
||||
getuname(void) {
|
||||
getuname(void)
|
||||
{
|
||||
#ifdef HAVE_UNAME
|
||||
struct utsname uts;
|
||||
|
||||
|
|
@ -878,9 +916,8 @@ getuname(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
snprintf(unamebuf, sizeof(unamebuf),
|
||||
"%s %s %s %s",
|
||||
uts.sysname, uts.machine, uts.release, uts.version);
|
||||
snprintf(unamebuf, sizeof(unamebuf), "%s %s %s %s", uts.sysname,
|
||||
uts.machine, uts.release, uts.version);
|
||||
#else
|
||||
snprintf(unamebuf, sizeof(unamebuf), "unknown architecture");
|
||||
#endif
|
||||
|
|
@ -888,7 +925,8 @@ getuname(void) {
|
|||
}
|
||||
|
||||
char *
|
||||
named_os_uname(void) {
|
||||
named_os_uname(void)
|
||||
{
|
||||
if (unamep == NULL)
|
||||
getuname();
|
||||
return (unamep);
|
||||
|
|
|
|||
|
|
@ -9,84 +9,81 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dns/log.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/dlz_dlopen.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <named/globals.h>
|
||||
#include <dns/dlz_dlopen.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
#include <dlz/dlz_dlopen_driver.h>
|
||||
#include <named/globals.h>
|
||||
|
||||
#ifdef ISC_DLZ_DLOPEN
|
||||
static dns_sdlzimplementation_t *dlz_dlopen = NULL;
|
||||
|
||||
|
||||
typedef struct dlopen_data {
|
||||
isc_mem_t *mctx;
|
||||
char *dl_path;
|
||||
char *dlzname;
|
||||
HMODULE dl_handle;
|
||||
void *dbdata;
|
||||
isc_mem_t * mctx;
|
||||
char * dl_path;
|
||||
char * dlzname;
|
||||
HMODULE dl_handle;
|
||||
void * dbdata;
|
||||
unsigned int flags;
|
||||
isc_mutex_t lock;
|
||||
int version;
|
||||
bool in_configure;
|
||||
isc_mutex_t lock;
|
||||
int version;
|
||||
bool in_configure;
|
||||
|
||||
dlz_dlopen_version_t *dlz_version;
|
||||
dlz_dlopen_create_t *dlz_create;
|
||||
dlz_dlopen_findzonedb_t *dlz_findzonedb;
|
||||
dlz_dlopen_lookup_t *dlz_lookup;
|
||||
dlz_dlopen_authority_t *dlz_authority;
|
||||
dlz_dlopen_allnodes_t *dlz_allnodes;
|
||||
dlz_dlopen_version_t * dlz_version;
|
||||
dlz_dlopen_create_t * dlz_create;
|
||||
dlz_dlopen_findzonedb_t * dlz_findzonedb;
|
||||
dlz_dlopen_lookup_t * dlz_lookup;
|
||||
dlz_dlopen_authority_t * dlz_authority;
|
||||
dlz_dlopen_allnodes_t * dlz_allnodes;
|
||||
dlz_dlopen_allowzonexfr_t *dlz_allowzonexfr;
|
||||
dlz_dlopen_newversion_t *dlz_newversion;
|
||||
dlz_dlopen_newversion_t * dlz_newversion;
|
||||
dlz_dlopen_closeversion_t *dlz_closeversion;
|
||||
dlz_dlopen_configure_t *dlz_configure;
|
||||
dlz_dlopen_ssumatch_t *dlz_ssumatch;
|
||||
dlz_dlopen_addrdataset_t *dlz_addrdataset;
|
||||
dlz_dlopen_subrdataset_t *dlz_subrdataset;
|
||||
dlz_dlopen_delrdataset_t *dlz_delrdataset;
|
||||
dlz_dlopen_destroy_t *dlz_destroy;
|
||||
dlz_dlopen_configure_t * dlz_configure;
|
||||
dlz_dlopen_ssumatch_t * dlz_ssumatch;
|
||||
dlz_dlopen_addrdataset_t * dlz_addrdataset;
|
||||
dlz_dlopen_subrdataset_t * dlz_subrdataset;
|
||||
dlz_dlopen_delrdataset_t * dlz_delrdataset;
|
||||
dlz_dlopen_destroy_t * dlz_destroy;
|
||||
} dlopen_data_t;
|
||||
|
||||
/* Modules can choose whether they are lock-safe or not. */
|
||||
#define MAYBE_LOCK(cd) \
|
||||
do { \
|
||||
#define MAYBE_LOCK(cd) \
|
||||
do { \
|
||||
if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
|
||||
cd->in_configure == false) \
|
||||
LOCK(&cd->lock); \
|
||||
cd->in_configure == false) \
|
||||
LOCK(&cd->lock); \
|
||||
} while (0)
|
||||
|
||||
#define MAYBE_UNLOCK(cd) \
|
||||
do { \
|
||||
#define MAYBE_UNLOCK(cd) \
|
||||
do { \
|
||||
if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
|
||||
cd->in_configure == false) \
|
||||
UNLOCK(&cd->lock); \
|
||||
cd->in_configure == false) \
|
||||
UNLOCK(&cd->lock); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Log a message at the given level.
|
||||
*/
|
||||
static void dlopen_log(int level, const char *fmt, ...)
|
||||
static void
|
||||
dlopen_log(int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
||||
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(level),
|
||||
fmt, ap);
|
||||
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
|
||||
ISC_LOG_DEBUG(level), fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
|
@ -98,9 +95,8 @@ static isc_result_t
|
|||
dlopen_dlz_allnodes(const char *zone, void *driverarg, void *dbdata,
|
||||
dns_sdlzallnodes_t *allnodes)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -114,17 +110,15 @@ dlopen_dlz_allnodes(const char *zone, void *driverarg, void *dbdata,
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static isc_result_t
|
||||
dlopen_dlz_allowzonexfr(void *driverarg, void *dbdata, const char *name,
|
||||
const char *client)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
||||
if (cd->dlz_allowzonexfr == NULL) {
|
||||
return (ISC_R_NOPERM);
|
||||
}
|
||||
|
|
@ -137,10 +131,10 @@ dlopen_dlz_allowzonexfr(void *driverarg, void *dbdata, const char *name,
|
|||
|
||||
static isc_result_t
|
||||
dlopen_dlz_authority(const char *zone, void *driverarg, void *dbdata,
|
||||
dns_sdlzlookup_t *lookup)
|
||||
dns_sdlzlookup_t *lookup)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -157,10 +151,10 @@ dlopen_dlz_authority(const char *zone, void *driverarg, void *dbdata,
|
|||
static isc_result_t
|
||||
dlopen_dlz_findzonedb(void *driverarg, void *dbdata, const char *name,
|
||||
dns_clientinfomethods_t *methods,
|
||||
dns_clientinfo_t *clientinfo)
|
||||
dns_clientinfo_t * clientinfo)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -170,21 +164,20 @@ dlopen_dlz_findzonedb(void *driverarg, void *dbdata, const char *name,
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static isc_result_t
|
||||
dlopen_dlz_lookup(const char *zone, const char *name, void *driverarg,
|
||||
void *dbdata, dns_sdlzlookup_t *lookup,
|
||||
dns_clientinfomethods_t *methods,
|
||||
dns_clientinfo_t *clientinfo)
|
||||
dns_clientinfo_t * clientinfo)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
MAYBE_LOCK(cd);
|
||||
result = cd->dlz_lookup(zone, name, cd->dbdata, lookup,
|
||||
methods, clientinfo);
|
||||
result = cd->dlz_lookup(zone, name, cd->dbdata, lookup, methods,
|
||||
clientinfo);
|
||||
MAYBE_UNLOCK(cd);
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -193,12 +186,14 @@ dlopen_dlz_lookup(const char *zone, const char *name, void *driverarg,
|
|||
* Load a symbol from the library
|
||||
*/
|
||||
static void *
|
||||
dl_load_symbol(dlopen_data_t *cd, const char *symbol, bool mandatory) {
|
||||
dl_load_symbol(dlopen_data_t *cd, const char *symbol, bool mandatory)
|
||||
{
|
||||
void *ptr = GetProcAddress(cd->dl_handle, symbol);
|
||||
if (ptr == NULL && mandatory) {
|
||||
dlopen_log(ISC_LOG_ERROR,
|
||||
"dlz_dlopen: library '%s' is missing "
|
||||
"required symbol '%s'", cd->dl_path, symbol);
|
||||
"required symbol '%s'",
|
||||
cd->dl_path, symbol);
|
||||
}
|
||||
return (ptr);
|
||||
}
|
||||
|
|
@ -211,16 +206,17 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
void *driverarg, void **dbdata)
|
||||
{
|
||||
dlopen_data_t *cd;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_result_t result = ISC_R_FAILURE;
|
||||
bool triedload = false;
|
||||
isc_mem_t * mctx = NULL;
|
||||
isc_result_t result = ISC_R_FAILURE;
|
||||
bool triedload = false;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
if (argc < 2) {
|
||||
dlopen_log(ISC_LOG_ERROR,
|
||||
"dlz_dlopen driver for '%s' needs a path to "
|
||||
"the shared library", dlzname);
|
||||
"the shared library",
|
||||
dlzname);
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -253,53 +249,47 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
}
|
||||
|
||||
/* Find the symbols */
|
||||
cd->dlz_version = (dlz_dlopen_version_t *)
|
||||
dl_load_symbol(cd, "dlz_version", true);
|
||||
cd->dlz_create = (dlz_dlopen_create_t *)
|
||||
dl_load_symbol(cd, "dlz_create", true);
|
||||
cd->dlz_lookup = (dlz_dlopen_lookup_t *)
|
||||
dl_load_symbol(cd, "dlz_lookup", true);
|
||||
cd->dlz_findzonedb = (dlz_dlopen_findzonedb_t *)
|
||||
dl_load_symbol(cd, "dlz_findzonedb", true);
|
||||
cd->dlz_version =
|
||||
(dlz_dlopen_version_t *)dl_load_symbol(cd, "dlz_version", true);
|
||||
cd->dlz_create =
|
||||
(dlz_dlopen_create_t *)dl_load_symbol(cd, "dlz_create", true);
|
||||
cd->dlz_lookup =
|
||||
(dlz_dlopen_lookup_t *)dl_load_symbol(cd, "dlz_lookup", true);
|
||||
cd->dlz_findzonedb = (dlz_dlopen_findzonedb_t *)dl_load_symbol(
|
||||
cd, "dlz_findzonedb", true);
|
||||
|
||||
if (cd->dlz_create == NULL ||
|
||||
cd->dlz_version == NULL ||
|
||||
cd->dlz_lookup == NULL ||
|
||||
cd->dlz_findzonedb == NULL)
|
||||
{
|
||||
if (cd->dlz_create == NULL || cd->dlz_version == NULL ||
|
||||
cd->dlz_lookup == NULL || cd->dlz_findzonedb == NULL) {
|
||||
/* We're missing a required symbol */
|
||||
result = ISC_R_FAILURE;
|
||||
goto cleanup_lock;
|
||||
}
|
||||
|
||||
cd->dlz_allowzonexfr = (dlz_dlopen_allowzonexfr_t *)
|
||||
dl_load_symbol(cd, "dlz_allowzonexfr", false);
|
||||
cd->dlz_allnodes = (dlz_dlopen_allnodes_t *)
|
||||
dl_load_symbol(cd, "dlz_allnodes",
|
||||
(cd->dlz_allowzonexfr != NULL));
|
||||
cd->dlz_authority = (dlz_dlopen_authority_t *)
|
||||
dl_load_symbol(cd, "dlz_authority", false);
|
||||
cd->dlz_newversion = (dlz_dlopen_newversion_t *)
|
||||
dl_load_symbol(cd, "dlz_newversion", false);
|
||||
cd->dlz_closeversion = (dlz_dlopen_closeversion_t *)
|
||||
dl_load_symbol(cd, "dlz_closeversion",
|
||||
(cd->dlz_newversion != NULL));
|
||||
cd->dlz_configure = (dlz_dlopen_configure_t *)
|
||||
dl_load_symbol(cd, "dlz_configure", false);
|
||||
cd->dlz_ssumatch = (dlz_dlopen_ssumatch_t *)
|
||||
dl_load_symbol(cd, "dlz_ssumatch", false);
|
||||
cd->dlz_addrdataset = (dlz_dlopen_addrdataset_t *)
|
||||
dl_load_symbol(cd, "dlz_addrdataset", false);
|
||||
cd->dlz_subrdataset = (dlz_dlopen_subrdataset_t *)
|
||||
dl_load_symbol(cd, "dlz_subrdataset", false);
|
||||
cd->dlz_delrdataset = (dlz_dlopen_delrdataset_t *)
|
||||
dl_load_symbol(cd, "dlz_delrdataset", false);
|
||||
cd->dlz_allowzonexfr = (dlz_dlopen_allowzonexfr_t *)dl_load_symbol(
|
||||
cd, "dlz_allowzonexfr", false);
|
||||
cd->dlz_allnodes = (dlz_dlopen_allnodes_t *)dl_load_symbol(
|
||||
cd, "dlz_allnodes", (cd->dlz_allowzonexfr != NULL));
|
||||
cd->dlz_authority = (dlz_dlopen_authority_t *)dl_load_symbol(
|
||||
cd, "dlz_authority", false);
|
||||
cd->dlz_newversion = (dlz_dlopen_newversion_t *)dl_load_symbol(
|
||||
cd, "dlz_newversion", false);
|
||||
cd->dlz_closeversion = (dlz_dlopen_closeversion_t *)dl_load_symbol(
|
||||
cd, "dlz_closeversion", (cd->dlz_newversion != NULL));
|
||||
cd->dlz_configure = (dlz_dlopen_configure_t *)dl_load_symbol(
|
||||
cd, "dlz_configure", false);
|
||||
cd->dlz_ssumatch = (dlz_dlopen_ssumatch_t *)dl_load_symbol(
|
||||
cd, "dlz_ssumatch", false);
|
||||
cd->dlz_addrdataset = (dlz_dlopen_addrdataset_t *)dl_load_symbol(
|
||||
cd, "dlz_addrdataset", false);
|
||||
cd->dlz_subrdataset = (dlz_dlopen_subrdataset_t *)dl_load_symbol(
|
||||
cd, "dlz_subrdataset", false);
|
||||
cd->dlz_delrdataset = (dlz_dlopen_delrdataset_t *)dl_load_symbol(
|
||||
cd, "dlz_delrdataset", false);
|
||||
|
||||
/* Check the version of the API is the same */
|
||||
cd->version = cd->dlz_version(&cd->flags);
|
||||
if (cd->version < (DLZ_DLOPEN_VERSION - DLZ_DLOPEN_AGE) ||
|
||||
cd->version > DLZ_DLOPEN_VERSION)
|
||||
{
|
||||
cd->version > DLZ_DLOPEN_VERSION) {
|
||||
dlopen_log(ISC_LOG_ERROR,
|
||||
"dlz_dlopen: %s: incorrect driver API version %d, "
|
||||
"requires %d",
|
||||
|
|
@ -316,13 +306,10 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||
* link the BIND9 libraries
|
||||
*/
|
||||
MAYBE_LOCK(cd);
|
||||
result = cd->dlz_create(dlzname, argc-1, argv+1,
|
||||
&cd->dbdata,
|
||||
"log", dlopen_log,
|
||||
"putrr", dns_sdlz_putrr,
|
||||
result = cd->dlz_create(dlzname, argc - 1, argv + 1, &cd->dbdata, "log",
|
||||
dlopen_log, "putrr", dns_sdlz_putrr,
|
||||
"putnamedrr", dns_sdlz_putnamedrr,
|
||||
"writeable_zone", dns_dlz_writeablezone,
|
||||
NULL);
|
||||
"writeable_zone", dns_dlz_writeablezone, NULL);
|
||||
MAYBE_UNLOCK(cd);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_lock;
|
||||
|
|
@ -352,14 +339,14 @@ failed:
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when bind is shutting down
|
||||
*/
|
||||
static void
|
||||
dlopen_dlz_destroy(void *driverarg, void *dbdata) {
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_mem_t *mctx;
|
||||
dlopen_dlz_destroy(void *driverarg, void *dbdata)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_mem_t * mctx;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -391,8 +378,8 @@ static isc_result_t
|
|||
dlopen_dlz_newversion(const char *zone, void *driverarg, void *dbdata,
|
||||
void **versionp)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -409,10 +396,10 @@ dlopen_dlz_newversion(const char *zone, void *driverarg, void *dbdata,
|
|||
* Called to end a transaction
|
||||
*/
|
||||
static void
|
||||
dlopen_dlz_closeversion(const char *zone, bool commit,
|
||||
void *driverarg, void *dbdata, void **versionp)
|
||||
dlopen_dlz_closeversion(const char *zone, bool commit, void *driverarg,
|
||||
void *dbdata, void **versionp)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -430,11 +417,11 @@ dlopen_dlz_closeversion(const char *zone, bool commit,
|
|||
* Called on startup to configure any writeable zones
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
||||
void *driverarg, void *dbdata)
|
||||
dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb, void *driverarg,
|
||||
void *dbdata)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -450,7 +437,6 @@ dlopen_dlz_configure(dns_view_t *view, dns_dlzdb_t *dlzdb,
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check for authority to change a name
|
||||
*/
|
||||
|
|
@ -459,8 +445,8 @@ dlopen_dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
|
|||
const char *type, const char *key, uint32_t keydatalen,
|
||||
unsigned char *keydata, void *driverarg, void *dbdata)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
bool ret;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
bool ret;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -475,16 +461,15 @@ dlopen_dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
|
|||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add an rdataset
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_addrdataset(const char *name, const char *rdatastr,
|
||||
void *driverarg, void *dbdata, void *version)
|
||||
dlopen_dlz_addrdataset(const char *name, const char *rdatastr, void *driverarg,
|
||||
void *dbdata, void *version)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -502,11 +487,11 @@ dlopen_dlz_addrdataset(const char *name, const char *rdatastr,
|
|||
* Subtract an rdataset
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_subrdataset(const char *name, const char *rdatastr,
|
||||
void *driverarg, void *dbdata, void *version)
|
||||
dlopen_dlz_subrdataset(const char *name, const char *rdatastr, void *driverarg,
|
||||
void *dbdata, void *version)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -524,11 +509,11 @@ dlopen_dlz_subrdataset(const char *name, const char *rdatastr,
|
|||
delete a rdataset
|
||||
*/
|
||||
static isc_result_t
|
||||
dlopen_dlz_delrdataset(const char *name, const char *type,
|
||||
void *driverarg, void *dbdata, void *version)
|
||||
dlopen_dlz_delrdataset(const char *name, const char *type, void *driverarg,
|
||||
void *dbdata, void *version)
|
||||
{
|
||||
dlopen_data_t *cd = (dlopen_data_t *) dbdata;
|
||||
isc_result_t result;
|
||||
dlopen_data_t *cd = (dlopen_data_t *)dbdata;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(driverarg);
|
||||
|
||||
|
|
@ -542,22 +527,12 @@ dlopen_dlz_delrdataset(const char *name, const char *type,
|
|||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static dns_sdlzmethods_t dlz_dlopen_methods = {
|
||||
dlopen_dlz_create,
|
||||
dlopen_dlz_destroy,
|
||||
dlopen_dlz_findzonedb,
|
||||
dlopen_dlz_lookup,
|
||||
dlopen_dlz_authority,
|
||||
dlopen_dlz_allnodes,
|
||||
dlopen_dlz_allowzonexfr,
|
||||
dlopen_dlz_newversion,
|
||||
dlopen_dlz_closeversion,
|
||||
dlopen_dlz_configure,
|
||||
dlopen_dlz_ssumatch,
|
||||
dlopen_dlz_addrdataset,
|
||||
dlopen_dlz_subrdataset,
|
||||
dlopen_dlz_delrdataset
|
||||
dlopen_dlz_create, dlopen_dlz_destroy, dlopen_dlz_findzonedb,
|
||||
dlopen_dlz_lookup, dlopen_dlz_authority, dlopen_dlz_allnodes,
|
||||
dlopen_dlz_allowzonexfr, dlopen_dlz_newversion, dlopen_dlz_closeversion,
|
||||
dlopen_dlz_configure, dlopen_dlz_ssumatch, dlopen_dlz_addrdataset,
|
||||
dlopen_dlz_subrdataset, dlopen_dlz_delrdataset
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
@ -565,7 +540,8 @@ static dns_sdlzmethods_t dlz_dlopen_methods = {
|
|||
* Register driver with BIND
|
||||
*/
|
||||
isc_result_t
|
||||
dlz_dlopen_init(isc_mem_t *mctx) {
|
||||
dlz_dlopen_init(isc_mem_t *mctx)
|
||||
{
|
||||
#ifndef ISC_DLZ_DLOPEN
|
||||
UNUSED(mctx);
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
|
|
@ -576,8 +552,8 @@ dlz_dlopen_init(isc_mem_t *mctx) {
|
|||
|
||||
result = dns_sdlzregister("dlopen", &dlz_dlopen_methods, NULL,
|
||||
DNS_SDLZFLAG_RELATIVEOWNER |
|
||||
DNS_SDLZFLAG_RELATIVERDATA |
|
||||
DNS_SDLZFLAG_THREADSAFE,
|
||||
DNS_SDLZFLAG_RELATIVERDATA |
|
||||
DNS_SDLZFLAG_THREADSAFE,
|
||||
mctx, &dlz_dlopen);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -591,12 +567,12 @@ dlz_dlopen_init(isc_mem_t *mctx) {
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Unregister the driver
|
||||
*/
|
||||
void
|
||||
dlz_dlopen_clear(void) {
|
||||
dlz_dlopen_clear(void)
|
||||
{
|
||||
#ifdef ISC_DLZ_DLOPEN
|
||||
dlopen_log(2, "Unregistering DLZ_dlopen driver");
|
||||
if (dlz_dlopen != NULL)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NTSERVICE_H
|
||||
#define NTSERVICE_H
|
||||
|
||||
|
|
@ -19,10 +18,12 @@
|
|||
#define BIND_SERVICE_NAME "named"
|
||||
|
||||
void
|
||||
ntservice_init();
|
||||
ntservice_init();
|
||||
void UpdateSCM(DWORD);
|
||||
void ServiceControl(DWORD dwCtrlCode);
|
||||
void
|
||||
ServiceControl(DWORD dwCtrlCode);
|
||||
void
|
||||
ntservice_shutdown();
|
||||
BOOL ntservice_isservice();
|
||||
BOOL
|
||||
ntservice_isservice();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -18,33 +18,36 @@
|
|||
#include <isc/string.h>
|
||||
|
||||
#include <named/globals.h>
|
||||
#include <named/ntservice.h>
|
||||
#include <named/main.h>
|
||||
#include <named/ntservice.h>
|
||||
#include <named/server.h>
|
||||
|
||||
/* Handle to SCM for updating service status */
|
||||
static SERVICE_STATUS_HANDLE hServiceStatus = 0;
|
||||
static BOOL foreground = FALSE;
|
||||
static char ConsoleTitle[128];
|
||||
static BOOL foreground = FALSE;
|
||||
static char ConsoleTitle[128];
|
||||
|
||||
/*
|
||||
* Forward declarations
|
||||
*/
|
||||
void ServiceControl(DWORD dwCtrlCode);
|
||||
int bindmain(int, char *[]); /* From main.c */
|
||||
void
|
||||
ServiceControl(DWORD dwCtrlCode);
|
||||
int
|
||||
bindmain(int, char *[]); /* From main.c */
|
||||
|
||||
/*
|
||||
* Initialize the Service by registering it.
|
||||
*/
|
||||
void
|
||||
ntservice_init(void) {
|
||||
ntservice_init(void)
|
||||
{
|
||||
if (!foreground) {
|
||||
/* Register handler with the SCM */
|
||||
hServiceStatus = RegisterServiceCtrlHandler(BIND_SERVICE_NAME,
|
||||
(LPHANDLER_FUNCTION)ServiceControl);
|
||||
hServiceStatus = RegisterServiceCtrlHandler(
|
||||
BIND_SERVICE_NAME, (LPHANDLER_FUNCTION)ServiceControl);
|
||||
if (!hServiceStatus) {
|
||||
named_main_earlyfatal(
|
||||
"could not register service control handler");
|
||||
named_main_earlyfatal("could not register service "
|
||||
"control handler");
|
||||
}
|
||||
UpdateSCM(SERVICE_RUNNING);
|
||||
} else {
|
||||
|
|
@ -55,24 +58,27 @@ ntservice_init(void) {
|
|||
}
|
||||
|
||||
void
|
||||
ntservice_shutdown(void) {
|
||||
ntservice_shutdown(void)
|
||||
{
|
||||
UpdateSCM(SERVICE_STOPPED);
|
||||
}
|
||||
/*
|
||||
* Routine to check if this is a service or a foreground program
|
||||
*/
|
||||
BOOL
|
||||
ntservice_isservice(void) {
|
||||
return(!foreground);
|
||||
ntservice_isservice(void)
|
||||
{
|
||||
return (!foreground);
|
||||
}
|
||||
/*
|
||||
* ServiceControl(): Handles requests from the SCM and passes them on
|
||||
* to named.
|
||||
*/
|
||||
void
|
||||
ServiceControl(DWORD dwCtrlCode) {
|
||||
ServiceControl(DWORD dwCtrlCode)
|
||||
{
|
||||
/* Handle the requested control code */
|
||||
switch(dwCtrlCode) {
|
||||
switch (dwCtrlCode) {
|
||||
case SERVICE_CONTROL_INTERROGATE:
|
||||
UpdateSCM(0);
|
||||
break;
|
||||
|
|
@ -91,9 +97,11 @@ ServiceControl(DWORD dwCtrlCode) {
|
|||
/*
|
||||
* Tell the Service Control Manager the state of the service.
|
||||
*/
|
||||
void UpdateSCM(DWORD state) {
|
||||
void
|
||||
UpdateSCM(DWORD state)
|
||||
{
|
||||
SERVICE_STATUS ss;
|
||||
static DWORD dwState = SERVICE_STOPPED;
|
||||
static DWORD dwState = SERVICE_STOPPED;
|
||||
|
||||
if (hServiceStatus) {
|
||||
if (state)
|
||||
|
|
@ -125,15 +133,15 @@ void UpdateSCM(DWORD state) {
|
|||
* We can now call bindmain() explicitly or via StartServiceCtrlDispatcher()
|
||||
* as we need to.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int rc, ch;
|
||||
|
||||
/* Command line users should put -f in the options. */
|
||||
isc_commandline_errprint = false;
|
||||
while ((ch = isc_commandline_parse(argc, argv,
|
||||
NAMED_MAIN_ARGS)) != -1)
|
||||
{
|
||||
while ((ch = isc_commandline_parse(argc, argv, NAMED_MAIN_ARGS)) !=
|
||||
-1) {
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
case 'g':
|
||||
|
|
@ -162,8 +170,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
rc = StartServiceCtrlDispatcher(dispatchTable);
|
||||
if (!rc) {
|
||||
fprintf(stderr,
|
||||
"Use -f to run from the command line.\n");
|
||||
fprintf(stderr, "Use -f to run from the command "
|
||||
"line.\n");
|
||||
/* will be 1063 when launched as a console app */
|
||||
exit(GetLastError());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,47 +9,45 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <isc/ntpaths.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/ntpaths.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/win32os.h>
|
||||
|
||||
#include <named/main.h>
|
||||
#include <named/log.h>
|
||||
#include <named/os.h>
|
||||
#include <named/globals.h>
|
||||
#include <named/log.h>
|
||||
#include <named/main.h>
|
||||
#include <named/ntservice.h>
|
||||
|
||||
#include <named/os.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static char *lockfile = NULL;
|
||||
static char *pidfile = NULL;
|
||||
static int devnullfd = -1;
|
||||
static int lockfilefd = -1;
|
||||
static int devnullfd = -1;
|
||||
static int lockfilefd = -1;
|
||||
|
||||
static BOOL Initialized = FALSE;
|
||||
|
||||
static char *version_error =
|
||||
"named requires Windows 2000 Service Pack 2 or later to run correctly";
|
||||
static char *version_error = "named requires Windows 2000 Service Pack 2 or "
|
||||
"later to run correctly";
|
||||
|
||||
void
|
||||
named_paths_init(void) {
|
||||
named_paths_init(void)
|
||||
{
|
||||
if (!Initialized)
|
||||
isc_ntpaths_init();
|
||||
|
||||
|
|
@ -69,11 +67,11 @@ named_paths_init(void) {
|
|||
* warn when it isn't.
|
||||
*/
|
||||
static void
|
||||
version_check(const char *progname) {
|
||||
|
||||
version_check(const char *progname)
|
||||
{
|
||||
if ((isc_win32os_versioncheck(4, 0, 0, 0) >= 0) &&
|
||||
(isc_win32os_versioncheck(5, 0, 0, 0) < 0))
|
||||
return; /* No problem with Version 4.0 */
|
||||
return; /* No problem with Version 4.0 */
|
||||
if (isc_win32os_versioncheck(5, 0, 2, 0) < 0)
|
||||
if (ntservice_isservice())
|
||||
NTReportError(progname, version_error);
|
||||
|
|
@ -82,7 +80,8 @@ version_check(const char *progname) {
|
|||
}
|
||||
|
||||
static void
|
||||
setup_syslog(const char *progname) {
|
||||
setup_syslog(const char *progname)
|
||||
{
|
||||
int options;
|
||||
|
||||
options = LOG_PID;
|
||||
|
|
@ -94,7 +93,8 @@ setup_syslog(const char *progname) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_init(const char *progname) {
|
||||
named_os_init(const char *progname)
|
||||
{
|
||||
named_paths_init();
|
||||
setup_syslog(progname);
|
||||
/*
|
||||
|
|
@ -121,7 +121,8 @@ named_os_init(const char *progname) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_daemonize(void) {
|
||||
named_os_daemonize(void)
|
||||
{
|
||||
/*
|
||||
* Try to set stdin, stdout, and stderr to /dev/null, but press
|
||||
* on even if it fails.
|
||||
|
|
@ -143,14 +144,15 @@ named_os_daemonize(void) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_opendevnull(void) {
|
||||
named_os_opendevnull(void)
|
||||
{
|
||||
devnullfd = open("NUL", O_RDWR, 0);
|
||||
}
|
||||
|
||||
void
|
||||
named_os_closedevnull(void) {
|
||||
if (devnullfd != _fileno(stdin) &&
|
||||
devnullfd != _fileno(stdout) &&
|
||||
named_os_closedevnull(void)
|
||||
{
|
||||
if (devnullfd != _fileno(stdin) && devnullfd != _fileno(stdout) &&
|
||||
devnullfd != _fileno(stderr)) {
|
||||
close(devnullfd);
|
||||
devnullfd = -1;
|
||||
|
|
@ -158,35 +160,42 @@ named_os_closedevnull(void) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_chroot(const char *root) {
|
||||
named_os_chroot(const char *root)
|
||||
{
|
||||
if (root != NULL)
|
||||
named_main_earlyfatal("chroot(): isn't supported by Win32 API");
|
||||
}
|
||||
|
||||
void
|
||||
named_os_inituserinfo(const char *username) {
|
||||
named_os_inituserinfo(const char *username)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
named_os_changeuser(void) {
|
||||
named_os_changeuser(void)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int
|
||||
ns_os_uid(void) {
|
||||
ns_os_uid(void)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
named_os_adjustnofile(void) {
|
||||
named_os_adjustnofile(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
named_os_minprivs(void) {
|
||||
named_os_minprivs(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
safe_open(const char *filename, int mode, bool append) {
|
||||
int fd;
|
||||
safe_open(const char *filename, int mode, bool append)
|
||||
{
|
||||
int fd;
|
||||
struct stat sb;
|
||||
|
||||
if (stat(filename, &sb) == -1) {
|
||||
|
|
@ -196,16 +205,17 @@ safe_open(const char *filename, int mode, bool append) {
|
|||
return (-1);
|
||||
|
||||
if (append)
|
||||
fd = open(filename, O_WRONLY|O_CREAT|O_APPEND, mode);
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_APPEND, mode);
|
||||
else {
|
||||
(void)unlink(filename);
|
||||
fd = open(filename, O_WRONLY|O_CREAT|O_EXCL, mode);
|
||||
fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, mode);
|
||||
}
|
||||
return (fd);
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup_pidfile(void) {
|
||||
cleanup_pidfile(void)
|
||||
{
|
||||
if (pidfile != NULL) {
|
||||
(void)unlink(pidfile);
|
||||
free(pidfile);
|
||||
|
|
@ -214,7 +224,8 @@ cleanup_pidfile(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
cleanup_lockfile(void) {
|
||||
cleanup_lockfile(void)
|
||||
{
|
||||
if (lockfilefd != -1) {
|
||||
close(lockfilefd);
|
||||
lockfilefd = -1;
|
||||
|
|
@ -231,10 +242,11 @@ cleanup_lockfile(void) {
|
|||
}
|
||||
|
||||
FILE *
|
||||
named_os_openfile(const char *filename, int mode, bool switch_user) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
named_os_openfile(const char *filename, int mode, bool switch_user)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
FILE *fp;
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
UNUSED(switch_user);
|
||||
fd = safe_open(filename, mode, false);
|
||||
|
|
@ -257,10 +269,11 @@ named_os_openfile(const char *filename, int mode, bool switch_user) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_writepidfile(const char *filename, bool first_time) {
|
||||
named_os_writepidfile(const char *filename, bool first_time)
|
||||
{
|
||||
FILE *pidlockfile;
|
||||
pid_t pid;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
void (*report)(const char *, ...);
|
||||
|
||||
/*
|
||||
|
|
@ -281,9 +294,8 @@ named_os_writepidfile(const char *filename, bool first_time) {
|
|||
return;
|
||||
}
|
||||
|
||||
pidlockfile = named_os_openfile(filename,
|
||||
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH,
|
||||
false);
|
||||
pidlockfile = named_os_openfile(
|
||||
filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, false);
|
||||
if (pidlockfile == NULL) {
|
||||
free(pidfile);
|
||||
pidfile = NULL;
|
||||
|
|
@ -308,8 +320,9 @@ named_os_writepidfile(const char *filename, bool first_time) {
|
|||
}
|
||||
|
||||
bool
|
||||
named_os_issingleton(const char *filename) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
named_os_issingleton(const char *filename)
|
||||
{
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
OVERLAPPED o;
|
||||
|
||||
if (lockfilefd != -1)
|
||||
|
|
@ -330,7 +343,7 @@ named_os_issingleton(const char *filename) {
|
|||
* files. We can't use that here.
|
||||
*/
|
||||
lockfilefd = open(filename, O_WRONLY | O_CREAT,
|
||||
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
if (lockfilefd == -1) {
|
||||
cleanup_lockfile();
|
||||
return (false);
|
||||
|
|
@ -338,9 +351,9 @@ named_os_issingleton(const char *filename) {
|
|||
|
||||
memset(&o, 0, sizeof(o));
|
||||
/* Expect ERROR_LOCK_VIOLATION if already locked */
|
||||
if (!LockFileEx((HANDLE) _get_osfhandle(lockfilefd),
|
||||
LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY,
|
||||
0, 0, 1, &o)) {
|
||||
if (!LockFileEx((HANDLE)_get_osfhandle(lockfilefd),
|
||||
LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0,
|
||||
0, 1, &o)) {
|
||||
cleanup_lockfile();
|
||||
return (false);
|
||||
}
|
||||
|
|
@ -348,23 +361,24 @@ named_os_issingleton(const char *filename) {
|
|||
return (true);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
named_os_shutdown(void) {
|
||||
named_os_shutdown(void)
|
||||
{
|
||||
closelog();
|
||||
cleanup_pidfile();
|
||||
|
||||
if (lockfilefd != -1) {
|
||||
(void) UnlockFile((HANDLE) _get_osfhandle(lockfilefd),
|
||||
0, 0, 0, 1);
|
||||
(void)UnlockFile((HANDLE)_get_osfhandle(lockfilefd), 0, 0, 0,
|
||||
1);
|
||||
}
|
||||
cleanup_lockfile();
|
||||
|
||||
ntservice_shutdown(); /* This MUST be the last thing done */
|
||||
ntservice_shutdown(); /* This MUST be the last thing done */
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
named_os_gethostname(char *buf, size_t len) {
|
||||
named_os_gethostname(char *buf, size_t len)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = gethostname(buf, (int)len);
|
||||
|
|
@ -372,34 +386,38 @@ named_os_gethostname(char *buf, size_t len) {
|
|||
}
|
||||
|
||||
void
|
||||
named_os_shutdownmsg(char *command, isc_buffer_t *text) {
|
||||
named_os_shutdownmsg(char *command, isc_buffer_t *text)
|
||||
{
|
||||
UNUSED(command);
|
||||
UNUSED(text);
|
||||
}
|
||||
|
||||
void
|
||||
named_os_tzset(void) {
|
||||
named_os_tzset(void)
|
||||
{
|
||||
#ifdef HAVE_TZSET
|
||||
tzset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
named_os_started(void) {
|
||||
named_os_started(void)
|
||||
{
|
||||
ntservice_init();
|
||||
}
|
||||
|
||||
static char unamebuf[BUFSIZ];
|
||||
static char unamebuf[BUFSIZ];
|
||||
static char *unamep = NULL;
|
||||
|
||||
static void
|
||||
getuname(void) {
|
||||
DWORD fvilen;
|
||||
char *fvi;
|
||||
getuname(void)
|
||||
{
|
||||
DWORD fvilen;
|
||||
char * fvi;
|
||||
VS_FIXEDFILEINFO *ffi;
|
||||
UINT ffilen;
|
||||
SYSTEM_INFO sysinfo;
|
||||
char *arch;
|
||||
UINT ffilen;
|
||||
SYSTEM_INFO sysinfo;
|
||||
char * arch;
|
||||
|
||||
fvi = NULL;
|
||||
fvilen = GetFileVersionInfoSize("kernel32.dll", 0);
|
||||
|
|
@ -416,8 +434,8 @@ getuname(void) {
|
|||
}
|
||||
ffi = NULL;
|
||||
ffilen = 0;
|
||||
if ((VerQueryValue(fvi, "\\", &ffi, &ffilen) == 0) ||
|
||||
(ffi == NULL) || (ffilen == 0)) {
|
||||
if ((VerQueryValue(fvi, "\\", &ffi, &ffilen) == 0) || (ffi == NULL) ||
|
||||
(ffilen == 0)) {
|
||||
goto err;
|
||||
}
|
||||
memset(&sysinfo, 0, sizeof(sysinfo));
|
||||
|
|
@ -445,10 +463,9 @@ getuname(void) {
|
|||
(ffi->dwProductVersionMS >> 16) & 0xffff,
|
||||
ffi->dwProductVersionMS & 0xffff,
|
||||
(ffi->dwProductVersionLS >> 16) & 0xffff,
|
||||
ffi->dwProductVersionLS & 0xffff,
|
||||
arch);
|
||||
ffi->dwProductVersionLS & 0xffff, arch);
|
||||
|
||||
err:
|
||||
err:
|
||||
if (fvi != NULL) {
|
||||
free(fvi);
|
||||
}
|
||||
|
|
@ -460,7 +477,8 @@ getuname(void) {
|
|||
* so we had to switch to the recommended way to get the Windows version.
|
||||
*/
|
||||
char *
|
||||
named_os_uname(void) {
|
||||
named_os_uname(void)
|
||||
{
|
||||
if (unamep == NULL)
|
||||
getuname();
|
||||
return (unamep);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -38,7 +38,6 @@
|
|||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* pkcs11-destroy [-m module] [-s $slot] [-i $id | -l $label]
|
||||
* [-p $pin] [ -w $wait ]
|
||||
|
|
@ -46,12 +45,11 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/print.h>
|
||||
|
|
@ -60,31 +58,32 @@
|
|||
|
||||
#include <pk11/pk11.h>
|
||||
#include <pk11/result.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define sleep(x) Sleep(x)
|
||||
#define sleep(x) Sleep(x)
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_result_t result;
|
||||
CK_RV rv;
|
||||
CK_SLOT_ID slot = 0;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_result_t result;
|
||||
CK_RV rv;
|
||||
CK_SLOT_ID slot = 0;
|
||||
CK_SESSION_HANDLE hSession;
|
||||
CK_BYTE attr_id[2];
|
||||
CK_OBJECT_HANDLE akey[50];
|
||||
pk11_context_t pctx;
|
||||
char *lib_name = NULL;
|
||||
char *label = NULL;
|
||||
char *pin = NULL;
|
||||
int error = 0;
|
||||
unsigned int id = 0, i = 0, wait = 5;
|
||||
int c, errflg = 0;
|
||||
CK_ULONG ulObjectCount;
|
||||
CK_ATTRIBUTE search_template[] = {
|
||||
{CKA_ID, &attr_id, sizeof(attr_id)}
|
||||
};
|
||||
unsigned int j, len;
|
||||
CK_BYTE attr_id[2];
|
||||
CK_OBJECT_HANDLE akey[50];
|
||||
pk11_context_t pctx;
|
||||
char * lib_name = NULL;
|
||||
char * label = NULL;
|
||||
char * pin = NULL;
|
||||
int error = 0;
|
||||
unsigned int id = 0, i = 0, wait = 5;
|
||||
int c, errflg = 0;
|
||||
CK_ULONG ulObjectCount;
|
||||
CK_ATTRIBUTE search_template[] = { { CKA_ID, &attr_id,
|
||||
sizeof(attr_id) } };
|
||||
unsigned int j, len;
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, ":m:s:i:l:p:w:")) != -1) {
|
||||
switch (c) {
|
||||
|
|
@ -108,8 +107,7 @@ main(int argc, char *argv[]) {
|
|||
wait = atoi(isc_commandline_argument);
|
||||
break;
|
||||
case ':':
|
||||
fprintf(stderr,
|
||||
"Option -%c requires an operand\n",
|
||||
fprintf(stderr, "Option -%c requires an operand\n",
|
||||
isc_commandline_option);
|
||||
errflg++;
|
||||
break;
|
||||
|
|
@ -147,17 +145,18 @@ main(int argc, char *argv[]) {
|
|||
pin = getpass("Enter Pin: ");
|
||||
}
|
||||
|
||||
result = pk11_get_session(&pctx, OP_ANY, false, true,
|
||||
true, (const char *) pin, slot);
|
||||
result = pk11_get_session(&pctx, OP_ANY, false, true, true,
|
||||
(const char *)pin, slot);
|
||||
if (result == PK11_R_NORANDOMSERVICE ||
|
||||
result == PK11_R_NODIGESTSERVICE ||
|
||||
result == PK11_R_NOAESSERVICE) {
|
||||
result == PK11_R_NODIGESTSERVICE || result == PK11_R_NOAESSERVICE) {
|
||||
fprintf(stderr, "Warning: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr, "This HSM will not work with BIND 9 "
|
||||
"using native PKCS#11.\n");
|
||||
} else if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr,
|
||||
"Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n",
|
||||
isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -166,14 +165,14 @@ main(int argc, char *argv[]) {
|
|||
hSession = pctx.session;
|
||||
|
||||
rv = pkcs_C_FindObjectsInit(hSession, search_template,
|
||||
((id != 0) || (label != NULL)) ? 1 : 0);
|
||||
((id != 0) || (label != NULL)) ? 1 : 0);
|
||||
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr, "C_FindObjectsInit: Error = 0x%.8lX\n", rv);
|
||||
error = 1;
|
||||
goto exit_session;
|
||||
}
|
||||
|
||||
|
||||
rv = pkcs_C_FindObjects(hSession, akey, 50, &ulObjectCount);
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr, "C_FindObjects: Error = 0x%.8lX\n", rv);
|
||||
|
|
@ -189,29 +188,29 @@ main(int argc, char *argv[]) {
|
|||
|
||||
for (i = 0; i < ulObjectCount; i++) {
|
||||
CK_OBJECT_CLASS oclass = 0;
|
||||
CK_BYTE labelbuf[64 + 1];
|
||||
CK_BYTE idbuf[64];
|
||||
CK_ATTRIBUTE attr_template[] = {
|
||||
{CKA_CLASS, &oclass, sizeof(oclass)},
|
||||
{CKA_LABEL, labelbuf, sizeof(labelbuf) - 1},
|
||||
{CKA_ID, idbuf, sizeof(idbuf)}
|
||||
CK_BYTE labelbuf[64 + 1];
|
||||
CK_BYTE idbuf[64];
|
||||
CK_ATTRIBUTE attr_template[] = {
|
||||
{ CKA_CLASS, &oclass, sizeof(oclass) },
|
||||
{ CKA_LABEL, labelbuf, sizeof(labelbuf) - 1 },
|
||||
{ CKA_ID, idbuf, sizeof(idbuf) }
|
||||
};
|
||||
|
||||
memset(labelbuf, 0, sizeof(labelbuf));
|
||||
memset(idbuf, 0, sizeof(idbuf));
|
||||
|
||||
rv = pkcs_C_GetAttributeValue(hSession, akey[i],
|
||||
attr_template, 3);
|
||||
rv = pkcs_C_GetAttributeValue(hSession, akey[i], attr_template,
|
||||
3);
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr,
|
||||
"C_GetAttributeValue[%u]: rv = 0x%.8lX\n",
|
||||
i, rv);
|
||||
"C_GetAttributeValue[%u]: rv = 0x%.8lX\n", i,
|
||||
rv);
|
||||
error = 1;
|
||||
goto exit_search;
|
||||
}
|
||||
len = attr_template[2].ulValueLen;
|
||||
printf(" object[%u]: class %lu, label '%s', id[%lu] ",
|
||||
i, oclass, labelbuf, attr_template[2].ulValueLen);
|
||||
printf(" object[%u]: class %lu, label '%s', id[%lu] ", i,
|
||||
oclass, labelbuf, attr_template[2].ulValueLen);
|
||||
if (len > 4)
|
||||
len = 4;
|
||||
if (len > 0)
|
||||
|
|
@ -226,7 +225,8 @@ main(int argc, char *argv[]) {
|
|||
|
||||
if (wait != 0) {
|
||||
printf("WARNING: This action is irreversible! "
|
||||
"Destroying key objects in %u seconds\n ", wait);
|
||||
"Destroying key objects in %u seconds\n ",
|
||||
wait);
|
||||
for (i = 0; i < wait; i++) {
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
|
|
@ -239,8 +239,8 @@ main(int argc, char *argv[]) {
|
|||
rv = pkcs_C_DestroyObject(hSession, akey[i]);
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr,
|
||||
"C_DestroyObject[%u] failed: rv = 0x%.8lX\n",
|
||||
i, rv);
|
||||
"C_DestroyObject[%u] failed: rv = 0x%.8lX\n", i,
|
||||
rv);
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -248,16 +248,16 @@ main(int argc, char *argv[]) {
|
|||
if (error == 0)
|
||||
printf("Destruction complete.\n");
|
||||
|
||||
exit_search:
|
||||
exit_search:
|
||||
rv = pkcs_C_FindObjectsFinal(hSession);
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr, "C_FindObjectsFinal: Error = 0x%.8lX\n", rv);
|
||||
error = 1;
|
||||
}
|
||||
|
||||
exit_session:
|
||||
exit_session:
|
||||
pk11_return_session(&pctx);
|
||||
(void) pk11_finalize();
|
||||
(void)pk11_finalize();
|
||||
|
||||
exit(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,12 +54,11 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/print.h>
|
||||
|
|
@ -67,22 +66,18 @@
|
|||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <pk11/constants.h>
|
||||
#include <pk11/pk11.h>
|
||||
#include <pk11/result.h>
|
||||
#include <pk11/constants.h>
|
||||
#include <pkcs11/eddsa.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Define static key template values */
|
||||
static CK_BBOOL truevalue = TRUE;
|
||||
static CK_BBOOL falsevalue = FALSE;
|
||||
|
||||
/* Key class: RSA, ECC, ECX, or unknown */
|
||||
typedef enum {
|
||||
key_unknown,
|
||||
key_rsa,
|
||||
key_ecc,
|
||||
key_ecx
|
||||
} key_class_t;
|
||||
typedef enum { key_unknown, key_rsa, key_ecc, key_ecx } key_class_t;
|
||||
|
||||
/*
|
||||
* Private key template: usable for most key classes without
|
||||
|
|
@ -98,13 +93,13 @@ typedef enum {
|
|||
#define PRIVATE_ID 6
|
||||
#define PRIVATE_ATTRS 7
|
||||
static CK_ATTRIBUTE private_template[] = {
|
||||
{CKA_LABEL, NULL_PTR, 0},
|
||||
{CKA_SIGN, &truevalue, sizeof(truevalue)},
|
||||
{CKA_TOKEN, &truevalue, sizeof(truevalue)},
|
||||
{CKA_PRIVATE, &truevalue, sizeof(truevalue)},
|
||||
{CKA_SENSITIVE, &truevalue, sizeof(truevalue)},
|
||||
{CKA_EXTRACTABLE, &falsevalue, sizeof(falsevalue)},
|
||||
{CKA_ID, NULL_PTR, 0}
|
||||
{ CKA_LABEL, NULL_PTR, 0 },
|
||||
{ CKA_SIGN, &truevalue, sizeof(truevalue) },
|
||||
{ CKA_TOKEN, &truevalue, sizeof(truevalue) },
|
||||
{ CKA_PRIVATE, &truevalue, sizeof(truevalue) },
|
||||
{ CKA_SENSITIVE, &truevalue, sizeof(truevalue) },
|
||||
{ CKA_EXTRACTABLE, &falsevalue, sizeof(falsevalue) },
|
||||
{ CKA_ID, NULL_PTR, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -119,13 +114,13 @@ static CK_ATTRIBUTE private_template[] = {
|
|||
#define RSA_ID 6
|
||||
#define RSA_ATTRS 7
|
||||
static CK_ATTRIBUTE rsa_template[] = {
|
||||
{CKA_LABEL, NULL_PTR, 0},
|
||||
{CKA_VERIFY, &truevalue, sizeof(truevalue)},
|
||||
{CKA_TOKEN, &truevalue, sizeof(truevalue)},
|
||||
{CKA_PRIVATE, &falsevalue, sizeof(falsevalue)},
|
||||
{CKA_MODULUS_BITS, NULL_PTR, 0},
|
||||
{CKA_PUBLIC_EXPONENT, NULL_PTR, 0},
|
||||
{CKA_ID, NULL_PTR, 0}
|
||||
{ CKA_LABEL, NULL_PTR, 0 },
|
||||
{ CKA_VERIFY, &truevalue, sizeof(truevalue) },
|
||||
{ CKA_TOKEN, &truevalue, sizeof(truevalue) },
|
||||
{ CKA_PRIVATE, &falsevalue, sizeof(falsevalue) },
|
||||
{ CKA_MODULUS_BITS, NULL_PTR, 0 },
|
||||
{ CKA_PUBLIC_EXPONENT, NULL_PTR, 0 },
|
||||
{ CKA_ID, NULL_PTR, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -139,12 +134,12 @@ static CK_ATTRIBUTE rsa_template[] = {
|
|||
#define ECC_ID 5
|
||||
#define ECC_ATTRS 6
|
||||
static CK_ATTRIBUTE ecc_template[] = {
|
||||
{CKA_LABEL, NULL_PTR, 0},
|
||||
{CKA_VERIFY, &truevalue, sizeof(truevalue)},
|
||||
{CKA_TOKEN, &truevalue, sizeof(truevalue)},
|
||||
{CKA_PRIVATE, &falsevalue, sizeof(falsevalue)},
|
||||
{CKA_EC_PARAMS, NULL_PTR, 0},
|
||||
{CKA_ID, NULL_PTR, 0}
|
||||
{ CKA_LABEL, NULL_PTR, 0 },
|
||||
{ CKA_VERIFY, &truevalue, sizeof(truevalue) },
|
||||
{ CKA_TOKEN, &truevalue, sizeof(truevalue) },
|
||||
{ CKA_PRIVATE, &falsevalue, sizeof(falsevalue) },
|
||||
{ CKA_EC_PARAMS, NULL_PTR, 0 },
|
||||
{ CKA_ID, NULL_PTR, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -153,7 +148,8 @@ static CK_ATTRIBUTE ecc_template[] = {
|
|||
* NSEC3RSASHA1 maps to RSA.
|
||||
*/
|
||||
static key_class_t
|
||||
keyclass_fromtext(const char *name) {
|
||||
keyclass_fromtext(const char *name)
|
||||
{
|
||||
if (name == NULL)
|
||||
return (key_unknown);
|
||||
|
||||
|
|
@ -171,44 +167,43 @@ keyclass_fromtext(const char *name) {
|
|||
}
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
"\tpkcs11-keygen -a algorithm -b keysize -l label\n"
|
||||
"\t [-P] [-m module] "
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n"
|
||||
"\tpkcs11-keygen -a algorithm -b keysize -l label\n"
|
||||
"\t [-P] [-m module] "
|
||||
"[-s slot] [-e] [-S] [-i id] [-p PIN]\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_result_t result;
|
||||
CK_RV rv;
|
||||
CK_SLOT_ID slot = 0;
|
||||
CK_MECHANISM mech;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_result_t result;
|
||||
CK_RV rv;
|
||||
CK_SLOT_ID slot = 0;
|
||||
CK_MECHANISM mech;
|
||||
CK_SESSION_HANDLE hSession;
|
||||
char *lib_name = NULL;
|
||||
char *pin = NULL;
|
||||
CK_ULONG bits = 0;
|
||||
CK_CHAR *label = NULL;
|
||||
CK_OBJECT_HANDLE privatekey, publickey;
|
||||
CK_BYTE exponent[5];
|
||||
CK_ULONG expsize = 0;
|
||||
pk11_context_t pctx;
|
||||
int error = 0;
|
||||
int c, errflg = 0;
|
||||
int hide = 1, quiet = 0;
|
||||
int idlen = 0, id_offset = 0;
|
||||
unsigned long id = 0;
|
||||
CK_BYTE idbuf[4];
|
||||
CK_ULONG ulObjectCount;
|
||||
CK_ATTRIBUTE search_template[] = {
|
||||
{CKA_LABEL, NULL_PTR, 0}
|
||||
};
|
||||
CK_ATTRIBUTE *public_template = NULL;
|
||||
CK_ULONG public_attrcnt = 0, private_attrcnt = PRIVATE_ATTRS;
|
||||
key_class_t keyclass = key_rsa;
|
||||
pk11_optype_t op_type = OP_ANY;
|
||||
char * lib_name = NULL;
|
||||
char * pin = NULL;
|
||||
CK_ULONG bits = 0;
|
||||
CK_CHAR * label = NULL;
|
||||
CK_OBJECT_HANDLE privatekey, publickey;
|
||||
CK_BYTE exponent[5];
|
||||
CK_ULONG expsize = 0;
|
||||
pk11_context_t pctx;
|
||||
int error = 0;
|
||||
int c, errflg = 0;
|
||||
int hide = 1, quiet = 0;
|
||||
int idlen = 0, id_offset = 0;
|
||||
unsigned long id = 0;
|
||||
CK_BYTE idbuf[4];
|
||||
CK_ULONG ulObjectCount;
|
||||
CK_ATTRIBUTE search_template[] = { { CKA_LABEL, NULL_PTR, 0 } };
|
||||
CK_ATTRIBUTE * public_template = NULL;
|
||||
CK_ULONG public_attrcnt = 0, private_attrcnt = PRIVATE_ATTRS;
|
||||
key_class_t keyclass = key_rsa;
|
||||
pk11_optype_t op_type = OP_ANY;
|
||||
|
||||
#define OPTIONS ":a:b:ei:l:m:Pp:qSs:"
|
||||
while ((c = isc_commandline_parse(argc, argv, OPTIONS)) != -1) {
|
||||
|
|
@ -246,8 +241,7 @@ main(int argc, char *argv[]) {
|
|||
quiet = 1;
|
||||
break;
|
||||
case ':':
|
||||
fprintf(stderr,
|
||||
"Option -%c requires an operand\n",
|
||||
fprintf(stderr, "Option -%c requires an operand\n",
|
||||
isc_commandline_option);
|
||||
errflg++;
|
||||
break;
|
||||
|
|
@ -360,8 +354,7 @@ main(int argc, char *argv[]) {
|
|||
sizeof(pk11_ecc_ed25519);
|
||||
} else {
|
||||
public_template[4].pValue = pk11_ecc_ed448;
|
||||
public_template[4].ulValueLen =
|
||||
sizeof(pk11_ecc_ed448);
|
||||
public_template[4].ulValueLen = sizeof(pk11_ecc_ed448);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -408,17 +401,18 @@ main(int argc, char *argv[]) {
|
|||
pin = getpass("Enter Pin: ");
|
||||
}
|
||||
|
||||
result = pk11_get_session(&pctx, op_type, false, true,
|
||||
true, (const char *) pin, slot);
|
||||
result = pk11_get_session(&pctx, op_type, false, true, true,
|
||||
(const char *)pin, slot);
|
||||
if (result == PK11_R_NORANDOMSERVICE ||
|
||||
result == PK11_R_NODIGESTSERVICE ||
|
||||
result == PK11_R_NOAESSERVICE) {
|
||||
result == PK11_R_NODIGESTSERVICE || result == PK11_R_NOAESSERVICE) {
|
||||
fprintf(stderr, "Warning: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr, "This HSM will not work with BIND 9 "
|
||||
"using native PKCS#11.\n");
|
||||
} else if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr,
|
||||
"Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n",
|
||||
isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -452,10 +446,9 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
/* Generate Key pair for signing/verifying */
|
||||
rv = pkcs_C_GenerateKeyPair(hSession, &mech,
|
||||
public_template, public_attrcnt,
|
||||
private_template, private_attrcnt,
|
||||
&publickey, &privatekey);
|
||||
rv = pkcs_C_GenerateKeyPair(hSession, &mech, public_template,
|
||||
public_attrcnt, private_template,
|
||||
private_attrcnt, &publickey, &privatekey);
|
||||
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr, "C_GenerateKeyPair: Error = 0x%.8lX\n", rv);
|
||||
|
|
@ -464,16 +457,16 @@ main(int argc, char *argv[]) {
|
|||
printf("Key pair generation complete.\n");
|
||||
}
|
||||
|
||||
exit_search:
|
||||
exit_search:
|
||||
rv = pkcs_C_FindObjectsFinal(hSession);
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr, "C_FindObjectsFinal: Error = 0x%.8lX\n", rv);
|
||||
error = 1;
|
||||
}
|
||||
|
||||
exit_session:
|
||||
exit_session:
|
||||
pk11_return_session(&pctx);
|
||||
(void) pk11_finalize();
|
||||
(void)pk11_finalize();
|
||||
|
||||
exit(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,18 +33,16 @@
|
|||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/* pkcs11-list [-P] [-m module] [-s slot] [-i $id | -l $label] [-p $pin] */
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/print.h>
|
||||
|
|
@ -53,26 +51,27 @@
|
|||
|
||||
#include <pk11/pk11.h>
|
||||
#include <pk11/result.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_result_t result;
|
||||
CK_RV rv;
|
||||
CK_SLOT_ID slot = 0;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_result_t result;
|
||||
CK_RV rv;
|
||||
CK_SLOT_ID slot = 0;
|
||||
CK_SESSION_HANDLE hSession;
|
||||
CK_BYTE attr_id[2];
|
||||
CK_OBJECT_HANDLE akey[50];
|
||||
pk11_context_t pctx;
|
||||
char *lib_name = NULL;
|
||||
char *label = NULL;
|
||||
char *pin = NULL;
|
||||
bool error = false, logon = true, all = false;
|
||||
unsigned int i = 0, id = 0;
|
||||
int c, errflg = 0;
|
||||
CK_ULONG ulObjectCount;
|
||||
CK_ATTRIBUTE search_template[] = {
|
||||
{CKA_ID, &attr_id, sizeof(attr_id)}
|
||||
};
|
||||
CK_BYTE attr_id[2];
|
||||
CK_OBJECT_HANDLE akey[50];
|
||||
pk11_context_t pctx;
|
||||
char * lib_name = NULL;
|
||||
char * label = NULL;
|
||||
char * pin = NULL;
|
||||
bool error = false, logon = true, all = false;
|
||||
unsigned int i = 0, id = 0;
|
||||
int c, errflg = 0;
|
||||
CK_ULONG ulObjectCount;
|
||||
CK_ATTRIBUTE search_template[] = { { CKA_ID, &attr_id,
|
||||
sizeof(attr_id) } };
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, ":m:s:i:l:p:P")) != -1) {
|
||||
switch (c) {
|
||||
|
|
@ -142,19 +141,22 @@ main(int argc, char *argv[]) {
|
|||
pin = getpass("Enter Pin: ");
|
||||
}
|
||||
|
||||
result = pk11_get_session(&pctx, OP_ANY, false, false,
|
||||
logon, pin, slot);
|
||||
result =
|
||||
pk11_get_session(&pctx, OP_ANY, false, false, logon, pin, slot);
|
||||
if (result == PK11_R_NORANDOMSERVICE ||
|
||||
result == PK11_R_NODIGESTSERVICE ||
|
||||
result == PK11_R_NOAESSERVICE) {
|
||||
result == PK11_R_NODIGESTSERVICE || result == PK11_R_NOAESSERVICE) {
|
||||
fprintf(stderr, "Warning: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr, "This HSM will not work with BIND 9 "
|
||||
"using native PKCS#11.\n");
|
||||
} else if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr, "Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr,
|
||||
"Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n",
|
||||
isc_result_totext(result));
|
||||
fprintf(stderr,
|
||||
"Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n",
|
||||
isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -174,9 +176,7 @@ main(int argc, char *argv[]) {
|
|||
while (ulObjectCount) {
|
||||
rv = pkcs_C_FindObjects(hSession, akey, 50, &ulObjectCount);
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr,
|
||||
"C_FindObjects: Error = 0x%.8lX\n",
|
||||
rv);
|
||||
fprintf(stderr, "C_FindObjects: Error = 0x%.8lX\n", rv);
|
||||
error = 1;
|
||||
goto exit_search;
|
||||
}
|
||||
|
|
@ -184,25 +184,25 @@ main(int argc, char *argv[]) {
|
|||
unsigned int j, len;
|
||||
|
||||
CK_OBJECT_CLASS oclass = 0;
|
||||
CK_BYTE labelbuf[64 + 1];
|
||||
CK_BYTE idbuf[64];
|
||||
CK_BBOOL extract = TRUE;
|
||||
CK_BBOOL never = FALSE;
|
||||
CK_BYTE labelbuf[64 + 1];
|
||||
CK_BYTE idbuf[64];
|
||||
CK_BBOOL extract = TRUE;
|
||||
CK_BBOOL never = FALSE;
|
||||
CK_ATTRIBUTE template[] = {
|
||||
{CKA_CLASS, &oclass, sizeof(oclass)},
|
||||
{CKA_LABEL, labelbuf, sizeof(labelbuf) - 1},
|
||||
{CKA_ID, idbuf, sizeof(idbuf)}
|
||||
{ CKA_CLASS, &oclass, sizeof(oclass) },
|
||||
{ CKA_LABEL, labelbuf, sizeof(labelbuf) - 1 },
|
||||
{ CKA_ID, idbuf, sizeof(idbuf) }
|
||||
};
|
||||
CK_ATTRIBUTE priv_template[] = {
|
||||
{CKA_EXTRACTABLE, &extract, sizeof(extract)},
|
||||
{CKA_NEVER_EXTRACTABLE, &never, sizeof(never)}
|
||||
{ CKA_EXTRACTABLE, &extract, sizeof(extract) },
|
||||
{ CKA_NEVER_EXTRACTABLE, &never, sizeof(never) }
|
||||
};
|
||||
|
||||
memset(labelbuf, 0, sizeof(labelbuf));
|
||||
memset(idbuf, 0, sizeof(idbuf));
|
||||
|
||||
rv = pkcs_C_GetAttributeValue(hSession, akey[i],
|
||||
template, 3);
|
||||
template, 3);
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr,
|
||||
"C_GetAttributeValue[%u]: "
|
||||
|
|
@ -211,8 +211,7 @@ main(int argc, char *argv[]) {
|
|||
if (rv == CKR_BUFFER_TOO_SMALL)
|
||||
fprintf(stderr,
|
||||
"%u too small: %lu %lu %lu\n",
|
||||
i,
|
||||
template[0].ulValueLen,
|
||||
i, template[0].ulValueLen,
|
||||
template[1].ulValueLen,
|
||||
template[2].ulValueLen);
|
||||
error = 1;
|
||||
|
|
@ -222,10 +221,8 @@ main(int argc, char *argv[]) {
|
|||
len = template[2].ulValueLen;
|
||||
printf("object[%u]: handle %lu class %lu "
|
||||
"label[%lu] '%s' id[%lu] ",
|
||||
i, akey[i], oclass,
|
||||
template[1].ulValueLen,
|
||||
labelbuf,
|
||||
template[2].ulValueLen);
|
||||
i, akey[i], oclass, template[1].ulValueLen,
|
||||
labelbuf, template[2].ulValueLen);
|
||||
if (len == 2) {
|
||||
id = (idbuf[0] << 8) & 0xff00;
|
||||
id |= idbuf[1] & 0xff;
|
||||
|
|
@ -243,25 +240,26 @@ main(int argc, char *argv[]) {
|
|||
if ((oclass == CKO_PRIVATE_KEY ||
|
||||
oclass == CKO_SECRET_KEY) &&
|
||||
pkcs_C_GetAttributeValue(hSession, akey[i],
|
||||
priv_template, 2) == CKR_OK) {
|
||||
priv_template,
|
||||
2) == CKR_OK) {
|
||||
printf(" E:%s",
|
||||
extract ? "true" :
|
||||
(never ? "never" : "false"));
|
||||
extract ? "true"
|
||||
: (never ? "never" : "false"));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
exit_search:
|
||||
exit_search:
|
||||
rv = pkcs_C_FindObjectsFinal(hSession);
|
||||
if (rv != CKR_OK) {
|
||||
fprintf(stderr, "C_FindObjectsFinal: Error = 0x%.8lX\n", rv);
|
||||
error = 1;
|
||||
}
|
||||
|
||||
exit_session:
|
||||
exit_session:
|
||||
pk11_return_session(&pctx);
|
||||
(void) pk11_finalize();
|
||||
(void)pk11_finalize();
|
||||
|
||||
exit(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,17 +9,15 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/* pkcs11-tokens [-m module] */
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <isc/commandline.h>
|
||||
#include <isc/mem.h>
|
||||
|
|
@ -29,13 +27,15 @@
|
|||
|
||||
#include <pk11/pk11.h>
|
||||
#include <pk11/result.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_result_t result;
|
||||
char *lib_name = NULL;
|
||||
int c, errflg = 0;
|
||||
isc_mem_t *mctx = NULL;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_result_t result;
|
||||
char * lib_name = NULL;
|
||||
int c, errflg = 0;
|
||||
isc_mem_t * mctx = NULL;
|
||||
pk11_context_t pctx;
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, ":m:v")) != -1) {
|
||||
|
|
@ -73,17 +73,17 @@ main(int argc, char *argv[]) {
|
|||
if (lib_name != NULL)
|
||||
pk11_set_lib_name(lib_name);
|
||||
|
||||
result = pk11_get_session(&pctx, OP_ANY, true, false,
|
||||
false, NULL, 0);
|
||||
result = pk11_get_session(&pctx, OP_ANY, true, false, false, NULL, 0);
|
||||
if (result == PK11_R_NORANDOMSERVICE ||
|
||||
result == PK11_R_NODIGESTSERVICE ||
|
||||
result == PK11_R_NOAESSERVICE) {
|
||||
result == PK11_R_NODIGESTSERVICE || result == PK11_R_NOAESSERVICE) {
|
||||
fprintf(stderr, "Warning: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr, "This HSM will not work with BIND 9 "
|
||||
"using native PKCS#11.\n\n");
|
||||
} else if ((result != ISC_R_SUCCESS) && (result != ISC_R_NOTFOUND)) {
|
||||
fprintf(stderr, "Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n", isc_result_totext(result));
|
||||
fprintf(stderr,
|
||||
"Unrecoverable error initializing "
|
||||
"PKCS#11: %s\n",
|
||||
isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ main(int argc, char *argv[]) {
|
|||
|
||||
if (pctx.handle != NULL)
|
||||
pk11_return_session(&pctx);
|
||||
(void) pk11_finalize();
|
||||
(void)pk11_finalize();
|
||||
|
||||
isc_mem_destroy(&mctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,16 +26,6 @@
|
|||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <isccfg/aclconf.h>
|
||||
#include <isccfg/cfg.h>
|
||||
#include <isccfg/grammar.h>
|
||||
|
||||
#include <ns/client.h>
|
||||
#include <ns/hooks.h>
|
||||
#include <ns/log.h>
|
||||
#include <ns/query.h>
|
||||
#include <ns/types.h>
|
||||
|
||||
#include <dns/acl.h>
|
||||
#include <dns/db.h>
|
||||
#include <dns/enumtype.h>
|
||||
|
|
@ -46,12 +36,22 @@
|
|||
#include <dns/types.h>
|
||||
#include <dns/view.h>
|
||||
|
||||
#define CHECK(op) \
|
||||
do { \
|
||||
result = (op); \
|
||||
if (result != ISC_R_SUCCESS) { \
|
||||
goto cleanup; \
|
||||
} \
|
||||
#include <isccfg/aclconf.h>
|
||||
#include <isccfg/cfg.h>
|
||||
#include <isccfg/grammar.h>
|
||||
|
||||
#include <ns/client.h>
|
||||
#include <ns/hooks.h>
|
||||
#include <ns/log.h>
|
||||
#include <ns/query.h>
|
||||
#include <ns/types.h>
|
||||
|
||||
#define CHECK(op) \
|
||||
do { \
|
||||
result = (op); \
|
||||
if (result != ISC_R_SUCCESS) { \
|
||||
goto cleanup; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
|
|
@ -59,11 +59,7 @@
|
|||
* filter-aaaa-on-v6: "no" is NONE, "yes" is FILTER, "break-dnssec"
|
||||
* is BREAK_DNSSEC.
|
||||
*/
|
||||
typedef enum {
|
||||
NONE = 0,
|
||||
FILTER = 1,
|
||||
BREAK_DNSSEC = 2
|
||||
} filter_aaaa_t;
|
||||
typedef enum { NONE = 0, FILTER = 1, BREAK_DNSSEC = 2 } filter_aaaa_t;
|
||||
|
||||
/*
|
||||
* Persistent data for use by this module. This will be associated
|
||||
|
|
@ -72,23 +68,23 @@ typedef enum {
|
|||
*/
|
||||
typedef struct filter_data {
|
||||
filter_aaaa_t mode;
|
||||
uint32_t flags;
|
||||
uint32_t flags;
|
||||
} filter_data_t;
|
||||
|
||||
typedef struct filter_instance {
|
||||
ns_plugin_t *module;
|
||||
isc_mem_t *mctx;
|
||||
isc_mem_t * mctx;
|
||||
|
||||
/*
|
||||
* Memory pool for use with persistent data.
|
||||
*/
|
||||
isc_mempool_t *datapool;
|
||||
isc_mutex_t plock;
|
||||
isc_mutex_t plock;
|
||||
|
||||
/*
|
||||
* Hash table associating a client object with its persistent data.
|
||||
*/
|
||||
isc_ht_t *ht;
|
||||
isc_ht_t * ht;
|
||||
isc_mutex_t hlock;
|
||||
|
||||
/*
|
||||
|
|
@ -96,21 +92,20 @@ typedef struct filter_instance {
|
|||
*/
|
||||
filter_aaaa_t v4_aaaa;
|
||||
filter_aaaa_t v6_aaaa;
|
||||
dns_acl_t *aaaa_acl;
|
||||
dns_acl_t * aaaa_acl;
|
||||
} filter_instance_t;
|
||||
|
||||
/*
|
||||
* Per-client flags set by this module
|
||||
*/
|
||||
#define FILTER_AAAA_RECURSING 0x0001 /* Recursing for A */
|
||||
#define FILTER_AAAA_FILTERED 0x0002 /* AAAA was removed from answer */
|
||||
#define FILTER_AAAA_RECURSING 0x0001 /* Recursing for A */
|
||||
#define FILTER_AAAA_FILTERED 0x0002 /* AAAA was removed from answer */
|
||||
|
||||
/*
|
||||
* Client attribute tests.
|
||||
*/
|
||||
#define WANTDNSSEC(c) (((c)->attributes & NS_CLIENTATTR_WANTDNSSEC) != 0)
|
||||
#define RECURSIONOK(c) (((c)->query.attributes & \
|
||||
NS_QUERYATTR_RECURSIONOK) != 0)
|
||||
#define WANTDNSSEC(c) (((c)->attributes & NS_CLIENTATTR_WANTDNSSEC) != 0)
|
||||
#define RECURSIONOK(c) (((c)->query.attributes & NS_QUERYATTR_RECURSIONOK) != 0)
|
||||
|
||||
/*
|
||||
* Forward declarations of functions referenced in install_hooks().
|
||||
|
|
@ -168,18 +163,14 @@ install_hooks(ns_hooktable_t *hooktable, isc_mem_t *mctx,
|
|||
.action_data = inst,
|
||||
};
|
||||
|
||||
ns_hook_add(hooktable, mctx, -
|
||||
NS_QUERY_QCTX_INITIALIZED, &filter_init);
|
||||
ns_hook_add(hooktable, mctx,
|
||||
NS_QUERY_RESPOND_BEGIN, &filter_respbegin);
|
||||
ns_hook_add(hooktable, mctx,
|
||||
NS_QUERY_RESPOND_ANY_FOUND, &filter_respanyfound);
|
||||
ns_hook_add(hooktable, mctx,
|
||||
NS_QUERY_PREP_RESPONSE_BEGIN, &filter_prepresp);
|
||||
ns_hook_add(hooktable, mctx,
|
||||
NS_QUERY_DONE_SEND, &filter_donesend);
|
||||
ns_hook_add(hooktable, mctx,
|
||||
NS_QUERY_QCTX_DESTROYED, &filter_destroy);
|
||||
ns_hook_add(hooktable, mctx, -NS_QUERY_QCTX_INITIALIZED, &filter_init);
|
||||
ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_BEGIN, &filter_respbegin);
|
||||
ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_ANY_FOUND,
|
||||
&filter_respanyfound);
|
||||
ns_hook_add(hooktable, mctx, NS_QUERY_PREP_RESPONSE_BEGIN,
|
||||
&filter_prepresp);
|
||||
ns_hook_add(hooktable, mctx, NS_QUERY_DONE_SEND, &filter_donesend);
|
||||
ns_hook_add(hooktable, mctx, NS_QUERY_QCTX_DESTROYED, &filter_destroy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -192,18 +183,20 @@ install_hooks(ns_hooktable_t *hooktable, isc_mem_t *mctx,
|
|||
static const char *filter_aaaa_enums[] = { "break-dnssec", NULL };
|
||||
|
||||
static isc_result_t
|
||||
parse_filter_aaaa(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
|
||||
parse_filter_aaaa(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
|
||||
{
|
||||
return (cfg_parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
|
||||
}
|
||||
|
||||
static void
|
||||
doc_filter_aaaa(cfg_printer_t *pctx, const cfg_type_t *type) {
|
||||
doc_filter_aaaa(cfg_printer_t *pctx, const cfg_type_t *type)
|
||||
{
|
||||
cfg_doc_enum_or_other(pctx, type, &cfg_type_boolean);
|
||||
}
|
||||
|
||||
static cfg_type_t cfg_type_filter_aaaa = {
|
||||
"filter_aaaa", parse_filter_aaaa, cfg_print_ustring,
|
||||
doc_filter_aaaa, &cfg_rep_string, filter_aaaa_enums,
|
||||
"filter_aaaa", parse_filter_aaaa, cfg_print_ustring,
|
||||
doc_filter_aaaa, &cfg_rep_string, filter_aaaa_enums,
|
||||
};
|
||||
|
||||
static cfg_clausedef_t param_clauses[] = {
|
||||
|
|
@ -212,14 +205,11 @@ static cfg_clausedef_t param_clauses[] = {
|
|||
{ "filter-aaaa-on-v6", &cfg_type_filter_aaaa, 0 },
|
||||
};
|
||||
|
||||
static cfg_clausedef_t *param_clausesets[] = {
|
||||
param_clauses,
|
||||
NULL
|
||||
};
|
||||
static cfg_clausedef_t *param_clausesets[] = { param_clauses, NULL };
|
||||
|
||||
static cfg_type_t cfg_type_parameters = {
|
||||
"filter-aaaa-params", cfg_parse_mapbody, cfg_print_mapbody,
|
||||
cfg_doc_mapbody, &cfg_rep_map, param_clausesets
|
||||
cfg_doc_mapbody, &cfg_rep_map, param_clausesets
|
||||
};
|
||||
|
||||
static isc_result_t
|
||||
|
|
@ -227,7 +217,7 @@ parse_filter_aaaa_on(const cfg_obj_t *param_obj, const char *param_name,
|
|||
filter_aaaa_t *dstp)
|
||||
{
|
||||
const cfg_obj_t *obj = NULL;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
result = cfg_map_get(param_obj, param_name, &obj);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -250,22 +240,21 @@ parse_filter_aaaa_on(const cfg_obj_t *param_obj, const char *param_name,
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
check_syntax(cfg_obj_t *fmap, const void *cfg,
|
||||
isc_mem_t *mctx, isc_log_t *lctx, void *actx)
|
||||
check_syntax(cfg_obj_t *fmap, const void *cfg, isc_mem_t *mctx, isc_log_t *lctx,
|
||||
void *actx)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
const cfg_obj_t *aclobj = NULL;
|
||||
dns_acl_t *acl = NULL;
|
||||
filter_aaaa_t f4 = NONE, f6 = NONE;
|
||||
dns_acl_t * acl = NULL;
|
||||
filter_aaaa_t f4 = NONE, f6 = NONE;
|
||||
|
||||
cfg_map_get(fmap, "filter-aaaa", &aclobj);
|
||||
if (aclobj == NULL) {
|
||||
return (result);
|
||||
}
|
||||
|
||||
CHECK(cfg_acl_fromconfig(aclobj, (const cfg_obj_t *) cfg,
|
||||
lctx, (cfg_aclconfctx_t *) actx,
|
||||
mctx, 0, &acl));
|
||||
CHECK(cfg_acl_fromconfig(aclobj, (const cfg_obj_t *)cfg, lctx,
|
||||
(cfg_aclconfctx_t *)actx, mctx, 0, &acl));
|
||||
|
||||
CHECK(parse_filter_aaaa_on(fmap, "filter-aaaa-on-v4", &f4));
|
||||
CHECK(parse_filter_aaaa_on(fmap, "filter-aaaa-on-v6", &f6));
|
||||
|
|
@ -284,7 +273,7 @@ check_syntax(cfg_obj_t *fmap, const void *cfg,
|
|||
result = ISC_R_FAILURE;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (acl != NULL) {
|
||||
dns_acl_detach(&acl);
|
||||
}
|
||||
|
|
@ -297,11 +286,11 @@ parse_parameters(filter_instance_t *inst, const char *parameters,
|
|||
const void *cfg, const char *cfg_file, unsigned long cfg_line,
|
||||
isc_mem_t *mctx, isc_log_t *lctx, void *actx)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *param_obj = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
cfg_parser_t * parser = NULL;
|
||||
cfg_obj_t * param_obj = NULL;
|
||||
const cfg_obj_t *obj = NULL;
|
||||
isc_buffer_t b;
|
||||
isc_buffer_t b;
|
||||
|
||||
CHECK(cfg_parser_create(mctx, lctx, &parser));
|
||||
|
||||
|
|
@ -319,14 +308,14 @@ parse_parameters(filter_instance_t *inst, const char *parameters,
|
|||
|
||||
result = cfg_map_get(param_obj, "filter-aaaa", &obj);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
CHECK(cfg_acl_fromconfig(obj, (const cfg_obj_t *) cfg,
|
||||
lctx, (cfg_aclconfctx_t *) actx,
|
||||
mctx, 0, &inst->aaaa_acl));
|
||||
CHECK(cfg_acl_fromconfig(obj, (const cfg_obj_t *)cfg, lctx,
|
||||
(cfg_aclconfctx_t *)actx, mctx, 0,
|
||||
&inst->aaaa_acl));
|
||||
} else {
|
||||
CHECK(dns_acl_any(mctx, &inst->aaaa_acl));
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (param_obj != NULL) {
|
||||
cfg_obj_destroy(parser, ¶m_obj);
|
||||
}
|
||||
|
|
@ -350,17 +339,15 @@ parse_parameters(filter_instance_t *inst, const char *parameters,
|
|||
* register hook functions into the view hook table.
|
||||
*/
|
||||
isc_result_t
|
||||
plugin_register(const char *parameters,
|
||||
const void *cfg, const char *cfg_file, unsigned long cfg_line,
|
||||
isc_mem_t *mctx, isc_log_t *lctx, void *actx,
|
||||
ns_hooktable_t *hooktable, void **instp)
|
||||
plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
unsigned long cfg_line, isc_mem_t *mctx, isc_log_t *lctx,
|
||||
void *actx, ns_hooktable_t *hooktable, void **instp)
|
||||
{
|
||||
filter_instance_t *inst = NULL;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
|
||||
isc_log_write(lctx, NS_LOGCATEGORY_GENERAL,
|
||||
NS_LOGMODULE_HOOKS, ISC_LOG_INFO,
|
||||
isc_log_write(lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
|
||||
ISC_LOG_INFO,
|
||||
"registering 'filter-aaaa' "
|
||||
"module from %s:%lu, %s parameters",
|
||||
cfg_file, cfg_line, parameters != NULL ? "with" : "no");
|
||||
|
|
@ -374,8 +361,7 @@ plugin_register(const char *parameters,
|
|||
cfg_line, mctx, lctx, actx));
|
||||
}
|
||||
|
||||
isc_mempool_create(mctx, sizeof(filter_data_t),
|
||||
&inst->datapool);
|
||||
isc_mempool_create(mctx, sizeof(filter_data_t), &inst->datapool);
|
||||
CHECK(isc_ht_init(&inst->ht, mctx, 16));
|
||||
isc_mutex_init(&inst->hlock);
|
||||
|
||||
|
|
@ -401,23 +387,23 @@ plugin_register(const char *parameters,
|
|||
|
||||
*instp = inst;
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (result != ISC_R_SUCCESS && inst != NULL) {
|
||||
plugin_destroy((void **) &inst);
|
||||
plugin_destroy((void **)&inst);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
plugin_check(const char *parameters,
|
||||
const void *cfg, const char *cfg_file, unsigned long cfg_line,
|
||||
isc_mem_t *mctx, isc_log_t *lctx, void *actx)
|
||||
plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
unsigned long cfg_line, isc_mem_t *mctx, isc_log_t *lctx,
|
||||
void *actx)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *param_obj = NULL;
|
||||
isc_buffer_t b;
|
||||
cfg_obj_t * param_obj = NULL;
|
||||
isc_buffer_t b;
|
||||
|
||||
CHECK(cfg_parser_create(mctx, lctx, &parser));
|
||||
|
||||
|
|
@ -428,7 +414,7 @@ plugin_check(const char *parameters,
|
|||
|
||||
CHECK(check_syntax(param_obj, cfg, mctx, lctx, actx));
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (param_obj != NULL) {
|
||||
cfg_obj_destroy(parser, ¶m_obj);
|
||||
}
|
||||
|
|
@ -443,8 +429,9 @@ plugin_check(const char *parameters,
|
|||
* the module when it was registered.
|
||||
*/
|
||||
void
|
||||
plugin_destroy(void **instp) {
|
||||
filter_instance_t *inst = (filter_instance_t *) *instp;
|
||||
plugin_destroy(void **instp)
|
||||
{
|
||||
filter_instance_t *inst = (filter_instance_t *)*instp;
|
||||
|
||||
if (inst->ht != NULL) {
|
||||
isc_ht_destroy(&inst->ht);
|
||||
|
|
@ -468,7 +455,8 @@ plugin_destroy(void **instp) {
|
|||
* Returns plugin API version for compatibility checks.
|
||||
*/
|
||||
int
|
||||
plugin_version(void) {
|
||||
plugin_version(void)
|
||||
{
|
||||
return (NS_PLUGIN_VERSION);
|
||||
}
|
||||
|
||||
|
|
@ -480,25 +468,25 @@ plugin_version(void) {
|
|||
* Structure describing the filtering to be applied by process_section().
|
||||
*/
|
||||
typedef struct section_filter {
|
||||
query_ctx_t * qctx;
|
||||
filter_aaaa_t mode;
|
||||
dns_section_t section;
|
||||
const dns_name_t * name;
|
||||
dns_rdatatype_t type;
|
||||
bool only_if_a_exists;
|
||||
query_ctx_t * qctx;
|
||||
filter_aaaa_t mode;
|
||||
dns_section_t section;
|
||||
const dns_name_t *name;
|
||||
dns_rdatatype_t type;
|
||||
bool only_if_a_exists;
|
||||
} section_filter_t;
|
||||
|
||||
/*
|
||||
* Check whether this is an IPv4 client.
|
||||
*/
|
||||
static bool
|
||||
is_v4_client(ns_client_t *client) {
|
||||
is_v4_client(ns_client_t *client)
|
||||
{
|
||||
if (isc_sockaddr_pf(&client->peeraddr) == AF_INET) {
|
||||
return (true);
|
||||
}
|
||||
if (isc_sockaddr_pf(&client->peeraddr) == AF_INET6 &&
|
||||
IN6_IS_ADDR_V4MAPPED(&client->peeraddr.type.sin6.sin6_addr))
|
||||
{
|
||||
IN6_IS_ADDR_V4MAPPED(&client->peeraddr.type.sin6.sin6_addr)) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
|
|
@ -508,19 +496,20 @@ is_v4_client(ns_client_t *client) {
|
|||
* Check whether this is an IPv6 client.
|
||||
*/
|
||||
static bool
|
||||
is_v6_client(ns_client_t *client) {
|
||||
is_v6_client(ns_client_t *client)
|
||||
{
|
||||
if (isc_sockaddr_pf(&client->peeraddr) == AF_INET6 &&
|
||||
!IN6_IS_ADDR_V4MAPPED(&client->peeraddr.type.sin6.sin6_addr))
|
||||
{
|
||||
!IN6_IS_ADDR_V4MAPPED(&client->peeraddr.type.sin6.sin6_addr)) {
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
static filter_data_t *
|
||||
client_state_get(const query_ctx_t *qctx, filter_instance_t *inst) {
|
||||
client_state_get(const query_ctx_t *qctx, filter_instance_t *inst)
|
||||
{
|
||||
filter_data_t *client_state = NULL;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
LOCK(&inst->hlock);
|
||||
result = isc_ht_find(inst->ht, (const unsigned char *)&qctx->client,
|
||||
|
|
@ -531,9 +520,10 @@ client_state_get(const query_ctx_t *qctx, filter_instance_t *inst) {
|
|||
}
|
||||
|
||||
static void
|
||||
client_state_create(const query_ctx_t *qctx, filter_instance_t *inst) {
|
||||
client_state_create(const query_ctx_t *qctx, filter_instance_t *inst)
|
||||
{
|
||||
filter_data_t *client_state;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
client_state = isc_mempool_get(inst->datapool);
|
||||
if (client_state == NULL) {
|
||||
|
|
@ -551,9 +541,10 @@ client_state_create(const query_ctx_t *qctx, filter_instance_t *inst) {
|
|||
}
|
||||
|
||||
static void
|
||||
client_state_destroy(const query_ctx_t *qctx, filter_instance_t *inst) {
|
||||
client_state_destroy(const query_ctx_t *qctx, filter_instance_t *inst)
|
||||
{
|
||||
filter_data_t *client_state = client_state_get(qctx, inst);
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
if (client_state == NULL) {
|
||||
return;
|
||||
|
|
@ -573,7 +564,8 @@ client_state_destroy(const query_ctx_t *qctx, filter_instance_t *inst) {
|
|||
* pointers and non-associated rdatasets.
|
||||
*/
|
||||
static void
|
||||
mark_as_rendered(dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) {
|
||||
mark_as_rendered(dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
|
||||
{
|
||||
if (rdataset != NULL && dns_rdataset_isassociated(rdataset)) {
|
||||
rdataset->attributes |= DNS_RDATASETATTR_RENDERED;
|
||||
}
|
||||
|
|
@ -596,8 +588,8 @@ process_name(query_ctx_t *qctx, filter_aaaa_t mode, const dns_name_t *name,
|
|||
dns_rdatatype_t type, bool only_if_a_exists)
|
||||
{
|
||||
dns_rdataset_t *rdataset = NULL, *sigrdataset = NULL;
|
||||
isc_result_t result;
|
||||
bool modified = false;
|
||||
isc_result_t result;
|
||||
bool modified = false;
|
||||
|
||||
if (only_if_a_exists) {
|
||||
CHECK(dns_message_findtype(name, dns_rdatatype_a, 0, NULL));
|
||||
|
|
@ -609,8 +601,7 @@ process_name(query_ctx_t *qctx, filter_aaaa_t mode, const dns_name_t *name,
|
|||
|
||||
if (rdataset != NULL &&
|
||||
(sigrdataset == NULL || !WANTDNSSEC(qctx->client) ||
|
||||
mode == BREAK_DNSSEC))
|
||||
{
|
||||
mode == BREAK_DNSSEC)) {
|
||||
/*
|
||||
* An RRset of given 'type' was found at 'name' and at least
|
||||
* one of the following is true:
|
||||
|
|
@ -626,7 +617,7 @@ process_name(query_ctx_t *qctx, filter_aaaa_t mode, const dns_name_t *name,
|
|||
modified = true;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
return (modified);
|
||||
}
|
||||
|
||||
|
|
@ -640,21 +631,21 @@ process_name(query_ctx_t *qctx, filter_aaaa_t mode, const dns_name_t *name,
|
|||
* process_name().
|
||||
*/
|
||||
static void
|
||||
process_section(const section_filter_t *filter) {
|
||||
query_ctx_t *qctx = filter->qctx;
|
||||
filter_aaaa_t mode = filter->mode;
|
||||
dns_section_t section = filter->section;
|
||||
process_section(const section_filter_t *filter)
|
||||
{
|
||||
query_ctx_t * qctx = filter->qctx;
|
||||
filter_aaaa_t mode = filter->mode;
|
||||
dns_section_t section = filter->section;
|
||||
const dns_name_t *name = filter->name;
|
||||
dns_rdatatype_t type = filter->type;
|
||||
bool only_if_a_exists = filter->only_if_a_exists;
|
||||
dns_rdatatype_t type = filter->type;
|
||||
bool only_if_a_exists = filter->only_if_a_exists;
|
||||
|
||||
dns_message_t *message = qctx->client->message;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
for (result = dns_message_firstname(message, section);
|
||||
result == ISC_R_SUCCESS;
|
||||
result = dns_message_nextname(message, section))
|
||||
{
|
||||
result = dns_message_nextname(message, section)) {
|
||||
dns_name_t *cur = NULL;
|
||||
dns_message_currentname(message, section, &cur);
|
||||
if (name != NULL && !dns_name_equal(name, cur)) {
|
||||
|
|
@ -672,8 +663,7 @@ process_section(const section_filter_t *filter) {
|
|||
}
|
||||
|
||||
if (section == DNS_SECTION_ANSWER ||
|
||||
section == DNS_SECTION_AUTHORITY)
|
||||
{
|
||||
section == DNS_SECTION_AUTHORITY) {
|
||||
message->flags &= ~DNS_MESSAGEFLAG_AD;
|
||||
}
|
||||
}
|
||||
|
|
@ -686,10 +676,11 @@ process_section(const section_filter_t *filter) {
|
|||
* object persists.
|
||||
*/
|
||||
static ns_hookresult_t
|
||||
filter_qctx_initialize(void *arg, void *cbdata, isc_result_t *resp) {
|
||||
query_ctx_t *qctx = (query_ctx_t *) arg;
|
||||
filter_instance_t *inst = (filter_instance_t *) cbdata;
|
||||
filter_data_t *client_state;
|
||||
filter_qctx_initialize(void *arg, void *cbdata, isc_result_t *resp)
|
||||
{
|
||||
query_ctx_t * qctx = (query_ctx_t *)arg;
|
||||
filter_instance_t *inst = (filter_instance_t *)cbdata;
|
||||
filter_data_t * client_state;
|
||||
|
||||
*resp = ISC_R_UNSET;
|
||||
|
||||
|
|
@ -707,11 +698,12 @@ filter_qctx_initialize(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
* filter-aaaa-on-v6.
|
||||
*/
|
||||
static ns_hookresult_t
|
||||
filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
||||
query_ctx_t *qctx = (query_ctx_t *) arg;
|
||||
filter_instance_t *inst = (filter_instance_t *) cbdata;
|
||||
filter_data_t *client_state = client_state_get(qctx, inst);
|
||||
isc_result_t result;
|
||||
filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp)
|
||||
{
|
||||
query_ctx_t * qctx = (query_ctx_t *)arg;
|
||||
filter_instance_t *inst = (filter_instance_t *)cbdata;
|
||||
filter_data_t * client_state = client_state_get(qctx, inst);
|
||||
isc_result_t result;
|
||||
|
||||
*resp = ISC_R_UNSET;
|
||||
|
||||
|
|
@ -722,15 +714,11 @@ filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
if (inst->v4_aaaa != NONE || inst->v6_aaaa != NONE) {
|
||||
result = ns_client_checkaclsilent(qctx->client, NULL,
|
||||
inst->aaaa_acl, true);
|
||||
if (result == ISC_R_SUCCESS &&
|
||||
inst->v4_aaaa != NONE &&
|
||||
is_v4_client(qctx->client))
|
||||
{
|
||||
if (result == ISC_R_SUCCESS && inst->v4_aaaa != NONE &&
|
||||
is_v4_client(qctx->client)) {
|
||||
client_state->mode = inst->v4_aaaa;
|
||||
} else if (result == ISC_R_SUCCESS &&
|
||||
inst->v6_aaaa != NONE &&
|
||||
is_v6_client(qctx->client))
|
||||
{
|
||||
} else if (result == ISC_R_SUCCESS && inst->v6_aaaa != NONE &&
|
||||
is_v6_client(qctx->client)) {
|
||||
client_state->mode = inst->v6_aaaa;
|
||||
}
|
||||
}
|
||||
|
|
@ -746,11 +734,12 @@ filter_prep_response_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
* queries are handled in filter_respond_any_found().)
|
||||
*/
|
||||
static ns_hookresult_t
|
||||
filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
||||
query_ctx_t *qctx = (query_ctx_t *) arg;
|
||||
filter_instance_t *inst = (filter_instance_t *) cbdata;
|
||||
filter_data_t *client_state = client_state_get(qctx, inst);
|
||||
isc_result_t result = ISC_R_UNSET;
|
||||
filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp)
|
||||
{
|
||||
query_ctx_t * qctx = (query_ctx_t *)arg;
|
||||
filter_instance_t *inst = (filter_instance_t *)cbdata;
|
||||
filter_data_t * client_state = client_state_get(qctx, inst);
|
||||
isc_result_t result = ISC_R_UNSET;
|
||||
|
||||
*resp = ISC_R_UNSET;
|
||||
|
||||
|
|
@ -761,19 +750,16 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
if (client_state->mode != BREAK_DNSSEC &&
|
||||
(client_state->mode != FILTER ||
|
||||
(WANTDNSSEC(qctx->client) && qctx->sigrdataset != NULL &&
|
||||
dns_rdataset_isassociated(qctx->sigrdataset))))
|
||||
{
|
||||
dns_rdataset_isassociated(qctx->sigrdataset)))) {
|
||||
return (NS_HOOK_CONTINUE);
|
||||
}
|
||||
|
||||
if (qctx->qtype == dns_rdatatype_aaaa) {
|
||||
dns_rdataset_t *trdataset;
|
||||
trdataset = ns_client_newrdataset(qctx->client);
|
||||
result = dns_db_findrdataset(qctx->db, qctx->node,
|
||||
qctx->version,
|
||||
dns_rdatatype_a, 0,
|
||||
qctx->client->now,
|
||||
trdataset, NULL);
|
||||
result = dns_db_findrdataset(
|
||||
qctx->db, qctx->node, qctx->version, dns_rdatatype_a, 0,
|
||||
qctx->client->now, trdataset, NULL);
|
||||
if (dns_rdataset_isassociated(trdataset)) {
|
||||
dns_rdataset_disassociate(trdataset);
|
||||
}
|
||||
|
|
@ -798,11 +784,9 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
mark_as_rendered(qctx->rdataset, qctx->sigrdataset);
|
||||
qctx->client->message->flags &= ~DNS_MESSAGEFLAG_AD;
|
||||
client_state->flags |= FILTER_AAAA_FILTERED;
|
||||
} else if (!qctx->authoritative &&
|
||||
RECURSIONOK(qctx->client) &&
|
||||
} else if (!qctx->authoritative && RECURSIONOK(qctx->client) &&
|
||||
(result == DNS_R_DELEGATION ||
|
||||
result == ISC_R_NOTFOUND))
|
||||
{
|
||||
result == ISC_R_NOTFOUND)) {
|
||||
/*
|
||||
* This is an ugly kludge to recurse
|
||||
* for the A and discard the result.
|
||||
|
|
@ -811,8 +795,7 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
* We'll make a note to not render it
|
||||
* if the recursion for the A succeeds.
|
||||
*/
|
||||
result = ns_query_recurse(qctx->client,
|
||||
dns_rdatatype_a,
|
||||
result = ns_query_recurse(qctx->client, dns_rdatatype_a,
|
||||
qctx->client->query.qname,
|
||||
NULL, NULL, qctx->resuming);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
|
|
@ -822,8 +805,7 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
}
|
||||
}
|
||||
} else if (qctx->qtype == dns_rdatatype_a &&
|
||||
(client_state->flags & FILTER_AAAA_RECURSING) != 0)
|
||||
{
|
||||
(client_state->flags & FILTER_AAAA_RECURSING) != 0) {
|
||||
const section_filter_t filter_answer = {
|
||||
.qctx = qctx,
|
||||
.mode = client_state->mode,
|
||||
|
|
@ -850,10 +832,11 @@ filter_respond_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
* When answering an ANY query, remove AAAA if A is present.
|
||||
*/
|
||||
static ns_hookresult_t
|
||||
filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp) {
|
||||
query_ctx_t *qctx = (query_ctx_t *) arg;
|
||||
filter_instance_t *inst = (filter_instance_t *) cbdata;
|
||||
filter_data_t *client_state = client_state_get(qctx, inst);
|
||||
filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp)
|
||||
{
|
||||
query_ctx_t * qctx = (query_ctx_t *)arg;
|
||||
filter_instance_t *inst = (filter_instance_t *)cbdata;
|
||||
filter_data_t * client_state = client_state_get(qctx, inst);
|
||||
|
||||
*resp = ISC_R_UNSET;
|
||||
|
||||
|
|
@ -885,10 +868,11 @@ filter_respond_any_found(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
* section.
|
||||
*/
|
||||
static ns_hookresult_t
|
||||
filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp) {
|
||||
query_ctx_t *qctx = (query_ctx_t *) arg;
|
||||
filter_instance_t *inst = (filter_instance_t *) cbdata;
|
||||
filter_data_t *client_state = client_state_get(qctx, inst);
|
||||
filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp)
|
||||
{
|
||||
query_ctx_t * qctx = (query_ctx_t *)arg;
|
||||
filter_instance_t *inst = (filter_instance_t *)cbdata;
|
||||
filter_data_t * client_state = client_state_get(qctx, inst);
|
||||
|
||||
*resp = ISC_R_UNSET;
|
||||
|
||||
|
|
@ -921,9 +905,10 @@ filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp) {
|
|||
* from hash table and return it to the memory pool.
|
||||
*/
|
||||
static ns_hookresult_t
|
||||
filter_qctx_destroy(void *arg, void *cbdata, isc_result_t *resp) {
|
||||
query_ctx_t *qctx = (query_ctx_t *) arg;
|
||||
filter_instance_t *inst = (filter_instance_t *) cbdata;
|
||||
filter_qctx_destroy(void *arg, void *cbdata, isc_result_t *resp)
|
||||
{
|
||||
query_ctx_t * qctx = (query_ctx_t *)arg;
|
||||
filter_instance_t *inst = (filter_instance_t *)cbdata;
|
||||
|
||||
*resp = ISC_R_UNSET;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,18 +9,19 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#ifndef RNDC_OS_H
|
||||
#define RNDC_OS_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
int set_user(FILE *fd, const char *user);
|
||||
int
|
||||
set_user(FILE *fd, const char *user);
|
||||
/*%<
|
||||
* Set the owner of the file referenced by 'fd' to 'user'.
|
||||
* Returns:
|
||||
|
|
|
|||
355
bin/rndc/rndc.c
355
bin/rndc/rndc.c
|
|
@ -21,8 +21,8 @@
|
|||
#include <isc/commandline.h>
|
||||
#include <isc/file.h>
|
||||
#include <isc/log.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/random.h>
|
||||
#include <isc/refcount.h>
|
||||
|
|
@ -33,10 +33,13 @@
|
|||
#include <isc/thread.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <pk11/site.h>
|
||||
#include <dns/name.h>
|
||||
|
||||
#include <isccfg/namedconf.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#include <bind9/getaddresses.h>
|
||||
#include <isccc/alist.h>
|
||||
#include <isccc/base64.h>
|
||||
#include <isccc/cc.h>
|
||||
|
|
@ -45,54 +48,51 @@
|
|||
#include <isccc/sexpr.h>
|
||||
#include <isccc/types.h>
|
||||
#include <isccc/util.h>
|
||||
|
||||
#include <dns/name.h>
|
||||
|
||||
#include <bind9/getaddresses.h>
|
||||
|
||||
#include "util.h"
|
||||
#include <pk11/site.h>
|
||||
|
||||
#define SERVERADDRS 10
|
||||
|
||||
const char *progname;
|
||||
bool verbose;
|
||||
bool verbose;
|
||||
|
||||
static const char *admin_conffile;
|
||||
static const char *admin_keyfile;
|
||||
static const char *version = VERSION;
|
||||
static const char *servername = NULL;
|
||||
static isc_sockaddr_t serveraddrs[SERVERADDRS];
|
||||
static isc_sockaddr_t local4, local6;
|
||||
static bool local4set = false, local6set = false;
|
||||
static int nserveraddrs;
|
||||
static int currentaddr = 0;
|
||||
static unsigned int remoteport = 0;
|
||||
static isc_socketmgr_t *socketmgr = NULL;
|
||||
static isc_buffer_t *databuf;
|
||||
static isccc_ccmsg_t ccmsg;
|
||||
static uint32_t algorithm;
|
||||
static isccc_region_t secret;
|
||||
static bool failed = false;
|
||||
static bool c_flag = false;
|
||||
static isc_mem_t *rndc_mctx;
|
||||
static const char * admin_conffile;
|
||||
static const char * admin_keyfile;
|
||||
static const char * version = VERSION;
|
||||
static const char * servername = NULL;
|
||||
static isc_sockaddr_t serveraddrs[SERVERADDRS];
|
||||
static isc_sockaddr_t local4, local6;
|
||||
static bool local4set = false, local6set = false;
|
||||
static int nserveraddrs;
|
||||
static int currentaddr = 0;
|
||||
static unsigned int remoteport = 0;
|
||||
static isc_socketmgr_t * socketmgr = NULL;
|
||||
static isc_buffer_t * databuf;
|
||||
static isccc_ccmsg_t ccmsg;
|
||||
static uint32_t algorithm;
|
||||
static isccc_region_t secret;
|
||||
static bool failed = false;
|
||||
static bool c_flag = false;
|
||||
static isc_mem_t * rndc_mctx;
|
||||
static atomic_uint_fast32_t sends = ATOMIC_VAR_INIT(0);
|
||||
static atomic_uint_fast32_t recvs = ATOMIC_VAR_INIT(0);
|
||||
static atomic_uint_fast32_t connects = ATOMIC_VAR_INIT(0);
|
||||
static char *command;
|
||||
static char *args;
|
||||
static char program[256];
|
||||
static isc_socket_t *sock = NULL;
|
||||
static uint32_t serial;
|
||||
static bool quiet = false;
|
||||
static bool showresult = false;
|
||||
static char * command;
|
||||
static char * args;
|
||||
static char program[256];
|
||||
static isc_socket_t * sock = NULL;
|
||||
static uint32_t serial;
|
||||
static bool quiet = false;
|
||||
static bool showresult = false;
|
||||
|
||||
static void rndc_startconnect(isc_sockaddr_t *addr, isc_task_t *task);
|
||||
static void
|
||||
rndc_startconnect(isc_sockaddr_t *addr, isc_task_t *task);
|
||||
|
||||
ISC_PLATFORM_NORETURN_PRE static void
|
||||
usage(int status) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static void
|
||||
usage(int status) {
|
||||
usage(int status)
|
||||
{
|
||||
fprintf(stderr, "\
|
||||
Usage: %s [-b address] [-c config] [-s server] [-p port]\n\
|
||||
[-k key-file ] [-y key] [-r] [-V] [-4 | -6] command\n\
|
||||
|
|
@ -219,9 +219,10 @@ Version: %s\n",
|
|||
#define CMDLINE_FLAGS "46b:c:hk:Mmp:qrs:Vy:"
|
||||
|
||||
static void
|
||||
preparse_args(int argc, char **argv) {
|
||||
preparse_args(int argc, char **argv)
|
||||
{
|
||||
bool ipv4only = false, ipv6only = false;
|
||||
int ch;
|
||||
int ch;
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
|
|
@ -247,30 +248,31 @@ preparse_args(int argc, char **argv) {
|
|||
}
|
||||
|
||||
static void
|
||||
get_addresses(const char *host, in_port_t port) {
|
||||
get_addresses(const char *host, in_port_t port)
|
||||
{
|
||||
isc_result_t result;
|
||||
int found = 0, count;
|
||||
int found = 0, count;
|
||||
|
||||
if (*host == '/') {
|
||||
result = isc_sockaddr_frompath(&serveraddrs[nserveraddrs],
|
||||
host);
|
||||
result =
|
||||
isc_sockaddr_frompath(&serveraddrs[nserveraddrs], host);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
nserveraddrs++;
|
||||
} else {
|
||||
count = SERVERADDRS - nserveraddrs;
|
||||
result = bind9_getaddresses(host, port,
|
||||
&serveraddrs[nserveraddrs],
|
||||
count, &found);
|
||||
result = bind9_getaddresses(
|
||||
host, port, &serveraddrs[nserveraddrs], count, &found);
|
||||
nserveraddrs += found;
|
||||
}
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("couldn't get address for '%s': %s",
|
||||
host, isc_result_totext(result));
|
||||
fatal("couldn't get address for '%s': %s", host,
|
||||
isc_result_totext(result));
|
||||
INSIST(nserveraddrs > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
rndc_senddone(isc_task_t *task, isc_event_t *event) {
|
||||
rndc_senddone(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
|
||||
|
||||
UNUSED(task);
|
||||
|
|
@ -280,8 +282,7 @@ rndc_senddone(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
isc_event_free(&event);
|
||||
if (atomic_fetch_sub_release(&sends, 1) == 1 &&
|
||||
atomic_load_acquire(&recvs) == 0)
|
||||
{
|
||||
atomic_load_acquire(&recvs) == 0) {
|
||||
isc_socket_detach(&sock);
|
||||
isc_task_shutdown(task);
|
||||
isc_app_shutdown();
|
||||
|
|
@ -289,13 +290,14 @@ rndc_senddone(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
rndc_recvdone(isc_task_t *task, isc_event_t *event) {
|
||||
rndc_recvdone(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isccc_sexpr_t *response = NULL;
|
||||
isccc_sexpr_t *data;
|
||||
isccc_region_t source;
|
||||
char *errormsg = NULL;
|
||||
char *textmsg = NULL;
|
||||
isc_result_t result;
|
||||
char * errormsg = NULL;
|
||||
char * textmsg = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
atomic_fetch_sub_release(&recvs, 1);
|
||||
|
||||
|
|
@ -323,20 +325,19 @@ rndc_recvdone(isc_task_t *task, isc_event_t *event) {
|
|||
result = isccc_cc_lookupstring(data, "err", &errormsg);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
failed = true;
|
||||
fprintf(stderr, "%s: '%s' failed: %s\n",
|
||||
progname, command, errormsg);
|
||||
}
|
||||
else if (result != ISC_R_NOTFOUND)
|
||||
fprintf(stderr, "%s: parsing response failed: %s\n",
|
||||
progname, isc_result_totext(result));
|
||||
fprintf(stderr, "%s: '%s' failed: %s\n", progname, command,
|
||||
errormsg);
|
||||
} else if (result != ISC_R_NOTFOUND)
|
||||
fprintf(stderr, "%s: parsing response failed: %s\n", progname,
|
||||
isc_result_totext(result));
|
||||
|
||||
result = isccc_cc_lookupstring(data, "text", &textmsg);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if ((!quiet || failed) && strlen(textmsg) != 0U)
|
||||
fprintf(failed ? stderr : stdout, "%s\n", textmsg);
|
||||
} else if (result != ISC_R_NOTFOUND)
|
||||
fprintf(stderr, "%s: parsing response failed: %s\n",
|
||||
progname, isc_result_totext(result));
|
||||
fprintf(stderr, "%s: parsing response failed: %s\n", progname,
|
||||
isc_result_totext(result));
|
||||
|
||||
if (showresult) {
|
||||
isc_result_t eresult;
|
||||
|
|
@ -350,8 +351,8 @@ rndc_recvdone(isc_task_t *task, isc_event_t *event) {
|
|||
|
||||
isc_event_free(&event);
|
||||
isccc_sexpr_free(&response);
|
||||
if (atomic_load_acquire(&sends) == 0
|
||||
&& atomic_load_acquire(&recvs) == 0) {
|
||||
if (atomic_load_acquire(&sends) == 0 &&
|
||||
atomic_load_acquire(&recvs) == 0) {
|
||||
isc_socket_detach(&sock);
|
||||
isc_task_shutdown(task);
|
||||
isc_app_shutdown();
|
||||
|
|
@ -359,17 +360,18 @@ rndc_recvdone(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
rndc_recvnonce(isc_task_t *task, isc_event_t *event) {
|
||||
rndc_recvnonce(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isccc_sexpr_t *response = NULL;
|
||||
isccc_sexpr_t *_ctrl;
|
||||
isccc_region_t source;
|
||||
isc_result_t result;
|
||||
uint32_t nonce;
|
||||
isc_result_t result;
|
||||
uint32_t nonce;
|
||||
isccc_sexpr_t *request = NULL;
|
||||
isccc_time_t now;
|
||||
isc_region_t r;
|
||||
isccc_time_t now;
|
||||
isc_region_t r;
|
||||
isccc_sexpr_t *data;
|
||||
isc_buffer_t b;
|
||||
isc_buffer_t b;
|
||||
|
||||
atomic_fetch_sub_release(&recvs, 1);
|
||||
|
||||
|
|
@ -430,11 +432,11 @@ rndc_recvnonce(isc_task_t *task, isc_event_t *event) {
|
|||
r.length = databuf->used;
|
||||
|
||||
isccc_ccmsg_cancelread(&ccmsg);
|
||||
DO("schedule recv", isccc_ccmsg_readmessage(&ccmsg, task,
|
||||
rndc_recvdone, NULL));
|
||||
DO("schedule recv",
|
||||
isccc_ccmsg_readmessage(&ccmsg, task, rndc_recvdone, NULL));
|
||||
atomic_fetch_add_relaxed(&recvs, 1);
|
||||
DO("send message", isc_socket_send(sock, &r, task, rndc_senddone,
|
||||
NULL));
|
||||
DO("send message",
|
||||
isc_socket_send(sock, &r, task, rndc_senddone, NULL));
|
||||
atomic_fetch_add_relaxed(&sends, 1);
|
||||
|
||||
isc_event_free(&event);
|
||||
|
|
@ -444,15 +446,16 @@ rndc_recvnonce(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
rndc_connected(isc_task_t *task, isc_event_t *event) {
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
rndc_connected(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
|
||||
isccc_sexpr_t *request = NULL;
|
||||
isccc_sexpr_t *data;
|
||||
isccc_time_t now;
|
||||
isc_region_t r;
|
||||
isc_buffer_t b;
|
||||
isc_result_t result;
|
||||
isccc_sexpr_t * request = NULL;
|
||||
isccc_sexpr_t * data;
|
||||
isccc_time_t now;
|
||||
isc_region_t r;
|
||||
isc_buffer_t b;
|
||||
isc_result_t result;
|
||||
|
||||
atomic_fetch_sub_release(&connects, 1);
|
||||
|
||||
|
|
@ -460,8 +463,7 @@ rndc_connected(isc_task_t *task, isc_event_t *event) {
|
|||
isc_sockaddr_format(&serveraddrs[currentaddr], socktext,
|
||||
sizeof(socktext));
|
||||
if (sevent->result != ISC_R_CANCELED &&
|
||||
++currentaddr < nserveraddrs)
|
||||
{
|
||||
++currentaddr < nserveraddrs) {
|
||||
notify("connection failed: %s: %s", socktext,
|
||||
isc_result_totext(sevent->result));
|
||||
isc_socket_detach(&sock);
|
||||
|
|
@ -498,20 +500,21 @@ rndc_connected(isc_task_t *task, isc_event_t *event) {
|
|||
isccc_ccmsg_init(rndc_mctx, sock, &ccmsg);
|
||||
isccc_ccmsg_setmaxsize(&ccmsg, 1024 * 1024);
|
||||
|
||||
DO("schedule recv", isccc_ccmsg_readmessage(&ccmsg, task,
|
||||
rndc_recvnonce, NULL));
|
||||
DO("schedule recv",
|
||||
isccc_ccmsg_readmessage(&ccmsg, task, rndc_recvnonce, NULL));
|
||||
atomic_fetch_add_relaxed(&recvs, 1);
|
||||
DO("send message", isc_socket_send(sock, &r, task, rndc_senddone,
|
||||
NULL));
|
||||
DO("send message",
|
||||
isc_socket_send(sock, &r, task, rndc_senddone, NULL));
|
||||
atomic_fetch_add_relaxed(&sends, 1);
|
||||
isc_event_free(&event);
|
||||
isccc_sexpr_free(&request);
|
||||
}
|
||||
|
||||
static void
|
||||
rndc_startconnect(isc_sockaddr_t *addr, isc_task_t *task) {
|
||||
isc_result_t result;
|
||||
int pf;
|
||||
rndc_startconnect(isc_sockaddr_t *addr, isc_task_t *task)
|
||||
{
|
||||
isc_result_t result;
|
||||
int pf;
|
||||
isc_sockettype_t type;
|
||||
|
||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||
|
|
@ -536,13 +539,14 @@ rndc_startconnect(isc_sockaddr_t *addr, isc_task_t *task) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
DO("connect", isc_socket_connect(sock, addr, task, rndc_connected,
|
||||
NULL));
|
||||
DO("connect",
|
||||
isc_socket_connect(sock, addr, task, rndc_connected, NULL));
|
||||
atomic_fetch_add_relaxed(&connects, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
rndc_start(isc_task_t *task, isc_event_t *event) {
|
||||
rndc_start(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_event_free(&event);
|
||||
|
||||
currentaddr = 0;
|
||||
|
|
@ -553,41 +557,42 @@ static void
|
|||
parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
|
||||
cfg_parser_t **pctxp, cfg_obj_t **configp)
|
||||
{
|
||||
isc_result_t result;
|
||||
const char *conffile = admin_conffile;
|
||||
const cfg_obj_t *addresses = NULL;
|
||||
const cfg_obj_t *defkey = NULL;
|
||||
const cfg_obj_t *options = NULL;
|
||||
const cfg_obj_t *servers = NULL;
|
||||
const cfg_obj_t *server = NULL;
|
||||
const cfg_obj_t *keys = NULL;
|
||||
const cfg_obj_t *key = NULL;
|
||||
const cfg_obj_t *defport = NULL;
|
||||
const cfg_obj_t *secretobj = NULL;
|
||||
const cfg_obj_t *algorithmobj = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
const cfg_obj_t *address = NULL;
|
||||
isc_result_t result;
|
||||
const char * conffile = admin_conffile;
|
||||
const cfg_obj_t * addresses = NULL;
|
||||
const cfg_obj_t * defkey = NULL;
|
||||
const cfg_obj_t * options = NULL;
|
||||
const cfg_obj_t * servers = NULL;
|
||||
const cfg_obj_t * server = NULL;
|
||||
const cfg_obj_t * keys = NULL;
|
||||
const cfg_obj_t * key = NULL;
|
||||
const cfg_obj_t * defport = NULL;
|
||||
const cfg_obj_t * secretobj = NULL;
|
||||
const cfg_obj_t * algorithmobj = NULL;
|
||||
cfg_obj_t * config = NULL;
|
||||
const cfg_obj_t * address = NULL;
|
||||
const cfg_listelt_t *elt;
|
||||
const char *secretstr;
|
||||
const char *algorithmstr;
|
||||
static char secretarray[1024];
|
||||
const cfg_type_t *conftype = &cfg_type_rndcconf;
|
||||
bool key_only = false;
|
||||
const char * secretstr;
|
||||
const char * algorithmstr;
|
||||
static char secretarray[1024];
|
||||
const cfg_type_t * conftype = &cfg_type_rndcconf;
|
||||
bool key_only = false;
|
||||
const cfg_listelt_t *element;
|
||||
|
||||
if (! isc_file_exists(conffile)) {
|
||||
if (!isc_file_exists(conffile)) {
|
||||
conffile = admin_keyfile;
|
||||
conftype = &cfg_type_rndckey;
|
||||
|
||||
if (c_flag)
|
||||
fatal("%s does not exist", admin_conffile);
|
||||
|
||||
if (! isc_file_exists(conffile))
|
||||
fatal("neither %s nor %s was found",
|
||||
admin_conffile, admin_keyfile);
|
||||
if (!isc_file_exists(conffile))
|
||||
fatal("neither %s nor %s was found", admin_conffile,
|
||||
admin_keyfile);
|
||||
key_only = true;
|
||||
} else if (! c_flag && isc_file_exists(admin_keyfile)) {
|
||||
fprintf(stderr, "WARNING: key file (%s) exists, but using "
|
||||
} else if (!c_flag && isc_file_exists(admin_keyfile)) {
|
||||
fprintf(stderr,
|
||||
"WARNING: key file (%s) exists, but using "
|
||||
"default configuration file (%s)\n",
|
||||
admin_keyfile, admin_conffile);
|
||||
}
|
||||
|
|
@ -619,13 +624,12 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
|
|||
if (!key_only) {
|
||||
(void)cfg_map_get(config, "server", &servers);
|
||||
if (servers != NULL) {
|
||||
for (elt = cfg_list_first(servers);
|
||||
elt != NULL;
|
||||
elt = cfg_list_next(elt))
|
||||
{
|
||||
for (elt = cfg_list_first(servers); elt != NULL;
|
||||
elt = cfg_list_next(elt)) {
|
||||
const char *name;
|
||||
server = cfg_listelt_value(elt);
|
||||
name = cfg_obj_asstring(cfg_map_getname(server));
|
||||
name = cfg_obj_asstring(
|
||||
cfg_map_getname(server));
|
||||
if (strcasecmp(name, servername) == 0)
|
||||
break;
|
||||
server = NULL;
|
||||
|
|
@ -637,13 +641,13 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
|
|||
* Look for the name of the key to use.
|
||||
*/
|
||||
if (keyname != NULL)
|
||||
; /* Was set on command line, do nothing. */
|
||||
; /* Was set on command line, do nothing. */
|
||||
else if (server != NULL) {
|
||||
DO("get key for server", cfg_map_get(server, "key", &defkey));
|
||||
keyname = cfg_obj_asstring(defkey);
|
||||
} else if (options != NULL) {
|
||||
DO("get default key", cfg_map_get(options, "default-key",
|
||||
&defkey));
|
||||
DO("get default key",
|
||||
cfg_map_get(options, "default-key", &defkey));
|
||||
keyname = cfg_obj_asstring(defkey);
|
||||
} else if (!key_only)
|
||||
fatal("no key for server and no default");
|
||||
|
|
@ -655,10 +659,8 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
|
|||
DO("get key", cfg_map_get(config, "key", &key));
|
||||
else {
|
||||
DO("get config key list", cfg_map_get(config, "key", &keys));
|
||||
for (elt = cfg_list_first(keys);
|
||||
elt != NULL;
|
||||
elt = cfg_list_next(elt))
|
||||
{
|
||||
for (elt = cfg_list_first(keys); elt != NULL;
|
||||
elt = cfg_list_next(elt)) {
|
||||
key = cfg_listelt_value(elt);
|
||||
if (strcasecmp(cfg_obj_asstring(cfg_map_getname(key)),
|
||||
keyname) == 0)
|
||||
|
|
@ -701,7 +703,7 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
|
|||
* Find the port to connect to.
|
||||
*/
|
||||
if (remoteport != 0)
|
||||
; /* Was set on command line, do nothing. */
|
||||
; /* Was set on command line, do nothing. */
|
||||
else {
|
||||
if (server != NULL)
|
||||
(void)cfg_map_get(server, "port", &defport);
|
||||
|
|
@ -720,16 +722,14 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
|
|||
else
|
||||
result = ISC_R_NOTFOUND;
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
for (element = cfg_list_first(addresses);
|
||||
element != NULL;
|
||||
element = cfg_list_next(element))
|
||||
{
|
||||
for (element = cfg_list_first(addresses); element != NULL;
|
||||
element = cfg_list_next(element)) {
|
||||
isc_sockaddr_t sa;
|
||||
|
||||
address = cfg_listelt_value(element);
|
||||
if (!cfg_obj_issockaddr(address)) {
|
||||
unsigned int myport;
|
||||
const char *name;
|
||||
unsigned int myport;
|
||||
const char * name;
|
||||
const cfg_obj_t *obj;
|
||||
|
||||
obj = cfg_tuple_get(address, "name");
|
||||
|
|
@ -737,17 +737,18 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
|
|||
obj = cfg_tuple_get(address, "port");
|
||||
if (cfg_obj_isuint32(obj)) {
|
||||
myport = cfg_obj_asuint32(obj);
|
||||
if (myport > UINT16_MAX ||
|
||||
myport == 0)
|
||||
if (myport > UINT16_MAX || myport == 0)
|
||||
fatal("port %u out of range",
|
||||
myport);
|
||||
} else
|
||||
myport = remoteport;
|
||||
if (nserveraddrs < SERVERADDRS)
|
||||
get_addresses(name, (in_port_t) myport);
|
||||
get_addresses(name, (in_port_t)myport);
|
||||
else
|
||||
fprintf(stderr, "too many address: "
|
||||
"%s: dropped\n", name);
|
||||
fprintf(stderr,
|
||||
"too many address: "
|
||||
"%s: dropped\n",
|
||||
name);
|
||||
continue;
|
||||
}
|
||||
sa = *cfg_obj_assockaddr(address);
|
||||
|
|
@ -805,23 +806,24 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname,
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
bool show_final_mem = false;
|
||||
isc_taskmgr_t *taskmgr = NULL;
|
||||
isc_task_t *task = NULL;
|
||||
isc_log_t *log = NULL;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
bool show_final_mem = false;
|
||||
isc_taskmgr_t * taskmgr = NULL;
|
||||
isc_task_t * task = NULL;
|
||||
isc_log_t * log = NULL;
|
||||
isc_logconfig_t * logconfig = NULL;
|
||||
isc_logdestination_t logdest;
|
||||
cfg_parser_t *pctx = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
const char *keyname = NULL;
|
||||
struct in_addr in;
|
||||
struct in6_addr in6;
|
||||
char *p;
|
||||
size_t argslen;
|
||||
int ch;
|
||||
int i;
|
||||
cfg_parser_t * pctx = NULL;
|
||||
cfg_obj_t * config = NULL;
|
||||
const char * keyname = NULL;
|
||||
struct in_addr in;
|
||||
struct in6_addr in6;
|
||||
char * p;
|
||||
size_t argslen;
|
||||
int ch;
|
||||
int i;
|
||||
|
||||
result = isc_file_progname(*argv, program, sizeof(program));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
|
|
@ -857,8 +859,8 @@ main(int argc, char **argv) {
|
|||
isc_net_disableipv4();
|
||||
break;
|
||||
case 'b':
|
||||
if (inet_pton(AF_INET, isc_commandline_argument,
|
||||
&in) == 1) {
|
||||
if (inet_pton(AF_INET, isc_commandline_argument, &in) ==
|
||||
1) {
|
||||
isc_sockaddr_fromin(&local4, &in, 0);
|
||||
local4set = true;
|
||||
} else if (inet_pton(AF_INET6, isc_commandline_argument,
|
||||
|
|
@ -923,8 +925,8 @@ main(int argc, char **argv) {
|
|||
usage(0);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: unhandled option -%c\n",
|
||||
program, isc_commandline_option);
|
||||
fprintf(stderr, "%s: unhandled option -%c\n", program,
|
||||
isc_commandline_option);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -938,14 +940,14 @@ main(int argc, char **argv) {
|
|||
serial = isc_random32();
|
||||
|
||||
isc_mem_create(&rndc_mctx);
|
||||
DO("create socket manager", isc_socketmgr_create(rndc_mctx,
|
||||
&socketmgr));
|
||||
DO("create task manager", isc_taskmgr_create(rndc_mctx, 1, 0,
|
||||
NULL, &taskmgr));
|
||||
DO("create socket manager",
|
||||
isc_socketmgr_create(rndc_mctx, &socketmgr));
|
||||
DO("create task manager",
|
||||
isc_taskmgr_create(rndc_mctx, 1, 0, NULL, &taskmgr));
|
||||
DO("create task", isc_task_create(taskmgr, 0, &task));
|
||||
|
||||
DO("create logging context", isc_log_create(rndc_mctx, &log,
|
||||
&logconfig));
|
||||
DO("create logging context",
|
||||
isc_log_create(rndc_mctx, &log, &logconfig));
|
||||
isc_log_setcontext(log);
|
||||
DO("setting log tag", isc_log_settag(logconfig, progname));
|
||||
logdest.file.stream = stderr;
|
||||
|
|
@ -953,11 +955,11 @@ main(int argc, char **argv) {
|
|||
logdest.file.versions = ISC_LOG_ROLLNEVER;
|
||||
logdest.file.maximum_size = 0;
|
||||
DO("creating log channel",
|
||||
isc_log_createchannel(logconfig, "stderr",
|
||||
ISC_LOG_TOFILEDESC, ISC_LOG_INFO, &logdest,
|
||||
ISC_LOG_PRINTTAG|ISC_LOG_PRINTLEVEL));
|
||||
DO("enabling log channel", isc_log_usechannel(logconfig, "stderr",
|
||||
NULL, NULL));
|
||||
isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_INFO, &logdest,
|
||||
ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL));
|
||||
DO("enabling log channel",
|
||||
isc_log_usechannel(logconfig, "stderr", NULL, NULL));
|
||||
|
||||
parse_config(rndc_mctx, log, keyname, &pctx, &config);
|
||||
|
||||
|
|
@ -996,7 +998,7 @@ main(int argc, char **argv) {
|
|||
fatal("'%s' is not implemented", command);
|
||||
|
||||
if (nserveraddrs == 0)
|
||||
get_addresses(servername, (in_port_t) remoteport);
|
||||
get_addresses(servername, (in_port_t)remoteport);
|
||||
|
||||
DO("post event", isc_app_onrun(rndc_mctx, task, rndc_start, NULL));
|
||||
|
||||
|
|
@ -1006,8 +1008,7 @@ main(int argc, char **argv) {
|
|||
|
||||
if (atomic_load_acquire(&connects) > 0 ||
|
||||
atomic_load_acquire(&sends) > 0 ||
|
||||
atomic_load_acquire(&recvs) > 0)
|
||||
{
|
||||
atomic_load_acquire(&recvs) > 0) {
|
||||
isc_socket_cancel(sock, task, ISC_SOCKCANCEL_ALL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,23 +9,23 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
extern bool verbose;
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
|
||||
extern bool verbose;
|
||||
extern const char *progname;
|
||||
|
||||
void
|
||||
notify(const char *fmt, ...) {
|
||||
notify(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (verbose) {
|
||||
|
|
@ -37,7 +37,8 @@ notify(const char *fmt, ...) {
|
|||
}
|
||||
|
||||
void
|
||||
fatal(const char *format, ...) {
|
||||
fatal(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr, "%s: ", progname);
|
||||
|
|
|
|||
|
|
@ -9,27 +9,25 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef RNDC_UTIL_H
|
||||
#define RNDC_UTIL_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/formatcheck.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
#include <isc/formatcheck.h>
|
||||
|
||||
#define NS_CONTROL_PORT 953
|
||||
#define NS_CONTROL_PORT 953
|
||||
|
||||
#undef DO
|
||||
#define DO(name, function) \
|
||||
do { \
|
||||
result = function; \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
#define DO(name, function) \
|
||||
do { \
|
||||
result = function; \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
fatal("%s: %s", name, isc_result_totext(result)); \
|
||||
else \
|
||||
notify("%s", name); \
|
||||
else \
|
||||
notify("%s", name); \
|
||||
} while (0)
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
|
@ -39,7 +37,7 @@ notify(const char *fmt, ...) ISC_FORMAT_PRINTF(1, 2);
|
|||
|
||||
ISC_PLATFORM_NORETURN_PRE void
|
||||
fatal(const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <errno.h>
|
||||
|
|
@ -21,13 +20,14 @@
|
|||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/log.h>
|
||||
|
||||
#include <isccfg/grammar.h>
|
||||
#include <isccfg/namedconf.h>
|
||||
|
||||
#include <dns/log.h>
|
||||
|
||||
static void
|
||||
check_result(isc_result_t result, const char *format, ...) {
|
||||
check_result(isc_result_t result, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
|
|
@ -41,34 +41,37 @@ check_result(isc_result_t result, const char *format, ...) {
|
|||
}
|
||||
|
||||
static void
|
||||
output(void *closure, const char *text, int textlen) {
|
||||
output(void *closure, const char *text, int textlen)
|
||||
{
|
||||
UNUSED(closure);
|
||||
(void) fwrite(text, 1, textlen, stdout);
|
||||
(void)fwrite(text, 1, textlen, stdout);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void) {
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: cfg_test --rndc|--named "
|
||||
"[--grammar] [--zonegrammar] [--active] "
|
||||
"[--memstats] conffile\n");
|
||||
"[--grammar] [--zonegrammar] [--active] "
|
||||
"[--memstats] conffile\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
isc_result_t result;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_logconfig_t *lcfg = NULL;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_mem_t * mctx = NULL;
|
||||
isc_log_t * lctx = NULL;
|
||||
isc_logconfig_t * lcfg = NULL;
|
||||
isc_logdestination_t destination;
|
||||
cfg_parser_t *pctx = NULL;
|
||||
cfg_obj_t *cfg = NULL;
|
||||
cfg_type_t *type = NULL;
|
||||
bool grammar = false;
|
||||
bool memstats = false;
|
||||
char *filename = NULL;
|
||||
unsigned int zonetype = 0;
|
||||
unsigned int pflags = 0;
|
||||
cfg_parser_t * pctx = NULL;
|
||||
cfg_obj_t * cfg = NULL;
|
||||
cfg_type_t * type = NULL;
|
||||
bool grammar = false;
|
||||
bool memstats = false;
|
||||
char * filename = NULL;
|
||||
unsigned int zonetype = 0;
|
||||
unsigned int pflags = 0;
|
||||
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
|
|
@ -83,10 +86,9 @@ main(int argc, char **argv) {
|
|||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
result = isc_log_createchannel(lcfg, "_default",
|
||||
ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination, ISC_LOG_PRINTTIME);
|
||||
result = isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC, &destination,
|
||||
ISC_LOG_PRINTTIME);
|
||||
check_result(result, "isc_log_createchannel()");
|
||||
result = isc_log_usechannel(lcfg, "_default", NULL, NULL);
|
||||
check_result(result, "isc_log_usechannel()");
|
||||
|
|
@ -106,16 +108,14 @@ main(int argc, char **argv) {
|
|||
grammar = true;
|
||||
} else if (strcmp(argv[1], "--zonegrammar") == 0) {
|
||||
argv++, argc--;
|
||||
if (argc <= 1) {
|
||||
if (argc <= 1) {
|
||||
usage();
|
||||
}
|
||||
if (strcmp(argv[1], "master") == 0 ||
|
||||
strcmp(argv[1], "primary") == 0)
|
||||
{
|
||||
strcmp(argv[1], "primary") == 0) {
|
||||
zonetype = CFG_ZONE_MASTER;
|
||||
} else if (strcmp(argv[1], "slave") == 0 ||
|
||||
strcmp(argv[1], "seconary") == 0)
|
||||
{
|
||||
strcmp(argv[1], "seconary") == 0) {
|
||||
zonetype = CFG_ZONE_SLAVE;
|
||||
} else if (strcmp(argv[1], "mirror") == 0) {
|
||||
zonetype = CFG_ZONE_MIRROR;
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@
|
|||
/*! \file */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/hash.h>
|
||||
#include <isc/log.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/db.h>
|
||||
|
|
@ -23,17 +25,14 @@
|
|||
#include <dns/journal.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/name.h>
|
||||
#include <isc/print.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CHECK(r) \
|
||||
do { \
|
||||
result = (r); \
|
||||
#define CHECK(r) \
|
||||
do { \
|
||||
result = (r); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto cleanup; \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
isc_mem_t *mctx = NULL;
|
||||
|
|
@ -44,29 +43,28 @@ static bool dst_active = false;
|
|||
/*
|
||||
* Logging categories: this needs to match the list in bin/named/log.c.
|
||||
*/
|
||||
static isc_logcategory_t categories[] = {
|
||||
{ "", 0 },
|
||||
{ "client", 0 },
|
||||
{ "network", 0 },
|
||||
{ "update", 0 },
|
||||
{ "queries", 0 },
|
||||
{ "unmatched", 0 },
|
||||
{ "update-security", 0 },
|
||||
{ "query-errors", 0 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
static isc_logcategory_t categories[] = { { "", 0 },
|
||||
{ "client", 0 },
|
||||
{ "network", 0 },
|
||||
{ "update", 0 },
|
||||
{ "queries", 0 },
|
||||
{ "unmatched", 0 },
|
||||
{ "update-security", 0 },
|
||||
{ "query-errors", 0 },
|
||||
{ NULL, 0 } };
|
||||
|
||||
static isc_result_t
|
||||
loadzone(dns_db_t **db, const char *origin, const char *filename) {
|
||||
isc_result_t result;
|
||||
loadzone(dns_db_t **db, const char *origin, const char *filename)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_fixedname_t fixed;
|
||||
dns_name_t *name;
|
||||
dns_name_t * name;
|
||||
|
||||
name = dns_fixedname_initname(&fixed);
|
||||
|
||||
result = dns_name_fromstring(name, origin, 0, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return(result);
|
||||
return (result);
|
||||
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone,
|
||||
dns_rdataclass_in, 0, NULL, db);
|
||||
|
|
@ -78,12 +76,13 @@ loadzone(dns_db_t **db, const char *origin, const char *filename) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
isc_result_t result;
|
||||
char *origin, *file1, *file2, *journal;
|
||||
dns_db_t *olddb = NULL, *newdb = NULL;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result;
|
||||
char * origin, *file1, *file2, *journal;
|
||||
dns_db_t * olddb = NULL, *newdb = NULL;
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
isc_logconfig_t * logconfig = NULL;
|
||||
|
||||
if (argc != 5) {
|
||||
printf("usage: %s origin file1 file2 journal\n", argv[0]);
|
||||
|
|
@ -111,9 +110,8 @@ main(int argc, char **argv) {
|
|||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
CHECK(isc_log_createchannel(logconfig, "stderr",
|
||||
ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
|
||||
&destination, 0));
|
||||
CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC, &destination, 0));
|
||||
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
|
||||
|
||||
dns_result_register();
|
||||
|
|
@ -132,7 +130,7 @@ main(int argc, char **argv) {
|
|||
|
||||
result = dns_db_diff(mctx, newdb, NULL, olddb, NULL, journal);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fprintf(stderr, "%s\n", isc_result_totext(result));
|
||||
|
||||
|
|
@ -150,6 +148,5 @@ main(int argc, char **argv) {
|
|||
if (mctx != NULL)
|
||||
isc_mem_destroy(&mctx);
|
||||
|
||||
return(result != ISC_R_SUCCESS ? 1 : 0);
|
||||
return (result != ISC_R_SUCCESS ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,42 +26,43 @@
|
|||
|
||||
#include <dns/adb.h>
|
||||
#include <dns/cache.h>
|
||||
#include <dns/dispatch.h>
|
||||
#include <dns/db.h>
|
||||
#include <dns/dispatch.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/rootns.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/rootns.h>
|
||||
|
||||
typedef struct client client_t;
|
||||
struct client {
|
||||
dns_name_t name;
|
||||
const char *target;
|
||||
ISC_LINK(client_t) link;
|
||||
dns_adbfind_t *find;
|
||||
dns_name_t name;
|
||||
const char *target;
|
||||
ISC_LINK(client_t) link;
|
||||
dns_adbfind_t *find;
|
||||
};
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static isc_mempool_t *cmp;
|
||||
static isc_log_t *lctx;
|
||||
static isc_logconfig_t *lcfg;
|
||||
static isc_taskmgr_t *taskmgr;
|
||||
static isc_socketmgr_t *socketmgr;
|
||||
static isc_timermgr_t *timermgr;
|
||||
static isc_mem_t * mctx = NULL;
|
||||
static isc_mempool_t * cmp;
|
||||
static isc_log_t * lctx;
|
||||
static isc_logconfig_t * lcfg;
|
||||
static isc_taskmgr_t * taskmgr;
|
||||
static isc_socketmgr_t * socketmgr;
|
||||
static isc_timermgr_t * timermgr;
|
||||
static dns_dispatchmgr_t *dispatchmgr;
|
||||
static isc_task_t *t1, *t2;
|
||||
static dns_view_t *view;
|
||||
static dns_db_t *rootdb;
|
||||
static isc_task_t * t1, *t2;
|
||||
static dns_view_t * view;
|
||||
static dns_db_t * rootdb;
|
||||
static ISC_LIST(client_t) clients;
|
||||
static isc_mutex_t client_lock;
|
||||
static isc_mutex_t client_lock;
|
||||
static isc_stdtime_t now;
|
||||
static dns_adb_t *adb;
|
||||
static dns_adb_t * adb;
|
||||
|
||||
static void
|
||||
check_result(isc_result_t result, const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(2, 3);
|
||||
ISC_FORMAT_PRINTF(2, 3);
|
||||
|
||||
static void
|
||||
check_result(isc_result_t result, const char *format, ...) {
|
||||
check_result(isc_result_t result, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
|
|
@ -75,7 +76,8 @@ check_result(isc_result_t result, const char *format, ...) {
|
|||
}
|
||||
|
||||
static client_t *
|
||||
new_client(void) {
|
||||
new_client(void)
|
||||
{
|
||||
client_t *client;
|
||||
|
||||
client = isc_mempool_get(cmp);
|
||||
|
|
@ -88,7 +90,8 @@ new_client(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
free_client(client_t **c) {
|
||||
free_client(client_t **c)
|
||||
{
|
||||
client_t *client;
|
||||
|
||||
INSIST(c != NULL);
|
||||
|
|
@ -103,25 +106,28 @@ free_client(client_t **c) {
|
|||
}
|
||||
|
||||
static inline void
|
||||
CLOCK(void) {
|
||||
CLOCK(void)
|
||||
{
|
||||
RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static inline void
|
||||
CUNLOCK(void) {
|
||||
CUNLOCK(void)
|
||||
{
|
||||
RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
lookup_callback(isc_task_t *task, isc_event_t *ev) {
|
||||
lookup_callback(isc_task_t *task, isc_event_t *ev)
|
||||
{
|
||||
client_t *client;
|
||||
|
||||
client = ev->ev_arg;
|
||||
INSIST(client->find == ev->ev_sender);
|
||||
|
||||
printf("NAME %s:\n\tTask %p got event %p type %08x from %p, client %p\n\terr4: %s err6: %s\n",
|
||||
client->target,
|
||||
task, ev, ev->ev_type, client->find, client,
|
||||
printf("NAME %s:\n\tTask %p got event %p type %08x from %p, client "
|
||||
"%p\n\terr4: %s err6: %s\n",
|
||||
client->target, task, ev, ev->ev_type, client->find, client,
|
||||
isc_result_totext(client->find->result_v4),
|
||||
isc_result_totext(client->find->result_v6));
|
||||
|
||||
|
|
@ -140,7 +146,8 @@ lookup_callback(isc_task_t *task, isc_event_t *ev) {
|
|||
}
|
||||
|
||||
static void
|
||||
create_managers(void) {
|
||||
create_managers(void)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
taskmgr = NULL;
|
||||
|
|
@ -161,7 +168,8 @@ create_managers(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
create_view(void) {
|
||||
create_view(void)
|
||||
{
|
||||
dns_cache_t *cache;
|
||||
isc_result_t result;
|
||||
|
||||
|
|
@ -184,8 +192,8 @@ create_view(void) {
|
|||
dns_cache_detach(&cache);
|
||||
|
||||
{
|
||||
unsigned int attrs;
|
||||
isc_sockaddr_t any4, any6;
|
||||
unsigned int attrs;
|
||||
isc_sockaddr_t any4, any6;
|
||||
dns_dispatch_t *disp4 = NULL;
|
||||
dns_dispatch_t *disp6 = NULL;
|
||||
|
||||
|
|
@ -194,26 +202,22 @@ create_view(void) {
|
|||
|
||||
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
|
||||
RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, socketmgr,
|
||||
taskmgr, &any4,
|
||||
512, 6, 1024, 17, 19,
|
||||
attrs, attrs, &disp4)
|
||||
== ISC_R_SUCCESS);
|
||||
taskmgr, &any4, 512, 6, 1024,
|
||||
17, 19, attrs, attrs,
|
||||
&disp4) == ISC_R_SUCCESS);
|
||||
INSIST(disp4 != NULL);
|
||||
|
||||
attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP;
|
||||
RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr, socketmgr,
|
||||
taskmgr, &any6,
|
||||
512, 6, 1024, 17, 19,
|
||||
attrs, attrs, &disp6)
|
||||
== ISC_R_SUCCESS);
|
||||
taskmgr, &any6, 512, 6, 1024,
|
||||
17, 19, attrs, attrs,
|
||||
&disp6) == ISC_R_SUCCESS);
|
||||
INSIST(disp6 != NULL);
|
||||
|
||||
RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10, 1,
|
||||
socketmgr,
|
||||
timermgr, 0,
|
||||
dispatchmgr,
|
||||
disp4, disp6) ==
|
||||
ISC_R_SUCCESS);
|
||||
socketmgr, timermgr, 0,
|
||||
dispatchmgr, disp4,
|
||||
disp6) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
rootdb = NULL;
|
||||
|
|
@ -226,13 +230,14 @@ create_view(void) {
|
|||
}
|
||||
|
||||
static void
|
||||
lookup(const char *target) {
|
||||
dns_name_t name;
|
||||
lookup(const char *target)
|
||||
{
|
||||
dns_name_t name;
|
||||
unsigned char namedata[256];
|
||||
client_t *client;
|
||||
isc_buffer_t t, namebuf;
|
||||
isc_result_t result;
|
||||
unsigned int options;
|
||||
client_t * client;
|
||||
isc_buffer_t t, namebuf;
|
||||
isc_result_t result;
|
||||
unsigned int options;
|
||||
|
||||
INSIST(target != NULL);
|
||||
|
||||
|
|
@ -252,10 +257,9 @@ lookup(const char *target) {
|
|||
options |= DNS_ADBFIND_WANTEVENT;
|
||||
options |= DNS_ADBFIND_HINTOK;
|
||||
options |= DNS_ADBFIND_GLUEOK;
|
||||
result = dns_adb_createfind(adb, t2, lookup_callback, client,
|
||||
&client->name, dns_rootname, 0, options,
|
||||
now, NULL, view->dstport, 0, NULL,
|
||||
&client->find);
|
||||
result = dns_adb_createfind(
|
||||
adb, t2, lookup_callback, client, &client->name, dns_rootname,
|
||||
0, options, now, NULL, view->dstport, 0, NULL, &client->find);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
printf("DNS_ADB_CREATEFIND -> %s\n", dns_result_totext(result));
|
||||
dns_adb_dumpfind(client->find, stderr);
|
||||
|
|
@ -264,8 +268,8 @@ lookup(const char *target) {
|
|||
client->target = target;
|
||||
ISC_LIST_APPEND(clients, client, link);
|
||||
} else {
|
||||
printf("NAME %s: err4 %s, err6 %s\n",
|
||||
target, isc_result_totext(client->find->result_v4),
|
||||
printf("NAME %s: err4 %s, err6 %s\n", target,
|
||||
isc_result_totext(client->find->result_v4),
|
||||
isc_result_totext(client->find->result_v6));
|
||||
|
||||
dns_adb_destroyfind(&client->find);
|
||||
|
|
@ -274,8 +278,9 @@ lookup(const char *target) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
isc_result_t result;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_logdestination_t destination;
|
||||
|
||||
UNUSED(argc);
|
||||
|
|
@ -297,8 +302,7 @@ main(int argc, char **argv) {
|
|||
isc_mem_create(&mctx);
|
||||
|
||||
cmp = NULL;
|
||||
isc_mempool_create(mctx, sizeof(client_t), &cmp)
|
||||
;
|
||||
isc_mempool_create(mctx, sizeof(client_t), &cmp);
|
||||
isc_mempool_setname(cmp, "adb test clients");
|
||||
|
||||
result = isc_log_create(mctx, &lctx, &lcfg);
|
||||
|
|
@ -314,10 +318,9 @@ main(int argc, char **argv) {
|
|||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
result = isc_log_createchannel(lcfg, "_default",
|
||||
ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination, ISC_LOG_PRINTTIME);
|
||||
result = isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC, &destination,
|
||||
ISC_LOG_PRINTTIME);
|
||||
check_result(result, "isc_log_createchannel()");
|
||||
result = isc_log_usechannel(lcfg, "_default", NULL, NULL);
|
||||
check_result(result, "isc_log_usechannel()");
|
||||
|
|
@ -348,17 +351,17 @@ main(int argc, char **argv) {
|
|||
* for found names to block as well.
|
||||
*/
|
||||
CLOCK();
|
||||
lookup("f.root-servers.net."); /* Should be in hints */
|
||||
lookup("www.iengines.com"); /* should fetch */
|
||||
lookup("www.isc.org"); /* should fetch */
|
||||
lookup("www.flame.org"); /* should fetch */
|
||||
lookup("kechara.flame.org."); /* should fetch */
|
||||
lookup("moghedien.flame.org."); /* should fetch */
|
||||
lookup("mailrelay.flame.org."); /* should fetch */
|
||||
lookup("ipv4v6.flame.org."); /* should fetch */
|
||||
lookup("nonexistant.flame.org."); /* should fail to be found */
|
||||
lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */
|
||||
lookup("i.root-servers.net."); /* Should be in hints */
|
||||
lookup("f.root-servers.net."); /* Should be in hints */
|
||||
lookup("www.iengines.com"); /* should fetch */
|
||||
lookup("www.isc.org"); /* should fetch */
|
||||
lookup("www.flame.org"); /* should fetch */
|
||||
lookup("kechara.flame.org."); /* should fetch */
|
||||
lookup("moghedien.flame.org."); /* should fetch */
|
||||
lookup("mailrelay.flame.org."); /* should fetch */
|
||||
lookup("ipv4v6.flame.org."); /* should fetch */
|
||||
lookup("nonexistant.flame.org."); /* should fail to be found */
|
||||
lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */
|
||||
lookup("i.root-servers.net."); /* Should be in hints */
|
||||
lookup("www.firstcard.com.");
|
||||
lookup("dns04.flame.org.");
|
||||
CUNLOCK();
|
||||
|
|
@ -370,17 +373,17 @@ main(int argc, char **argv) {
|
|||
sleep(10);
|
||||
|
||||
CLOCK();
|
||||
lookup("f.root-servers.net."); /* Should be in hints */
|
||||
lookup("www.iengines.com"); /* should fetch */
|
||||
lookup("www.isc.org"); /* should fetch */
|
||||
lookup("www.flame.org"); /* should fetch */
|
||||
lookup("kechara.flame.org."); /* should fetch */
|
||||
lookup("moghedien.flame.org."); /* should fetch */
|
||||
lookup("mailrelay.flame.org."); /* should fetch */
|
||||
lookup("ipv4v6.flame.org."); /* should fetch */
|
||||
lookup("nonexistant.flame.org."); /* should fail to be found */
|
||||
lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */
|
||||
lookup("i.root-servers.net."); /* Should be in hints */
|
||||
lookup("f.root-servers.net."); /* Should be in hints */
|
||||
lookup("www.iengines.com"); /* should fetch */
|
||||
lookup("www.isc.org"); /* should fetch */
|
||||
lookup("www.flame.org"); /* should fetch */
|
||||
lookup("kechara.flame.org."); /* should fetch */
|
||||
lookup("moghedien.flame.org."); /* should fetch */
|
||||
lookup("mailrelay.flame.org."); /* should fetch */
|
||||
lookup("ipv4v6.flame.org."); /* should fetch */
|
||||
lookup("nonexistant.flame.org."); /* should fail to be found */
|
||||
lookup("foobar.badns.flame.org."); /* should fail utterly (NS) */
|
||||
lookup("i.root-servers.net."); /* Should be in hints */
|
||||
CUNLOCK();
|
||||
|
||||
sleep(20);
|
||||
|
|
|
|||
|
|
@ -16,20 +16,16 @@
|
|||
#include <isc/print.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
const char *expected_symbols[] = {
|
||||
"func3",
|
||||
"func2",
|
||||
"func1",
|
||||
"main"
|
||||
};
|
||||
const char *expected_symbols[] = { "func3", "func2", "func1", "main" };
|
||||
|
||||
static int
|
||||
func3() {
|
||||
void *tracebuf[16];
|
||||
int i, nframes;
|
||||
int error = 0;
|
||||
const char *fname;
|
||||
isc_result_t result;
|
||||
func3()
|
||||
{
|
||||
void * tracebuf[16];
|
||||
int i, nframes;
|
||||
int error = 0;
|
||||
const char * fname;
|
||||
isc_result_t result;
|
||||
unsigned long offset;
|
||||
|
||||
result = isc_backtrace_gettrace(tracebuf, 16, &nframes);
|
||||
|
|
@ -74,16 +70,19 @@ func3() {
|
|||
}
|
||||
|
||||
static int
|
||||
func2() {
|
||||
func2()
|
||||
{
|
||||
return (func3());
|
||||
}
|
||||
|
||||
static int
|
||||
func1() {
|
||||
func1()
|
||||
{
|
||||
return (func2());
|
||||
}
|
||||
|
||||
int
|
||||
main() {
|
||||
main()
|
||||
{
|
||||
return (func1());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,22 +34,21 @@
|
|||
#include <dns/view.h>
|
||||
|
||||
static void
|
||||
done(isc_task_t *task, isc_event_t *event) {
|
||||
done(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
dns_byaddrevent_t *bevent;
|
||||
dns_byaddr_t *byaddr;
|
||||
dns_name_t *name;
|
||||
dns_byaddr_t * byaddr;
|
||||
dns_name_t * name;
|
||||
|
||||
REQUIRE(event->ev_type == DNS_EVENT_BYADDRDONE);
|
||||
bevent = (dns_byaddrevent_t *)event;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
printf("byaddr event result = %s\n",
|
||||
isc_result_totext(bevent->result));
|
||||
printf("byaddr event result = %s\n", isc_result_totext(bevent->result));
|
||||
|
||||
if (bevent->result == ISC_R_SUCCESS) {
|
||||
for (name = ISC_LIST_HEAD(bevent->names);
|
||||
name != NULL;
|
||||
for (name = ISC_LIST_HEAD(bevent->names); name != NULL;
|
||||
name = ISC_LIST_NEXT(name, link)) {
|
||||
char text[DNS_NAME_FORMATSIZE];
|
||||
dns_name_format(name, text, sizeof(text));
|
||||
|
|
@ -65,22 +64,23 @@ done(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_mem_t *mctx;
|
||||
bool verbose = false;
|
||||
unsigned int workers = 2;
|
||||
isc_taskmgr_t *taskmgr;
|
||||
isc_task_t *task;
|
||||
isc_timermgr_t *timermgr;
|
||||
dns_view_t *view;
|
||||
int ch;
|
||||
isc_socketmgr_t *socketmgr;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_mem_t * mctx;
|
||||
bool verbose = false;
|
||||
unsigned int workers = 2;
|
||||
isc_taskmgr_t * taskmgr;
|
||||
isc_task_t * task;
|
||||
isc_timermgr_t * timermgr;
|
||||
dns_view_t * view;
|
||||
int ch;
|
||||
isc_socketmgr_t * socketmgr;
|
||||
dns_dispatchmgr_t *dispatchmgr;
|
||||
isc_netaddr_t na;
|
||||
dns_byaddr_t *byaddr;
|
||||
isc_result_t result;
|
||||
unsigned int options = 0;
|
||||
dns_cache_t *cache;
|
||||
isc_netaddr_t na;
|
||||
dns_byaddr_t * byaddr;
|
||||
isc_result_t result;
|
||||
unsigned int options = 0;
|
||||
dns_cache_t * cache;
|
||||
|
||||
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
|
||||
|
||||
|
|
@ -112,16 +112,15 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
taskmgr = NULL;
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL, &taskmgr)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL, &taskmgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
task = NULL;
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) == ISC_R_SUCCESS);
|
||||
isc_task_setname(task, "byaddr", NULL);
|
||||
|
||||
dispatchmgr = NULL;
|
||||
RUNTIME_CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
timermgr = NULL;
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
|
||||
|
|
@ -138,7 +137,7 @@ main(int argc, char *argv[]) {
|
|||
&view) == ISC_R_SUCCESS);
|
||||
|
||||
{
|
||||
unsigned int attrs;
|
||||
unsigned int attrs;
|
||||
dns_dispatch_t *disp4 = NULL;
|
||||
dns_dispatch_t *disp6 = NULL;
|
||||
|
||||
|
|
@ -148,13 +147,11 @@ main(int argc, char *argv[]) {
|
|||
isc_sockaddr_any(&any4);
|
||||
|
||||
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
|
||||
RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr,
|
||||
socketmgr,
|
||||
taskmgr, &any4,
|
||||
512, 6, 1024,
|
||||
17, 19, attrs,
|
||||
attrs, &disp4)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(
|
||||
dns_dispatch_getudp(dispatchmgr, socketmgr,
|
||||
taskmgr, &any4, 512, 6,
|
||||
1024, 17, 19, attrs, attrs,
|
||||
&disp4) == ISC_R_SUCCESS);
|
||||
INSIST(disp4 != NULL);
|
||||
}
|
||||
|
||||
|
|
@ -164,32 +161,28 @@ main(int argc, char *argv[]) {
|
|||
isc_sockaddr_any6(&any6);
|
||||
|
||||
attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP;
|
||||
RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr,
|
||||
socketmgr,
|
||||
taskmgr, &any6,
|
||||
512, 6, 1024,
|
||||
17, 19, attrs,
|
||||
attrs, &disp6)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(
|
||||
dns_dispatch_getudp(dispatchmgr, socketmgr,
|
||||
taskmgr, &any6, 512, 6,
|
||||
1024, 17, 19, attrs, attrs,
|
||||
&disp6) == ISC_R_SUCCESS);
|
||||
INSIST(disp6 != NULL);
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10, 1,
|
||||
socketmgr,
|
||||
timermgr, 0,
|
||||
dispatchmgr,
|
||||
disp4, disp6) ==
|
||||
ISC_R_SUCCESS);
|
||||
socketmgr, timermgr, 0,
|
||||
dispatchmgr, disp4,
|
||||
disp6) == ISC_R_SUCCESS);
|
||||
|
||||
if (disp4 != NULL)
|
||||
dns_dispatch_detach(&disp4);
|
||||
dns_dispatch_detach(&disp4);
|
||||
if (disp6 != NULL)
|
||||
dns_dispatch_detach(&disp6);
|
||||
dns_dispatch_detach(&disp6);
|
||||
}
|
||||
|
||||
{
|
||||
struct in_addr ina;
|
||||
isc_sockaddr_t sa;
|
||||
struct in_addr ina;
|
||||
isc_sockaddr_t sa;
|
||||
isc_sockaddrlist_t sal;
|
||||
|
||||
ISC_LIST_INIT(sal);
|
||||
|
|
@ -198,8 +191,8 @@ main(int argc, char *argv[]) {
|
|||
ISC_LIST_APPEND(sal, &sa, link);
|
||||
|
||||
RUNTIME_CHECK(dns_fwdtable_add(view->fwdtable, dns_rootname,
|
||||
&sal, dns_fwdpolicy_only)
|
||||
== ISC_R_SUCCESS);
|
||||
&sal, dns_fwdpolicy_only) ==
|
||||
ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
dns_view_setcache(view, cache, false);
|
||||
|
|
@ -219,8 +212,8 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
result = dns_byaddr_create(mctx, &na, view, options, task,
|
||||
done, NULL, &byaddr);
|
||||
result = dns_byaddr_create(mctx, &na, view, options, task, done, NULL,
|
||||
&byaddr);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
printf("dns_byaddr_create() returned %s\n",
|
||||
isc_result_totext(result));
|
||||
|
|
|
|||
|
|
@ -34,23 +34,25 @@
|
|||
#include <dns/resolver.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static isc_taskmgr_t *taskmgr;
|
||||
static dns_view_t *view = NULL;
|
||||
static dns_adbfind_t *find = NULL;
|
||||
static isc_task_t *task = NULL;
|
||||
static dns_fixedname_t fixed;
|
||||
static dns_fixedname_t target;
|
||||
static isc_log_t *lctx;
|
||||
static isc_mem_t * mctx = NULL;
|
||||
static isc_taskmgr_t * taskmgr;
|
||||
static dns_view_t * view = NULL;
|
||||
static dns_adbfind_t * find = NULL;
|
||||
static isc_task_t * task = NULL;
|
||||
static dns_fixedname_t fixed;
|
||||
static dns_fixedname_t target;
|
||||
static isc_log_t * lctx;
|
||||
static isc_logconfig_t *lcfg;
|
||||
static unsigned int level = 0;
|
||||
|
||||
static void adb_callback(isc_task_t *task, isc_event_t *event);
|
||||
static unsigned int level = 0;
|
||||
|
||||
static void
|
||||
log_init(void) {
|
||||
adb_callback(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
static void
|
||||
log_init(void)
|
||||
{
|
||||
isc_logdestination_t destination;
|
||||
unsigned int flags;
|
||||
unsigned int flags;
|
||||
|
||||
/*
|
||||
* Setup a logging context.
|
||||
|
|
@ -69,24 +71,23 @@ log_init(void) {
|
|||
destination.file.maximum_size = 0;
|
||||
flags = ISC_LOG_PRINTTIME;
|
||||
RUNTIME_CHECK(isc_log_createchannel(lcfg, "_default",
|
||||
ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination, flags) ==
|
||||
ISC_R_SUCCESS);
|
||||
ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
|
||||
&destination,
|
||||
flags) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL) ==
|
||||
ISC_R_SUCCESS);
|
||||
isc_log_setdebuglevel(lctx, level);
|
||||
}
|
||||
|
||||
static void
|
||||
print_addresses(dns_adbfind_t *adbfind) {
|
||||
print_addresses(dns_adbfind_t *adbfind)
|
||||
{
|
||||
dns_adbaddrinfo_t *address;
|
||||
|
||||
for (address = ISC_LIST_HEAD(adbfind->list);
|
||||
address != NULL;
|
||||
for (address = ISC_LIST_HEAD(adbfind->list); address != NULL;
|
||||
address = ISC_LIST_NEXT(address, publink)) {
|
||||
isc_netaddr_t netaddr;
|
||||
char text[ISC_NETADDR_FORMATSIZE];
|
||||
char text[ISC_NETADDR_FORMATSIZE];
|
||||
isc_netaddr_fromsockaddr(&netaddr, &address->sockaddr);
|
||||
isc_netaddr_format(&netaddr, text, sizeof(text));
|
||||
printf("%s\n", text);
|
||||
|
|
@ -94,7 +95,8 @@ print_addresses(dns_adbfind_t *adbfind) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_name(dns_name_t *name) {
|
||||
print_name(dns_name_t *name)
|
||||
{
|
||||
char text[DNS_NAME_FORMATSIZE];
|
||||
|
||||
dns_name_format(name, text, sizeof(text));
|
||||
|
|
@ -102,9 +104,10 @@ print_name(dns_name_t *name) {
|
|||
}
|
||||
|
||||
static void
|
||||
do_find(bool want_event) {
|
||||
do_find(bool want_event)
|
||||
{
|
||||
isc_result_t result;
|
||||
bool done = false;
|
||||
bool done = false;
|
||||
unsigned int options;
|
||||
|
||||
options = DNS_ADBFIND_INET | DNS_ADBFIND_INET6;
|
||||
|
|
@ -112,9 +115,8 @@ do_find(bool want_event) {
|
|||
options |= DNS_ADBFIND_WANTEVENT | DNS_ADBFIND_EMPTYEVENT;
|
||||
dns_fixedname_init(&target);
|
||||
result = dns_adb_createfind(view->adb, task, adb_callback, NULL,
|
||||
dns_fixedname_name(&fixed),
|
||||
dns_rootname, 0, options, 0,
|
||||
dns_fixedname_name(&target), 0,
|
||||
dns_fixedname_name(&fixed), dns_rootname, 0,
|
||||
options, 0, dns_fixedname_name(&target), 0,
|
||||
0, NULL, &find);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (!ISC_LIST_EMPTY(find->list)) {
|
||||
|
|
@ -159,7 +161,8 @@ do_find(bool want_event) {
|
|||
}
|
||||
|
||||
static void
|
||||
adb_callback(isc_task_t *etask, isc_event_t *event) {
|
||||
adb_callback(isc_task_t *etask, isc_event_t *event)
|
||||
{
|
||||
unsigned int type = event->ev_type;
|
||||
|
||||
REQUIRE(etask == task);
|
||||
|
|
@ -179,22 +182,24 @@ adb_callback(isc_task_t *etask, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
run(isc_task_t *xtask, isc_event_t *event) {
|
||||
run(isc_task_t *xtask, isc_event_t *event)
|
||||
{
|
||||
UNUSED(xtask);
|
||||
do_find(true);
|
||||
isc_event_free(&event);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
bool verbose = false;
|
||||
unsigned int workers = 2;
|
||||
isc_timermgr_t *timermgr;
|
||||
int ch;
|
||||
isc_socketmgr_t *socketmgr;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
bool verbose = false;
|
||||
unsigned int workers = 2;
|
||||
isc_timermgr_t * timermgr;
|
||||
int ch;
|
||||
isc_socketmgr_t * socketmgr;
|
||||
dns_dispatchmgr_t *dispatchmgr;
|
||||
dns_cache_t *cache;
|
||||
isc_buffer_t b;
|
||||
dns_cache_t * cache;
|
||||
isc_buffer_t b;
|
||||
|
||||
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
|
||||
|
||||
|
|
@ -229,13 +234,12 @@ main(int argc, char *argv[]) {
|
|||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL, &taskmgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
task = NULL;
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) == ISC_R_SUCCESS);
|
||||
isc_task_setname(task, "byname", NULL);
|
||||
|
||||
dispatchmgr = NULL;
|
||||
RUNTIME_CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
timermgr = NULL;
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
|
||||
|
|
@ -252,7 +256,7 @@ main(int argc, char *argv[]) {
|
|||
&view) == ISC_R_SUCCESS);
|
||||
|
||||
{
|
||||
unsigned int attrs;
|
||||
unsigned int attrs;
|
||||
dns_dispatch_t *disp4 = NULL;
|
||||
dns_dispatch_t *disp6 = NULL;
|
||||
|
||||
|
|
@ -261,13 +265,11 @@ main(int argc, char *argv[]) {
|
|||
isc_sockaddr_any(&any4);
|
||||
|
||||
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
|
||||
RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr,
|
||||
socketmgr,
|
||||
taskmgr, &any4,
|
||||
512, 6, 1024,
|
||||
17, 19, attrs,
|
||||
attrs, &disp4)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(
|
||||
dns_dispatch_getudp(dispatchmgr, socketmgr,
|
||||
taskmgr, &any4, 512, 6,
|
||||
1024, 17, 19, attrs, attrs,
|
||||
&disp4) == ISC_R_SUCCESS);
|
||||
INSIST(disp4 != NULL);
|
||||
}
|
||||
|
||||
|
|
@ -277,22 +279,18 @@ main(int argc, char *argv[]) {
|
|||
isc_sockaddr_any6(&any6);
|
||||
|
||||
attrs = DNS_DISPATCHATTR_IPV6 | DNS_DISPATCHATTR_UDP;
|
||||
RUNTIME_CHECK(dns_dispatch_getudp(dispatchmgr,
|
||||
socketmgr,
|
||||
taskmgr, &any6,
|
||||
512, 6, 1024,
|
||||
17, 19, attrs,
|
||||
attrs, &disp6)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(
|
||||
dns_dispatch_getudp(dispatchmgr, socketmgr,
|
||||
taskmgr, &any6, 512, 6,
|
||||
1024, 17, 19, attrs, attrs,
|
||||
&disp6) == ISC_R_SUCCESS);
|
||||
INSIST(disp6 != NULL);
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(dns_view_createresolver(view, taskmgr, 10, 1,
|
||||
socketmgr,
|
||||
timermgr, 0,
|
||||
dispatchmgr,
|
||||
disp4, disp6) ==
|
||||
ISC_R_SUCCESS);
|
||||
socketmgr, timermgr, 0,
|
||||
dispatchmgr, disp4,
|
||||
disp6) == ISC_R_SUCCESS);
|
||||
|
||||
if (disp4 != NULL)
|
||||
dns_dispatch_detach(&disp4);
|
||||
|
|
@ -301,8 +299,8 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
{
|
||||
struct in_addr ina;
|
||||
isc_sockaddr_t sa;
|
||||
struct in_addr ina;
|
||||
isc_sockaddr_t sa;
|
||||
isc_sockaddrlist_t sal;
|
||||
|
||||
ISC_LIST_INIT(sal);
|
||||
|
|
@ -311,8 +309,8 @@ main(int argc, char *argv[]) {
|
|||
ISC_LIST_APPEND(sal, &sa, link);
|
||||
|
||||
RUNTIME_CHECK(dns_fwdtable_add(view->fwdtable, dns_rootname,
|
||||
&sal, dns_fwdpolicy_only)
|
||||
== ISC_R_SUCCESS);
|
||||
&sal, dns_fwdpolicy_only) ==
|
||||
ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
dns_view_setcache(view, cache, false);
|
||||
|
|
@ -327,8 +325,8 @@ main(int argc, char *argv[]) {
|
|||
dns_fixedname_init(&fixed);
|
||||
dns_fixedname_init(&target);
|
||||
RUNTIME_CHECK(dns_name_fromtext(dns_fixedname_name(&fixed), &b,
|
||||
dns_rootname, 0, NULL) ==
|
||||
ISC_R_SUCCESS);
|
||||
dns_rootname, 0,
|
||||
NULL) == ISC_R_SUCCESS);
|
||||
|
||||
RUNTIME_CHECK(isc_app_onrun(mctx, task, run, NULL) == ISC_R_SUCCESS);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
#include <isc/log.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/db.h>
|
||||
|
|
@ -33,35 +33,35 @@
|
|||
#include <dns/rdatasetiter.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
#define MAXHOLD 100
|
||||
#define MAXVERSIONS 100
|
||||
#define MAXHOLD 100
|
||||
#define MAXVERSIONS 100
|
||||
|
||||
typedef struct dbinfo {
|
||||
dns_db_t * db;
|
||||
dns_dbversion_t * version;
|
||||
dns_dbversion_t * wversion;
|
||||
dns_dbversion_t * rversions[MAXVERSIONS];
|
||||
int rcount;
|
||||
dns_dbnode_t * hold_nodes[MAXHOLD];
|
||||
int hold_count;
|
||||
dns_dbiterator_t * dbiterator;
|
||||
dns_dbversion_t * iversion;
|
||||
int pause_every;
|
||||
bool ascending;
|
||||
ISC_LINK(struct dbinfo) link;
|
||||
dns_db_t * db;
|
||||
dns_dbversion_t * version;
|
||||
dns_dbversion_t * wversion;
|
||||
dns_dbversion_t * rversions[MAXVERSIONS];
|
||||
int rcount;
|
||||
dns_dbnode_t * hold_nodes[MAXHOLD];
|
||||
int hold_count;
|
||||
dns_dbiterator_t *dbiterator;
|
||||
dns_dbversion_t * iversion;
|
||||
int pause_every;
|
||||
bool ascending;
|
||||
ISC_LINK(struct dbinfo) link;
|
||||
} dbinfo;
|
||||
|
||||
static isc_mem_t * mctx = NULL;
|
||||
static char dbtype[128];
|
||||
static dns_dbtable_t * dbtable;
|
||||
static ISC_LIST(dbinfo) dbs;
|
||||
static dbinfo * cache_dbi = NULL;
|
||||
static int pause_every = 0;
|
||||
static bool ascending = true;
|
||||
static isc_mem_t * mctx = NULL;
|
||||
static char dbtype[128];
|
||||
static dns_dbtable_t *dbtable;
|
||||
static ISC_LIST(dbinfo) dbs;
|
||||
static dbinfo *cache_dbi = NULL;
|
||||
static int pause_every = 0;
|
||||
static bool ascending = true;
|
||||
|
||||
static void
|
||||
print_result(const char *message, isc_result_t result) {
|
||||
|
||||
print_result(const char *message, isc_result_t result)
|
||||
{
|
||||
if (message == NULL)
|
||||
message = "";
|
||||
printf("%s%sresult %08x: %s\n", message, (*message == '\0') ? "" : " ",
|
||||
|
|
@ -69,15 +69,15 @@ print_result(const char *message, isc_result_t result) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) {
|
||||
print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset)
|
||||
{
|
||||
isc_buffer_t text;
|
||||
char t[1000];
|
||||
char t[1000];
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
|
||||
isc_buffer_init(&text, t, sizeof(t));
|
||||
result = dns_rdataset_totext(rdataset, name, false, false,
|
||||
&text);
|
||||
result = dns_rdataset_totext(rdataset, name, false, false, &text);
|
||||
isc_buffer_usedregion(&text, &r);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
printf("%.*s", (int)r.length, (char *)r.base);
|
||||
|
|
@ -86,8 +86,9 @@ print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_rdatasets(dns_name_t *name, dns_rdatasetiter_t *rdsiter) {
|
||||
isc_result_t result;
|
||||
print_rdatasets(dns_name_t *name, dns_rdatasetiter_t *rdsiter)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdataset_t rdataset;
|
||||
|
||||
dns_rdataset_init(&rdataset);
|
||||
|
|
@ -103,13 +104,14 @@ print_rdatasets(dns_name_t *name, dns_rdatasetiter_t *rdsiter) {
|
|||
}
|
||||
|
||||
static dbinfo *
|
||||
select_db(char *origintext) {
|
||||
select_db(char *origintext)
|
||||
{
|
||||
dns_fixedname_t forigin;
|
||||
dns_name_t *origin;
|
||||
isc_buffer_t source;
|
||||
size_t len;
|
||||
dbinfo *dbi;
|
||||
isc_result_t result;
|
||||
dns_name_t * origin;
|
||||
isc_buffer_t source;
|
||||
size_t len;
|
||||
dbinfo * dbi;
|
||||
isc_result_t result;
|
||||
|
||||
if (strcasecmp(origintext, "cache") == 0) {
|
||||
if (cache_dbi == NULL)
|
||||
|
|
@ -126,8 +128,7 @@ select_db(char *origintext) {
|
|||
return (NULL);
|
||||
}
|
||||
|
||||
for (dbi = ISC_LIST_HEAD(dbs);
|
||||
dbi != NULL;
|
||||
for (dbi = ISC_LIST_HEAD(dbs); dbi != NULL;
|
||||
dbi = ISC_LIST_NEXT(dbi, link)) {
|
||||
if (dns_name_compare(dns_db_origin(dbi->db), origin) == 0)
|
||||
break;
|
||||
|
|
@ -137,17 +138,18 @@ select_db(char *origintext) {
|
|||
}
|
||||
|
||||
static void
|
||||
list(dbinfo *dbi, char *seektext) {
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t *name;
|
||||
dns_dbnode_t *node;
|
||||
list(dbinfo *dbi, char *seektext)
|
||||
{
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t * name;
|
||||
dns_dbnode_t * node;
|
||||
dns_rdatasetiter_t *rdsiter;
|
||||
isc_result_t result;
|
||||
int i;
|
||||
size_t len;
|
||||
dns_fixedname_t fseekname;
|
||||
dns_name_t *seekname;
|
||||
isc_buffer_t source;
|
||||
isc_result_t result;
|
||||
int i;
|
||||
size_t len;
|
||||
dns_fixedname_t fseekname;
|
||||
dns_name_t * seekname;
|
||||
isc_buffer_t source;
|
||||
|
||||
name = dns_fixedname_initname(&fname);
|
||||
|
||||
|
|
@ -168,14 +170,12 @@ list(dbinfo *dbi, char *seektext) {
|
|||
isc_buffer_init(&source, seektext, len);
|
||||
isc_buffer_add(&source, len);
|
||||
seekname = dns_fixedname_initname(&fseekname);
|
||||
result = dns_name_fromtext(seekname, &source,
|
||||
dns_db_origin(
|
||||
dbi->db),
|
||||
0, NULL);
|
||||
result = dns_name_fromtext(
|
||||
seekname, &source,
|
||||
dns_db_origin(dbi->db), 0, NULL);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
result = dns_dbiterator_seek(
|
||||
dbi->dbiterator,
|
||||
seekname);
|
||||
dbi->dbiterator, seekname);
|
||||
} else if (dbi->ascending)
|
||||
result = dns_dbiterator_first(dbi->dbiterator);
|
||||
else
|
||||
|
|
@ -221,14 +221,15 @@ list(dbinfo *dbi, char *seektext) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
load(const char *filename, const char *origintext, bool cache) {
|
||||
load(const char *filename, const char *origintext, bool cache)
|
||||
{
|
||||
dns_fixedname_t forigin;
|
||||
dns_name_t *origin;
|
||||
isc_result_t result;
|
||||
isc_buffer_t source;
|
||||
size_t len;
|
||||
dbinfo *dbi;
|
||||
unsigned int i;
|
||||
dns_name_t * origin;
|
||||
isc_result_t result;
|
||||
isc_buffer_t source;
|
||||
size_t len;
|
||||
dbinfo * dbi;
|
||||
unsigned int i;
|
||||
|
||||
dbi = isc_mem_get(mctx, sizeof(*dbi));
|
||||
|
||||
|
|
@ -258,8 +259,7 @@ load(const char *filename, const char *origintext, bool cache) {
|
|||
|
||||
result = dns_db_create(mctx, dbtype, origin,
|
||||
cache ? dns_dbtype_cache : dns_dbtype_zone,
|
||||
dns_rdataclass_in,
|
||||
0, NULL, &dbi->db);
|
||||
dns_rdataclass_in, 0, NULL, &dbi->db);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_put(mctx, dbi, sizeof(*dbi));
|
||||
return (result);
|
||||
|
|
@ -292,7 +292,8 @@ load(const char *filename, const char *origintext, bool cache) {
|
|||
}
|
||||
|
||||
static void
|
||||
unload_all(void) {
|
||||
unload_all(void)
|
||||
{
|
||||
dbinfo *dbi, *dbi_next;
|
||||
|
||||
for (dbi = ISC_LIST_HEAD(dbs); dbi != NULL; dbi = dbi_next) {
|
||||
|
|
@ -310,55 +311,56 @@ unload_all(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#define DBI_CHECK(dbi) \
|
||||
if ((dbi) == NULL) { \
|
||||
printf("You must first select a database with !DB\n"); \
|
||||
continue; \
|
||||
}
|
||||
#define DBI_CHECK(dbi) \
|
||||
if ((dbi) == NULL) { \
|
||||
printf("You must first select a database with !DB\n"); \
|
||||
continue; \
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
dns_db_t *db;
|
||||
dns_dbnode_t *node;
|
||||
isc_result_t result;
|
||||
dns_name_t name;
|
||||
dns_offsets_t offsets;
|
||||
size_t len;
|
||||
isc_buffer_t source, target;
|
||||
char s[1000];
|
||||
char b[255];
|
||||
dns_rdataset_t rdataset, sigrdataset;
|
||||
int ch;
|
||||
dns_rdatatype_t type = 1;
|
||||
bool printnode = false;
|
||||
bool addmode = false;
|
||||
bool delmode = false;
|
||||
bool holdmode = false;
|
||||
bool verbose = false;
|
||||
bool done = false;
|
||||
bool quiet = false;
|
||||
bool time_lookups = false;
|
||||
bool found_as;
|
||||
bool find_zonecut = false;
|
||||
bool noexact_zonecut = false;
|
||||
int i, v;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
dns_db_t * db;
|
||||
dns_dbnode_t * node;
|
||||
isc_result_t result;
|
||||
dns_name_t name;
|
||||
dns_offsets_t offsets;
|
||||
size_t len;
|
||||
isc_buffer_t source, target;
|
||||
char s[1000];
|
||||
char b[255];
|
||||
dns_rdataset_t rdataset, sigrdataset;
|
||||
int ch;
|
||||
dns_rdatatype_t type = 1;
|
||||
bool printnode = false;
|
||||
bool addmode = false;
|
||||
bool delmode = false;
|
||||
bool holdmode = false;
|
||||
bool verbose = false;
|
||||
bool done = false;
|
||||
bool quiet = false;
|
||||
bool time_lookups = false;
|
||||
bool found_as;
|
||||
bool find_zonecut = false;
|
||||
bool noexact_zonecut = false;
|
||||
int i, v;
|
||||
dns_rdatasetiter_t *rdsiter;
|
||||
char t1[256];
|
||||
char t2[256];
|
||||
isc_buffer_t tb1, tb2;
|
||||
isc_region_t r1, r2;
|
||||
dns_fixedname_t foundname;
|
||||
dns_name_t *fname;
|
||||
unsigned int options = 0, zcoptions;
|
||||
isc_time_t start, finish;
|
||||
const char *origintext;
|
||||
dbinfo *dbi;
|
||||
dns_dbversion_t *version;
|
||||
const dns_name_t *origin;
|
||||
dns_trust_t trust = 0;
|
||||
unsigned int addopts;
|
||||
isc_log_t *lctx = NULL;
|
||||
size_t n;
|
||||
char t1[256];
|
||||
char t2[256];
|
||||
isc_buffer_t tb1, tb2;
|
||||
isc_region_t r1, r2;
|
||||
dns_fixedname_t foundname;
|
||||
dns_name_t * fname;
|
||||
unsigned int options = 0, zcoptions;
|
||||
isc_time_t start, finish;
|
||||
const char * origintext;
|
||||
dbinfo * dbi;
|
||||
dns_dbversion_t * version;
|
||||
const dns_name_t * origin;
|
||||
dns_trust_t trust = 0;
|
||||
unsigned int addopts;
|
||||
isc_log_t * lctx = NULL;
|
||||
size_t n;
|
||||
|
||||
dns_result_register();
|
||||
|
||||
|
|
@ -367,8 +369,8 @@ main(int argc, char *argv[]) {
|
|||
ISC_R_SUCCESS);
|
||||
|
||||
snprintf(dbtype, sizeof(dbtype), "rbt");
|
||||
while ((ch = isc_commandline_parse(argc, argv, "c:d:t:z:P:Q:glpqvT"))
|
||||
!= -1) {
|
||||
while ((ch = isc_commandline_parse(argc, argv, "c:d:t:z:P:Q:glpqvT")) !=
|
||||
-1) {
|
||||
switch (ch) {
|
||||
case 'c':
|
||||
result = load(isc_commandline_argument, ".", true);
|
||||
|
|
@ -387,11 +389,12 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
break;
|
||||
case 'g':
|
||||
options |= (DNS_DBFIND_GLUEOK|DNS_DBFIND_VALIDATEGLUE);
|
||||
options |=
|
||||
(DNS_DBFIND_GLUEOK | DNS_DBFIND_VALIDATEGLUE);
|
||||
break;
|
||||
case 'l':
|
||||
RUNTIME_CHECK(isc_log_create(mctx, &lctx,
|
||||
NULL) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_log_create(mctx, &lctx, NULL) ==
|
||||
ISC_R_SUCCESS);
|
||||
isc_log_setcontext(lctx);
|
||||
dns_log_init(lctx);
|
||||
dns_log_setcontext(lctx);
|
||||
|
|
@ -420,7 +423,7 @@ main(int argc, char *argv[]) {
|
|||
if (origintext == NULL)
|
||||
origintext = isc_commandline_argument;
|
||||
else
|
||||
origintext++; /* Skip '/'. */
|
||||
origintext++; /* Skip '/'. */
|
||||
result = load(isc_commandline_argument, origintext,
|
||||
false);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
|
|
@ -511,11 +514,11 @@ main(int argc, char *argv[]) {
|
|||
dbi->wversion = NULL;
|
||||
} else {
|
||||
for (i = 0; i < dbi->rcount; i++) {
|
||||
if (dbi->version ==
|
||||
dbi->rversions[i]) {
|
||||
if (dbi->version == dbi->rversions[i]) {
|
||||
dbi->rversions[i] = NULL;
|
||||
printf("closing open version %d\n",
|
||||
i);
|
||||
printf("closing open version "
|
||||
"%d\n",
|
||||
i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -534,11 +537,11 @@ main(int argc, char *argv[]) {
|
|||
dbi->wversion = NULL;
|
||||
} else {
|
||||
for (i = 0; i < dbi->rcount; i++) {
|
||||
if (dbi->version ==
|
||||
dbi->rversions[i]) {
|
||||
if (dbi->version == dbi->rversions[i]) {
|
||||
dbi->rversions[i] = NULL;
|
||||
printf("closing open version %d\n",
|
||||
i);
|
||||
printf("closing open version "
|
||||
"%d\n",
|
||||
i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -575,8 +578,7 @@ main(int argc, char *argv[]) {
|
|||
} else if (strcmp(s, "!HR") == 0) {
|
||||
DBI_CHECK(dbi);
|
||||
for (i = 0; i < dbi->hold_count; i++)
|
||||
dns_db_detachnode(dbi->db,
|
||||
&dbi->hold_nodes[i]);
|
||||
dns_db_detachnode(dbi->db, &dbi->hold_nodes[i]);
|
||||
dbi->hold_count = 0;
|
||||
holdmode = false;
|
||||
printf("held nodes have been detached\n");
|
||||
|
|
@ -616,8 +618,8 @@ main(int argc, char *argv[]) {
|
|||
else
|
||||
options |= DNS_DBFIND_GLUEOK;
|
||||
printf("glue ok = %s\n",
|
||||
((options & DNS_DBFIND_GLUEOK) != 0) ?
|
||||
"TRUE" : "FALSE");
|
||||
((options & DNS_DBFIND_GLUEOK) != 0) ? "TRUE"
|
||||
: "FALSE");
|
||||
continue;
|
||||
} else if (strcmp(s, "!GV") == 0) {
|
||||
if ((options & DNS_DBFIND_VALIDATEGLUE) != 0)
|
||||
|
|
@ -625,8 +627,9 @@ main(int argc, char *argv[]) {
|
|||
else
|
||||
options |= DNS_DBFIND_VALIDATEGLUE;
|
||||
printf("validate glue = %s\n",
|
||||
((options & DNS_DBFIND_VALIDATEGLUE) != 0) ?
|
||||
"TRUE" : "FALSE");
|
||||
((options & DNS_DBFIND_VALIDATEGLUE) != 0)
|
||||
? "TRUE"
|
||||
: "FALSE");
|
||||
continue;
|
||||
} else if (strcmp(s, "!WC") == 0) {
|
||||
if ((options & DNS_DBFIND_NOWILD) != 0)
|
||||
|
|
@ -634,8 +637,8 @@ main(int argc, char *argv[]) {
|
|||
else
|
||||
options |= DNS_DBFIND_NOWILD;
|
||||
printf("wildcard matching = %s\n",
|
||||
((options & DNS_DBFIND_NOWILD) == 0) ?
|
||||
"TRUE" : "FALSE");
|
||||
((options & DNS_DBFIND_NOWILD) == 0) ? "TRUE"
|
||||
: "FALSE");
|
||||
continue;
|
||||
} else if (strstr(s, "!LS ") == s) {
|
||||
DBI_CHECK(dbi);
|
||||
|
|
@ -647,7 +650,7 @@ main(int argc, char *argv[]) {
|
|||
continue;
|
||||
} else if (strstr(s, "!DU ") == s) {
|
||||
DBI_CHECK(dbi);
|
||||
result = dns_db_dump(dbi->db, dbi->version, s+4);
|
||||
result = dns_db_dump(dbi->db, dbi->version, s + 4);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
printf("\n");
|
||||
print_result("", result);
|
||||
|
|
@ -681,7 +684,7 @@ main(int argc, char *argv[]) {
|
|||
printf("now searching all databases\n");
|
||||
continue;
|
||||
} else if (strncmp(s, "!DB ", 4) == 0) {
|
||||
dbi = select_db(s+4);
|
||||
dbi = select_db(s + 4);
|
||||
if (dbi != NULL) {
|
||||
db = dbi->db;
|
||||
origin = dns_db_origin(dbi->db);
|
||||
|
|
@ -740,8 +743,8 @@ main(int argc, char *argv[]) {
|
|||
continue;
|
||||
}
|
||||
isc_buffer_init(&tb1, t1, sizeof(t1));
|
||||
result = dns_name_totext(dns_db_origin(db), false,
|
||||
&tb1);
|
||||
result =
|
||||
dns_name_totext(dns_db_origin(db), false, &tb1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
printf("\n");
|
||||
print_result("", result);
|
||||
|
|
@ -749,9 +752,8 @@ main(int argc, char *argv[]) {
|
|||
continue;
|
||||
}
|
||||
isc_buffer_usedregion(&tb1, &r1);
|
||||
printf("\ndatabase = %.*s (%s)\n",
|
||||
(int)r1.length, r1.base,
|
||||
(dns_db_iszone(db)) ? "zone" : "cache");
|
||||
printf("\ndatabase = %.*s (%s)\n", (int)r1.length,
|
||||
r1.base, (dns_db_iszone(db)) ? "zone" : "cache");
|
||||
}
|
||||
node = NULL;
|
||||
dns_rdataset_init(&rdataset);
|
||||
|
|
@ -761,13 +763,13 @@ main(int argc, char *argv[]) {
|
|||
zcoptions = options;
|
||||
if (noexact_zonecut)
|
||||
zcoptions |= DNS_DBFIND_NOEXACT;
|
||||
result = dns_db_findzonecut(db, &name, zcoptions,
|
||||
0, &node, fname, NULL,
|
||||
result = dns_db_findzonecut(db, &name, zcoptions, 0,
|
||||
&node, fname, NULL,
|
||||
&rdataset, &sigrdataset);
|
||||
} else {
|
||||
result = dns_db_find(db, &name, version, type,
|
||||
options, 0, &node, fname,
|
||||
&rdataset, &sigrdataset);
|
||||
result = dns_db_find(db, &name, version, type, options,
|
||||
0, &node, fname, &rdataset,
|
||||
&sigrdataset);
|
||||
}
|
||||
|
||||
if (!quiet) {
|
||||
|
|
@ -836,8 +838,7 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
isc_buffer_usedregion(&tb1, &r1);
|
||||
isc_buffer_usedregion(&tb2, &r2);
|
||||
printf("found %.*s as %.*s\n",
|
||||
(int)r1.length, r1.base,
|
||||
printf("found %.*s as %.*s\n", (int)r1.length, r1.base,
|
||||
(int)r2.length, r2.base);
|
||||
}
|
||||
|
||||
|
|
@ -877,9 +878,8 @@ main(int argc, char *argv[]) {
|
|||
if (printnode)
|
||||
dns_db_printnode(db, node, stdout);
|
||||
} else if (dbi != NULL && delmode && !found_as) {
|
||||
result = dns_db_deleterdataset(db, node,
|
||||
version, type,
|
||||
0);
|
||||
result = dns_db_deleterdataset(
|
||||
db, node, version, type, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
print_result("", result);
|
||||
if (printnode)
|
||||
|
|
|
|||
|
|
@ -11,25 +11,26 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h> /* Non-portable. */
|
||||
#include <sys/stat.h> /* Non-portable. */
|
||||
|
||||
#include <isc/fsaccess.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
#include <sys/stat.h> /* Non-portable. */
|
||||
#include <sys/types.h> /* Non-portable. */
|
||||
|
||||
#define PATH "/tmp/fsaccess"
|
||||
|
||||
int
|
||||
main(void) {
|
||||
main(void)
|
||||
{
|
||||
isc_fsaccess_t access;
|
||||
isc_result_t result;
|
||||
FILE *fp;
|
||||
int n;
|
||||
isc_result_t result;
|
||||
FILE * fp;
|
||||
int n;
|
||||
|
||||
n = remove(PATH);
|
||||
if (n != 0 && errno != ENOENT) {
|
||||
|
|
@ -50,8 +51,7 @@ main(void) {
|
|||
access = 0;
|
||||
|
||||
isc_fsaccess_add(ISC_FSACCESS_OWNER | ISC_FSACCESS_GROUP,
|
||||
ISC_FSACCESS_READ | ISC_FSACCESS_WRITE,
|
||||
&access);
|
||||
ISC_FSACCESS_READ | ISC_FSACCESS_WRITE, &access);
|
||||
|
||||
printf("fsaccess=%u\n", access);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,61 +25,65 @@
|
|||
#include <isc/util.h>
|
||||
|
||||
#include <dns/dispatch.h>
|
||||
#include <dns/dnssec.h>
|
||||
#include <dns/events.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/keyvalues.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/masterdump.h>
|
||||
#include <dns/message.h>
|
||||
#include <dns/name.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/request.h>
|
||||
#include <dns/resolver.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/tkey.h>
|
||||
#include <dns/tsig.h>
|
||||
#include <dns/view.h>
|
||||
|
||||
#include <dns/dnssec.h>
|
||||
#include <dns/events.h>
|
||||
#include <dns/masterdump.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/resolver.h>
|
||||
#include <dns/types.h>
|
||||
#include <dns/view.h>
|
||||
|
||||
#include <dst/result.h>
|
||||
|
||||
#ifdef GSSAPI
|
||||
#include ISC_PLATFORM_GSSAPIHEADER
|
||||
|
||||
#define CHECK(str, x) { \
|
||||
if ((x) != ISC_R_SUCCESS) { \
|
||||
fprintf(stderr, "I:%d:%s: %s\n", __LINE__, (str), isc_result_totext(x)); \
|
||||
goto end; \
|
||||
} \
|
||||
}
|
||||
#define CHECK(str, x) \
|
||||
{ \
|
||||
if ((x) != ISC_R_SUCCESS) { \
|
||||
fprintf(stderr, "I:%d:%s: %s\n", __LINE__, (str), \
|
||||
isc_result_totext(x)); \
|
||||
goto end; \
|
||||
} \
|
||||
}
|
||||
|
||||
static dns_fixedname_t servername, gssname;
|
||||
|
||||
static isc_mem_t *mctx;
|
||||
static isc_mem_t * mctx;
|
||||
static dns_requestmgr_t *requestmgr;
|
||||
static isc_sockaddr_t address;
|
||||
static isc_sockaddr_t address;
|
||||
|
||||
static dns_tsig_keyring_t *ring;
|
||||
static dns_tsigkey_t *tsigkey = NULL;
|
||||
static gss_ctx_id_t gssctx;
|
||||
static gss_ctx_id_t *gssctxp = &gssctx;
|
||||
static dns_tsigkey_t * tsigkey = NULL;
|
||||
static gss_ctx_id_t gssctx;
|
||||
static gss_ctx_id_t * gssctxp = &gssctx;
|
||||
|
||||
#define RUNCHECK(x) RUNTIME_CHECK((x) == ISC_R_SUCCESS)
|
||||
|
||||
#define PORT 53
|
||||
#define TIMEOUT 30
|
||||
|
||||
static void initctx1(isc_task_t *task, isc_event_t *event);
|
||||
static void sendquery(isc_task_t *task, isc_event_t *event);
|
||||
static void setup();
|
||||
static void
|
||||
initctx1(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
sendquery(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
setup();
|
||||
|
||||
static void
|
||||
console(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
char buf[32];
|
||||
int c;
|
||||
int c;
|
||||
|
||||
isc_event_t *ev = NULL;
|
||||
|
||||
|
|
@ -113,13 +117,14 @@ console(isc_task_t *task, isc_event_t *event)
|
|||
}
|
||||
|
||||
static void
|
||||
recvresponse(isc_task_t *task, isc_event_t *event) {
|
||||
recvresponse(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
dns_requestevent_t *reqev = (dns_requestevent_t *)event;
|
||||
isc_result_t result, result2;
|
||||
dns_message_t *query = NULL, *response = NULL;
|
||||
isc_buffer_t outtoken;
|
||||
isc_buffer_t outbuf;
|
||||
char output[10 * 1024];
|
||||
isc_result_t result, result2;
|
||||
dns_message_t * query = NULL, *response = NULL;
|
||||
isc_buffer_t outtoken;
|
||||
isc_buffer_t outbuf;
|
||||
char output[10 * 1024];
|
||||
|
||||
unsigned char array[DNS_NAME_MAXTEXT + 1];
|
||||
isc_buffer_init(&outtoken, array, sizeof(array));
|
||||
|
|
@ -143,7 +148,7 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
|
|||
printf("\nReceived Response:\n");
|
||||
|
||||
result2 = dns_request_getresponse(reqev->request, response,
|
||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||
isc_buffer_init(&outbuf, output, sizeof(output));
|
||||
result = dns_message_totext(response, &dns_master_style_debug, 0,
|
||||
&outbuf);
|
||||
|
|
@ -156,7 +161,7 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
|
|||
if (response != NULL)
|
||||
dns_message_destroy(&response);
|
||||
|
||||
end:
|
||||
end:
|
||||
if (query != NULL)
|
||||
dns_message_destroy(&query);
|
||||
|
||||
|
|
@ -171,21 +176,20 @@ recvresponse(isc_task_t *task, isc_event_t *event) {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sendquery(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
dns_request_t *request = NULL;
|
||||
dns_message_t *message = NULL;
|
||||
dns_name_t *qname = NULL;
|
||||
dns_request_t * request = NULL;
|
||||
dns_message_t * message = NULL;
|
||||
dns_name_t * qname = NULL;
|
||||
dns_rdataset_t *qrdataset = NULL;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
dns_fixedname_t queryname;
|
||||
isc_buffer_t buf;
|
||||
isc_buffer_t outbuf;
|
||||
char output[10 * 1024];
|
||||
static char host[256];
|
||||
int c;
|
||||
isc_buffer_t buf;
|
||||
isc_buffer_t outbuf;
|
||||
char output[10 * 1024];
|
||||
static char host[256];
|
||||
int c;
|
||||
|
||||
isc_event_free(&event);
|
||||
|
||||
|
|
@ -225,8 +229,8 @@ sendquery(isc_task_t *task, isc_event_t *event)
|
|||
dns_message_addname(message, qname, DNS_SECTION_QUESTION);
|
||||
|
||||
result = dns_request_create(requestmgr, message, &address, 0, tsigkey,
|
||||
TIMEOUT, task, recvresponse,
|
||||
message, &request);
|
||||
TIMEOUT, task, recvresponse, message,
|
||||
&request);
|
||||
CHECK("dns_request_create", result);
|
||||
|
||||
printf("Submitting query:\n");
|
||||
|
|
@ -239,7 +243,7 @@ sendquery(isc_task_t *task, isc_event_t *event)
|
|||
|
||||
return;
|
||||
|
||||
end:
|
||||
end:
|
||||
if (qname != NULL)
|
||||
dns_message_puttempname(message, &qname);
|
||||
if (qrdataset != NULL)
|
||||
|
|
@ -249,15 +253,16 @@ sendquery(isc_task_t *task, isc_event_t *event)
|
|||
}
|
||||
|
||||
static void
|
||||
initctx2(isc_task_t *task, isc_event_t *event) {
|
||||
initctx2(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
dns_requestevent_t *reqev = (dns_requestevent_t *)event;
|
||||
isc_result_t result;
|
||||
dns_message_t *query = NULL, *response = NULL;
|
||||
isc_buffer_t outtoken;
|
||||
unsigned char array[DNS_NAME_MAXTEXT + 1];
|
||||
dns_rdataset_t *rdataset;
|
||||
dns_rdatatype_t qtype;
|
||||
dns_name_t *question_name;
|
||||
isc_result_t result;
|
||||
dns_message_t * query = NULL, *response = NULL;
|
||||
isc_buffer_t outtoken;
|
||||
unsigned char array[DNS_NAME_MAXTEXT + 1];
|
||||
dns_rdataset_t * rdataset;
|
||||
dns_rdatatype_t qtype;
|
||||
dns_name_t * question_name;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
|
|
@ -288,10 +293,9 @@ initctx2(isc_task_t *task, isc_event_t *event) {
|
|||
|
||||
printf("Received token from server, calling gss_init_sec_context()\n");
|
||||
isc_buffer_init(&outtoken, array, DNS_NAME_MAXTEXT + 1);
|
||||
result = dns_tkey_processgssresponse(query, response,
|
||||
dns_fixedname_name(&gssname),
|
||||
&gssctx, &outtoken,
|
||||
&tsigkey, ring, NULL);
|
||||
result = dns_tkey_processgssresponse(
|
||||
query, response, dns_fixedname_name(&gssname), &gssctx,
|
||||
&outtoken, &tsigkey, ring, NULL);
|
||||
gssctx = *gssctxp;
|
||||
CHECK("dns_tkey_processgssresponse", result);
|
||||
printf("Context accepted\n");
|
||||
|
|
@ -313,7 +317,7 @@ initctx2(isc_task_t *task, isc_event_t *event) {
|
|||
|
||||
dns_message_destroy(&response);
|
||||
|
||||
end:
|
||||
end:
|
||||
if (query != NULL)
|
||||
dns_message_destroy(&query);
|
||||
|
||||
|
|
@ -329,14 +333,15 @@ initctx2(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
initctx1(isc_task_t *task, isc_event_t *event) {
|
||||
char gssid[512];
|
||||
char contextname[512];
|
||||
isc_result_t result;
|
||||
isc_buffer_t buf;
|
||||
initctx1(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
char gssid[512];
|
||||
char contextname[512];
|
||||
isc_result_t result;
|
||||
isc_buffer_t buf;
|
||||
dns_message_t *query;
|
||||
dns_request_t *request;
|
||||
int c;
|
||||
int c;
|
||||
|
||||
isc_event_free(&event);
|
||||
|
||||
|
|
@ -345,8 +350,8 @@ initctx1(isc_task_t *task, isc_event_t *event) {
|
|||
if (c == EOF)
|
||||
return;
|
||||
|
||||
snprintf(contextname, sizeof(contextname),
|
||||
"gsstest.context.%d.", (int)time(NULL));
|
||||
snprintf(contextname, sizeof(contextname), "gsstest.context.%d.",
|
||||
(int)time(NULL));
|
||||
|
||||
printf("Initctx - context name we're using: %s\n", contextname);
|
||||
|
||||
|
|
@ -379,9 +384,8 @@ initctx1(isc_task_t *task, isc_event_t *event) {
|
|||
printf("Calling gss_init_sec_context()\n");
|
||||
gssctx = GSS_C_NO_CONTEXT;
|
||||
result = dns_tkey_buildgssquery(query, dns_fixedname_name(&servername),
|
||||
dns_fixedname_name(&gssname),
|
||||
NULL, 36000, &gssctx, true,
|
||||
mctx, NULL);
|
||||
dns_fixedname_name(&gssname), NULL,
|
||||
36000, &gssctx, true, mctx, NULL);
|
||||
CHECK("dns_tkey_buildgssquery", result);
|
||||
|
||||
printf("Sending context token to server\n");
|
||||
|
|
@ -391,19 +395,20 @@ initctx1(isc_task_t *task, isc_event_t *event) {
|
|||
CHECK("dns_request_create", result);
|
||||
|
||||
return;
|
||||
end:
|
||||
end:
|
||||
event = isc_event_allocate(mctx, (void *)1, 1, console, NULL,
|
||||
sizeof(*event));
|
||||
isc_task_send(task, &event);return;
|
||||
isc_task_send(task, &event);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
setup(void)
|
||||
{
|
||||
for (;;) {
|
||||
char serveraddress[512];
|
||||
char serveraddress[512];
|
||||
struct in_addr inaddr;
|
||||
int c;
|
||||
int c;
|
||||
|
||||
printf("Server IP => ");
|
||||
c = scanf("%511s", serveraddress);
|
||||
|
|
@ -417,24 +422,24 @@ setup(void)
|
|||
isc_sockaddr_fromin(&address, &inaddr, PORT);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_taskmgr_t *taskmgr;
|
||||
isc_timermgr_t *timermgr;
|
||||
isc_socketmgr_t *socketmgr;
|
||||
isc_socket_t *sock;
|
||||
unsigned int attrs, attrmask;
|
||||
isc_sockaddr_t bind_any;
|
||||
dns_dispatchmgr_t *dispatchmgr;
|
||||
dns_dispatch_t *dispatchv4;
|
||||
dns_view_t *view;
|
||||
isc_task_t *task;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_logconfig_t *lcfg = NULL;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_taskmgr_t * taskmgr;
|
||||
isc_timermgr_t * timermgr;
|
||||
isc_socketmgr_t * socketmgr;
|
||||
isc_socket_t * sock;
|
||||
unsigned int attrs, attrmask;
|
||||
isc_sockaddr_t bind_any;
|
||||
dns_dispatchmgr_t * dispatchmgr;
|
||||
dns_dispatch_t * dispatchv4;
|
||||
dns_view_t * view;
|
||||
isc_task_t * task;
|
||||
isc_log_t * lctx = NULL;
|
||||
isc_logconfig_t * lcfg = NULL;
|
||||
isc_logdestination_t destination;
|
||||
|
||||
UNUSED(argv);
|
||||
|
|
@ -459,10 +464,9 @@ main(int argc, char *argv[]) {
|
|||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
RUNCHECK(isc_log_createchannel(lcfg, "_default",
|
||||
ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC,
|
||||
&destination, ISC_LOG_PRINTTIME));
|
||||
RUNCHECK(isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC, &destination,
|
||||
ISC_LOG_PRINTTIME));
|
||||
RUNCHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL));
|
||||
|
||||
isc_log_setdebuglevel(lctx, 9);
|
||||
|
|
@ -480,21 +484,18 @@ main(int argc, char *argv[]) {
|
|||
dispatchmgr = NULL;
|
||||
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
|
||||
isc_sockaddr_any(&bind_any);
|
||||
attrs = DNS_DISPATCHATTR_UDP |
|
||||
DNS_DISPATCHATTR_MAKEQUERY |
|
||||
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
|
||||
DNS_DISPATCHATTR_IPV4;
|
||||
attrmask = DNS_DISPATCHATTR_UDP |
|
||||
DNS_DISPATCHATTR_TCP |
|
||||
DNS_DISPATCHATTR_IPV4 |
|
||||
DNS_DISPATCHATTR_IPV6;
|
||||
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
|
||||
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
|
||||
dispatchv4 = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
&bind_any, 4096, 4, 2, 3, 5,
|
||||
attrs, attrmask, &dispatchv4));
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &bind_any,
|
||||
4096, 4, 2, 3, 5, attrs, attrmask,
|
||||
&dispatchv4));
|
||||
requestmgr = NULL;
|
||||
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
|
||||
dispatchmgr, dispatchv4, NULL,
|
||||
&requestmgr));
|
||||
dispatchmgr, dispatchv4, NULL,
|
||||
&requestmgr));
|
||||
|
||||
ring = NULL;
|
||||
RUNCHECK(dns_tsigkeyring_create(mctx, &ring));
|
||||
|
|
@ -545,7 +546,8 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
#else
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
fprintf(stderr, "R:GSSAPIONLY\n");
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@
|
|||
#include <isc/util.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
isc_mem_t *mctx = NULL;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_mem_t * mctx = NULL;
|
||||
isc_interfaceiter_t *iter = NULL;
|
||||
isc_interface_t ifdata;
|
||||
isc_result_t result;
|
||||
const char * res;
|
||||
char buf[128];
|
||||
isc_interface_t ifdata;
|
||||
isc_result_t result;
|
||||
const char * res;
|
||||
char buf[128];
|
||||
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
|
@ -49,8 +50,7 @@ main(int argc, char **argv) {
|
|||
sizeof(buf));
|
||||
if (ifdata.address.zone != 0)
|
||||
fprintf(stdout, "address = %s (zone %u)\n",
|
||||
res == NULL ? "BAD" : res,
|
||||
ifdata.address.zone);
|
||||
res == NULL ? "BAD" : res, ifdata.address.zone);
|
||||
else
|
||||
fprintf(stdout, "address = %s\n",
|
||||
res == NULL ? "BAD" : res);
|
||||
|
|
@ -60,8 +60,8 @@ main(int argc, char **argv) {
|
|||
fprintf(stdout, "netmask = %s\n", res == NULL ? "BAD" : res);
|
||||
INSIST(ifdata.netmask.family == ifdata.af);
|
||||
if ((ifdata.flags & INTERFACE_F_POINTTOPOINT) != 0) {
|
||||
res = inet_ntop(ifdata.af, &ifdata.dstaddress.type,
|
||||
buf, sizeof(buf));
|
||||
res = inet_ntop(ifdata.af, &ifdata.dstaddress.type, buf,
|
||||
sizeof(buf));
|
||||
fprintf(stdout, "dstaddress = %s\n",
|
||||
res == NULL ? "BAD" : res);
|
||||
|
||||
|
|
@ -96,8 +96,7 @@ main(int argc, char **argv) {
|
|||
sizeof(buf));
|
||||
if (ifdata.address.zone != 0)
|
||||
fprintf(stdout, "address = %s (zone %u)\n",
|
||||
res == NULL ? "BAD" : res,
|
||||
ifdata.address.zone);
|
||||
res == NULL ? "BAD" : res, ifdata.address.zone);
|
||||
else
|
||||
fprintf(stdout, "address = %s\n",
|
||||
res == NULL ? "BAD" : res);
|
||||
|
|
@ -107,8 +106,8 @@ main(int argc, char **argv) {
|
|||
fprintf(stdout, "netmask = %s\n", res == NULL ? "BAD" : res);
|
||||
INSIST(ifdata.netmask.family == ifdata.af);
|
||||
if ((ifdata.flags & INTERFACE_F_POINTTOPOINT) != 0) {
|
||||
res = inet_ntop(ifdata.af, &ifdata.dstaddress.type,
|
||||
buf, sizeof(buf));
|
||||
res = inet_ntop(ifdata.af, &ifdata.dstaddress.type, buf,
|
||||
sizeof(buf));
|
||||
fprintf(stdout, "dstaddress = %s\n",
|
||||
res == NULL ? "BAD" : res);
|
||||
|
||||
|
|
@ -122,7 +121,7 @@ main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
isc_interfaceiter_destroy(&iter);
|
||||
cleanup:
|
||||
cleanup:
|
||||
isc_mem_destroy(&mctx);
|
||||
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ isc_lex_t *lex;
|
|||
isc_lexspecials_t specials;
|
||||
|
||||
static void
|
||||
print_token(isc_token_t *tokenp, FILE *stream) {
|
||||
print_token(isc_token_t *tokenp, FILE *stream)
|
||||
{
|
||||
switch (tokenp->type) {
|
||||
case isc_tokentype_unknown:
|
||||
fprintf(stream, "UNKNOWN");
|
||||
|
|
@ -63,15 +64,16 @@ print_token(isc_token_t *tokenp, FILE *stream) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_token_t token;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_token_t token;
|
||||
isc_result_t result;
|
||||
int quiet = 0;
|
||||
int c;
|
||||
int masterfile = 1;
|
||||
int stats = 0;
|
||||
int quiet = 0;
|
||||
int c;
|
||||
int masterfile = 1;
|
||||
int stats = 0;
|
||||
unsigned int options = 0;
|
||||
int done = 0;
|
||||
int done = 0;
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, "qmcs")) != -1) {
|
||||
switch (c) {
|
||||
|
|
@ -101,8 +103,8 @@ main(int argc, char *argv[]) {
|
|||
specials['"'] = 1;
|
||||
isc_lex_setspecials(lex, specials);
|
||||
options = ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE |
|
||||
ISC_LEXOPT_EOF |
|
||||
ISC_LEXOPT_QSTRING | ISC_LEXOPT_NOMORE;
|
||||
ISC_LEXOPT_EOF | ISC_LEXOPT_QSTRING |
|
||||
ISC_LEXOPT_NOMORE;
|
||||
isc_lex_setcomments(lex, ISC_LEXCOMMENT_DNSMASTERFILE);
|
||||
} else {
|
||||
/* Set up to lex DNS config file. */
|
||||
|
|
@ -115,24 +117,24 @@ main(int argc, char *argv[]) {
|
|||
specials['!'] = 1;
|
||||
specials['*'] = 1;
|
||||
isc_lex_setspecials(lex, specials);
|
||||
options = ISC_LEXOPT_EOF |
|
||||
ISC_LEXOPT_QSTRING |
|
||||
ISC_LEXOPT_NUMBER | ISC_LEXOPT_NOMORE;
|
||||
isc_lex_setcomments(lex, (ISC_LEXCOMMENT_C|
|
||||
ISC_LEXCOMMENT_CPLUSPLUS|
|
||||
options = ISC_LEXOPT_EOF | ISC_LEXOPT_QSTRING |
|
||||
ISC_LEXOPT_NUMBER | ISC_LEXOPT_NOMORE;
|
||||
isc_lex_setcomments(lex, (ISC_LEXCOMMENT_C |
|
||||
ISC_LEXCOMMENT_CPLUSPLUS |
|
||||
ISC_LEXCOMMENT_SHELL));
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS);
|
||||
|
||||
while ((result = isc_lex_gettoken(lex, options, &token)) ==
|
||||
ISC_R_SUCCESS && !done) {
|
||||
ISC_R_SUCCESS &&
|
||||
!done) {
|
||||
if (!quiet) {
|
||||
char *name = isc_lex_getsourcename(lex);
|
||||
print_token(&token, stdout);
|
||||
printf(" line = %lu file = %s\n",
|
||||
isc_lex_getsourceline(lex),
|
||||
(name == NULL) ? "<none>" : name);
|
||||
isc_lex_getsourceline(lex),
|
||||
(name == NULL) ? "<none>" : name);
|
||||
}
|
||||
if (token.type == isc_tokentype_eof)
|
||||
isc_lex_close(lex);
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lfsr.h>
|
||||
#include <isc/print.h>
|
||||
|
|
@ -21,10 +21,11 @@
|
|||
uint32_t state[1024 * 64];
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
isc_lfsr_t lfsr1, lfsr2;
|
||||
int i;
|
||||
uint32_t temp;
|
||||
int i;
|
||||
uint32_t temp;
|
||||
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
|
|
|||
|
|
@ -27,24 +27,26 @@
|
|||
|
||||
char usage[] = "Usage: %s [-m] [-s syslog_logfile] [-r file_versions]\n";
|
||||
|
||||
#define CHECK(expr) result = expr; \
|
||||
if (result != ISC_R_SUCCESS) { \
|
||||
fprintf(stderr, "%s: " #expr "%s: exiting\n", \
|
||||
progname, isc_result_totext(result)); \
|
||||
#define CHECK(expr) \
|
||||
result = expr; \
|
||||
if (result != ISC_R_SUCCESS) { \
|
||||
fprintf(stderr, "%s: " #expr "%s: exiting\n", progname, \
|
||||
isc_result_totext(result)); \
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
const char *progname, *syslog_file, *message;
|
||||
int ch, i, file_versions, stderr_line;
|
||||
bool show_final_mem = false;
|
||||
isc_log_t *lctx;
|
||||
isc_logconfig_t *lcfg;
|
||||
isc_mem_t *mctx;
|
||||
isc_result_t result;
|
||||
isc_logdestination_t destination;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const char * progname, *syslog_file, *message;
|
||||
int ch, i, file_versions, stderr_line;
|
||||
bool show_final_mem = false;
|
||||
isc_log_t * lctx;
|
||||
isc_logconfig_t * lcfg;
|
||||
isc_mem_t * mctx;
|
||||
isc_result_t result;
|
||||
isc_logdestination_t destination;
|
||||
const isc_logcategory_t *category;
|
||||
const isc_logmodule_t *module;
|
||||
const isc_logmodule_t * module;
|
||||
|
||||
progname = strrchr(*argv, '/');
|
||||
if (progname != NULL)
|
||||
|
|
@ -68,11 +70,12 @@ main(int argc, char **argv) {
|
|||
if (file_versions < 0 &&
|
||||
file_versions != ISC_LOG_ROLLNEVER &&
|
||||
file_versions != ISC_LOG_ROLLINFINITE) {
|
||||
fprintf(stderr, "%s: file rotations must be "
|
||||
fprintf(stderr,
|
||||
"%s: file rotations must be "
|
||||
"%d (ISC_LOG_ROLLNEVER),\n\t"
|
||||
"%d (ISC_LOG_ROLLINFINITE) "
|
||||
"or > 0\n", progname,
|
||||
ISC_LOG_ROLLNEVER,
|
||||
"or > 0\n",
|
||||
progname, ISC_LOG_ROLLNEVER,
|
||||
ISC_LOG_ROLLINFINITE);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -94,10 +97,11 @@ main(int argc, char **argv) {
|
|||
|
||||
fprintf(stderr, "EXPECT:\n%s%d%s%s%s",
|
||||
"8 lines to stderr (first 4 numbered, #3 repeated)\n",
|
||||
file_versions == 0 || file_versions == ISC_LOG_ROLLNEVER ? 1 :
|
||||
file_versions > 0 ? file_versions + 1 : FILE_VERSIONS + 1,
|
||||
" " TEST_FILE " files, and\n",
|
||||
"2 lines to syslog\n",
|
||||
file_versions == 0 || file_versions == ISC_LOG_ROLLNEVER
|
||||
? 1
|
||||
: file_versions > 0 ? file_versions + 1
|
||||
: FILE_VERSIONS + 1,
|
||||
" " TEST_FILE " files, and\n", "2 lines to syslog\n",
|
||||
"lines ending with exclamation marks are errors\n\n");
|
||||
|
||||
isc_log_opensyslog(progname, LOG_PID, LOG_DAEMON);
|
||||
|
|
@ -140,13 +144,10 @@ main(int argc, char **argv) {
|
|||
destination.file.maximum_size = 1;
|
||||
destination.file.versions = file_versions;
|
||||
|
||||
CHECK(isc_log_createchannel(lcfg, "file_test", ISC_LOG_TOFILE,
|
||||
ISC_LOG_INFO, &destination,
|
||||
ISC_LOG_PRINTTIME|
|
||||
ISC_LOG_PRINTTAG|
|
||||
ISC_LOG_PRINTLEVEL|
|
||||
ISC_LOG_PRINTCATEGORY|
|
||||
ISC_LOG_PRINTMODULE));
|
||||
CHECK(isc_log_createchannel(
|
||||
lcfg, "file_test", ISC_LOG_TOFILE, ISC_LOG_INFO, &destination,
|
||||
ISC_LOG_PRINTTIME | ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL |
|
||||
ISC_LOG_PRINTCATEGORY | ISC_LOG_PRINTMODULE));
|
||||
|
||||
/*
|
||||
* Create a dynamic debugging channel to a file descriptor.
|
||||
|
|
@ -155,9 +156,8 @@ main(int argc, char **argv) {
|
|||
|
||||
CHECK(isc_log_createchannel(lcfg, "debug_test", ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC, &destination,
|
||||
ISC_LOG_PRINTTIME|
|
||||
ISC_LOG_PRINTLEVEL|
|
||||
ISC_LOG_DEBUGONLY));
|
||||
ISC_LOG_PRINTTIME | ISC_LOG_PRINTLEVEL |
|
||||
ISC_LOG_DEBUGONLY));
|
||||
|
||||
/*
|
||||
* Test the usability of the four predefined logging channels.
|
||||
|
|
@ -171,19 +171,15 @@ main(int argc, char **argv) {
|
|||
CHECK(isc_log_usechannel(lcfg, "default_debug",
|
||||
DNS_LOGCATEGORY_DATABASE,
|
||||
DNS_LOGMODULE_CACHE));
|
||||
CHECK(isc_log_usechannel(lcfg, "null",
|
||||
DNS_LOGCATEGORY_DATABASE,
|
||||
NULL));
|
||||
CHECK(isc_log_usechannel(lcfg, "null", DNS_LOGCATEGORY_DATABASE, NULL));
|
||||
|
||||
/*
|
||||
* Use the custom channels.
|
||||
*/
|
||||
CHECK(isc_log_usechannel(lcfg, "file_test",
|
||||
DNS_LOGCATEGORY_GENERAL,
|
||||
CHECK(isc_log_usechannel(lcfg, "file_test", DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_DB));
|
||||
|
||||
CHECK(isc_log_usechannel(lcfg, "debug_test",
|
||||
DNS_LOGCATEGORY_GENERAL,
|
||||
CHECK(isc_log_usechannel(lcfg, "debug_test", DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_RBTDB));
|
||||
|
||||
fprintf(stderr, "\n==> stderr begin\n");
|
||||
|
|
@ -232,7 +228,6 @@ main(int argc, char **argv) {
|
|||
* Write to the file channel.
|
||||
*/
|
||||
if (file_versions >= 0 || file_versions == ISC_LOG_ROLLINFINITE) {
|
||||
|
||||
/*
|
||||
* If file_versions is 0 or ISC_LOG_ROLLINFINITE, write
|
||||
* the "should not appear" and "should be in file" messages
|
||||
|
|
@ -253,9 +248,8 @@ main(int argc, char **argv) {
|
|||
"should be in file %d/%d", i,
|
||||
file_versions - 1);
|
||||
|
||||
isc_log_write(lctx, DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_DB, ISC_LOG_NOTICE,
|
||||
"should be in base file");
|
||||
isc_log_write(lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_DB,
|
||||
ISC_LOG_NOTICE, "should be in base file");
|
||||
} else {
|
||||
file_versions = FILE_VERSIONS;
|
||||
for (i = 1; i <= file_versions; i++)
|
||||
|
|
@ -264,7 +258,6 @@ main(int argc, char **argv) {
|
|||
"This is message %d in the log file", i);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Write a debugging message to a category that has no
|
||||
* debugging channels for the named module.
|
||||
|
|
@ -277,7 +270,8 @@ main(int argc, char **argv) {
|
|||
* Write debugging messages to a dynamic debugging channel.
|
||||
*/
|
||||
isc_log_write(lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_RBTDB,
|
||||
ISC_LOG_CRITICAL, "This critical message should "
|
||||
ISC_LOG_CRITICAL,
|
||||
"This critical message should "
|
||||
"not appear because the debug level is 0!");
|
||||
|
||||
isc_log_setdebuglevel(lctx, 3);
|
||||
|
|
@ -315,8 +309,8 @@ main(int argc, char **argv) {
|
|||
*/
|
||||
fputc('\n', stderr);
|
||||
if (system("head " TEST_FILE "*; rm -f " TEST_FILE "*") != 0) {
|
||||
fprintf(stderr, "system(\"head " TEST_FILE "*; rm -f "
|
||||
TEST_FILE "*\") failed\n");
|
||||
fprintf(stderr, "system(\"head " TEST_FILE "*; rm -f " TEST_FILE
|
||||
"*\") failed\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +327,7 @@ main(int argc, char **argv) {
|
|||
}
|
||||
fputc('\n', stderr);
|
||||
|
||||
cleanup:
|
||||
cleanup:
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
if (show_final_mem)
|
||||
|
|
|
|||
|
|
@ -26,19 +26,19 @@
|
|||
isc_mem_t *mctx;
|
||||
|
||||
static isc_result_t
|
||||
print_dataset(void *arg, const dns_name_t *owner, dns_rdataset_t *dataset) {
|
||||
char buf[64*1024];
|
||||
print_dataset(void *arg, const dns_name_t *owner, dns_rdataset_t *dataset)
|
||||
{
|
||||
char buf[64 * 1024];
|
||||
isc_buffer_t target;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(arg);
|
||||
|
||||
isc_buffer_init(&target, buf, 64*1024);
|
||||
result = dns_rdataset_totext(dataset, owner, false, false,
|
||||
&target);
|
||||
isc_buffer_init(&target, buf, 64 * 1024);
|
||||
result = dns_rdataset_totext(dataset, owner, false, false, &target);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
fprintf(stdout, "%.*s\n", (int)target.used,
|
||||
(char*)target.base);
|
||||
(char *)target.base);
|
||||
else
|
||||
fprintf(stdout, "dns_rdataset_totext: %s\n",
|
||||
dns_result_totext(result));
|
||||
|
|
@ -47,12 +47,13 @@ print_dataset(void *arg, const dns_name_t *owner, dns_rdataset_t *dataset) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_result_t result;
|
||||
dns_name_t origin;
|
||||
isc_buffer_t source;
|
||||
isc_buffer_t target;
|
||||
unsigned char name_buf[255];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_name_t origin;
|
||||
isc_buffer_t source;
|
||||
isc_buffer_t target;
|
||||
unsigned char name_buf[255];
|
||||
dns_rdatacallbacks_t callbacks;
|
||||
|
||||
UNUSED(argc);
|
||||
|
|
@ -65,8 +66,8 @@ main(int argc, char *argv[]) {
|
|||
isc_buffer_setactive(&source, strlen(argv[1]));
|
||||
isc_buffer_init(&target, name_buf, 255);
|
||||
dns_name_init(&origin, NULL);
|
||||
result = dns_name_fromtext(&origin, &source, dns_rootname,
|
||||
0, &target);
|
||||
result = dns_name_fromtext(&origin, &source, dns_rootname, 0,
|
||||
&target);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stdout, "dns_name_fromtext: %s\n",
|
||||
dns_result_totext(result));
|
||||
|
|
@ -76,10 +77,9 @@ main(int argc, char *argv[]) {
|
|||
dns_rdatacallbacks_init_stdio(&callbacks);
|
||||
callbacks.add = print_dataset;
|
||||
|
||||
result = dns_master_loadfile(argv[1], &origin, &origin,
|
||||
dns_rdataclass_in, 0, 0,
|
||||
&callbacks, NULL, NULL, mctx,
|
||||
dns_masterformat_text, 0);
|
||||
result = dns_master_loadfile(
|
||||
argv[1], &origin, &origin, dns_rdataclass_in, 0, 0,
|
||||
&callbacks, NULL, NULL, mctx, dns_masterformat_text, 0);
|
||||
fprintf(stdout, "dns_master_loadfile: %s\n",
|
||||
dns_result_totext(result));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,14 @@
|
|||
isc_mem_t *mctx;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
void *items1[50];
|
||||
void *items2[50];
|
||||
void *tmp;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
void * items1[50];
|
||||
void * items2[50];
|
||||
void * tmp;
|
||||
isc_mempool_t *mp1, *mp2;
|
||||
unsigned int i, j;
|
||||
isc_mutex_t lock;
|
||||
unsigned int i, j;
|
||||
isc_mutex_t lock;
|
||||
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@
|
|||
#include <dns/result.h>
|
||||
|
||||
static void
|
||||
print_wirename(isc_region_t *name) {
|
||||
print_wirename(isc_region_t *name)
|
||||
{
|
||||
unsigned char *ccurr, *cend;
|
||||
|
||||
if (name->length == 0) {
|
||||
|
|
@ -36,11 +37,12 @@ print_wirename(isc_region_t *name) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_name(dns_name_t *name) {
|
||||
print_name(dns_name_t *name)
|
||||
{
|
||||
isc_result_t result;
|
||||
isc_buffer_t source;
|
||||
isc_region_t r;
|
||||
char s[1000];
|
||||
char s[1000];
|
||||
|
||||
isc_buffer_init(&source, s, sizeof(s));
|
||||
if (dns_name_countlabels(name) > 0)
|
||||
|
|
@ -58,28 +60,29 @@ print_name(dns_name_t *name) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
char s[1000];
|
||||
isc_result_t result;
|
||||
dns_fixedname_t wname, wname2, oname, compname, downname;
|
||||
isc_buffer_t source;
|
||||
isc_region_t r;
|
||||
dns_name_t *name, *comp, *down;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char s[1000];
|
||||
isc_result_t result;
|
||||
dns_fixedname_t wname, wname2, oname, compname, downname;
|
||||
isc_buffer_t source;
|
||||
isc_region_t r;
|
||||
dns_name_t * name, *comp, *down;
|
||||
const dns_name_t *origin;
|
||||
unsigned int downcase = 0;
|
||||
size_t len;
|
||||
bool quiet = false;
|
||||
bool concatenate = false;
|
||||
bool got_name = false;
|
||||
bool check_absolute = false;
|
||||
bool check_wildcard = false;
|
||||
bool test_downcase = false;
|
||||
bool inplace = false;
|
||||
bool want_split = false;
|
||||
unsigned int labels, split_label = 0;
|
||||
dns_fixedname_t fprefix, fsuffix;
|
||||
dns_name_t *prefix, *suffix;
|
||||
int ch;
|
||||
unsigned int downcase = 0;
|
||||
size_t len;
|
||||
bool quiet = false;
|
||||
bool concatenate = false;
|
||||
bool got_name = false;
|
||||
bool check_absolute = false;
|
||||
bool check_wildcard = false;
|
||||
bool test_downcase = false;
|
||||
bool inplace = false;
|
||||
bool want_split = false;
|
||||
unsigned int labels, split_label = 0;
|
||||
dns_fixedname_t fprefix, fsuffix;
|
||||
dns_name_t * prefix, *suffix;
|
||||
int ch;
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, "acdiqs:w")) != -1) {
|
||||
switch (ch) {
|
||||
|
|
@ -143,8 +146,8 @@ main(int argc, char *argv[]) {
|
|||
isc_buffer_init(&source, argv[1], len);
|
||||
isc_buffer_add(&source, len);
|
||||
comp = dns_fixedname_initname(&compname);
|
||||
result = dns_name_fromtext(comp, &source, origin,
|
||||
0, NULL);
|
||||
result = dns_name_fromtext(comp, &source, origin, 0,
|
||||
NULL);
|
||||
if (result != 0) {
|
||||
fprintf(stderr,
|
||||
"dns_name_fromtext() failed: %s\n",
|
||||
|
|
@ -209,10 +212,9 @@ main(int argc, char *argv[]) {
|
|||
if (got_name) {
|
||||
printf("Concatenating.\n");
|
||||
result = dns_name_concatenate(
|
||||
dns_fixedname_name(&wname),
|
||||
dns_fixedname_name(&wname2),
|
||||
dns_fixedname_name(&wname2),
|
||||
NULL);
|
||||
dns_fixedname_name(&wname),
|
||||
dns_fixedname_name(&wname2),
|
||||
dns_fixedname_name(&wname2), NULL);
|
||||
name = dns_fixedname_name(&wname2);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (check_absolute &&
|
||||
|
|
@ -235,7 +237,8 @@ main(int argc, char *argv[]) {
|
|||
print_wirename(&r);
|
||||
printf("%u labels, "
|
||||
"%u bytes.\n",
|
||||
dns_name_countlabels(name),
|
||||
dns_name_countlabels(
|
||||
name),
|
||||
r.length);
|
||||
}
|
||||
} else
|
||||
|
|
@ -274,16 +277,15 @@ main(int argc, char *argv[]) {
|
|||
dns_name_toregion(down, &r);
|
||||
print_wirename(&r);
|
||||
printf("%u labels, %u bytes.\n",
|
||||
dns_name_countlabels(down),
|
||||
r.length);
|
||||
dns_name_countlabels(down), r.length);
|
||||
}
|
||||
isc_buffer_init(&source, s, sizeof(s));
|
||||
print_name(down);
|
||||
}
|
||||
|
||||
if (comp != NULL && dns_name_countlabels(name) > 0) {
|
||||
int order;
|
||||
unsigned int nlabels;
|
||||
int order;
|
||||
unsigned int nlabels;
|
||||
dns_namereln_t namereln;
|
||||
|
||||
namereln = dns_name_fullcompare(name, comp, &order,
|
||||
|
|
|
|||
|
|
@ -30,26 +30,28 @@ ISC_PLATFORM_NORETURN_PRE static inline void
|
|||
fatal(const char *message) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
static inline void
|
||||
fatal(const char *message) {
|
||||
fatal(const char *message)
|
||||
{
|
||||
fprintf(stderr, "%s\n", message);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
check_result(isc_result_t result, const char *message) {
|
||||
check_result(isc_result_t result, const char *message)
|
||||
{
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "%s: %s\n", message,
|
||||
isc_result_totext(result));
|
||||
fprintf(stderr, "%s: %s\n", message, isc_result_totext(result));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
active_node(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node) {
|
||||
active_node(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node)
|
||||
{
|
||||
dns_rdatasetiter_t *rdsiter;
|
||||
bool active = false;
|
||||
isc_result_t result;
|
||||
dns_rdataset_t rdataset;
|
||||
bool active = false;
|
||||
isc_result_t result;
|
||||
dns_rdataset_t rdataset;
|
||||
|
||||
dns_rdataset_init(&rdataset);
|
||||
rdsiter = NULL;
|
||||
|
|
@ -89,7 +91,7 @@ next_active(dns_db_t *db, dns_dbversion_t *version, dns_dbiterator_t *dbiter,
|
|||
dns_name_t *name, dns_dbnode_t **nodep)
|
||||
{
|
||||
isc_result_t result;
|
||||
bool active;
|
||||
bool active;
|
||||
|
||||
do {
|
||||
active = false;
|
||||
|
|
@ -107,18 +109,19 @@ next_active(dns_db_t *db, dns_dbversion_t *version, dns_dbiterator_t *dbiter,
|
|||
}
|
||||
|
||||
static void
|
||||
nsecify(char *filename) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db;
|
||||
dns_dbversion_t *wversion;
|
||||
dns_dbnode_t *node, *nextnode;
|
||||
const char *origintext;
|
||||
dns_fixedname_t fname, fnextname;
|
||||
dns_name_t *name, *nextname, *target;
|
||||
isc_buffer_t b;
|
||||
size_t len;
|
||||
nsecify(char *filename)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_db_t * db;
|
||||
dns_dbversion_t * wversion;
|
||||
dns_dbnode_t * node, *nextnode;
|
||||
const char * origintext;
|
||||
dns_fixedname_t fname, fnextname;
|
||||
dns_name_t * name, *nextname, *target;
|
||||
isc_buffer_t b;
|
||||
size_t len;
|
||||
dns_dbiterator_t *dbiter;
|
||||
char newfilename[1024];
|
||||
char newfilename[1024];
|
||||
|
||||
name = dns_fixedname_initname(&fname);
|
||||
nextname = dns_fixedname_initname(&fnextname);
|
||||
|
|
@ -127,7 +130,7 @@ nsecify(char *filename) {
|
|||
if (origintext == NULL)
|
||||
origintext = filename;
|
||||
else
|
||||
origintext++; /* Skip '/'. */
|
||||
origintext++; /* Skip '/'. */
|
||||
len = strlen(origintext);
|
||||
isc_buffer_constinit(&b, origintext, len);
|
||||
isc_buffer_add(&b, len);
|
||||
|
|
@ -163,7 +166,7 @@ nsecify(char *filename) {
|
|||
else if (result == ISC_R_NOMORE)
|
||||
target = dns_db_origin(db);
|
||||
else {
|
||||
target = NULL; /* Make compiler happy. */
|
||||
target = NULL; /* Make compiler happy. */
|
||||
fatal("db iteration failed");
|
||||
}
|
||||
dns_nsec_build(db, wversion, node, target, 3600); /* XXX BEW */
|
||||
|
|
@ -187,7 +190,8 @@ nsecify(char *filename) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
dns_result_register();
|
||||
|
|
|
|||
|
|
@ -12,65 +12,66 @@
|
|||
#include <isc/app.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/ratelimiter.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/timer.h>
|
||||
#include <isc/ratelimiter.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
isc_ratelimiter_t *rlim = NULL;
|
||||
isc_taskmgr_t *taskmgr = NULL;
|
||||
isc_timermgr_t *timermgr = NULL;
|
||||
isc_task_t *g_task = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_taskmgr_t * taskmgr = NULL;
|
||||
isc_timermgr_t * timermgr = NULL;
|
||||
isc_task_t * g_task = NULL;
|
||||
isc_mem_t * mctx = NULL;
|
||||
|
||||
static void utick(isc_task_t *task, isc_event_t *event);
|
||||
static void shutdown_rl(isc_task_t *task, isc_event_t *event);
|
||||
static void shutdown_all(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
utick(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
shutdown_rl(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
shutdown_all(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
typedef struct {
|
||||
int milliseconds;
|
||||
void (*fun)(isc_task_t *, isc_event_t *);
|
||||
} schedule_t;
|
||||
|
||||
schedule_t schedule[] = {
|
||||
{ 100, utick },
|
||||
{ 200, utick },
|
||||
{ 300, utick },
|
||||
{ 3000, utick },
|
||||
{ 3100, utick },
|
||||
{ 3200, utick },
|
||||
{ 3300, shutdown_rl },
|
||||
{ 5000, utick },
|
||||
{ 6000, shutdown_all }
|
||||
};
|
||||
schedule_t schedule[] = { { 100, utick }, { 200, utick },
|
||||
{ 300, utick }, { 3000, utick },
|
||||
{ 3100, utick }, { 3200, utick },
|
||||
{ 3300, shutdown_rl }, { 5000, utick },
|
||||
{ 6000, shutdown_all } };
|
||||
|
||||
#define NEVENTS (int)(sizeof(schedule)/sizeof(schedule[0]))
|
||||
#define NEVENTS (int)(sizeof(schedule) / sizeof(schedule[0]))
|
||||
|
||||
isc_timer_t *timers[NEVENTS];
|
||||
|
||||
static void
|
||||
ltick(isc_task_t *task, isc_event_t *event) {
|
||||
ltick(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
UNUSED(task);
|
||||
printf("** ltick%s **\n",
|
||||
(event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0 ?
|
||||
" (canceled)" : "");
|
||||
(event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0 ? " ("
|
||||
"canceled"
|
||||
")"
|
||||
: "");
|
||||
isc_event_free(&event);
|
||||
}
|
||||
|
||||
static void
|
||||
utick(isc_task_t *task, isc_event_t *event) {
|
||||
utick(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_result_t result;
|
||||
UNUSED(task);
|
||||
event->ev_action = ltick;
|
||||
event->ev_sender = NULL;
|
||||
result = isc_ratelimiter_enqueue(rlim, g_task, &event);
|
||||
printf("enqueue: %s\n",
|
||||
result == ISC_R_SUCCESS ? "ok" : "failed");
|
||||
printf("enqueue: %s\n", result == ISC_R_SUCCESS ? "ok" : "failed");
|
||||
}
|
||||
|
||||
static void
|
||||
shutdown_rl(isc_task_t *task, isc_event_t *event) {
|
||||
shutdown_rl(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
UNUSED(task);
|
||||
UNUSED(event);
|
||||
printf("shutdown ratelimiter\n");
|
||||
|
|
@ -78,7 +79,8 @@ shutdown_rl(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
shutdown_all(isc_task_t *task, isc_event_t *event) {
|
||||
shutdown_all(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
int i;
|
||||
UNUSED(task);
|
||||
UNUSED(event);
|
||||
|
|
@ -91,9 +93,10 @@ shutdown_all(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_interval_t linterval;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
|
@ -104,27 +107,23 @@ main(int argc, char *argv[]) {
|
|||
isc_mem_create(&mctx);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, 3, 0, NULL, &taskmgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &g_task) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &g_task) == ISC_R_SUCCESS);
|
||||
|
||||
RUNTIME_CHECK(isc_ratelimiter_create(mctx, timermgr, g_task,
|
||||
&rlim) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_ratelimiter_create(mctx, timermgr, g_task, &rlim) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
RUNTIME_CHECK(isc_ratelimiter_setinterval(rlim, &linterval) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
for (i = 0; i < NEVENTS; i++) {
|
||||
isc_interval_t uinterval;
|
||||
int ms = schedule[i].milliseconds;
|
||||
isc_interval_set(&uinterval, ms / 1000,
|
||||
(ms % 1000) * 1000000);
|
||||
int ms = schedule[i].milliseconds;
|
||||
isc_interval_set(&uinterval, ms / 1000, (ms % 1000) * 1000000);
|
||||
timers[i] = NULL;
|
||||
RUNTIME_CHECK(isc_timer_create(timermgr,
|
||||
isc_timertype_once, NULL,
|
||||
&uinterval,
|
||||
g_task, schedule[i].fun, NULL,
|
||||
RUNTIME_CHECK(isc_timer_create(timermgr, isc_timertype_once,
|
||||
NULL, &uinterval, g_task,
|
||||
schedule[i].fun, NULL,
|
||||
&timers[i]) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,20 +18,21 @@
|
|||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/rbt.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/rbt.h>
|
||||
#include <dns/result.h>
|
||||
|
||||
const char *progname;
|
||||
isc_mem_t *mctx;
|
||||
isc_mem_t * mctx;
|
||||
|
||||
#define DNSNAMELEN 255
|
||||
|
||||
static dns_name_t *
|
||||
create_name(char *s) {
|
||||
int length;
|
||||
isc_result_t result;
|
||||
isc_buffer_t source, target;
|
||||
create_name(char *s)
|
||||
{
|
||||
int length;
|
||||
isc_result_t result;
|
||||
isc_buffer_t source, target;
|
||||
static dns_name_t *name;
|
||||
|
||||
if (s == NULL || *s == '\0') {
|
||||
|
|
@ -62,8 +63,8 @@ create_name(char *s) {
|
|||
result = dns_name_fromtext(name, &source, dns_rootname, 0, &target);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
printf("dns_name_fromtext(%s) failed: %s\n",
|
||||
s, dns_result_totext(result));
|
||||
printf("dns_name_fromtext(%s) failed: %s\n", s,
|
||||
dns_result_totext(result));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +72,8 @@ create_name(char *s) {
|
|||
}
|
||||
|
||||
static void
|
||||
delete_name(void *data, void *arg) {
|
||||
delete_name(void *data, void *arg)
|
||||
{
|
||||
dns_name_t *name;
|
||||
|
||||
UNUSED(arg);
|
||||
|
|
@ -80,9 +82,10 @@ delete_name(void *data, void *arg) {
|
|||
}
|
||||
|
||||
static void
|
||||
print_name(dns_name_t *name) {
|
||||
print_name(dns_name_t *name)
|
||||
{
|
||||
isc_buffer_t target;
|
||||
char buffer[1024];
|
||||
char buffer[1024];
|
||||
|
||||
isc_buffer_init(&target, buffer, sizeof(buffer));
|
||||
|
||||
|
|
@ -95,13 +98,14 @@ print_name(dns_name_t *name) {
|
|||
}
|
||||
|
||||
static void
|
||||
detail(dns_rbt_t *rbt, dns_name_t *name) {
|
||||
dns_name_t *foundname, *origin, *fullname;
|
||||
dns_fixedname_t fixedfoundname, fixedorigin, fixedfullname;
|
||||
dns_rbtnode_t *node1, *node2;
|
||||
detail(dns_rbt_t *rbt, dns_name_t *name)
|
||||
{
|
||||
dns_name_t * foundname, *origin, *fullname;
|
||||
dns_fixedname_t fixedfoundname, fixedorigin, fixedfullname;
|
||||
dns_rbtnode_t * node1, *node2;
|
||||
dns_rbtnodechain_t chain;
|
||||
isc_result_t result;
|
||||
bool nodes_should_match = false;
|
||||
isc_result_t result;
|
||||
bool nodes_should_match = false;
|
||||
|
||||
dns_rbtnodechain_init(&chain);
|
||||
|
||||
|
|
@ -150,8 +154,8 @@ detail(dns_rbt_t *rbt, dns_name_t *name) {
|
|||
if (result == ISC_R_SUCCESS) {
|
||||
printf("\n name from dns_rbtnodechain_current: ");
|
||||
|
||||
result = dns_name_concatenate(foundname, origin,
|
||||
fullname, NULL);
|
||||
result =
|
||||
dns_name_concatenate(foundname, origin, fullname, NULL);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
print_name(fullname);
|
||||
else
|
||||
|
|
@ -169,18 +173,19 @@ detail(dns_rbt_t *rbt, dns_name_t *name) {
|
|||
printf("\n result from dns_rbtnodechain_current: %s\n",
|
||||
dns_result_totext(result));
|
||||
|
||||
printf(" level_matches = %u, level_count = %u\n",
|
||||
chain.level_matches, chain.level_count);
|
||||
printf(" level_matches = %u, level_count = %u\n", chain.level_matches,
|
||||
chain.level_count);
|
||||
}
|
||||
|
||||
static void
|
||||
iterate(dns_rbt_t *rbt, bool forward) {
|
||||
dns_name_t foundname, *origin;
|
||||
iterate(dns_rbt_t *rbt, bool forward)
|
||||
{
|
||||
dns_name_t foundname, *origin;
|
||||
dns_rbtnodechain_t chain;
|
||||
dns_fixedname_t fixedorigin;
|
||||
isc_result_t result;
|
||||
isc_result_t (*move)(dns_rbtnodechain_t *chain, dns_name_t *name,
|
||||
dns_name_t *origin);
|
||||
dns_fixedname_t fixedorigin;
|
||||
isc_result_t result;
|
||||
isc_result_t (*move)(dns_rbtnodechain_t * chain, dns_name_t * name,
|
||||
dns_name_t * origin);
|
||||
|
||||
dns_rbtnodechain_init(&chain);
|
||||
|
||||
|
|
@ -188,18 +193,17 @@ iterate(dns_rbt_t *rbt, bool forward) {
|
|||
origin = dns_fixedname_initname(&fixedorigin);
|
||||
|
||||
if (forward) {
|
||||
printf("iterating forward\n" );
|
||||
printf("iterating forward\n");
|
||||
move = dns_rbtnodechain_next;
|
||||
|
||||
result = dns_rbtnodechain_first(&chain, rbt, &foundname,
|
||||
origin);
|
||||
result =
|
||||
dns_rbtnodechain_first(&chain, rbt, &foundname, origin);
|
||||
|
||||
} else {
|
||||
printf("iterating backward\n" );
|
||||
printf("iterating backward\n");
|
||||
move = dns_rbtnodechain_prev;
|
||||
|
||||
result = dns_rbtnodechain_last(&chain, rbt, &foundname,
|
||||
origin);
|
||||
result = dns_rbtnodechain_last(&chain, rbt, &foundname, origin);
|
||||
}
|
||||
|
||||
if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN)
|
||||
|
|
@ -220,8 +224,8 @@ iterate(dns_rbt_t *rbt, bool forward) {
|
|||
|
||||
} else {
|
||||
if (result != ISC_R_NOMORE)
|
||||
printf("UNEXEPCTED ITERATION ERROR: %s",
|
||||
dns_result_totext(result));
|
||||
printf("UNEXEPCTED ITERATION ERROR: %s",
|
||||
dns_result_totext(result));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -230,22 +234,23 @@ iterate(dns_rbt_t *rbt, bool forward) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define CMDCHECK(s) (strncasecmp(command, (s), length) == 0)
|
||||
#define PRINTERR(r) if (r != ISC_R_SUCCESS) \
|
||||
printf("... %s\n", dns_result_totext(r));
|
||||
#define CMDCHECK(s) (strncasecmp(command, (s), length) == 0)
|
||||
#define PRINTERR(r) \
|
||||
if (r != ISC_R_SUCCESS) \
|
||||
printf("... %s\n", dns_result_totext(r));
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
char *command, *arg, buffer[1024];
|
||||
const char *whitespace;
|
||||
dns_name_t *name, *foundname;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char * command, *arg, buffer[1024];
|
||||
const char * whitespace;
|
||||
dns_name_t * name, *foundname;
|
||||
dns_fixedname_t fixedname;
|
||||
dns_rbt_t *rbt = NULL;
|
||||
int length, ch;
|
||||
bool show_final_mem = false;
|
||||
isc_result_t result;
|
||||
void *data;
|
||||
dns_rbt_t * rbt = NULL;
|
||||
int length, ch;
|
||||
bool show_final_mem = false;
|
||||
isc_result_t result;
|
||||
void * data;
|
||||
|
||||
progname = strrchr(*argv, '/');
|
||||
if (progname != NULL)
|
||||
|
|
@ -316,8 +321,8 @@ main(int argc, char **argv) {
|
|||
name = create_name(arg);
|
||||
if (name != NULL) {
|
||||
printf("adding name %s\n", arg);
|
||||
result = dns_rbt_addname(rbt,
|
||||
name, name);
|
||||
result = dns_rbt_addname(rbt, name,
|
||||
name);
|
||||
PRINTERR(result);
|
||||
}
|
||||
|
||||
|
|
@ -335,7 +340,8 @@ main(int argc, char **argv) {
|
|||
name = create_name(arg);
|
||||
if (name != NULL) {
|
||||
printf("nuking name %s "
|
||||
"and its descendants\n", arg);
|
||||
"and its descendants\n",
|
||||
arg);
|
||||
result = dns_rbt_deletename(rbt, name,
|
||||
true);
|
||||
PRINTERR(result);
|
||||
|
|
@ -348,13 +354,12 @@ main(int argc, char **argv) {
|
|||
printf("searching for name %s ... ",
|
||||
arg);
|
||||
|
||||
foundname =
|
||||
dns_fixedname_initname(&fixedname);
|
||||
foundname = dns_fixedname_initname(
|
||||
&fixedname);
|
||||
data = NULL;
|
||||
|
||||
result = dns_rbt_findname(rbt, name, 0,
|
||||
foundname,
|
||||
&data);
|
||||
result = dns_rbt_findname(
|
||||
rbt, name, 0, foundname, &data);
|
||||
switch (result) {
|
||||
case ISC_R_SUCCESS:
|
||||
printf("found exact: ");
|
||||
|
|
@ -419,10 +424,8 @@ main(int argc, char **argv) {
|
|||
} else {
|
||||
printf("a(dd) NAME, d(elete) NAME, "
|
||||
"s(earch) NAME, p(rint), or q(uit)\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dns_rbt_destroy(&rbt);
|
||||
|
|
|
|||
|
|
@ -14,22 +14,23 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
#include <isc/thread.h>
|
||||
#include <isc/rwlock.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/thread.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define sleep(x) Sleep(1000 * x)
|
||||
#define sleep(x) Sleep(1000 * x)
|
||||
#endif
|
||||
|
||||
isc_rwlock_t lock;
|
||||
|
||||
static isc_threadresult_t
|
||||
#ifdef WIN32
|
||||
WINAPI
|
||||
WINAPI
|
||||
#endif
|
||||
run1(void *arg) {
|
||||
run1(void *arg)
|
||||
{
|
||||
char *message = arg;
|
||||
|
||||
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_read) ==
|
||||
|
|
@ -38,29 +39,30 @@ run1(void *arg) {
|
|||
sleep(1);
|
||||
printf("%s giving up READ lock\n", message);
|
||||
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
|
||||
ISC_R_SUCCESS);
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_read) ==
|
||||
ISC_R_SUCCESS);
|
||||
printf("%s got READ lock\n", message);
|
||||
sleep(1);
|
||||
printf("%s giving up READ lock\n", message);
|
||||
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
|
||||
ISC_R_SUCCESS);
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_write) ==
|
||||
ISC_R_SUCCESS);
|
||||
printf("%s got WRITE lock\n", message);
|
||||
sleep(1);
|
||||
printf("%s giving up WRITE lock\n", message);
|
||||
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
|
||||
ISC_R_SUCCESS);
|
||||
ISC_R_SUCCESS);
|
||||
return ((isc_threadresult_t)0);
|
||||
}
|
||||
|
||||
static isc_threadresult_t
|
||||
#ifdef WIN32
|
||||
WINAPI
|
||||
WINAPI
|
||||
#endif
|
||||
run2(void *arg) {
|
||||
run2(void *arg)
|
||||
{
|
||||
char *message = arg;
|
||||
|
||||
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_write) ==
|
||||
|
|
@ -69,31 +71,32 @@ run2(void *arg) {
|
|||
sleep(1);
|
||||
printf("%s giving up WRITE lock\n", message);
|
||||
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
|
||||
ISC_R_SUCCESS);
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_write) ==
|
||||
ISC_R_SUCCESS);
|
||||
printf("%s got WRITE lock\n", message);
|
||||
sleep(1);
|
||||
printf("%s giving up WRITE lock\n", message);
|
||||
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_write) ==
|
||||
ISC_R_SUCCESS);
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_rwlock_lock(&lock, isc_rwlocktype_read) ==
|
||||
ISC_R_SUCCESS);
|
||||
printf("%s got READ lock\n", message);
|
||||
sleep(1);
|
||||
printf("%s giving up READ lock\n", message);
|
||||
RUNTIME_CHECK(isc_rwlock_unlock(&lock, isc_rwlocktype_read) ==
|
||||
ISC_R_SUCCESS);
|
||||
ISC_R_SUCCESS);
|
||||
return ((isc_threadresult_t)0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int nworkers;
|
||||
unsigned int i;
|
||||
isc_thread_t workers[100];
|
||||
char name[100];
|
||||
void *dupname;
|
||||
char name[100];
|
||||
void * dupname;
|
||||
|
||||
if (argc > 1)
|
||||
nworkers = atoi(argv[1]);
|
||||
|
|
|
|||
|
|
@ -9,18 +9,19 @@
|
|||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <isc/print.h>
|
||||
#include <isc/serial.h>
|
||||
|
||||
int
|
||||
main() {
|
||||
main()
|
||||
{
|
||||
uint32_t a, b;
|
||||
char buf[1024];
|
||||
char *s, *e;
|
||||
char buf[1024];
|
||||
char * s, *e;
|
||||
|
||||
while (fgets(buf, sizeof(buf), stdin) != NULL) {
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
|
|
@ -33,10 +34,9 @@ main() {
|
|||
if (s == e)
|
||||
continue;
|
||||
fprintf(stdout, "%u %u gt:%d lt:%d ge:%d le:%d eq:%d ne:%d\n",
|
||||
a, b,
|
||||
isc_serial_gt(a,b), isc_serial_lt(a,b),
|
||||
isc_serial_ge(a,b), isc_serial_le(a,b),
|
||||
isc_serial_eq(a,b), isc_serial_ne(a,b));
|
||||
a, b, isc_serial_gt(a, b), isc_serial_lt(a, b),
|
||||
isc_serial_ge(a, b), isc_serial_le(a, b),
|
||||
isc_serial_eq(a, b), isc_serial_ne(a, b));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,27 +23,28 @@
|
|||
#include <isc/util.h>
|
||||
|
||||
typedef struct {
|
||||
isc_mem_t * mctx;
|
||||
isc_task_t * task;
|
||||
isc_timer_t * timer;
|
||||
unsigned int ticks;
|
||||
char name[16];
|
||||
bool exiting;
|
||||
isc_task_t * peer;
|
||||
isc_mem_t * mctx;
|
||||
isc_task_t * task;
|
||||
isc_timer_t *timer;
|
||||
unsigned int ticks;
|
||||
char name[16];
|
||||
bool exiting;
|
||||
isc_task_t * peer;
|
||||
} t_info;
|
||||
|
||||
#define MAX_TASKS 3
|
||||
#define T2_SHUTDOWNOK (ISC_EVENTCLASS(1024) + 0)
|
||||
#define T2_SHUTDOWNDONE (ISC_EVENTCLASS(1024) + 1)
|
||||
#define FOO_EVENT (ISC_EVENTCLASS(1024) + 2)
|
||||
#define MAX_TASKS 3
|
||||
#define T2_SHUTDOWNOK (ISC_EVENTCLASS(1024) + 0)
|
||||
#define T2_SHUTDOWNDONE (ISC_EVENTCLASS(1024) + 1)
|
||||
#define FOO_EVENT (ISC_EVENTCLASS(1024) + 2)
|
||||
|
||||
static t_info tasks[MAX_TASKS];
|
||||
static unsigned int task_count;
|
||||
static isc_taskmgr_t * task_manager;
|
||||
static isc_timermgr_t * timer_manager;
|
||||
static t_info tasks[MAX_TASKS];
|
||||
static unsigned int task_count;
|
||||
static isc_taskmgr_t * task_manager;
|
||||
static isc_timermgr_t *timer_manager;
|
||||
|
||||
static void
|
||||
t1_shutdown(isc_task_t *task, isc_event_t *event) {
|
||||
t1_shutdown(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
t_info *info = event->ev_arg;
|
||||
|
||||
printf("task %s (%p) t1_shutdown\n", info->name, task);
|
||||
|
|
@ -52,7 +53,8 @@ t1_shutdown(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
t2_shutdown(isc_task_t *task, isc_event_t *event) {
|
||||
t2_shutdown(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
t_info *info = event->ev_arg;
|
||||
|
||||
printf("task %s (%p) t2_shutdown\n", info->name, task);
|
||||
|
|
@ -61,8 +63,9 @@ t2_shutdown(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
shutdown_action(isc_task_t *task, isc_event_t *event) {
|
||||
t_info *info = event->ev_arg;
|
||||
shutdown_action(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
t_info * info = event->ev_arg;
|
||||
isc_event_t *nevent;
|
||||
|
||||
INSIST(event->ev_type == ISC_TASKEVENT_SHUTDOWN);
|
||||
|
|
@ -81,14 +84,16 @@ shutdown_action(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
foo_event(isc_task_t *task, isc_event_t *event) {
|
||||
foo_event(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
printf("task(%p) foo\n", task);
|
||||
isc_event_free(&event);
|
||||
}
|
||||
|
||||
static void
|
||||
tick(isc_task_t *task, isc_event_t *event) {
|
||||
t_info *info = event->ev_arg;
|
||||
tick(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
t_info * info = event->ev_arg;
|
||||
isc_event_t *nevent;
|
||||
|
||||
INSIST(event->ev_type == ISC_TIMEREVENT_TICK);
|
||||
|
|
@ -102,20 +107,17 @@ tick(isc_task_t *task, isc_event_t *event) {
|
|||
} else if (info->ticks >= 15 && info->exiting) {
|
||||
isc_timer_detach(&info->timer);
|
||||
isc_task_detach(&info->task);
|
||||
nevent = isc_event_allocate(info->mctx, info,
|
||||
T2_SHUTDOWNDONE,
|
||||
t1_shutdown, &tasks[0],
|
||||
sizeof(*event));
|
||||
nevent = isc_event_allocate(
|
||||
info->mctx, info, T2_SHUTDOWNDONE, t1_shutdown,
|
||||
&tasks[0], sizeof(*event));
|
||||
RUNTIME_CHECK(nevent != NULL);
|
||||
isc_task_send(info->peer, &nevent);
|
||||
isc_task_detach(&info->peer);
|
||||
}
|
||||
} else if (strcmp(info->name, "foo") == 0) {
|
||||
isc_timer_detach(&info->timer);
|
||||
nevent = isc_event_allocate(info->mctx, info,
|
||||
FOO_EVENT,
|
||||
foo_event, task,
|
||||
sizeof(*event));
|
||||
nevent = isc_event_allocate(info->mctx, info, FOO_EVENT,
|
||||
foo_event, task, sizeof(*event));
|
||||
RUNTIME_CHECK(nevent != NULL);
|
||||
isc_task_sendanddetach(&task, &nevent);
|
||||
}
|
||||
|
|
@ -124,9 +126,10 @@ tick(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static t_info *
|
||||
new_task(isc_mem_t *mctx, const char *name) {
|
||||
t_info *ti;
|
||||
isc_time_t expires;
|
||||
new_task(isc_mem_t *mctx, const char *name)
|
||||
{
|
||||
t_info * ti;
|
||||
isc_time_t expires;
|
||||
isc_interval_t interval;
|
||||
|
||||
RUNTIME_CHECK(task_count < MAX_TASKS);
|
||||
|
|
@ -149,9 +152,8 @@ new_task(isc_mem_t *mctx, const char *name) {
|
|||
isc_time_settoepoch(&expires);
|
||||
isc_interval_set(&interval, 1, 0);
|
||||
RUNTIME_CHECK(isc_timer_create(timer_manager, isc_timertype_ticker,
|
||||
&expires, &interval, ti->task,
|
||||
tick, ti, &ti->timer) ==
|
||||
ISC_R_SUCCESS);
|
||||
&expires, &interval, ti->task, tick, ti,
|
||||
&ti->timer) == ISC_R_SUCCESS);
|
||||
|
||||
task_count++;
|
||||
|
||||
|
|
@ -159,11 +161,12 @@ new_task(isc_mem_t *mctx, const char *name) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int workers;
|
||||
t_info *t1, *t2;
|
||||
isc_task_t *task;
|
||||
isc_mem_t *mctx, *mctx2;
|
||||
t_info * t1, *t2;
|
||||
isc_task_t * task;
|
||||
isc_mem_t * mctx, *mctx2;
|
||||
|
||||
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
|
||||
|
||||
|
|
@ -181,8 +184,8 @@ main(int argc, char *argv[]) {
|
|||
isc_mem_create(&mctx);
|
||||
mctx2 = NULL;
|
||||
isc_mem_create(&mctx2);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL, &task_manager) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, NULL,
|
||||
&task_manager) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timer_manager) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
|
|
@ -200,15 +203,13 @@ main(int argc, char *argv[]) {
|
|||
* Test implicit shutdown.
|
||||
*/
|
||||
task = NULL;
|
||||
RUNTIME_CHECK(isc_task_create(task_manager, 0, &task) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_task_create(task_manager, 0, &task) == ISC_R_SUCCESS);
|
||||
isc_task_detach(&task);
|
||||
|
||||
/*
|
||||
* Test anti-zombie code.
|
||||
*/
|
||||
RUNTIME_CHECK(isc_task_create(task_manager, 0, &task) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_task_create(task_manager, 0, &task) == ISC_R_SUCCESS);
|
||||
isc_task_detach(&task);
|
||||
|
||||
RUNTIME_CHECK(isc_app_run() == ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@
|
|||
#include <isc/mutex.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/socket.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/timer.h>
|
||||
#include <isc/socket.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/dnssec.h>
|
||||
|
|
@ -40,33 +40,35 @@
|
|||
#include <dns/result.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
#include <dst/result.h>
|
||||
#include <dst/dst.h>
|
||||
#include <dst/result.h>
|
||||
|
||||
#define CHECK(str, x) { \
|
||||
if ((x) != ISC_R_SUCCESS) { \
|
||||
printf("%s: %s\n", (str), isc_result_totext(x)); \
|
||||
exit(-1); \
|
||||
} \
|
||||
}
|
||||
#define CHECK(str, x) \
|
||||
{ \
|
||||
if ((x) != ISC_R_SUCCESS) { \
|
||||
printf("%s: %s\n", (str), isc_result_totext(x)); \
|
||||
exit(-1); \
|
||||
} \
|
||||
}
|
||||
|
||||
isc_mutex_t lock;
|
||||
dst_key_t *key;
|
||||
isc_mem_t *mctx;
|
||||
unsigned char qdata[1024], rdata[1024];
|
||||
isc_buffer_t qbuffer, rbuffer;
|
||||
isc_taskmgr_t *taskmgr;
|
||||
isc_task_t *task1;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
isc_socket_t *s;
|
||||
isc_sockaddr_t address;
|
||||
char output[10 * 1024];
|
||||
isc_buffer_t outbuf;
|
||||
isc_mutex_t lock;
|
||||
dst_key_t * key;
|
||||
isc_mem_t * mctx;
|
||||
unsigned char qdata[1024], rdata[1024];
|
||||
isc_buffer_t qbuffer, rbuffer;
|
||||
isc_taskmgr_t * taskmgr;
|
||||
isc_task_t * task1;
|
||||
isc_log_t * lctx = NULL;
|
||||
isc_logconfig_t * logconfig = NULL;
|
||||
isc_socket_t * s;
|
||||
isc_sockaddr_t address;
|
||||
char output[10 * 1024];
|
||||
isc_buffer_t outbuf;
|
||||
static const dns_master_style_t *style = &dns_master_style_debug;
|
||||
|
||||
static void
|
||||
senddone(isc_task_t *task, isc_event_t *event) {
|
||||
senddone(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
|
||||
|
||||
REQUIRE(sevent != NULL);
|
||||
|
|
@ -79,11 +81,12 @@ senddone(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
recvdone(isc_task_t *task, isc_event_t *event) {
|
||||
recvdone(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
|
||||
isc_buffer_t source;
|
||||
isc_result_t result;
|
||||
dns_message_t *response;
|
||||
isc_buffer_t source;
|
||||
isc_result_t result;
|
||||
dns_message_t * response;
|
||||
|
||||
REQUIRE(sevent != NULL);
|
||||
REQUIRE(sevent->ev_type == ISC_SOCKEVENT_RECVDONE);
|
||||
|
|
@ -117,17 +120,18 @@ recvdone(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
buildquery(void) {
|
||||
isc_result_t result;
|
||||
buildquery(void)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_rdataset_t *question = NULL;
|
||||
dns_name_t *qname = NULL;
|
||||
isc_region_t r, inr;
|
||||
dns_message_t *query;
|
||||
char nametext[] = "host.example";
|
||||
isc_buffer_t namesrc, namedst;
|
||||
unsigned char namedata[256];
|
||||
isc_sockaddr_t sa;
|
||||
dns_compress_t cctx;
|
||||
dns_name_t * qname = NULL;
|
||||
isc_region_t r, inr;
|
||||
dns_message_t * query;
|
||||
char nametext[] = "host.example";
|
||||
isc_buffer_t namesrc, namedst;
|
||||
unsigned char namedata[256];
|
||||
isc_sockaddr_t sa;
|
||||
dns_compress_t cctx;
|
||||
|
||||
query = NULL;
|
||||
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &query);
|
||||
|
|
@ -137,8 +141,7 @@ buildquery(void) {
|
|||
|
||||
result = dns_message_gettemprdataset(query, &question);
|
||||
CHECK("dns_message_gettemprdataset", result);
|
||||
dns_rdataset_makequestion(question, dns_rdataclass_in,
|
||||
dns_rdatatype_a);
|
||||
dns_rdataset_makequestion(question, dns_rdataclass_in, dns_rdatatype_a);
|
||||
result = dns_message_gettempname(query, &qname);
|
||||
CHECK("dns_message_gettempname", result);
|
||||
isc_buffer_init(&namesrc, nametext, strlen(nametext));
|
||||
|
|
@ -178,8 +181,8 @@ buildquery(void) {
|
|||
isc_sockaddr_any(&sa);
|
||||
result = isc_socket_bind(s, &sa, 0);
|
||||
CHECK("isc_socket_bind", result);
|
||||
result = isc_socket_sendto(s, &r, task1, senddone, NULL, &address,
|
||||
NULL);
|
||||
result =
|
||||
isc_socket_sendto(s, &r, task1, senddone, NULL, &address, NULL);
|
||||
CHECK("isc_socket_sendto", result);
|
||||
|
||||
inr.base = rdata;
|
||||
|
|
@ -190,17 +193,18 @@ buildquery(void) {
|
|||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
bool verbose = false;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
bool verbose = false;
|
||||
isc_socketmgr_t *socketmgr;
|
||||
isc_timermgr_t *timermgr;
|
||||
struct in_addr inaddr;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t *name;
|
||||
isc_buffer_t b;
|
||||
int ch;
|
||||
isc_result_t result;
|
||||
in_port_t port = 53;
|
||||
isc_timermgr_t * timermgr;
|
||||
struct in_addr inaddr;
|
||||
dns_fixedname_t fname;
|
||||
dns_name_t * name;
|
||||
isc_buffer_t b;
|
||||
int ch;
|
||||
isc_result_t result;
|
||||
in_port_t port = 53;
|
||||
|
||||
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
|
||||
|
||||
|
|
@ -239,9 +243,8 @@ main(int argc, char *argv[]) {
|
|||
RUNTIME_CHECK(isc_log_create(mctx, &lctx, &logconfig) == ISC_R_SUCCESS);
|
||||
|
||||
s = NULL;
|
||||
RUNTIME_CHECK(isc_socket_create(socketmgr, PF_INET,
|
||||
isc_sockettype_udp, &s) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp,
|
||||
&s) == ISC_R_SUCCESS);
|
||||
|
||||
inaddr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
isc_sockaddr_fromin(&address, &inaddr, port);
|
||||
|
|
@ -254,8 +257,8 @@ main(int argc, char *argv[]) {
|
|||
|
||||
key = NULL;
|
||||
result = dst_key_fromfile(name, 33180, DNS_KEYALG_RSASHA1,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE,
|
||||
NULL, mctx, &key);
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, NULL,
|
||||
mctx, &key);
|
||||
CHECK("dst_key_fromfile", result);
|
||||
|
||||
buildquery();
|
||||
|
|
|
|||
|
|
@ -21,11 +21,12 @@
|
|||
#include <isc/timer.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
isc_mem_t *mctx;
|
||||
isc_mem_t * mctx;
|
||||
isc_taskmgr_t *manager;
|
||||
|
||||
static void
|
||||
my_shutdown(isc_task_t *task, isc_event_t *event) {
|
||||
my_shutdown(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
char *name = event->ev_arg;
|
||||
|
||||
printf("shutdown %s (%p)\n", name, task);
|
||||
|
|
@ -34,8 +35,9 @@ my_shutdown(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
my_send(isc_task_t *task, isc_event_t *event) {
|
||||
isc_socket_t *sock;
|
||||
my_send(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socket_t * sock;
|
||||
isc_socketevent_t *dev;
|
||||
|
||||
sock = event->ev_sender;
|
||||
|
|
@ -43,9 +45,8 @@ my_send(isc_task_t *task, isc_event_t *event) {
|
|||
|
||||
printf("my_send: %s task %p\n\t(sock %p, base %p, length %u, n %u, "
|
||||
"result %u)\n",
|
||||
(char *)(event->ev_arg), task, sock,
|
||||
dev->region.base, dev->region.length,
|
||||
dev->n, dev->result);
|
||||
(char *)(event->ev_arg), task, sock, dev->region.base,
|
||||
dev->region.length, dev->n, dev->result);
|
||||
|
||||
if (dev->result != ISC_R_SUCCESS) {
|
||||
isc_socket_detach(&sock);
|
||||
|
|
@ -59,28 +60,28 @@ my_send(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
my_recv(isc_task_t *task, isc_event_t *event) {
|
||||
isc_socket_t *sock;
|
||||
my_recv(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socket_t * sock;
|
||||
isc_socketevent_t *dev;
|
||||
isc_region_t region;
|
||||
char buf[1024];
|
||||
char host[256];
|
||||
isc_region_t region;
|
||||
char buf[1024];
|
||||
char host[256];
|
||||
|
||||
sock = event->ev_sender;
|
||||
dev = (isc_socketevent_t *)event;
|
||||
|
||||
printf("Socket %s (sock %p, base %p, length %u, n %u, result %u)\n",
|
||||
(char *)(event->ev_arg), sock,
|
||||
dev->region.base, dev->region.length,
|
||||
dev->n, dev->result);
|
||||
(char *)(event->ev_arg), sock, dev->region.base,
|
||||
dev->region.length, dev->n, dev->result);
|
||||
if (dev->address.type.sa.sa_family == AF_INET6) {
|
||||
inet_ntop(AF_INET6, &dev->address.type.sin6.sin6_addr,
|
||||
host, sizeof(host));
|
||||
inet_ntop(AF_INET6, &dev->address.type.sin6.sin6_addr, host,
|
||||
sizeof(host));
|
||||
printf("\tFrom: %s port %d\n", host,
|
||||
ntohs(dev->address.type.sin6.sin6_port));
|
||||
} else {
|
||||
inet_ntop(AF_INET, &dev->address.type.sin.sin_addr,
|
||||
host, sizeof(host));
|
||||
inet_ntop(AF_INET, &dev->address.type.sin.sin_addr, host,
|
||||
sizeof(host));
|
||||
printf("\tFrom: %s port %d\n", host,
|
||||
ntohs(dev->address.type.sin.sin_port));
|
||||
}
|
||||
|
|
@ -111,8 +112,8 @@ my_recv(isc_task_t *task, isc_event_t *event) {
|
|||
isc_socket_send(sock, ®ion, task, my_send, event->ev_arg);
|
||||
} else {
|
||||
region = dev->region;
|
||||
printf("\r\nReceived: %.*s\r\n\r\n",
|
||||
(int)dev->n, (char *)region.base);
|
||||
printf("\r\nReceived: %.*s\r\n\r\n", (int)dev->n,
|
||||
(char *)region.base);
|
||||
}
|
||||
|
||||
isc_socket_recv(sock, &dev->region, 1, task, my_recv, event->ev_arg);
|
||||
|
|
@ -121,8 +122,9 @@ my_recv(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
my_http_get(isc_task_t *task, isc_event_t *event) {
|
||||
isc_socket_t *sock;
|
||||
my_http_get(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socket_t * sock;
|
||||
isc_socketevent_t *dev;
|
||||
|
||||
sock = event->ev_sender;
|
||||
|
|
@ -130,9 +132,8 @@ my_http_get(isc_task_t *task, isc_event_t *event) {
|
|||
|
||||
printf("my_http_get: %s task %p\n\t(sock %p, base %p, length %u, "
|
||||
"n %u, result %u)\n",
|
||||
(char *)(event->ev_arg), task, sock,
|
||||
dev->region.base, dev->region.length,
|
||||
dev->n, dev->result);
|
||||
(char *)(event->ev_arg), task, sock, dev->region.base,
|
||||
dev->region.length, dev->n, dev->result);
|
||||
|
||||
if (dev->result != ISC_R_SUCCESS) {
|
||||
isc_socket_detach(&sock);
|
||||
|
|
@ -149,11 +150,12 @@ my_http_get(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
my_connect(isc_task_t *task, isc_event_t *event) {
|
||||
isc_socket_t *sock;
|
||||
my_connect(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socket_t * sock;
|
||||
isc_socket_connev_t *dev;
|
||||
isc_region_t region;
|
||||
char buf[1024];
|
||||
isc_region_t region;
|
||||
char buf[1024];
|
||||
|
||||
sock = event->ev_sender;
|
||||
dev = (isc_socket_connev_t *)event;
|
||||
|
|
@ -187,17 +189,18 @@ my_connect(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
my_listen(isc_task_t *task, isc_event_t *event) {
|
||||
char *name = event->ev_arg;
|
||||
my_listen(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
char * name = event->ev_arg;
|
||||
isc_socket_newconnev_t *dev;
|
||||
isc_region_t region;
|
||||
isc_socket_t *oldsock;
|
||||
isc_task_t *newtask;
|
||||
isc_region_t region;
|
||||
isc_socket_t * oldsock;
|
||||
isc_task_t * newtask;
|
||||
|
||||
dev = (isc_socket_newconnev_t *)event;
|
||||
|
||||
printf("newcon %s (task %p, oldsock %p, newsock %p, result %u)\n",
|
||||
name, task, event->ev_sender, dev->newsocket, dev->result);
|
||||
printf("newcon %s (task %p, oldsock %p, newsock %p, result %u)\n", name,
|
||||
task, event->ev_sender, dev->newsocket, dev->result);
|
||||
fflush(stdout);
|
||||
|
||||
if (dev->result == ISC_R_SUCCESS) {
|
||||
|
|
@ -205,8 +208,8 @@ my_listen(isc_task_t *task, isc_event_t *event) {
|
|||
* Queue another listen on this socket.
|
||||
*/
|
||||
RUNTIME_CHECK(isc_socket_accept(event->ev_sender, task,
|
||||
my_listen, event->ev_arg)
|
||||
== ISC_R_SUCCESS);
|
||||
my_listen, event->ev_arg) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
region.base = isc_mem_get(mctx, 20);
|
||||
region.length = 20;
|
||||
|
|
@ -216,10 +219,10 @@ my_listen(isc_task_t *task, isc_event_t *event) {
|
|||
* recv on it.
|
||||
*/
|
||||
newtask = NULL;
|
||||
RUNTIME_CHECK(isc_task_create(manager, 0, &newtask)
|
||||
== ISC_R_SUCCESS);
|
||||
isc_socket_recv(dev->newsocket, ®ion, 1,
|
||||
newtask, my_recv, event->ev_arg);
|
||||
RUNTIME_CHECK(isc_task_create(manager, 0, &newtask) ==
|
||||
ISC_R_SUCCESS);
|
||||
isc_socket_recv(dev->newsocket, ®ion, 1, newtask, my_recv,
|
||||
event->ev_arg);
|
||||
isc_task_detach(&newtask);
|
||||
} else {
|
||||
printf("detaching from socket %p\n", event->ev_sender);
|
||||
|
|
@ -236,7 +239,8 @@ my_listen(isc_task_t *task, isc_event_t *event) {
|
|||
}
|
||||
|
||||
static void
|
||||
timeout(isc_task_t *task, isc_event_t *event) {
|
||||
timeout(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_socket_t *sock = event->ev_arg;
|
||||
|
||||
printf("Timeout, canceling IO on socket %p (task %p)\n", sock, task);
|
||||
|
|
@ -252,20 +256,21 @@ static char xso1[] = "so1";
|
|||
static char xso2[] = "so2";
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_task_t *t1, *t2;
|
||||
isc_timermgr_t *timgr;
|
||||
isc_time_t expires;
|
||||
isc_interval_t interval;
|
||||
isc_timer_t *ti1;
|
||||
unsigned int workers;
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_task_t * t1, *t2;
|
||||
isc_timermgr_t * timgr;
|
||||
isc_time_t expires;
|
||||
isc_interval_t interval;
|
||||
isc_timer_t * ti1;
|
||||
unsigned int workers;
|
||||
isc_socketmgr_t *socketmgr;
|
||||
isc_socket_t *so1, *so2;
|
||||
isc_sockaddr_t sockaddr;
|
||||
struct in_addr ina;
|
||||
struct in6_addr in6a;
|
||||
isc_result_t result;
|
||||
int pf;
|
||||
isc_socket_t * so1, *so2;
|
||||
isc_sockaddr_t sockaddr;
|
||||
struct in_addr ina;
|
||||
struct in6_addr in6a;
|
||||
isc_result_t result;
|
||||
int pf;
|
||||
|
||||
if (argc > 1) {
|
||||
workers = atoi(argv[1]);
|
||||
|
|
@ -337,14 +342,14 @@ main(int argc, char *argv[]) {
|
|||
/*
|
||||
* Queue up the first accept event.
|
||||
*/
|
||||
RUNTIME_CHECK(isc_socket_accept(so1, t1, my_listen, xso1)
|
||||
== ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_socket_accept(so1, t1, my_listen, xso1) ==
|
||||
ISC_R_SUCCESS);
|
||||
isc_time_settoepoch(&expires);
|
||||
isc_interval_set(&interval, 10, 0);
|
||||
ti1 = NULL;
|
||||
RUNTIME_CHECK(isc_timer_create(timgr, isc_timertype_once, &expires,
|
||||
&interval, t1, timeout, so1, &ti1) ==
|
||||
ISC_R_SUCCESS);
|
||||
&interval, t1, timeout, so1,
|
||||
&ti1) == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* Open up a socket that will connect to www.flame.org, port 80.
|
||||
|
|
@ -360,8 +365,8 @@ main(int argc, char *argv[]) {
|
|||
isc_sockettype_tcp,
|
||||
&so2) == ISC_R_SUCCESS);
|
||||
|
||||
RUNTIME_CHECK(isc_socket_connect(so2, &sockaddr, t2,
|
||||
my_connect, xso2) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_socket_connect(so2, &sockaddr, t2, my_connect,
|
||||
xso2) == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* Detaching these is safe, since the socket will attach to the
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue