config_file.c File Reference

This file contains functions for the config file. More...

#include "config.h"
#include "util/log.h"
#include "util/configyyrename.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "util/data/msgparse.h"
#include "util/module.h"
#include "util/regional.h"
#include "util/fptr_wlist.h"
#include "util/data/dname.h"

Data Structures

struct  config_collate_arg
 collate func arg More...

Defines

#define IS_NUMBER_OR_ZERO   if(atoi(val) == 0 && strcmp(val, "0") != 0) return 0
 check that the value passed is >= 0
#define IS_NONZERO_NUMBER   if(atoi(val) == 0) return 0
 check that the value passed is > 0
#define IS_POW2_NUMBER   if(atoi(val) == 0 || !is_pow2((size_t)atoi(val))) return 0
 check that the value passed is not 0 and a power of 2
#define IS_YES_OR_NO   if(strcmp(val, "yes") != 0 && strcmp(val, "no") != 0) return 0
 check that the value passed is yes or no
#define S_NUMBER_OR_ZERO(str, var)
 put integer_or_zero into variable
#define S_NUMBER_NONZERO(str, var)
 put integer_nonzero into variable
#define S_UNSIGNED_OR_ZERO(str, var)
 put integer_or_zero into unsigned
#define S_SIZET_OR_ZERO(str, var)
 put integer_or_zero into size_t
#define S_SIZET_NONZERO(str, var)
 put integer_nonzero into size_t
#define S_YNO(str, var)
 put yesno into variable
#define S_MEMSIZE(str, var)
 put memsize into variable
#define S_POW2(str, var)
 put pow2 number into variable
#define S_STR(str, var)
 put string into variable
#define S_STRLIST(str, var)
 put string into strlist
#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

int ub_c_parse (void)
 the yacc lex generated parse function
int ub_c_lex (void)
 the lexer function
int ub_c_wrap (void)
 wrap function
static void init_outgoing_availports (int *array, int num)
 init ports possible for use
struct config_fileconfig_create ()
 Create config file structure.
struct config_fileconfig_create_forlib ()
 Create config file structure for library use.
int config_set_option (struct config_file *cfg, const char *opt, const char *val)
 Set the given keyword to the given value.
void config_print_func (char *line, void *arg)
 function to print to a file, use as func with config_get_option.
void config_collate_func (char *line, void *arg)
 function to collate the text strings into a strlist_head.
int config_get_option_list (struct config_file *cfg, const char *opt, struct config_strlist **list)
 Get an option and return strlist.
int config_get_option_collate (struct config_file *cfg, const char *opt, char **str)
 Get an option and collate results into string.
char * config_collate_cat (struct config_strlist *list)
 take a strlist_head list and return a malloc string.
int config_get_option (struct config_file *cfg, const char *opt, void(*func)(char *, void *), void *arg)
 Call print routine for the given option.
static void create_cfg_parser (struct config_file *cfg, char *filename, const char *chroot)
 initialize the global cfg_parser object
int config_read (struct config_file *cfg, const char *filename, const char *chroot)
 Read the config file from the specified filename.
void config_delstrlist (struct config_strlist *p)
 Delete items in config string list.
void config_deldblstrlist (struct config_str2list *p)
 Delete items in config double string list.
void config_delstubs (struct config_stub *p)
 Delete items in config stub list.
void config_delete (struct config_file *cfg)
 Destroy the config file structure.
int cfg_mark_ports (const char *str, int allow, int *avail, int num)
 Mark "number" or "low-high" as available or not in ports array.
int cfg_scan_ports (int *avail, int num)
 Scan ports available.
int cfg_condense_ports (struct config_file *cfg, int **avail)
 Get a condensed list of ports returned.
void ub_c_error_va_list (const char *fmt, va_list args)
 print error with file and line number
void ub_c_error_msg (const char *fmt,...)
 print error with file and line number
void ub_c_error (const char *str)
 parsing helpers: print error with file and line numbers
int cfg_strlist_append (struct config_strlist_head *list, char *item)
 Append text at end of list.
int cfg_strlist_insert (struct config_strlist **head, char *item)
 Insert string into strlist.
int cfg_str2list_insert (struct config_str2list **head, char *item, char *i2)
 Insert string into str2list.
uint32_t cfg_convert_timeval (const char *str)
 Convert 14digit to time value.
int cfg_count_numbers (const char *s)
 Count number of values in the string.
static int isalldigit (const char *str, size_t l)
 all digit number
int cfg_parse_memsize (const char *str, size_t *res)
 Convert a 'nice' memory or file size into a bytecount From '100k' to 102400.
void config_apply (struct config_file *config)
 Apply config to global constants; this routine is called in single thread.
static size_t strlen_after_chroot (const char *fname, struct config_file *cfg, int use_chdir)
 Calculate string length of full pathname in original filesys.
char * fname_after_chroot (const char *fname, struct config_file *cfg, int use_chdir)
 Convert a filename to full pathname in original filesys.
static char * next_space_pos (const char *str)
 return next space character in string
static char * last_space_pos (const char *str)
 return last space character in string
int cfg_parse_local_zone (struct config_file *cfg, const char *val)
 Parse local-zone directive into two strings and register it in the config.
char * cfg_ptr_reverse (char *str)
 Convert a ptr shorthand into a full reverse-notation PTR record.
void errinf (struct module_qstate *qstate, const char *str)
 Append text to the error info for validation.
void errinf_origin (struct module_qstate *qstate, struct sock_list *origin)
 Append text to error info: from 1.2.3.4.
char * errinf_to_str (struct module_qstate *qstate)
 Create error info in string.
void errinf_rrset (struct module_qstate *qstate, struct ub_packed_rrset_key *rr)
 Append text to error info: for RRset name type class.
void errinf_dname (struct module_qstate *qstate, const char *str, uint8_t *dname)
 Append text to error info: str dname.

Variables

struct config_parser_statecfg_parser = 0
 global config during parsing
FILE * ub_c_in
 lex in file
FILE * ub_c_out
 lex out file

Detailed Description

This file contains functions for the config file.


Define Documentation

#define S_NUMBER_OR_ZERO ( str,
var   ) 
Value:
if(strcmp(opt, str) == 0) \
        { IS_NUMBER_OR_ZERO; cfg->var = atoi(val); }

put integer_or_zero into variable

Referenced by config_set_option().

#define S_NUMBER_NONZERO ( str,
var   ) 
Value:
if(strcmp(opt, str) == 0) \
        { IS_NONZERO_NUMBER; cfg->var = atoi(val); }

put integer_nonzero into variable

Referenced by config_set_option().

#define S_UNSIGNED_OR_ZERO ( str,
var   ) 
Value:
if(strcmp(opt, str) == 0) \
        { IS_NUMBER_OR_ZERO; cfg->var = (unsigned)atoi(val); }

put integer_or_zero into unsigned

Referenced by config_set_option().

#define S_SIZET_OR_ZERO ( str,
var   ) 
Value:
if(strcmp(opt, str) == 0) \
        { IS_NUMBER_OR_ZERO; cfg->var = (size_t)atoi(val); }

put integer_or_zero into size_t

Referenced by config_set_option().

#define S_SIZET_NONZERO ( str,
var   ) 
Value:
if(strcmp(opt, str) == 0) \
        { IS_NONZERO_NUMBER; cfg->var = (size_t)atoi(val); }

put integer_nonzero into size_t

Referenced by config_set_option().

#define S_YNO ( str,
var   ) 
Value:
if(strcmp(opt, str) == 0) \
        { IS_YES_OR_NO; cfg->var = (strcmp(val, "yes") == 0); }

put yesno into variable

Referenced by config_set_option().

#define S_MEMSIZE ( str,
var   ) 
Value:
if(strcmp(opt, str)==0) \
        { return cfg_parse_memsize(val, &cfg->var); }

put memsize into variable

Referenced by config_set_option().

#define S_POW2 ( str,
var   ) 
Value:
if(strcmp(opt, str)==0) \
        { IS_POW2_NUMBER; cfg->var = (size_t)atoi(val); }

put pow2 number into variable

Referenced by config_set_option().

#define S_STR ( str,
var   ) 
Value:
if(strcmp(opt, str)==0) \
        { free(cfg->var); return (cfg->var = strdup(val)) != NULL; }

put string into variable

Referenced by config_set_option().

#define S_STRLIST ( str,
var   ) 
Value:
if(strcmp(opt, str)==0) \
        { return cfg_strlist_insert(&cfg->var, strdup(val)); }

put string into strlist

Referenced by config_set_option().

#define O_DEC ( opt,
str,
var   ) 
Value:
if(strcmp(opt, str)==0) \
        {snprintf(buf, len, "%d", (int)cfg->var); \
        func(buf, arg);}

compare and print decimal option

Referenced by config_get_option().

#define O_UNS ( opt,
str,
var   ) 
Value:
if(strcmp(opt, str)==0) \
        {snprintf(buf, len, "%u", (unsigned)cfg->var); \
        func(buf, arg);}

compare and print unsigned option

Referenced by config_get_option().

#define O_YNO ( opt,
str,
var   ) 
Value:
if(strcmp(opt, str)==0) \
        {func(cfg->var?"yes":"no", arg);}

compare and print yesno option

Referenced by config_get_option().

#define O_STR ( opt,
str,
var   ) 
Value:
if(strcmp(opt, str)==0) \
        {func(cfg->var?cfg->var:"", arg);}

compare and print string option

Referenced by config_get_option().

#define O_IFC ( opt,
str,
num,
arr   ) 
Value:
if(strcmp(opt, str)==0) \
        {int i; for(i=0; i<cfg->num; i++) func(cfg->arr[i], arg);}

compare and print array option

Referenced by config_get_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; \
          snprintf(buf, len, "%u%6.6u\n", (unsigned)f, (unsigned)b); \
        } else snprintf(buf, len, "%u\n", (unsigned)cfg->var); \
        func(buf, arg);}

compare and print memorysize option

Referenced by config_get_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) \
                func(p->str, arg); \
        }

compare and print list option

Referenced by config_get_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) \
                snprintf(buf, len, "%s %s\n", p->str, p->str2); \
                func(buf, arg); \
        }

compare and print list option

Referenced by config_get_option().


Function Documentation

struct config_file* config_create (  )  [read]

Create config file structure.

Filled with default values.

Returns:
: the new structure or NULL on memory error.

References config_file::acls, config_file::add_holddown, config_file::auto_trust_anchor_file_list, config_file::bogus_ttl, config_file::chrootdir, config_delete(), config_file::control_cert_file, config_file::control_ifs, config_file::control_key_file, config_file::control_port, config_file::del_holddown, config_file::directory, config_file::dlv_anchor_file, config_file::dlv_anchor_list, config_file::do_daemonize, config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_udp, config_file::domain_insecure, config_file::donotquery_localhost, config_file::donotqueryaddrs, config_file::edns_buffer_size, error_exit(), config_file::forwards, config_file::harden_dnssec_stripped, config_file::harden_glue, config_file::harden_large_queries, config_file::harden_referral_path, config_file::harden_short_bufsize, config_file::hide_identity, config_file::hide_version, config_file::host_ttl, config_file::identity, config_file::if_automatic, config_file::ifs, config_file::incoming_num_tcp, config_file::infra_cache_lame_size, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, init_outgoing_availports(), config_file::jostle_time, config_file::keep_missing, config_file::key_cache_size, config_file::key_cache_slabs, config_file::lame_ttl, config_file::local_data, config_file::local_zones, config_file::local_zones_nodefault, config_file::log_time_ascii, config_file::logfile, config_file::max_ttl, config_file::min_ttl, config_file::module_conf, config_file::msg_buffer_size, config_file::msg_cache_size, config_file::msg_cache_slabs, config_file::neg_cache_size, config_file::num_ifs, config_file::num_out_ifs, config_file::num_queries_per_thread, config_file::num_threads, config_file::out_ifs, config_file::outgoing_avail_ports, config_file::outgoing_num_ports, config_file::outgoing_num_tcp, config_file::pidfile, config_file::port, config_file::prefetch, config_file::prefetch_key, config_file::private_address, config_file::private_domain, config_file::python_script, config_file::remote_control_enable, config_file::root_hints, config_file::rrset_cache_size, config_file::rrset_cache_slabs, config_file::server_cert_file, config_file::server_key_file, config_file::socket_rcvbuf, config_file::stat_cumulative, config_file::stat_extended, config_file::stat_interval, config_file::stubs, config_file::target_fetch_policy, config_file::trust_anchor_file_list, config_file::trust_anchor_list, config_file::trusted_keys_file_list, config_file::unwanted_threshold, config_file::use_caps_bits_for_id, config_file::use_syslog, config_file::username, config_file::val_clean_additional, config_file::val_date_override, config_file::val_log_level, config_file::val_log_squelch, config_file::val_nsec3_key_iterations, config_file::val_permissive_mode, config_file::val_sig_skew_max, config_file::val_sig_skew_min, config_file::verbosity, and config_file::version.

Referenced by checkconf(), config_create_forlib(), go(), infra_test(), run_daemon(), and service_init().

struct config_file* config_create_forlib (  )  [read]
int config_set_option ( struct config_file config,
const char *  option,
const char *  value 
)

Set the given keyword to the given value.

Parameters:
config,: where to store config
option,: option name, including the ':' character.
value,: value, this string is copied if needed, or parsed. The caller owns the value string.
Returns:
0 on error (malloc or syntax error).

References config_file::add_holddown, config_file::auto_trust_anchor_file_list, config_file::bogus_ttl, cfg_convert_timeval(), cfg_mark_ports(), cfg_parse_local_zone(), cfg_ptr_reverse(), cfg_strlist_insert(), config_file::chrootdir, config_file::control_cert_file, config_file::control_ifs, config_file::control_key_file, config_file::control_port, config_file::del_holddown, config_file::directory, config_file::dlv_anchor_file, config_file::dlv_anchor_list, config_file::do_daemonize, config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_udp, config_file::domain_insecure, config_file::donotquery_localhost, config_file::donotqueryaddrs, config_file::edns_buffer_size, config_file::harden_dnssec_stripped, config_file::harden_glue, config_file::harden_large_queries, config_file::harden_referral_path, config_file::harden_short_bufsize, config_file::hide_identity, config_file::hide_version, config_file::host_ttl, config_file::identity, config_file::if_automatic, config_file::incoming_num_tcp, config_file::infra_cache_lame_size, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, config_file::jostle_time, config_file::keep_missing, config_file::key_cache_size, config_file::key_cache_slabs, config_file::lame_ttl, config_file::local_data, config_file::logfile, config_file::max_ttl, config_file::module_conf, config_file::msg_buffer_size, config_file::msg_cache_size, config_file::msg_cache_slabs, config_file::neg_cache_size, config_file::num_queries_per_thread, config_file::outgoing_avail_ports, config_file::outgoing_num_ports, config_file::outgoing_num_tcp, config_file::pidfile, config_file::port, config_file::prefetch, config_file::prefetch_key, config_file::private_address, config_file::private_domain, config_file::python_script, config_file::remote_control_enable, config_file::root_hints, config_file::rrset_cache_size, config_file::rrset_cache_slabs, S_MEMSIZE, S_NUMBER_NONZERO, S_NUMBER_OR_ZERO, S_POW2, S_SIZET_NONZERO, S_SIZET_OR_ZERO, S_STR, S_STRLIST, S_UNSIGNED_OR_ZERO, S_YNO, config_file::server_cert_file, config_file::server_key_file, config_file::socket_rcvbuf, config_file::stat_cumulative, config_file::stat_extended, config_file::stat_interval, config_file::target_fetch_policy, config_file::trust_anchor_file_list, config_file::trust_anchor_list, config_file::trusted_keys_file_list, config_file::unwanted_threshold, config_file::use_caps_bits_for_id, config_file::use_syslog, config_file::username, config_file::val_clean_additional, config_file::val_date_override, config_file::val_log_level, config_file::val_log_squelch, config_file::val_nsec3_key_iterations, config_file::val_permissive_mode, verbosity, and config_file::version.

Referenced by do_set_option(), and ub_ctx_set_option().

void config_print_func ( char *  line,
void *  arg 
)

function to print to a file, use as func with config_get_option.

Parameters:
line,: text to print.
appended.
arg,: pass a FILE*, like stdout.

Referenced by fptr_whitelist_print_func(), and print_option().

void config_collate_func ( char *  line,
void *  arg 
)

function to collate the text strings into a strlist_head.

Parameters:
line,: text to append.
arg,: pass a strlist_head structure. zeroed on start.

References cfg_strlist_append(), config_collate_arg::list, and config_collate_arg::status.

Referenced by config_get_option_list(), and fptr_whitelist_print_func().

int config_get_option_list ( struct config_file cfg,
const char *  opt,
struct config_strlist **  list 
)

Get an option and return strlist.

Parameters:
cfg,: config file
opt,: option name.
list,: list is returned here. malloced, caller must free it.
Returns:
0=OK, 1=syntax error, 2=malloc failed.

References config_collate_func(), config_delstrlist(), config_get_option(), config_strlist_head::first, config_collate_arg::list, and config_collate_arg::status.

Referenced by config_get_option_collate().

int config_get_option_collate ( struct config_file cfg,
const char *  opt,
char **  str 
)

Get an option and collate results into string.

Parameters:
cfg,: config file
opt,: option name.
str,: string. malloced, caller must free it.
Returns:
0=OK, 1=syntax error, 2=malloc failed.

References config_collate_cat(), config_delstrlist(), and config_get_option_list().

Referenced by ub_ctx_get_option().

char* config_collate_cat ( struct config_strlist list  ) 

take a strlist_head list and return a malloc string.

separated with newline.

Parameters:
list,: strlist first to collate. zeroes return "".
Returns:
NULL on malloc failure. Or if malloc failure happened in strlist.

References config_strlist::next, and config_strlist::str.

Referenced by config_get_option_collate().

int config_get_option ( struct config_file cfg,
const char *  opt,
void(*)(char *, void *)  func,
void *  arg 
)

Call print routine for the given option.

Parameters:
cfg,: config.
opt,: option name without trailing :. This is different from config_set_option.
func,: print func, called as (str, arg) for every data element.
arg,: user argument for print func.
Returns:
false if the option name is not supported (syntax error).

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

Referenced by config_get_option_list(), do_get_option(), and print_option().

int config_read ( struct config_file config,
const char *  filename,
const char *  chroot 
)

Read the config file from the specified filename.

Parameters:
config,: where options are stored into, must be freshly created.
filename,: name of configfile. If NULL nothing is done.
chroot,: if not NULL, the chroot dir currently in use (for include).
Returns:
: false on error. In that case errno is set, ENOENT means file not found.

References create_cfg_parser(), config_parser_state::errors, config_parser_state::filename, log_err(), ub_c_in, and ub_c_parse().

Referenced by checkconf(), go(), run_daemon(), service_init(), and ub_ctx_config().

void config_delstrlist ( struct config_strlist list  ) 
void config_deldblstrlist ( struct config_str2list list  ) 

Delete items in config double string list.

Parameters:
list,: list.

References config_str2list::next, config_str2list::str, and config_str2list::str2.

Referenced by config_delete(), and lz_freeup_cfg().

void config_delstubs ( struct config_stub list  ) 

Delete items in config stub list.

Parameters:
list,: list.

References config_stub::addrs, config_delstrlist(), config_stub::hosts, config_stub::name, and config_stub::next.

Referenced by config_delete(), and ub_ctx_set_fwd().

void config_delete ( struct config_file config  ) 
int cfg_mark_ports ( const char *  str,
int  allow,
int *  avail,
int  num 
)

Mark "number" or "low-high" as available or not in ports array.

Parameters:
str,: string in input
allow,: give true if this range is permitted.
avail,: the array from cfg.
num,: size of the array (65536).
Returns:
: true if parsed correctly, or 0 on a parse error (and an error is logged).

References log_err().

Referenced by config_set_option().

int cfg_scan_ports ( int *  avail,
int  num 
)

Scan ports available.

Parameters:
avail,: the array from cfg.
num,: size of the array (65536).
Returns:
the number of ports available for use.

Referenced by cfg_condense_ports().

int cfg_condense_ports ( struct config_file cfg,
int **  avail 
)

Get a condensed list of ports returned.

allocated.

Parameters:
cfg,: config file.
avail,: the available ports array is returned here.
Returns:
: number of ports in array or 0 on error.

References cfg_scan_ports(), log_assert, and config_file::outgoing_avail_ports.

Referenced by libworker_setup().

int cfg_strlist_append ( struct config_strlist_head list,
char *  item 
)

Append text at end of list.

Parameters:
list,: list head. zeroed at start.
item,: new item. malloced by caller. if NULL the insertion fails.
Returns:
true on success.

References config_strlist_head::first, config_strlist_head::last, config_strlist::next, and config_strlist::str.

Referenced by config_collate_func().

int cfg_strlist_insert ( struct config_strlist **  head,
char *  item 
)

Insert string into strlist.

Parameters:
head,: pointer to strlist head variable.
item,: new item. malloced by caller. If NULL the insertion fails.
Returns:
: true on success.

References config_strlist::next, and config_strlist::str.

Referenced by cfg_parse_local_zone(), config_set_option(), read_file_content(), setup_config(), spool_auto_file(), ub_ctx_add_ta(), ub_ctx_add_ta_file(), ub_ctx_hosts(), ub_ctx_set_fwd(), and ub_ctx_trustedkeys().

int cfg_str2list_insert ( struct config_str2list **  head,
char *  item,
char *  i2 
)

Insert string into str2list.

Parameters:
head,: pointer to str2list head variable.
item,: new item. malloced by caller. If NULL the insertion fails.
i2,: 2nd string, malloced by caller. If NULL the insertion fails.
Returns:
: true on success.

References config_str2list::next, config_str2list::str, and config_str2list::str2.

Referenced by cfg_parse_local_zone().

uint32_t cfg_convert_timeval ( const char *  str  ) 

Convert 14digit to time value.

Parameters:
str,: string of 14 digits
Returns:
time value or 0 for error.

Referenced by config_set_option(), parse_cmdline(), and verifytest_file().

int cfg_count_numbers ( const char *  str  ) 

Count number of values in the string.

format ::= (sp num)+ sp num ::= [-](0-9)+ sp ::= (space|tab)*

Parameters:
str,: string
Returns:
: 0 on parse error, or empty string, else number of integer values in the string.

Referenced by read_fetch_policy(), and val_apply_cfg().

int cfg_parse_memsize ( const char *  str,
size_t *  res 
)

Convert a 'nice' memory or file size into a bytecount From '100k' to 102400.

and so on. Understands kKmMgG. k=1024, m=1024*1024, g=1024*1024*1024.

Parameters:
str,: string
res,: result is stored here, size in bytes.
Returns:
: true if parsed correctly, or 0 on a parse error (and an error is logged).

References isalldigit(), and log_err().

Referenced by config_memsize_test(), and main().

void config_apply ( struct config_file config  ) 

Apply config to global constants; this routine is called in single thread.

Parameters:
config,: to apply. Side effect: global constants change.

References EDNS_ADVERTISED_SIZE, config_file::edns_buffer_size, log_set_time_asc(), config_file::log_time_ascii, config_file::max_ttl, MAX_TTL, config_file::min_ttl, and MIN_TTL.

Referenced by context_finalize(), and daemon_apply_cfg().

static size_t strlen_after_chroot ( const char *  fname,
struct config_file cfg,
int  use_chdir 
) [static]

Calculate string length of full pathname in original filesys.

Parameters:
fname,: the path name to convert. Must not be null or empty.
cfg,: config struct for chroot and chdir (if set).
use_chdir,: if false, only chroot is applied.
Returns:
length of string. remember to allocate one more for 0 at end in mallocs.

References config_file::chrootdir, and config_file::directory.

Referenced by fname_after_chroot().

char* fname_after_chroot ( const char *  fname,
struct config_file cfg,
int  use_chdir 
)

Convert a filename to full pathname in original filesys.

Parameters:
fname,: the path name to convert. Must not be null or empty.
cfg,: config struct for chroot and chdir (if set).
use_chdir,: if false, only chroot is applied.
Returns:
pointer to malloced buffer which is: [chroot][chdir]fname or NULL on malloc failure.

References config_file::chrootdir, config_file::directory, and strlen_after_chroot().

Referenced by check_chroot_filelist_wild(), check_chroot_string(), daemon_remote_create(), morechecks(), perform_setup(), and setup_ctx().

int cfg_parse_local_zone ( struct config_file cfg,
const char *  val 
)

Parse local-zone directive into two strings and register it in the config.

Parameters:
cfg,: to put it in.
val,: argument strings to local-zone, "example.com nodefault".
Returns:
: false on failure

References cfg_str2list_insert(), cfg_strlist_insert(), last_space_pos(), config_file::local_zones, config_file::local_zones_nodefault, log_err(), and next_space_pos().

Referenced by config_set_option().

char* cfg_ptr_reverse ( char *  str  ) 

Convert a ptr shorthand into a full reverse-notation PTR record.

Parameters:
str,: input string, "IP name"
Returns:
: malloced string "reversed-ip-name PTR name"

References addr_is_ip6(), ipstrtoaddr(), last_space_pos(), log_err(), and next_space_pos().

Referenced by config_set_option().

void errinf ( struct module_qstate qstate,
const char *  str 
)

Append text to the error info for validation.

Parameters:
qstate,: query state.
str,: copied into query region and appended. Failures to allocate are logged.

References module_env::cfg, module_qstate::env, module_qstate::errinf, log_err(), config_strlist::next, module_qstate::region, regional_alloc(), regional_strdup(), config_strlist::str, and config_file::val_log_level.

Referenced by ds_response_to_ke(), errinf_dname(), errinf_origin(), errinf_rrset(), primeResponseToKE(), process_dnskey_response(), processInit(), processValidate(), and validate_msg_signatures().

void errinf_origin ( struct module_qstate qstate,
struct sock_list origin 
)

Append text to error info: from 1.2.3.4.

Parameters:
qstate,: query state.
origin,: sock list with origin of trouble. Every element added. If NULL: nothing is added. if 0len element: 'from cache' is added.

References sock_list::addr, addr_to_str(), module_env::cfg, module_qstate::env, errinf(), sock_list::len, sock_list::next, and config_file::val_log_level.

Referenced by process_dnskey_response(), process_ds_response(), process_prime_response(), processValidate(), and validate_msg_signatures().

char* errinf_to_str ( struct module_qstate qstate  ) 

Create error info in string.

Parameters:
qstate,: query state.
Returns:
string or NULL on malloc failure (already logged). This string is malloced and has to be freed by caller.

References dname_str(), module_qstate::errinf, log_err(), config_strlist::next, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qtype, and config_strlist::str.

Referenced by key_cache_insert(), mesh_do_callback(), and processFinished().

void errinf_rrset ( struct module_qstate qstate,
struct ub_packed_rrset_key rr 
)

Append text to error info: for RRset name type class.

Parameters:
qstate,: query state.
rr,: rrset_key.

References module_env::cfg, dname_str(), module_qstate::env, errinf(), log_err(), module_qstate::qinfo, query_info::qname, ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, packed_rrset_key::type, and config_file::val_log_level.

Referenced by validate_msg_signatures().

void errinf_dname ( struct module_qstate qstate,
const char *  str,
uint8_t *  dname 
)

Append text to error info: str dname.

Parameters:
qstate,: query state.
str,: explanation string
dname,: the dname.

References module_env::cfg, dname_str(), module_qstate::env, errinf(), and config_file::val_log_level.

Referenced by process_dnskey_response(), process_ds_response(), process_prime_response(), and processInit().


Variable Documentation

global config during parsing

global config parser object used during config parsing

Generated on Thu Apr 22 00:30:18 2010 for unbound by  doxygen 1.6.3