Main program to start the DNS resolver daemon. More...
#include "config.h"#include <getopt.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 <pwd.h>#include <grp.h>#include <sys/resource.h>#include "util/mini_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. | |
| int | replay_var_compare (const void *a, const void *b) |
| compare two replay_vars | |
| 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 pid_t | readpid (const char *file) |
| Read existing pid from pidfile. | |
| static void | writepid (const char *pidfile, pid_t pid) |
| write pid to file. | |
| static void | checkoldpid (char *pidfile, int inchroot) |
| check old pid file. | |
| 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. | |
| int | main (int argc, char *argv[]) |
| main program. | |
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. | |
| char * | optarg |
| getopt global, in case header files fail to declare it. | |
Main program to start the DNS resolver daemon.
| static void usage | ( | void | ) | [static] |
| static pid_t readpid | ( | const char * | file | ) | [static] |
Read existing pid from pidfile.
| file,: | file name of pid file. |
References log_err().
Referenced by checkoldpid().
| static void writepid | ( | const char * | pidfile, |
| pid_t | pid | ||
| ) | [static] |
write pid to file.
| pidfile,: | file name of pid file. |
| pid,: | pid to write to file. |
References log_err().
Referenced by perform_setup().
| static void checkoldpid | ( | char * | pidfile, |
| int | inchroot | ||
| ) | [static] |
check old pid file.
| pidfile,: | the file name of the pid file. |
| inchroot,: | if pidfile is inchroot and we can thus expect to be able to delete it. |
References readpid(), and log_warn().
Referenced by perform_setup().
| static void run_daemon | ( | const char * | cfgfile, |
| int | cmdline_verbose, | ||
| int | debug_mode | ||
| ) | [static] |
Run the daemon.
| 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 daemon_init(), fatal_exit(), daemon::need_to_exit, verbose(), VERB_OPS, config_create(), config_read(), daemon::chroot, log_warn(), apply_settings(), daemon_open_shared_ports(), perform_setup(), config_file::use_syslog, log_init(), config_file::logfile, config_file::chrootdir, daemon_fork(), VERB_ALGO, daemon_cleanup(), config_delete(), daemon::pidfile, and daemon_delete().
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
main program.
Set options given commandline arguments.
| argc,: | number of commandline arguments. |
| argv,: | array of commandline arguments. |
References unbound_start_brk, log_init(), verbosity, usage(), wsvc_command_option(), fatal_exit(), and run_daemon().