The patch below modifies the behavior of the unbound daemon so that if
the -d option is specified twice, the logfile and use-syslog settings
are ignored and all messages go to stderr.
DES
--
Dag-Erling Smørgrav - [email protected]
Index: daemon/unbound.c
===================================================================
--- daemon/unbound.c (revision 3195)
+++ daemon/unbound.c (working copy)
@@ -269,8 +269,6 @@
#ifdef HAVE_SETRLIMIT
if(setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
log_warn("setrlimit: %s", strerror(errno));
-#else
- if(1) {
#endif
log_warn("cannot increase max open fds from %u to %u",
(unsigned)avail, (unsigned)total+10);
@@ -286,7 +284,9 @@
log_warn("increase ulimit or decrease threads, "
"ports in config to remove this warning");
return;
+#ifdef HAVE_SETRLIMIT
}
+#endif
log_warn("increased limit(open files) from %u to %u",
(unsigned)avail, (unsigned)total+10);
}
@@ -299,10 +299,14 @@
/** set verbosity, check rlimits, cache settings */
static void
apply_settings(struct daemon* daemon, struct config_file* cfg,
- int cmdline_verbose)
+ int cmdline_verbose, int debug_mode)
{
/* apply if they have changed */
verbosity = cmdline_verbose + cfg->verbosity;
+ if (debug_mode > 1) {
+ cfg->use_syslog = 0;
+ cfg->logfile = NULL;
+ }
daemon_apply_cfg(daemon, cfg);
checkrlimits(cfg);
}
@@ -661,7 +665,7 @@
cfgfile);
log_warn("Continuing with default config settings");
}
- apply_settings(daemon, cfg, cmdline_verbose);
+ apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
/* prepare */
if(!daemon_open_shared_ports(daemon))
@@ -741,7 +745,7 @@
verbosity++;
break;
case 'd':
- debug_mode = 1;
+ debug_mode++;
break;
case 'w':
winopt = optarg;
Index: doc/unbound.8.in
===================================================================
--- doc/unbound.8.in (revision 3195)
+++ doc/unbound.8.in (working copy)
@@ -36,9 +36,10 @@
described in \fIunbound.conf\fR(5).
.TP
.B \-d
-Debug flag, do not fork into the background, but stay attached to the
-console. This flag will also delay writing to the logfile until the
-thread\-spawn time. So that most config and setup errors appear on stderr.
+Debug flag: do not fork into the background. This flag will also delay
+writing to the log file until the thread\-spawn time, so that most
+config and setup errors appear on stderr. If given twice or more, the
+log messages will always go to stderr, not to the log file or syslog.
.TP
.B \-v
Increase verbosity. If given multiple times, more information is logged.
_______________________________________________
Unbound-users mailing list
[email protected]
http://unbound.nlnetlabs.nl/mailman/listinfo/unbound-users