check.c revision 35541328a8c18ba1f984300dfe30ec8713c90031
/*
* Copyright (C) 2001, 2002 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* 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 INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM 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.c,v 1.42 2004/01/14 02:06:49 marka Exp $ */
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <isc/parseint.h>
#include <isc/sockaddr.h>
#include <dns/fixedname.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
static isc_result_t
isc_buffer_t b;
const char *str;
if (cfg_obj_isstring(obj)) {
if (tresult != ISC_R_SUCCESS) {
"rrset-order: invalid class '%s'",
r.base);
}
}
if (cfg_obj_isstring(obj)) {
if (tresult != ISC_R_SUCCESS) {
"rrset-order: invalid type '%s'",
r.base);
}
}
if (cfg_obj_isstring(obj)) {
if (tresult != ISC_R_SUCCESS) {
"rrset-order: invalid name '%s'", str);
}
}
if (!cfg_obj_isstring(obj) ||
"rrset-order: keyword 'order' missing");
}
if (!cfg_obj_isstring(obj)) {
"rrset-order: missing ordering");
"rrset-order: order 'fixed' not implemented");
} else if (/* strcasecmp(cfg_obj_asstring(obj), "fixed") != 0 && */
"rrset-order: invalid order '%s'",
}
return (result);
}
static isc_result_t
return (result);
{
if (tresult != ISC_R_SUCCESS)
}
return (result);
}
static isc_result_t
char *str;
if (alternates == NULL)
return (ISC_R_SUCCESS);
if (cfg_obj_isuint32(obj)) {
if (val > ISC_UINT16_MAX) {
"port '%u' out of range", val);
}
}
if (cfg_obj_issockaddr(value))
continue;
if (tresult != ISC_R_SUCCESS) {
"bad name '%s'", str);
}
if (cfg_obj_isuint32(obj)) {
if (val > ISC_UINT16_MAX) {
"port '%u' out of range", val);
}
}
}
return (result);
}
static isc_result_t
"no matching 'forwarders' statement");
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
const char *str;
isc_buffer_t b;
if (tresult != ISC_R_SUCCESS) {
"bad domain name '%s'", str);
}
{
if (tresult != ISC_R_SUCCESS) {
}
if (tresult != ISC_R_SUCCESS) {
ISC_LOG_ERROR, "invalid algorithm");
}
}
return (result);
}
typedef struct {
const char *name;
unsigned int scale;
unsigned int max;
static isc_result_t
unsigned int i;
static intervaltable intervals[] = {
{ "cleaning-interval", 60, 28 * 24 * 60 }, /* 28 days */
{ "heartbeat-interval", 60, 28 * 24 * 60 }, /* 28 days */
{ "interface-interval", 60, 28 * 24 * 60 }, /* 28 days */
{ "max-transfer-idle-in", 60, 28 * 24 * 60 }, /* 28 days */
{ "max-transfer-idle-out", 60, 28 * 24 * 60 }, /* 28 days */
{ "max-transfer-time-in", 60, 28 * 24 * 60 }, /* 28 days */
{ "max-transfer-time-out", 60, 28 * 24 * 60 }, /* 28 days */
{ "sig-validity-interval", 86400, 10 * 366 }, /* 10 years */
{ "statistics-interval", 60, 28 * 24 * 60 }, /* 28 days */
};
/*
* Check that fields specified in units of time other than seconds
* have reasonable values.
*/
continue;
"%s '%u' is out of range (0..%u)",
"%s '%d' is out of range",
}
}
const char *str;
"preferred-glue unexpected value '%s'",
str);
}
if (!cfg_obj_isvoid(obj)) {
char *str;
isc_buffer_t b;
if (tresult != ISC_R_SUCCESS) {
"bad domain name '%s'",
str);
}
}
}
}
/*
* Set supported DNSSEC algorithms.
*/
{
if (tresult != ISC_R_SUCCESS)
}
}
return (result);
}
static isc_result_t
if (result != ISC_R_SUCCESS)
return (result);
const char *listname;
return (ISC_R_SUCCESS);
}
}
return (ISC_R_NOTFOUND);
}
static isc_result_t
{
isc_uint32_t count = 0;
if (result != ISC_R_SUCCESS)
return (result);
for ( ;
{
char *listname;
"masterselement");
if (cfg_obj_issockaddr(addr)) {
count++;
continue;
}
if (!cfg_obj_isvoid(key)) {
"unexpected token '%s'",
if (result == ISC_R_SUCCESS)
}
if (tresult == ISC_R_EXISTS)
continue;
if (tresult != ISC_R_SUCCESS) {
if (result == ISC_R_SUCCESS)
"unable to find masters list '%s'",
listname);
continue;
}
/* Grow stack? */
if (stackcount == pushed) {
void * new;
goto cleanup;
if (stackcount != 0) {
}
stackcount = newlen;
}
goto newlist;
}
if (pushed != 0) {
goto resume;
}
return (result);
}
#define MASTERZONE 1
#define SLAVEZONE 2
#define STUBZONE 4
#define HINTZONE 8
#define FORWARDZONE 16
#define DELEGATIONZONE 32
typedef struct {
const char *name;
int allowed;
} optionstable;
static isc_result_t
{
const char *zname;
const char *typestr;
unsigned int ztype;
unsigned int i;
isc_buffer_t b;
static optionstable options[] = {
{ "allow-notify", SLAVEZONE },
{ "sig-validity-interval", MASTERZONE },
{ "allow-update", MASTERZONE },
{ "allow-update-forwarding", SLAVEZONE },
{ "update-policy", MASTERZONE },
{ "key-directory", MASTERZONE },
};
static optionstable dialups[] = {
{ "notify-passive", SLAVEZONE },
};
"zone '%s': type not present", zname);
return (ISC_R_FAILURE);
}
ztype = MASTERZONE;
ztype = FORWARDZONE;
else {
"zone '%s': invalid type %s",
return (ISC_R_FAILURE);
}
if (cfg_obj_isstring(obj)) {
if (result != ISC_R_SUCCESS) {
"zone '%s': invalid class %s",
return (ISC_R_FAILURE);
}
"zone '%s': class '%s' does not "
return (ISC_R_FAILURE);
}
}
/*
* Look for an already existing zone.
* We need to make this cannonical as isc_symtab_define()
* deals with strings.
*/
if (result != ISC_R_SUCCESS) {
"zone '%s': is not a valid name", zname);
} else {
char namebuf[DNS_NAME_FORMATSIZE];
char *key;
return (ISC_R_NOMEMORY);
if (tresult == ISC_R_EXISTS) {
const char *file;
unsigned int line;
&symvalue) == ISC_R_SUCCESS);
file = "<unknown file>";
"zone '%s': already exists "
"previous definition: %s:%u",
} else if (tresult != ISC_R_SUCCESS) {
return (tresult);
}
}
/*
* Look for inappropriate options for the given zone type.
*/
{
"option '%s' is not allowed "
"in '%s' zone '%s'",
} else
"option '%s' is not allowed "
"in '%s' zone '%s'",
}
}
/*
* Slave & stub zones must have a "masters" field.
*/
"zone '%s': missing 'masters' entry",
zname);
} else {
"zone '%s': empty 'masters' entry",
zname);
}
}
}
/*
* Master zones can't have both "allow-update" and "update-policy".
*/
if (ztype == MASTERZONE) {
"zone '%s': 'allow-update' is ignored "
"when 'update-policy' is present",
zname);
}
}
/*
* Check the excessively complicated "dialup" option.
*/
for (i = 0;
i++)
{
continue;
"dialup type '%s' is not "
"allowed in '%s' "
"zone '%s'",
}
break;
}
"invalid dialup type '%s' in zone "
}
}
}
/*
* Check that forwarding is reasonable.
*/
/*
* Check various options.
*/
if (tresult != ISC_R_SUCCESS)
return (result);
}
"key '%s' must have both 'secret' and "
"'algorithm' defined",
keyname);
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
{
if (tresult == ISC_R_EXISTS) {
const char *file;
unsigned int line;
file = "<unknown file>";
"key '%s': already exists "
"previous definition: %s:%u",
} else if (tresult != ISC_R_SUCCESS)
return (tresult);
if (tresult != ISC_R_SUCCESS)
return (tresult);
}
return (result);
}
static void
}
static isc_result_t
char buf[128];
const char *xfr;
xfr = "transfer-source-v6";
else
xfr = "transfer-source";
== ISC_R_SUCCESS);
}
file = "<unknown file>";
== ISC_R_SUCCESS);
"server '%s': already exists "
"previous definition: %s:%u",
}
}
}
return (result);
}
static isc_result_t
{
/*
* Check that all zone statements are syntactically correct and
* there are no duplicate zones.
*/
if (tresult != ISC_R_SUCCESS)
return (ISC_R_NOMEMORY);
else
{
if (tresult != ISC_R_SUCCESS)
}
/*
* Check that all key statements are syntactically correct and
* there are no duplicate keys.
*/
if (tresult != ISC_R_SUCCESS)
return (ISC_R_NOMEMORY);
if (tresult == ISC_R_EXISTS)
else if (tresult != ISC_R_SUCCESS) {
return (tresult);
}
if (tresult == ISC_R_EXISTS)
else if (tresult != ISC_R_SUCCESS) {
return (tresult);
}
}
/*
* Check that forwarding is reasonable.
*/
} else {
}
/*
* Check that dual-stack-servers is reasonable.
*/
} else {
}
/*
* Check that rrset-order is reasonable.
*/
}
}
else
if (tresult != ISC_R_SUCCESS)
return (result);
}
"any", "none"};
} else {
"when using 'view' statements, "
"all zones must be in views");
}
}
{
if (cfg_obj_isstring(vclassobj)) {
if (tresult != ISC_R_SUCCESS)
"view '%s': invalid class %s",
}
if (tresult == ISC_R_SUCCESS)
if (tresult != ISC_R_SUCCESS)
}
if (tresult == ISC_R_SUCCESS) {
"'cache-file' cannot be a global "
"option if views are present");
}
}
if (tresult == ISC_R_SUCCESS) {
const char *aclname;
unsigned int i;
for (i = 0;
i++)
"attempt to redefine "
"builtin acl '%s'",
aclname);
break;
}
const char *name;
"name"));
file = "<unknown file>";
"attempt to redefine "
"acl '%s' previous "
"definition: %s:%u",
}
}
}
}
if (tresult == ISC_R_SUCCESS) {
const char *aclname;
const char *name;
"name"));
file = "<unknown file>";
"attempt to redefine "
"kal '%s' previous "
"definition: %s:%u",
}
}
}
}
return (result);
}