Deleted Added
sdiff udiff text old ( 256281 ) new ( 269257 )
full compact
1/*
2 * checkconf/unbound-checkconf.c - config file checker for unbound.conf file.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 7 unchanged lines hidden (view full) ---

16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/**
37 * \file
38 *
39 * The config checker checks for syntax and other errors in the unbound.conf
40 * file, and can be used to check for errors before the server is started
41 * or sigHUPped.

--- 6 unchanged lines hidden (view full) ---

48#include "util/module.h"
49#include "util/net_help.h"
50#include "util/regional.h"
51#include "iterator/iterator.h"
52#include "iterator/iter_fwd.h"
53#include "iterator/iter_hints.h"
54#include "validator/validator.h"
55#include "services/localzone.h"
56#include "ldns/sbuffer.h"
57#ifdef HAVE_GETOPT_H
58#include <getopt.h>
59#endif
60#ifdef HAVE_PWD_H
61#include <pwd.h>
62#endif
63#ifdef HAVE_SYS_STAT_H
64#include <sys/stat.h>

--- 36 unchanged lines hidden (view full) ---

101/** check if module works with config */
102static void
103check_mod(struct config_file* cfg, struct module_func_block* fb)
104{
105 struct module_env env;
106 memset(&env, 0, sizeof(env));
107 env.cfg = cfg;
108 env.scratch = regional_create();
109 env.scratch_buffer = sldns_buffer_new(BUFSIZ);
110 if(!env.scratch || !env.scratch_buffer)
111 fatal_exit("out of memory");
112 if(!(*fb->init)(&env, 0)) {
113 fatal_exit("bad config for %s module", fb->name);
114 }
115 (*fb->deinit)(&env, 0);
116 sldns_buffer_free(env.scratch_buffer);
117 regional_destroy(env.scratch);
118}
119
120/** check localzones */
121static void
122localzonechecks(struct config_file* cfg)
123{
124 struct local_zones* zs;

--- 214 unchanged lines hidden (view full) ---

339 fatal_exit("bad chroot directory");
340 }
341 if(cfg->chrootdir && cfg->chrootdir[0]) {
342 char buf[10240];
343 buf[0] = 0;
344 if(fname[0] != '/') {
345 if(getcwd(buf, sizeof(buf)) == NULL)
346 fatal_exit("getcwd: %s", strerror(errno));
347 (void)strlcat(buf, "/", sizeof(buf));
348 }
349 (void)strlcat(buf, fname, sizeof(buf));
350 if(strncmp(buf, cfg->chrootdir, strlen(cfg->chrootdir)) != 0)
351 fatal_exit("config file %s is not inside chroot %s",
352 buf, cfg->chrootdir);
353 }
354 if(cfg->directory && cfg->directory[0]) {
355 char* ad = fname_after_chroot(cfg->directory, cfg, 0);
356 if(!ad) fatal_exit("out of memory");
357 if(!is_dir(ad)) fatal_exit("bad chdir directory");

--- 161 unchanged lines hidden ---