zoneconf.c revision 90c099e88e9f16bfee9edee3ac1a51fc98843772
/*
* Copyright (C) 1999-2001 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: zoneconf.c,v 1.83 2001/03/04 21:21:30 bwelling 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);
{
char *str;
unsigned int mtype;
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
}
{
char *zname;
char *cpval;
unsigned int dbargc;
char **dbargv;
static char default_dbtype[] = "rbt";
int i;
i = 0;
}
}
maps[i++] = ns_g_defaults;
/*
* Configure values common to all zone types.
*/
if (result == ISC_R_SUCCESS)
else
/*
* 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 (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
}
/*
* 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);
} else if (ztype == dns_zone_slave) {
}
/*
* Configure slave functionality.
*/
switch (ztype) {
case dns_zone_slave:
case dns_zone_stub:
&count));
count);
} else
break;
default:
break;
}
return (ISC_R_SUCCESS);
}
const char *cfilename;
const char *zfilename;
return (ISC_FALSE);
else
return (ISC_FALSE);
return (ISC_TRUE);
}