* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: check.c,v 1.46 2004/05/17 05:37:41 marka Exp $ */
+/* $Id: check.c,v 1.47 2004/06/04 02:31:43 marka Exp $ */
#include <config.h>
return (result);
}
+static isc_result_t
+nameexist(cfg_obj_t *obj, const char *name, int value, isc_symtab_t *symtab,
+ const char *fmt, isc_log_t *logctx, isc_mem_t *mctx)
+{
+ char *key;
+ const char *file;
+ unsigned int line;
+ isc_result_t result;
+ isc_symvalue_t symvalue;
+
+ key = isc_mem_strdup(mctx, name);
+ if (key == NULL)
+ return (ISC_R_NOMEMORY);
+ symvalue.as_pointer = obj;
+ result = isc_symtab_define(symtab, key, value, symvalue,
+ isc_symexists_reject);
+ if (result == ISC_R_EXISTS) {
+ RUNTIME_CHECK(isc_symtab_lookup(symtab, key, value,
+ &symvalue) == ISC_R_SUCCESS);
+ file = cfg_obj_file(symvalue.as_pointer);
+ line = cfg_obj_line(symvalue.as_pointer);
+
+ if (file == NULL)
+ file = "<unknown file>";
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR, fmt, key, file, line);
+ isc_mem_free(mctx, key);
+ result = ISC_R_EXISTS;
+ } else if (result != ISC_R_SUCCESS) {
+ isc_mem_free(mctx, key);
+ }
+ return (result);
+}
+
static isc_result_t
mustbesecure(cfg_obj_t *secure, isc_symtab_t *symtab, isc_log_t *logctx,
isc_mem_t *mctx)
dns_name_t *name;
isc_buffer_t b;
isc_result_t result = ISC_R_SUCCESS;
- isc_result_t tresult;
- isc_symvalue_t symvalue;
- char *key;
dns_fixedname_init(&fixed);
name = dns_fixedname_name(&fixed);
str = cfg_obj_asstring(obj);
isc_buffer_init(&b, str, strlen(str));
isc_buffer_add(&b, strlen(str));
- tresult = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL);
- if (tresult != ISC_R_SUCCESS) {
+ result = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL);
+ if (result != ISC_R_SUCCESS) {
cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
"bad domain name '%s'", str);
- result = tresult;
} else {
-
dns_name_format(name, namebuf, sizeof(namebuf));
- key = isc_mem_strdup(mctx, namebuf);
- if (key == NULL)
- return (ISC_R_NOMEMORY);
- symvalue.as_pointer = secure;
- tresult = isc_symtab_define(symtab, key, 1, symvalue,
- isc_symexists_reject);
- if (tresult == ISC_R_EXISTS) {
- const char *file;
- unsigned int line;
-
- RUNTIME_CHECK(isc_symtab_lookup(symtab, key, 1,
- &symvalue) == ISC_R_SUCCESS);
- isc_mem_free(mctx, key);
- file = cfg_obj_file(symvalue.as_pointer);
- line = cfg_obj_line(symvalue.as_pointer);
-
- if (file == NULL)
- file = "<unknown file>";
-
- cfg_obj_log(secure, logctx, ISC_LOG_ERROR,
- "dnssec-must-be-secure '%s': already "
- "exists previous definition: %s:%u",
- namebuf, file, line);
- result = tresult;
- } else if (tresult != ISC_R_SUCCESS) {
- isc_mem_free(mctx, key);
- result = tresult;
- }
+ result = nameexist(secure, namebuf, 1, symtab,
+ "dnssec-must-be-secure '%s': already "
+ "exists previous definition: %s:%u",
+ logctx, mctx);
}
return (result);
}
unsigned int i;
cfg_obj_t *obj = NULL;
cfg_listelt_t *element;
+ isc_symtab_t *symtab = NULL;
static intervaltable intervals[] = {
{ "cleaning-interval", 60, 28 * 24 * 60 }, /* 28 days */
obj = NULL;
(void)cfg_map_get(options, "dnssec-lookaside", &obj);
if (obj != NULL) {
- dns_fixedname_t fixedname;
- const char *dlv;
- isc_buffer_t b;
-
- dlv = cfg_obj_asstring(obj);
- dns_fixedname_init(&fixedname);
- isc_buffer_init(&b, dlv, strlen(dlv));
- isc_buffer_add(&b, strlen(dlv));
- tresult = dns_name_fromtext(dns_fixedname_name(&fixedname), &b,
- dns_rootname, ISC_TRUE, NULL);
- if (tresult != ISC_R_SUCCESS) {
- cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
- "bad domain name '%s'", dlv);
+ tresult = isc_symtab_create(mctx, 100, freekey, mctx,
+ ISC_TRUE, &symtab);
+ if (tresult != ISC_R_SUCCESS)
result = tresult;
+ for (element = cfg_list_first(obj);
+ element != NULL;
+ element = cfg_list_next(element))
+ {
+ dns_fixedname_t fixedname;
+ dns_name_t *name;
+ const char *dlv;
+ isc_buffer_t b;
+
+ obj = cfg_listelt_value(element);
+
+ dlv = cfg_obj_asstring(cfg_tuple_get(obj, "domain"));
+ dns_fixedname_init(&fixedname);
+ name = dns_fixedname_name(&fixedname);
+ isc_buffer_init(&b, dlv, strlen(dlv));
+ isc_buffer_add(&b, strlen(dlv));
+ tresult = dns_name_fromtext(name, &b, dns_rootname,
+ ISC_TRUE, NULL);
+ if (tresult != ISC_R_SUCCESS) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "bad domain name '%s'", dlv);
+ result = tresult;
+ }
+ if (symtab != NULL) {
+ tresult = nameexist(obj, dlv, 1, symtab,
+ "dnssec-lookaside '%s': "
+ "already exists previous "
+ "definition: %s:%u",
+ logctx, mctx);
+ if (tresult != ISC_R_SUCCESS &&
+ result == ISC_R_SUCCESS)
+ result = tresult;
+ }
+ /*
+ * XXXMPA to be removed when multiple lookaside
+ * namespaces are supported.
+ */
+ if (!dns_name_equal(dns_rootname, name)) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "dnssec-lookaside '%s': "
+ "non-root not yet supported", dlv);
+ if (result == ISC_R_SUCCESS)
+ result = ISC_R_FAILURE;
+ }
+ dlv = cfg_obj_asstring(cfg_tuple_get(obj,
+ "trust-anchor"));
+ dns_fixedname_init(&fixedname);
+ isc_buffer_init(&b, dlv, strlen(dlv));
+ isc_buffer_add(&b, strlen(dlv));
+ tresult = dns_name_fromtext(name, &b, dns_rootname,
+ ISC_TRUE, NULL);
+ if (tresult != ISC_R_SUCCESS) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "bad domain name '%s'", dlv);
+ if (result == ISC_R_SUCCESS)
+ result = tresult;
+ }
}
+ if (symtab != NULL)
+ isc_symtab_destroy(&symtab);
}
/*
unsigned int ztype;
cfg_obj_t *zoptions;
cfg_obj_t *obj = NULL;
- isc_symvalue_t symvalue;
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
unsigned int i;
dns_fixedname_init(&fixedname);
isc_buffer_init(&b, zname, strlen(zname));
isc_buffer_add(&b, strlen(zname));
- result = dns_name_fromtext(dns_fixedname_name(&fixedname), &b,
+ tresult = dns_name_fromtext(dns_fixedname_name(&fixedname), &b,
dns_rootname, ISC_TRUE, NULL);
if (result != ISC_R_SUCCESS) {
cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR,
"zone '%s': is not a valid name", zname);
- result = ISC_R_FAILURE;
+ tresult = ISC_R_FAILURE;
} else {
char namebuf[DNS_NAME_FORMATSIZE];
- char *key;
dns_name_format(dns_fixedname_name(&fixedname),
namebuf, sizeof(namebuf));
- key = isc_mem_strdup(mctx, namebuf);
- if (key == NULL)
- return (ISC_R_NOMEMORY);
- symvalue.as_pointer = zconfig;
- tresult = isc_symtab_define(symtab, key,
- ztype == HINTZONE ? 1 : 2,
- symvalue, isc_symexists_reject);
- if (tresult == ISC_R_EXISTS) {
- const char *file;
- unsigned int line;
-
- RUNTIME_CHECK(isc_symtab_lookup(symtab, key,
- ztype == HINTZONE ? 1 : 2,
- &symvalue) == ISC_R_SUCCESS);
- isc_mem_free(mctx, key);
- file = cfg_obj_file(symvalue.as_pointer);
- line = cfg_obj_line(symvalue.as_pointer);
-
- if (file == NULL)
- file = "<unknown file>";
- cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR,
- "zone '%s': already exists "
- "previous definition: %s:%u",
- zname, file, line);
- result = ISC_R_FAILURE;
- } else if (tresult != ISC_R_SUCCESS) {
- isc_mem_free(mctx, key);
-
- return (tresult);
- }
+ tresult = nameexist(zconfig, namebuf, ztype == HINTZONE ? 1 : 2,
+ symtab, "zone '%s': already exists "
+ "previous definition: %s:%u", logctx, mctx);
+ if (tresult != ISC_R_SUCCESS)
+ result = tresult;
}
/*