check-tool.c revision 307d2084502eddc7ce921e5ce439aec3531d90e0
/*
* Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2002 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: check-tool.c,v 1.39 2009/09/01 00:22:24 jinmei Exp $ */
/*! \file */
#include <config.h>
#include <stdio.h>
#include "check-tool.h"
#include <dns/fixedname.h>
#include <dns/rdataclass.h>
#include <dns/rdataset.h>
#ifndef CHECK_SIBLING
#define CHECK_SIBLING 1
#endif
#ifndef CHECK_LOCAL
#define CHECK_LOCAL 1
#endif
#ifdef HAVE_ADDRINFO
#ifdef HAVE_GETADDRINFO
#ifdef HAVE_GAISTRERROR
#define USE_GETADDRINFO
#endif
#endif
#endif
#define CHECK(r) \
do { \
result = (r); \
if (result != ISC_R_SUCCESS) \
goto cleanup; \
} while (0)
#define ERR_IS_CNAME 1
#define ERR_NO_ADDRESSES 2
#define ERR_LOOKUP_FAILURE 3
#define ERR_EXTRA_A 4
#define ERR_EXTRA_AAAA 5
#define ERR_MISSING_GLUE 5
#define ERR_IS_MXCNAME 6
#define ERR_IS_SRVCNAME 7
static const char *dbtype[] = { "rbt" };
int debug = 0;
#if CHECK_LOCAL
#else
#endif
unsigned int zone_options = DNS_ZONEOPT_CHECKNS |
#if CHECK_SIBLING
#endif
/*
*/
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 void
}
static void
if (result != ISC_R_SUCCESS)
return;
}
if (result != ISC_R_SUCCESS)
return;
}
return;
if (result != ISC_R_SUCCESS)
}
static isc_boolean_t
return (ISC_FALSE);
if (result == ISC_R_SUCCESS)
return (ISC_TRUE);
return (ISC_FALSE);
}
static isc_boolean_t
{
#ifdef USE_GETADDRINFO
char ownerbuf[DNS_NAME_FORMATSIZE];
char addrbuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:123.123.123.123")];
const char *type;
int result;
a->type == dns_rdatatype_a);
/*
* Turn off search.
*/
switch (result) {
case 0:
/*
* Work around broken getaddrinfo() implementations that
* fail to set ai_canonname on first entry.
*/
"is a CNAME '%s' (illegal)",
cur->ai_canonname);
/* XXX950 make fatal for 9.5.0 */
/* answer = ISC_FALSE; */
}
break;
case EAI_NONAME:
case EAI_NODATA:
#endif
"has no addresses records (A or AAAA)",
}
/* XXX950 make fatal for 9.5.0 */
return (ISC_TRUE);
default:
"getaddrinfo(%s) failed: %s",
}
return (ISC_TRUE);
}
return (answer);
/*
* Check that all glue records really exist.
*/
if (!dns_rdataset_isassociated(a))
goto checkaaaa;
result = dns_rdataset_first(a);
while (result == ISC_R_SUCCESS) {
dns_rdataset_current(a, &rdata);
continue;
break;
}
}
"extra GLUE A record (%s)",
/* XXX950 make fatal for 9.5.0 */
/* answer = ISC_FALSE; */
}
result = dns_rdataset_next(a);
}
if (!dns_rdataset_isassociated(aaaa))
goto checkmissing;
while (result == ISC_R_SUCCESS) {
continue;
break;
}
}
"extra GLUE AAAA record (%s)",
/* XXX950 make fatal for 9.5.0. */
/* answer = ISC_FALSE; */
}
}
/*
* Check that all addresses appear in the glue.
*/
case AF_INET:
rdataset = a;
type = "A";
break;
case AF_INET6:
type = "AAAA";
break;
default:
continue;
}
else
}
if (!match) {
"missing GLUE %s record (%s)",
/* XXX950 make fatal for 9.5.0. */
/* answer = ISC_FALSE; */
}
}
if (missing_glue)
}
return (answer);
#else
return (ISC_TRUE);
#endif
}
static isc_boolean_t
#ifdef USE_GETADDRINFO
char ownerbuf[DNS_NAME_FORMATSIZE];
int result;
int level = ISC_LOG_ERROR;
/*
* Turn off search.
*/
switch (result) {
case 0:
/*
* Work around broken getaddrinfo() implementations that
* fail to set ai_canonname on first entry.
*/
if ((zone_options & DNS_ZONEOPT_WARNMXCNAME) != 0)
if ((zone_options & DNS_ZONEOPT_IGNOREMXCNAME) == 0) {
" is a CNAME '%s' "
"(illegal)",
cur->ai_canonname);
}
if (level == ISC_LOG_ERROR)
}
}
return (answer);
case EAI_NONAME:
case EAI_NODATA:
#endif
"has no addresses records (A or AAAA)",
}
/* XXX950 make fatal for 9.5.0. */
return (ISC_TRUE);
default:
"getaddrinfo(%s) failed: %s",
}
return (ISC_TRUE);
}
#else
return (ISC_TRUE);
#endif
}
static isc_boolean_t
#ifdef USE_GETADDRINFO
char ownerbuf[DNS_NAME_FORMATSIZE];
int result;
int level = ISC_LOG_ERROR;
/*
* Turn off search.
*/
switch (result) {
case 0:
/*
* Work around broken getaddrinfo() implementations that
* fail to set ai_canonname on first entry.
*/
if ((zone_options & DNS_ZONEOPT_WARNSRVCNAME) != 0)
if ((zone_options & DNS_ZONEOPT_IGNORESRVCNAME) == 0) {
" (out of zone) is a "
"CNAME '%s' (illegal)",
cur->ai_canonname);
}
if (level == ISC_LOG_ERROR)
}
}
return (answer);
case EAI_NONAME:
case EAI_NODATA:
#endif
"has no addresses records (A or AAAA)",
}
/* XXX950 make fatal for 9.5.0. */
return (ISC_TRUE);
default:
"getaddrinfo(%s) failed: %s",
}
return (ISC_TRUE);
}
#else
return (ISC_TRUE);
#endif
}
&destination, 0) == ISC_R_SUCCESS);
return (ISC_R_SUCCESS);
}
/*% load the zone */
dns_zone_t **zonep)
{
if (debug)
if (docheckmx)
if (docheckns)
if (dochecksrv)
}
return (result);
}
/*% dump the zone */
{
if (debug) {
else
}
if (result != ISC_R_SUCCESS) {
"file \"%s\" for writing\n", filename);
return (ISC_R_FAILURE);
}
}
(void)isc_stdio_close(output);
return (result);
}