Functions | Variables
unbound.c File Reference

Main program to start the DNS resolver daemon. More...

#include "config.h"
#include <sys/time.h>
#include "util/log.h"
#include "daemon/daemon.h"
#include "daemon/remote.h"
#include "util/config_file.h"
#include "util/storage/slabhash.h"
#include "services/listen_dnsport.h"
#include "services/cache/rrset.h"
#include "services/cache/infra.h"
#include "util/data/msgreply.h"
#include "util/module.h"
#include "util/net_help.h"
#include <signal.h>
#include <fcntl.h>
#include <openssl/crypto.h>
#include <event.h>

Functions

static void get_event_sys (const char **n, const char **s, const char **m)
 get the event system in use
 
static void usage ()
 print usage. More...
 
int replay_var_compare (const void *ATTR_UNUSED(a), const void *ATTR_UNUSED(b))
 
static void checkrlimits (struct config_file *cfg)
 check file descriptor count
 
static void apply_settings (struct daemon *daemon, struct config_file *cfg, int cmdline_verbose)
 set verbosity, check rlimits, cache settings
 
static void detach (void)
 detach from command line
 
static void perform_setup (struct daemon *daemon, struct config_file *cfg, int debug_mode, const char **cfgfile)
 daemonize, drop user priviliges and chroot if needed
 
static void run_daemon (const char *cfgfile, int cmdline_verbose, int debug_mode)
 Run the daemon. More...
 
int main (int argc, char *argv[])
 main program. More...
 

Variables

void * unbound_start_brk = 0
 global debug value to keep track of heap memory allocation
 
int optind
 getopt global, in case header files fail to declare it. More...
 
char * optarg
 getopt global, in case header files fail to declare it. More...
 

Detailed Description

Main program to start the DNS resolver daemon.

Function Documentation

static void usage ( void  )
static

print usage.

References get_event_sys(), and module_list_avail().

Referenced by main().

static void run_daemon ( const char *  cfgfile,
int  cmdline_verbose,
int  debug_mode 
)
static

Run the daemon.

Parameters
cfgfile,:the config file name.
cmdline_verbose,:verbosity resulting from commandline -v. These increase verbosity as specified in the config file.
debug_mode,:if set, do not daemonize.

References apply_settings(), daemon::chroot, config_file::chrootdir, config_create(), config_delete(), config_read(), daemon_cleanup(), daemon_delete(), daemon_fork(), daemon_init(), daemon_open_shared_ports(), fatal_exit(), log_init(), log_warn(), config_file::logfile, daemon::need_to_exit, perform_setup(), daemon::pidfile, config_file::use_syslog, VERB_ALGO, VERB_OPS, and verbose().

Referenced by main().

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

main program.

Set options given commandline arguments.

Parameters
argc,:number of commandline arguments.
argv,:array of commandline arguments.
Returns
: exit status of the program.

References fatal_exit(), log_ident_set(), log_init(), run_daemon(), unbound_start_brk, usage(), and verbosity.

Variable Documentation

int optind

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

Referenced by main().

char* optarg

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

Referenced by main().