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 "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 "validator/validator.h"
#include "services/localzone.h"
#include <pwd.h>
#include <sys/stat.h>
#include <glob.h>

Defines

#define O_DEC(opt, str, var)
 compare and print decimal option
#define O_UNS(opt, str, var)
 compare and print unsigned option
#define O_YNO(opt, str, var)
 compare and print yesno option
#define O_STR(opt, str, var)
 compare and print string option
#define O_IFC(opt, str, num, arr)
 compare and print array option
#define O_MEM(opt, str, var)
 compare and print memorysize option
#define O_LST(opt, name, lst)
 compare and print list option
#define O_LS2(opt, name, lst)
 compare and print list option

Functions

static void usage ()
 Give checkconf usage, and exit (1).
static void print_option (struct config_file *cfg, const char *opt)
 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 void localzonechecks (struct config_file *cfg)
 check localzones
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 aclchecks (struct config_file *cfg)
 check acl 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 morechecks (struct config_file *cfg, const char *fname)
 check configuration for errors
static void check_fwd (struct config_file *cfg)
 check forwards
static void checkconf (const char *cfgfile, const char *opt)
 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.


Define Documentation

#define O_DEC ( opt,
str,
var   ) 

Value:

if(strcmp(opt, str)==0) \
        {printf("%d\n", (int)cfg->var);}
compare and print decimal option

Referenced by print_option().

#define O_UNS ( opt,
str,
var   ) 

Value:

if(strcmp(opt, str)==0) \
        {printf("%u\n", (unsigned)cfg->var);}
compare and print unsigned option

Referenced by print_option().

#define O_YNO ( opt,
str,
var   ) 

Value:

if(strcmp(opt, str)==0) \
        {printf("%s\n", cfg->var?"yes":"no");}
compare and print yesno option

Referenced by print_option().

#define O_STR ( opt,
str,
var   ) 

Value:

if(strcmp(opt, str)==0) \
        {printf("%s\n", cfg->var?cfg->var:"");}
compare and print string option

Referenced by print_option().

#define O_IFC ( opt,
str,
num,
arr   ) 

Value:

if(strcmp(opt, str)==0) \
        {int i; for(i=0; i<cfg->num; i++) printf("%s\n", cfg->arr[i]);}
compare and print array option

Referenced by print_option().

#define O_MEM ( opt,
str,
var   ) 

Value:

if(strcmp(opt, str)==0) { \
        if(cfg->var > 1024*1024*1024) { \
          size_t f=cfg->var/(size_t)1000000, b=cfg->var%(size_t)1000000; \
          printf("%u%6.6u\n", (unsigned)f, (unsigned)b); \
        } else printf("%u\n", (unsigned)cfg->var);}
compare and print memorysize option

Referenced by print_option().

#define O_LST ( opt,
name,
lst   ) 

Value:

if(strcmp(opt, name)==0) { \
        struct config_strlist* p = cfg->lst; \
        for(p = cfg->lst; p; p = p->next) \
                printf("%s\n", p->str); \
        }
compare and print list option

Referenced by print_option().

#define O_LS2 ( opt,
name,
lst   ) 

Value:

if(strcmp(opt, name)==0) { \
        struct config_str2list* p = cfg->lst; \
        for(p = cfg->lst; p; p = p->next) \
                printf("%s %s\n", p->str, p->str2); \
        }
compare and print list option

Referenced by print_option().


Function Documentation

static void usage ( void   )  [static]

Give checkconf usage, and exit (1).

static void print_option ( struct config_file cfg,
const char *  opt 
) [static]

Print given option to stdout.

Parameters:
cfg,: config
opt,: option name without trailing :. This is different from config_set_option.

References fatal_exit(), logfile, O_DEC, O_IFC, O_LS2, O_LST, O_MEM, O_STR, O_UNS, O_YNO, and verbosity.

Referenced by checkconf().


Variable Documentation

int optind

getopt global, in case header files fail to declare it.

char* optarg

getopt global, in case header files fail to declare it.


Generated on Tue Oct 13 06:46:31 2009 for unbound by  doxygen 1.5.9