zoneconf.c revision 59d84d1b077678cb77f6cbcc53d8cfa60ff69cb7
/*
* Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 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 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: zoneconf.c,v 1.132 2006/03/06 01:27:52 marka Exp $ */
/*% */
#include <config.h>
#include <dns/fixedname.h>
#include <dns/rdatatype.h>
#include <named/zoneconf.h>
/*%
* These are BIND9 server defaults, not necessarily identical to the
* library defaults defined in zone.c.
*/
#define RETERR(x) do { \
isc_result_t _r = (x); \
if (_r != ISC_R_SUCCESS) \
return (_r); \
} while (0)
/*%
* Convenience function for configuring a single zone ACL.
*/
static isc_result_t
void (*clearzacl)(dns_zone_t *))
{
int i = 0;
}
return (ISC_R_SUCCESS);
}
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_SUCCESS);
}
/*%
* Parse the zone update-policy statement.
*/
static isc_result_t
if (updatepolicy == NULL) {
return (ISC_R_SUCCESS);
}
if (result != ISC_R_SUCCESS)
return (result);
{
const char *str;
unsigned int mtype = DNS_SSUMATCHTYPE_NAME;
isc_buffer_t b;
unsigned int i, n;
else
INSIST(0);
else
INSIST(0);
if (result != ISC_R_SUCCESS) {
"'%s' is not a valid name", str);
goto cleanup;
}
if (result != ISC_R_SUCCESS) {
"'%s' is not a valid name", str);
goto cleanup;
}
n = ns_config_listcount(typelist);
if (n == 0)
else {
goto cleanup;
}
}
i = 0;
{
INSIST(i < n);
if (result != ISC_R_SUCCESS) {
"'%s' is not a valid type", str);
n * sizeof(dns_rdatatype_t));
goto cleanup;
}
}
INSIST(i == n);
n, types);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
}
return (result);
}
/*%
* Convert a config file zone type into a server zone type.
*/
static inline dns_zonetype_t
return (ns_config_getzonetype(obj));
}
/*%
* Helper function for strtoargv(). Pardon the gratuitous recursion.
*/
static isc_result_t
char ***argvp, unsigned int n)
{
/* Discard leading whitespace. */
while (*s == ' ' || *s == '\t')
s++;
if (*s == '\0') {
/* We have reached the end of the string. */
*argcp = n;
return (ISC_R_NOMEMORY);
} else {
char *p = s;
while (*p != ' ' && *p != '\t' && *p != '\0')
p++;
if (*p != '\0')
*p++ = '\0';
if (result != ISC_R_SUCCESS)
return (result);
(*argvp)[n] = s;
}
return (ISC_R_SUCCESS);
}
/*%
* Tokenize the string "s" into whitespace-separated words,
* return the number of words in '*argcp' and an array
* of pointers to the words in '*argvp'. The caller
* must free the array using isc_mem_put(). The string
* is modified in-place.
*/
static isc_result_t
}
static void
{
switch (ztype) {
default:
INSIST(0);
}
}
{
const char *zname;
char *cpval;
unsigned int dbargc;
char **dbargv;
static char default_dbtype[] = "rbt";
int i;
i = 0;
}
}
maps[i++] = ns_g_defaults;
dns_rdataclass_in, &vclass));
else
/*
* Configure values common to all zone types.
*/
if (result == ISC_R_SUCCESS)
else
return(ISC_R_NOMEMORY);
return (result);
}
/*
* ANSI C is strange here. There is no logical reason why (char **)
* cannot be promoted automatically to (const char * const *) by the
* compiler w/o generating a warning.
*/
if (cpval != default_dbtype)
if (result != ISC_R_SUCCESS)
return (result);
if (result == ISC_R_SUCCESS)
if (result == ISC_R_SUCCESS) {
else
INSIST(0);
}
if (result == ISC_R_SUCCESS)
if (ztype == dns_zone_slave)
/*
* XXXAG This probably does not make sense for stubs.
*/
if (cfg_obj_isboolean(obj)) {
if (cfg_obj_asboolean(obj))
else
} else {
else
INSIST(0);
}
/*
* Configure master functionality. This applies
* to primary masters (type "master") and slaves
* acting as masters (type "slave"), but not to stubs.
*/
if (ztype != dns_zone_stub) {
if (cfg_obj_isboolean(obj)) {
if (cfg_obj_asboolean(obj))
else
} else {
else
INSIST(0);
}
if (result == ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
} else
if (cfg_obj_isstring(obj)) {
} else {
"'max-journal-size "
"is too large",
value);
}
}
if (cfg_obj_isboolean(obj))
ztype == dns_zone_master)
ztype == dns_zone_slave)
else
} else
INSIST(0);
}
/*
* Configure update-related options. These apply to
* primary masters only.
*/
if (ztype == dns_zone_master) {
"zone '%s' allows updates by IP "
"address, which is insecure",
zname);
if (result == ISC_R_SUCCESS) {
if (!isc_file_isabsolute(filename)) {
"key-directory '%s' "
"is not absolute", filename);
return (ISC_R_FAILURE);
}
}
if (result == ISC_R_SUCCESS)
else
} else
INSIST(0);
} else
INSIST(0);
} else
INSIST(0);
}
/*
* Configure update-related options. These apply to
* primary masters only.
*/
if (ztype == dns_zone_master) {
"zone '%s' allows updates by IP "
"address, which is insecure",
zname);
if (result == ISC_R_SUCCESS) {
if (!isc_file_isabsolute(filename)) {
"key-directory '%s' "
"is not absolute", filename);
return (ISC_R_FAILURE);
}
}
} else if (ztype == dns_zone_slave) {
}
/*
* Configure slave functionality.
*/
switch (ztype) {
case dns_zone_slave:
case dns_zone_stub:
count = 0;
&count));
count);
} else
if (count > 1) {
}
/*
* Default off when views are in use otherwise
* on for BIND 8 compatibility.
*/
else
} else
break;
default:
break;
}
return (ISC_R_SUCCESS);
}
const char *cfilename;
const char *zfilename;
return (ISC_FALSE);
else
return (ISC_FALSE);
return (ISC_TRUE);
}