named-checkconf.c revision c4abb197160a74f7cd4ad23ebc63fbe0194010ab
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley/*
a7038d1a0513c8e804937ebc95fc9cb3a46c04f5Mark Andrews * Copyright (C) 2004-2007, 2009-2014 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Copyright (C) 1999-2002 Internet Software Consortium.
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley *
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * Permission to use, copy, modify, and/or distribute this software for any
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley * purpose with or without fee is hereby granted, provided that the above
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence *
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
15a44745412679c30a6d022733925af70a38b715David Lawrence * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15a44745412679c30a6d022733925af70a38b715David Lawrence * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15a44745412679c30a6d022733925af70a38b715David Lawrence * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15a44745412679c30a6d022733925af70a38b715David Lawrence * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15a44745412679c30a6d022733925af70a38b715David Lawrence * PERFORMANCE OF THIS SOFTWARE.
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley */
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews/* $Id: named-checkconf.c,v 1.56 2011/03/12 04:59:46 tbox Exp $ */
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
e419f613d8591885df608cb73065921be07dd12eBob Halley/*! \file */
e419f613d8591885df608cb73065921be07dd12eBob Halley
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#include <config.h>
fca5f81ad69098ea8abba130c7f841c951ef91c2Bob Halley
e419f613d8591885df608cb73065921be07dd12eBob Halley#include <errno.h>
e419f613d8591885df608cb73065921be07dd12eBob Halley#include <stdlib.h>
9695ae1c24b168996e3a267855dc754971ccb32cBob Halley#include <stdio.h>
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews#include <isc/commandline.h>
1c776a2909632bc755f3fddd3b53addd792ab4d0Brian Wellington#include <isc/dir.h>
e419f613d8591885df608cb73065921be07dd12eBob Halley#include <isc/entropy.h>
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley#include <isc/hash.h>
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson#include <isc/log.h>
e83cae7fa837e4757c687035d6f6c0900f152749Brian Wellington#include <isc/mem.h>
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews#include <isc/result.h>
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews#include <isc/string.h>
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley#include <isc/util.h>
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley#include <isccfg/namedconf.h>
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington#include <bind9/check.h>
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence
09f22ac5b09e70bc526015f37168ba33e21ea91fDavid Lawrence#include <dns/db.h>
e419f613d8591885df608cb73065921be07dd12eBob Halley#include <dns/fixedname.h>
e419f613d8591885df608cb73065921be07dd12eBob Halley#include <dns/log.h>
92ef1a9b9dbd48ecb507b42ac62c15afefdaf838David Lawrence#include <dns/name.h>
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews#include <dns/rdataclass.h>
bf43fdafa3bff9e84cb03f1a19aca74514d2516eBob Halley#include <dns/result.h>
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley#include <dns/rootns.h>
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington#include <dns/zone.h>
6bc1a645619a14707da68b130dafe41721fd2f25Brian Wellington
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews#include "check-tool.h"
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halleystatic const char *program = "named-checkconf";
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrenceisc_log_t *logc = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence#define CHECK(r)\
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington do { \
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews result = (r); \
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence if (result != ISC_R_SUCCESS) \
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington goto cleanup; \
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington } while (0)
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence/*% usage */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark AndrewsISC_PLATFORM_NORETURN_PRE static void
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsusage(void) ISC_PLATFORM_NORETURN_POST;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellingtonstatic void
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrewsusage(void) {
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence fprintf(stderr, "usage: %s [-h] [-j] [-p [-x]] [-v] [-z] [-t directory] "
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington "[named.conf]\n", program);
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence exit(1);
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence}
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington/*% directory callback */
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellingtonstatic isc_result_t
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellingtondirectory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) {
23e4260821eefa5019808e18e14e2b366461aad7Brian Wellington isc_result_t result;
ed019cabc1cc75d4412010c331876e4ae5080a4dDavid Lawrence const char *directory;
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson REQUIRE(strcasecmp("directory", clausename) == 0);
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews UNUSED(arg);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews UNUSED(clausename);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews /*
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * Change directory.
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley */
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley directory = cfg_obj_asstring(obj);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley result = isc_dir_chdir(directory);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley if (result != ISC_R_SUCCESS) {
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington cfg_obj_log(obj, logc, ISC_LOG_ERROR,
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington "change directory to '%s' failed: %s\n",
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley directory, isc_result_totext(result));
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley return (result);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley }
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley return (ISC_R_SUCCESS);
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington}
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graffstatic isc_boolean_t
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graffget_maps(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj) {
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff int i;
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff for (i = 0;; i++) {
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley if (maps[i] == NULL)
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley return (ISC_FALSE);
0ec4b862c9abd11c82c88ed62438f0cf06fed25dBob Halley if (cfg_map_get(maps[i], name, obj) == ISC_R_SUCCESS)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (ISC_TRUE);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews}
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic isc_boolean_t
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsget_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_listelt_t *element;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_obj_t *checknames;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_obj_t *type;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_obj_t *value;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews isc_result_t result;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews int i;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews for (i = 0;; i++) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (maps[i] == NULL)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (ISC_FALSE);
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington checknames = NULL;
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington result = cfg_map_get(maps[i], "check-names", &checknames);
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington if (result != ISC_R_SUCCESS)
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington continue;
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington if (checknames != NULL && !cfg_obj_islist(checknames)) {
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington *obj = checknames;
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington return (ISC_TRUE);
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington }
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington for (element = cfg_list_first(checknames);
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington element != NULL;
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington element = cfg_list_next(element)) {
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington value = cfg_listelt_value(element);
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington type = cfg_tuple_get(value, "type");
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington if (strcasecmp(cfg_obj_asstring(type), "master") != 0)
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington continue;
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington *obj = cfg_tuple_get(value, "mode");
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington return (ISC_TRUE);
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington }
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington }
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington}
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellington
98d010a24a9f1b4b45ce9791845941ef90426d0cBrian Wellingtonstatic isc_result_t
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsconfigure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews isc_result_t result;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews dns_db_t *db = NULL;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews dns_rdataclass_t rdclass;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews isc_textregion_t r;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews if (zfile == NULL)
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews return (ISC_R_FAILURE);
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews DE_CONST(zclass, r.base);
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews r.length = strlen(zclass);
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews result = dns_rdataclass_fromtext(&rdclass, &r);
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews if (result != ISC_R_SUCCESS)
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews return (result);
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews result = dns_rootns_create(mctx, rdclass, zfile, &db);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews if (result != ISC_R_SUCCESS)
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews return (result);
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews dns_db_detach(&db);
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews return (ISC_R_SUCCESS);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews}
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews/*% configure the zone */
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsstatic isc_result_t
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrewsconfigure_zone(const char *vclass, const char *view,
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews const cfg_obj_t *zconfig, const cfg_obj_t *vconfig,
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews const cfg_obj_t *config, isc_mem_t *mctx)
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews{
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews int i = 0;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews isc_result_t result;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews const char *zclass;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews const char *zname;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington const char *zfile = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington const cfg_obj_t *maps[4];
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington const cfg_obj_t *mastersobj = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington const cfg_obj_t *zoptions = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington const cfg_obj_t *classobj = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_obj_t *typeobj = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington const cfg_obj_t *fileobj = NULL;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington const cfg_obj_t *dlzobj = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington const cfg_obj_t *dbobj = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington const cfg_obj_t *obj = NULL;
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff const cfg_obj_t *fmtobj = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington dns_masterformat_t masterformat;
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff dns_ttl_t maxttl = 0;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington zone_options = DNS_ZONEOPT_CHECKNS | DNS_ZONEOPT_MANYERRORS;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington zname = cfg_obj_asstring(cfg_tuple_get(zconfig, "name"));
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington classobj = cfg_tuple_get(zconfig, "class");
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington if (!cfg_obj_isstring(classobj))
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington zclass = vclass;
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington else
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson zclass = cfg_obj_asstring(classobj);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington zoptions = cfg_tuple_get(zconfig, "options");
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson maps[i++] = zoptions;
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington if (vconfig != NULL)
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington maps[i++] = cfg_tuple_get(vconfig, "options");
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington if (config != NULL) {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington cfg_map_get(config, "options", &obj);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington if (obj != NULL)
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington maps[i++] = obj;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington }
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington maps[i] = NULL;
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington cfg_map_get(zoptions, "type", &typeobj);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (typeobj == NULL)
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington return (ISC_R_FAILURE);
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson /*
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson * Skip checks when using an alternate data source.
18b7133679efa8f60fd4e396c628576f3f416b3eBrian Wellington */
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington cfg_map_get(zoptions, "database", &dbobj);
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington if (dbobj != NULL &&
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington strcmp("rbt", cfg_obj_asstring(dbobj)) != 0 &&
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington strcmp("rbt64", cfg_obj_asstring(dbobj)) != 0)
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington return (ISC_R_SUCCESS);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington cfg_map_get(zoptions, "dlz", &dlzobj);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (dlzobj != NULL)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (ISC_R_SUCCESS);
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington cfg_map_get(zoptions, "file", &fileobj);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington if (fileobj != NULL)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zfile = cfg_obj_asstring(fileobj);
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington /*
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * Check hints files for hint zones.
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews * Skip loading checks for any type other than
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington * master and redirect
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington */
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington if (strcasecmp(cfg_obj_asstring(typeobj), "hint") == 0)
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington return (configure_hint(zfile, zclass, mctx));
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington else if ((strcasecmp(cfg_obj_asstring(typeobj), "master") != 0) &&
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington (strcasecmp(cfg_obj_asstring(typeobj), "redirect") != 0))
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington return (ISC_R_SUCCESS);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington /*
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington * Is the redirect zone configured as a slave?
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews */
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington if (strcasecmp(cfg_obj_asstring(typeobj), "redirect") == 0) {
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington cfg_map_get(zoptions, "masters", &mastersobj);
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington if (mastersobj != NULL)
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington return (ISC_R_SUCCESS);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington if (zfile == NULL)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (ISC_R_FAILURE);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews obj = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (get_maps(maps, "check-dup-records", &obj)) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_CHECKDUPRR;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington zone_options |= DNS_ZONEOPT_CHECKDUPRR;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_CHECKDUPRRFAIL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKDUPRR;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL;
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington } else
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington INSIST(0);
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington } else {
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson zone_options |= DNS_ZONEOPT_CHECKDUPRR;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKDUPRRFAIL;
18b7133679efa8f60fd4e396c628576f3f416b3eBrian Wellington }
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington obj = NULL;
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington if (get_maps(maps, "check-mx", &obj)) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington zone_options |= DNS_ZONEOPT_CHECKMX;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKMXFAIL;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_CHECKMX;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_CHECKMXFAIL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKMX;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKMXFAIL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews INSIST(0);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_CHECKMX;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKMXFAIL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews obj = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (get_maps(maps, "check-integrity", &obj)) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (cfg_obj_asboolean(obj))
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_CHECKINTEGRITY;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews else
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKINTEGRITY;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_CHECKINTEGRITY;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews obj = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (get_maps(maps, "check-mx-cname", &obj)) {
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_WARNMXCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_IGNOREMXCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_WARNMXCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_IGNOREMXCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_WARNMXCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_IGNOREMXCNAME;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews } else
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews INSIST(0);
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews } else {
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews zone_options |= DNS_ZONEOPT_WARNMXCNAME;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews zone_options &= ~DNS_ZONEOPT_IGNOREMXCNAME;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews }
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews obj = NULL;
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews if (get_maps(maps, "check-srv-cname", &obj)) {
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews zone_options |= DNS_ZONEOPT_WARNSRVCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_IGNORESRVCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_WARNSRVCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_IGNORESRVCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_WARNSRVCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_IGNORESRVCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews INSIST(0);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_WARNSRVCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_IGNORESRVCNAME;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews obj = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (get_maps(maps, "check-sibling", &obj)) {
ff30cdeb783ca7ffe69b222c56197828e882c229Mark Andrews if (cfg_obj_asboolean(obj))
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options |= DNS_ZONEOPT_CHECKSIBLING;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews else
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKSIBLING;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington
48ed268b3378a8b729a0037bc4ae2ed73647a96aBrian Wellington obj = NULL;
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington if (get_maps(maps, "check-spf", &obj)) {
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington zone_options |= DNS_ZONEOPT_CHECKSPF;
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options &= ~DNS_ZONEOPT_CHECKSPF;
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington } else
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington INSIST(0);
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington } else {
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington zone_options |= DNS_ZONEOPT_CHECKSPF;
e44487bfc23599b6b240e09d83d1c862fecfcc82Michael Graff }
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington obj = NULL;
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington if (get_checknames(maps, &obj)) {
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington zone_options |= DNS_ZONEOPT_CHECKNAMES;
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington zone_options &= ~DNS_ZONEOPT_CHECKNAMESFAIL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington zone_options |= DNS_ZONEOPT_CHECKNAMES;
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington zone_options |= DNS_ZONEOPT_CHECKNAMESFAIL;
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson zone_options &= ~DNS_ZONEOPT_CHECKNAMES;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington zone_options &= ~DNS_ZONEOPT_CHECKNAMESFAIL;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington } else
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson INSIST(0);
76c8294c81fb48b1da6e1fc5b83322a4cedb8e58Andreas Gustafsson } else {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington zone_options |= DNS_ZONEOPT_CHECKNAMES;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington zone_options |= DNS_ZONEOPT_CHECKNAMESFAIL;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington }
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington masterformat = dns_masterformat_text;
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fmtobj = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (get_maps(maps, "masterfile-format", &fmtobj)) {
3676eeb6ca95c66aae1256f37af8c990d9f25eb4Brian Wellington const char *masterformatstr = cfg_obj_asstring(fmtobj);
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington if (strcasecmp(masterformatstr, "text") == 0)
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson masterformat = dns_masterformat_text;
1b1e1fda4638334b484aa38c15f53a131c0b0fdfAndreas Gustafsson else if (strcasecmp(masterformatstr, "raw") == 0)
18b7133679efa8f60fd4e396c628576f3f416b3eBrian Wellington masterformat = dns_masterformat_raw;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington else if (strcasecmp(masterformatstr, "map") == 0)
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington masterformat = dns_masterformat_map;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews else
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews INSIST(0);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews obj = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (get_maps(maps, "max-zone-ttl", &obj)) {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews maxttl = cfg_obj_asuint32(obj);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zone_options2 |= DNS_ZONEOPT2_CHECKTTL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews result = load_zone(mctx, zname, zfile, masterformat,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zclass, maxttl, NULL);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (result != ISC_R_SUCCESS)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews fprintf(stderr, "%s/%s/%s: %s\n", view, zname, zclass,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews dns_result_totext(result));
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews return (result);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews}
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews/*% configure a view */
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsstatic isc_result_t
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrewsconfigure_view(const char *vclass, const char *view, const cfg_obj_t *config,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_obj_t *vconfig, isc_mem_t *mctx)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews{
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_listelt_t *element;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_obj_t *voptions;
17a3fcecd069130a5f318685493b0db5639a77c9Brian Wellington const cfg_obj_t *zonelist;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews isc_result_t result = ISC_R_SUCCESS;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews isc_result_t tresult;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews voptions = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (vconfig != NULL)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews voptions = cfg_tuple_get(vconfig, "options");
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews zonelist = NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (voptions != NULL)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews (void)cfg_map_get(voptions, "zone", &zonelist);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews else
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews (void)cfg_map_get(config, "zone", &zonelist);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews for (element = cfg_list_first(zonelist);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews element != NULL;
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews element = cfg_list_next(element))
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews {
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews const cfg_obj_t *zconfig = cfg_listelt_value(element);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington tresult = configure_zone(vclass, view, zconfig, vconfig,
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews config, mctx);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (tresult != ISC_R_SUCCESS)
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington result = tresult;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington }
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington return (result);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews}
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington/*% load zones from the configuration */
c03bb27f0675a6e60ceea66b451548e8481bc05cMark Andrewsstatic isc_result_t
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrewsload_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx) {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington const cfg_listelt_t *element;
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews const cfg_obj_t *classobj;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews const cfg_obj_t *views;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington const cfg_obj_t *vconfig;
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews const char *vclass;
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews isc_result_t result = ISC_R_SUCCESS;
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews isc_result_t tresult;
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews views = NULL;
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews (void)cfg_map_get(config, "view", &views);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews for (element = cfg_list_first(views);
c70908209ee26c51a8e7242a56fdb73847249728Brian Wellington element != NULL;
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson element = cfg_list_next(element))
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews {
c70908209ee26c51a8e7242a56fdb73847249728Brian Wellington const char *vname;
c70908209ee26c51a8e7242a56fdb73847249728Brian Wellington
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews vclass = "IN";
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington vconfig = cfg_listelt_value(element);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews if (vconfig != NULL) {
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews classobj = cfg_tuple_get(vconfig, "class");
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews if (cfg_obj_isstring(classobj))
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington vclass = cfg_obj_asstring(classobj);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington }
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews vname = cfg_obj_asstring(cfg_tuple_get(vconfig, "name"));
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington tresult = configure_view(vclass, vname, config, vconfig, mctx);
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews if (tresult != ISC_R_SUCCESS)
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews result = tresult;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews }
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews if (views == NULL) {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington tresult = configure_view("IN", "_default", config, NULL, mctx);
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson if (tresult != ISC_R_SUCCESS)
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson result = tresult;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington }
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington return (result);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington}
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafssonstatic void
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonoutput(void *closure, const char *text, int textlen) {
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington UNUSED(closure);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington if (fwrite(text, 1, textlen, stdout) != (size_t)textlen) {
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews perror("fwrite");
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington exit(1);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews }
d1cbf714097e900ed1703529584d3e1a50e8a4a8Brian Wellington}
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews/*% The main processing routine */
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellingtonint
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrewsmain(int argc, char **argv) {
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews int c;
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews cfg_parser_t *parser = NULL;
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews cfg_obj_t *config = NULL;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews const char *conffile = NULL;
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews isc_mem_t *mctx = NULL;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews isc_result_t result;
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews int exit_status = 0;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews isc_entropy_t *ectx = NULL;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews isc_boolean_t load_zones = ISC_FALSE;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews isc_boolean_t print = ISC_FALSE;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews unsigned int flags = 0;
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews isc_commandline_errprint = ISC_FALSE;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews /*
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews * Process memory debugging argument first.
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews */
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews#define CMDLINE_FLAGS "dhjm:t:pvxz"
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews switch (c) {
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews case 'm':
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews if (strcasecmp(isc_commandline_argument, "record") == 0)
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews if (strcasecmp(isc_commandline_argument, "trace") == 0)
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews isc_mem_debugging |= ISC_MEM_DEBUGTRACE;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews if (strcasecmp(isc_commandline_argument, "usage") == 0)
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews if (strcasecmp(isc_commandline_argument, "size") == 0)
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews isc_mem_debugging |= ISC_MEM_DEBUGSIZE;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews if (strcasecmp(isc_commandline_argument, "mctx") == 0)
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews isc_mem_debugging |= ISC_MEM_DEBUGCTX;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews break;
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews default:
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews break;
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews }
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews }
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews isc_commandline_reset = ISC_TRUE;
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews
c99d9017ba00099bfa89e1ed53e63a5cb07d28d5Mark Andrews while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != EOF) {
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews switch (c) {
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews case 'd':
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews debug++;
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews break;
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews case 'j':
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews nomerge = ISC_FALSE;
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews break;
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews case 'm':
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews break;
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews
638fe804a524ee0c028863c0301b999c79de7651Mark Andrews case 't':
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews result = isc_dir_chroot(isc_commandline_argument);
c70908209ee26c51a8e7242a56fdb73847249728Brian Wellington if (result != ISC_R_SUCCESS) {
c70908209ee26c51a8e7242a56fdb73847249728Brian Wellington fprintf(stderr, "isc_dir_chroot: %s\n",
368b37b616234fce3d23099eb180f1dd38e1fb62Mark Andrews isc_result_totext(result));
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews exit(1);
8b5de9701428e2b5eb50aba96af23dc1186124ddMark Andrews }
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews break;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews case 'p':
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington print = ISC_TRUE;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington break;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews case 'v':
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson printf(VERSION "\n");
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington exit(0);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington case 'x':
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington flags |= CFG_PRINTER_XKEY;
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson break;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews case 'z':
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews load_zones = ISC_TRUE;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews docheckmx = ISC_FALSE;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews docheckns = ISC_FALSE;
421e4cf66e4cba0b0751a34a9c027e39fe0474f9Mark Andrews dochecksrv = ISC_FALSE;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington break;
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews case '?':
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington if (isc_commandline_option != '?')
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson fprintf(stderr, "%s: invalid argument -%c\n",
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews program, isc_commandline_option);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington /* FALLTHROUGH */
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews case 'h':
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews usage();
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington default:
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington fprintf(stderr, "%s: unhandled option -%c\n",
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington program, isc_commandline_option);
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington exit(1);
b5debbe212097d1c573a2ba3bd9a3d526d86b0aeBrian Wellington }
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington }
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (((flags & CFG_PRINTER_XKEY) != 0) && !print) {
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington fprintf(stderr, "%s: -x cannot be used without -p\n", program);
e27021ee1f37185ab839a7a3b6bc078c24255e62Brian Wellington exit(1);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews }
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (isc_commandline_index + 1 < argc)
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington usage();
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (argv[isc_commandline_index] != NULL)
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington conffile = argv[isc_commandline_index];
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington if (conffile == NULL || conffile[0] == '\0')
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington conffile = NAMED_CONFFILE;
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington#ifdef _WIN32
b0d31c78bc24080d4c470a8bd98862375f6e3055Mark Andrews InitSockets();
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews#endif
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington
8839b6acbf816fedc15b8e9e1c71fd606a9cd8eaBrian Wellington RUNTIME_CHECK(setup_logging(mctx, stdout, &logc) == ISC_R_SUCCESS);
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson RUNTIME_CHECK(isc_entropy_create(mctx, &ectx) == ISC_R_SUCCESS);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington RUNTIME_CHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE)
b0d31c78bc24080d4c470a8bd98862375f6e3055Mark Andrews == ISC_R_SUCCESS);
34aa7909371f13b4bc0ba6d155cfc38bfa1e3c5cAndreas Gustafsson
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington dns_result_register();
b0d31c78bc24080d4c470a8bd98862375f6e3055Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews RUNTIME_CHECK(cfg_parser_create(mctx, logc, &parser) == ISC_R_SUCCESS);
f15af68028adc665d3bdddf955fc52bad83f0514Brian Wellington
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_parser_setcallback(parser, directory_callback, NULL);
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews if (cfg_parse_file(parser, conffile, &cfg_type_namedconf, &config) !=
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews ISC_R_SUCCESS)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews exit(1);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews result = bind9_check_namedconf(config, logc, mctx);
86f6b92e35c7bdb5fc1fd1021af75b981863313eMark Andrews if (result != ISC_R_SUCCESS)
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews exit_status = 1;
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (result == ISC_R_SUCCESS && load_zones) {
93d6dfaf66258337985427c86181f01fc51f0bb4Mark Andrews result = load_zones_fromconfig(config, mctx);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington if (result != ISC_R_SUCCESS)
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington exit_status = 1;
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington }
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington if (print && exit_status == 0)
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_printx(config, flags, output, NULL);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews cfg_obj_destroy(parser, &config);
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington cfg_parser_destroy(&parser);
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington
94766449d6125cd5870891b70d46573e5deaceb4Brian Wellington dns_name_destroy();
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington isc_log_destroy(&logc);
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington isc_hash_destroy();
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington isc_entropy_detach(&ectx);
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington isc_mem_destroy(&mctx);
0b09763c354ec91fb352b6b4cea383bd0195b2d8Mark Andrews
ca9af3aaf798f98624fc1dc69d8c7d51bf01334dBrian Wellington#ifdef _WIN32
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington DestroySockets();
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington#endif
5c6117688525d0e8d247f50c63364f66bd8d4185Brian Wellington
9cd6710f91bdffef5aed68ab02533e398f6134d7Brian Wellington return (exit_status);
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington}
6f071989da905bb5ab2c6dfd01a71ee5ecea5918Brian Wellington