printf(" start unbound daemon DNS resolver.\n");
printf("-h this help\n");
printf("-c file config file to read, unbound.conf(5).\n");
+ printf("-d do not fork into the background.\n");
printf("-v verbose (multiple times increase verbosity)\n");
printf("Version %s\n", PACKAGE_VERSION);
printf("BSD licensed, see LICENSE in source package for details.\n");
/** daemonize, drop user priviliges and chroot if needed */
static void
-do_chroot(struct daemon* daemon, struct config_file* cfg)
+do_chroot(struct daemon* daemon, struct config_file* cfg, int debug_mode)
{
log_assert(cfg);
/* init logfile just before fork */
log_init(cfg->logfile);
- if(cfg->do_daemonize) {
+ if(!debug_mode && cfg->do_daemonize) {
int fd;
/* Take off... */
switch (fork()) {
* @param cfgfile: the config file name.
* @param cmdline_verbose: verbosity resulting from commandline -v.
* These increase verbosity as specified in the config file.
+ * @param debug_mode: if set, do not daemonize.
*/
-static void run_daemon(const char* cfgfile, int cmdline_verbose)
+static void run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode)
{
struct config_file* cfg = NULL;
struct daemon* daemon = NULL;
if(!daemon_open_shared_ports(daemon))
fatal_exit("could not open ports");
if(!done_chroot) {
- do_chroot(daemon, cfg);
+ do_chroot(daemon, cfg, debug_mode);
done_chroot = 1;
}
/* work */
int c;
const char* cfgfile = NULL;
int cmdline_verbose = 0;
+ int debug_mode = 0;
log_init(NULL);
/* parse the options */
- while( (c=getopt(argc, argv, "c:hv")) != -1) {
+ while( (c=getopt(argc, argv, "c:dhv")) != -1) {
switch(c) {
case 'c':
cfgfile = optarg;
cmdline_verbose ++;
verbosity++;
break;
+ case 'd':
+ debug_mode = 1;
+ break;
case '?':
case 'h':
default:
return 1;
}
- run_daemon(cfgfile, cmdline_verbose);
+ run_daemon(cfgfile, cmdline_verbose, debug_mode);
return 0;
}
- Ports for queries are shared.
- config file added interface:, chroot: and username:.
- config file: directory, logfile, pidfile. And they work too.
+ - will daemonize by default now. Use -d to stay in the foreground.
22 February 2007: Wouter
- Have a config file. Removed commandline options, moved to config.