Deleted Added
full compact
unbound-checkconf.c (256281) unbound-checkconf.c (269257)
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
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 LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
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"
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"
56#ifdef HAVE_GETOPT_H
57#include <getopt.h>
58#endif
59#ifdef HAVE_PWD_H
60#include <pwd.h>
61#endif
62#ifdef HAVE_SYS_STAT_H
63#include <sys/stat.h>

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

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

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

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

--- 161 unchanged lines hidden ---
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 ---