unbound 0.1
unbound-checkconf.c File Reference

The config checker checks for syntax and other errors in the unbound.conf file, and can be used to check for errors before the server is started or sigHUPped. More...

#include "config.h"
#include <ctype.h>
#include "util/as112.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/module.h"
#include "util/net_help.h"
#include "util/regional.h"
#include "iterator/iterator.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_hints.h"
#include "validator/validator.h"
#include "services/localzone.h"
#include "services/listen_dnsport.h"
#include "services/view.h"
#include "services/authzone.h"
#include "respip/respip.h"
#include "sldns/sbuffer.h"
#include "sldns/str2wire.h"

Macros

#define COMPARE_ZONE_NAME(confname, builtname, len)

Functions

static void usage (void)
 Give checkconf usage, and exit (1).
static void print_option (struct config_file *cfg, const char *opt, int final)
 Print given option to stdout.
static void check_mod (struct config_file *cfg, struct module_func_block *fb)
 check if module works with config
static int str_addr_is_localhost (const char *a)
 true if addr is a localhost address, 127.0.0.1 or ::1 (with maybe "@port" after it)
static void donotquerylocalhostcheck (struct config_file *cfg)
 check do-not-query-localhost
static void nodefaultzonescheck (struct config_file *cfg)
static void localzonechecks (struct config_file *cfg)
 check localzones
static void acl_view_tag_checks (struct config_file *cfg, struct views *views)
 checks for acl and views
static void view_and_respipchecks (struct config_file *cfg)
 check view and response-ip configuration
static void warn_hosts (const char *typ, struct config_stub *list)
 emit warnings for IP in hosts
static void interfacechecks (struct config_file *cfg)
 check interface strings
static void ifautomaticportschecks (char *ifautomaticports)
 check interface-automatic-ports
static void controlinterfacechecks (struct config_file *cfg)
 check control interface strings
static void aclchecks (struct config_file *cfg)
 check acl ips
static void tcpconnlimitchecks (struct config_file *cfg)
 check tcp connection limit ips
static void allowproxychecks (struct config_file *cfg)
 check allow-proxy ips
static int is_file (const char *fname)
 true if fname is a file
static int is_dir (const char *fname)
 true if fname is a directory
static char * basedir (char *fname)
 get base dir of a fname
static void check_chroot_string (const char *desc, char **ss, const char *chrootdir, struct config_file *cfg)
 check chroot for a file string
static void check_chroot_filelist (const char *desc, struct config_strlist *list, const char *chrootdir, struct config_file *cfg)
 check file list, every file must be inside the chroot location
static void check_chroot_filelist_wild (const char *desc, struct config_strlist *list, const char *chrootdir, struct config_file *cfg)
 check file list, with wildcard processing
static void check_modules_exist (const char *module_conf)
 check that the modules exist, are compiled in
static int file_list_contains (struct config_strlist *list, char *fname, struct config_file *cfg)
 Compare filename with list of files, true if list contains the name.
static int file_list_contains_wild (struct config_strlist *list, char *fname, struct config_file *cfg)
 Compare filename with list of files, true if list contains the name, with glob compare.
static void check_file_clobber (struct config_file *cfg)
 Check if the auth-zone/rpz zonefile: conflicts with other files, so it would overwrite that file.
static void morechecks (struct config_file *cfg)
 check configuration for errors
static void check_fwd (struct config_file *cfg)
 check forwards
static void check_hints (struct config_file *cfg)
 check hints
static void check_auth (struct config_file *cfg, int readauth)
 check auth zones
static void checkconf (const char *cfgfile, const char *opt, int final, int quiet, int readauth)
 check config file
int main (int argc, char *argv[])
 Main routine for checkconf.

Variables

int optind
 getopt global, in case header files fail to declare it.
char * optarg
 getopt global, in case header files fail to declare it.

Detailed Description

The config checker checks for syntax and other errors in the unbound.conf file, and can be used to check for errors before the server is started or sigHUPped.

Exit status 1 means an error.

Macro Definition Documentation

◆ COMPARE_ZONE_NAME

#define COMPARE_ZONE_NAME ( confname,
builtname,
len )
Value:
(strncasecmp(confname, builtname, (len)) == 0 && \
(strlen(confname) == (len) || \
(strlen(confname) == (len) + 1 \
&& confname[(len)] == '.')))

Function Documentation

◆ usage()

void usage ( void )
static

Give checkconf usage, and exit (1).

References usage().

◆ print_option()

void print_option ( struct config_file * cfg,
const char * opt,
int final )
static

Print given option to stdout.

Parameters
cfgconfig
optoption name without trailing :. This is different from config_set_option.
finalif final pathname with chroot applied has to be printed.

References config_file::auto_trust_anchor_file_list, config_get_option(), config_print_func(), fatal_exit(), fname_after_chroot(), config_strlist::next, config_file::pidfile, print_option(), and config_strlist::str.

Referenced by checkconf(), and print_option().

◆ check_mod()

◆ str_addr_is_localhost()

int str_addr_is_localhost ( const char * a)
static

true if addr is a localhost address, 127.0.0.1 or ::1 (with maybe "@port" after it)

References str_addr_is_localhost().

Referenced by donotquerylocalhostcheck(), and str_addr_is_localhost().

◆ donotquerylocalhostcheck()

◆ localzonechecks()

void localzonechecks ( struct config_file * cfg)
static

◆ acl_view_tag_checks()

◆ view_and_respipchecks()

◆ warn_hosts()

void warn_hosts ( const char * typ,
struct config_stub * list )
static

◆ interfacechecks()

◆ ifautomaticportschecks()

void ifautomaticportschecks ( char * ifautomaticports)
static

check interface-automatic-ports

References fatal_exit(), and ifautomaticportschecks().

Referenced by ifautomaticportschecks(), and morechecks().

◆ controlinterfacechecks()

◆ aclchecks()

void aclchecks ( struct config_file * cfg)
static

◆ tcpconnlimitchecks()

void tcpconnlimitchecks ( struct config_file * cfg)
static

◆ allowproxychecks()

void allowproxychecks ( struct config_file * cfg)
static

◆ is_file()

int is_file ( const char * fname)
static

true if fname is a file

References is_file().

Referenced by check_chroot_string(), is_file(), and morechecks().

◆ is_dir()

int is_dir ( const char * fname)
static

true if fname is a directory

References is_dir().

Referenced by is_dir(), and morechecks().

◆ basedir()

char * basedir ( char * fname)
static

get base dir of a fname

References basedir(), and fatal_exit().

Referenced by basedir(), and morechecks().

◆ check_chroot_string()

void check_chroot_string ( const char * desc,
char ** ss,
const char * chrootdir,
struct config_file * cfg )
static

◆ check_chroot_filelist()

void check_chroot_filelist ( const char * desc,
struct config_strlist * list,
const char * chrootdir,
struct config_file * cfg )
static

check file list, every file must be inside the chroot location

References check_chroot_filelist(), check_chroot_string(), config_strlist::next, and config_strlist::str.

Referenced by check_chroot_filelist(), and morechecks().

◆ check_chroot_filelist_wild()

void check_chroot_filelist_wild ( const char * desc,
struct config_strlist * list,
const char * chrootdir,
struct config_file * cfg )
static

◆ check_modules_exist()

void check_modules_exist ( const char * module_conf)
static

check that the modules exist, are compiled in

References check_modules_exist(), fatal_exit(), and module_list_avail().

Referenced by check_modules_exist(), and morechecks().

◆ file_list_contains()

int file_list_contains ( struct config_strlist * list,
char * fname,
struct config_file * cfg )
static

Compare filename with list of files, true if list contains the name.

References fatal_exit(), file_list_contains(), fname_after_chroot(), config_strlist::next, and config_strlist::str.

Referenced by check_file_clobber(), and file_list_contains().

◆ file_list_contains_wild()

int file_list_contains_wild ( struct config_strlist * list,
char * fname,
struct config_file * cfg )
static

Compare filename with list of files, true if list contains the name, with glob compare.

References fatal_exit(), file_list_contains_wild(), fname_after_chroot(), log_err(), config_strlist::next, and config_strlist::str.

Referenced by check_file_clobber(), and file_list_contains_wild().

◆ check_file_clobber()

◆ morechecks()

◆ check_fwd()

void check_fwd ( struct config_file * cfg)
static

◆ check_hints()

void check_hints ( struct config_file * cfg)
static

◆ check_auth()

void check_auth ( struct config_file * cfg,
int readauth )
static

◆ checkconf()

void checkconf ( const char * cfgfile,
const char * opt,
int final,
int quiet,
int readauth )
static

◆ main()

int main ( int argc,
char * argv[] )

Main routine for checkconf.

References checkconf(), log_ident_set(), log_init(), main, optarg, optind, and usage().