summaryrefslogtreecommitdiff
path: root/usr.sbin/unbound/libunbound
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2019-09-11 14:13:28 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2019-09-11 14:13:28 +0000
commit8e93f11dfb8d73f15e084a3da8ef2b7bec018ea3 (patch)
treea4d83ff706a61e84e73bd817576db74da8650c73 /usr.sbin/unbound/libunbound
parenta6af4ccc826e64f8e2964fbf5b4a7cea34ff75cb (diff)
merge unbound 1.9.3
Diffstat (limited to 'usr.sbin/unbound/libunbound')
-rw-r--r--usr.sbin/unbound/libunbound/context.c11
-rw-r--r--usr.sbin/unbound/libunbound/context.h3
-rw-r--r--usr.sbin/unbound/libunbound/libunbound.c13
3 files changed, 23 insertions, 4 deletions
diff --git a/usr.sbin/unbound/libunbound/context.c b/usr.sbin/unbound/libunbound/context.c
index 20e3680ec3b..b8fe87d2e58 100644
--- a/usr.sbin/unbound/libunbound/context.c
+++ b/usr.sbin/unbound/libunbound/context.c
@@ -57,9 +57,16 @@ context_finalize(struct ub_ctx* ctx)
{
struct config_file* cfg = ctx->env->cfg;
verbosity = cfg->verbosity;
- if(ctx->logfile_override)
+ if(ctx_logfile_overridden && !ctx->logfile_override) {
+ log_file(NULL); /* clear that override */
+ ctx_logfile_overridden = 0;
+ }
+ if(ctx->logfile_override) {
+ ctx_logfile_overridden = 1;
log_file(ctx->log_out);
- else log_init(cfg->logfile, cfg->use_syslog, NULL);
+ } else {
+ log_init(cfg->logfile, cfg->use_syslog, NULL);
+ }
config_apply(cfg);
if(!modstack_setup(&ctx->mods, cfg->module_conf, ctx->env))
return UB_INITFAIL;
diff --git a/usr.sbin/unbound/libunbound/context.h b/usr.sbin/unbound/libunbound/context.h
index 11147226a8c..c3900154f8b 100644
--- a/usr.sbin/unbound/libunbound/context.h
+++ b/usr.sbin/unbound/libunbound/context.h
@@ -52,6 +52,9 @@ struct tube;
struct sldns_buffer;
struct ub_event_base;
+/** store that the logfile has a debug override */
+extern int ctx_logfile_overridden;
+
/**
* The context structure
*
diff --git a/usr.sbin/unbound/libunbound/libunbound.c b/usr.sbin/unbound/libunbound/libunbound.c
index 5f5a8a10265..63770cc025d 100644
--- a/usr.sbin/unbound/libunbound/libunbound.c
+++ b/usr.sbin/unbound/libunbound/libunbound.c
@@ -79,6 +79,9 @@
#include <iphlpapi.h>
#endif /* UB_ON_WINDOWS */
+/** store that the logfile has a debug override */
+int ctx_logfile_overridden = 0;
+
/** create context functionality, but no pipes */
static struct ub_ctx* ub_ctx_create_nopipe(void)
{
@@ -90,7 +93,8 @@ static struct ub_ctx* ub_ctx_create_nopipe(void)
#endif
checklock_start();
- log_init(NULL, 0, NULL); /* logs to stderr */
+ if(!ctx_logfile_overridden)
+ log_init(NULL, 0, NULL); /* logs to stderr */
log_ident_set("libunbound");
#ifdef USE_WINSOCK
if((r = WSAStartup(MAKEWORD(2,2), &wsa_data)) != 0) {
@@ -328,6 +332,10 @@ ub_ctx_delete(struct ub_ctx* ctx)
ub_randfree(ctx->seed_rnd);
alloc_clear(&ctx->superalloc);
traverse_postorder(&ctx->queries, delq, NULL);
+ if(ctx_logfile_overridden) {
+ log_file(NULL);
+ ctx_logfile_overridden = 0;
+ }
free(ctx);
#ifdef USE_WINSOCK
WSACleanup();
@@ -469,6 +477,7 @@ int ub_ctx_debugout(struct ub_ctx* ctx, void* out)
{
lock_basic_lock(&ctx->cfglock);
log_file((FILE*)out);
+ ctx_logfile_overridden = 1;
ctx->logfile_override = 1;
ctx->log_out = out;
lock_basic_unlock(&ctx->cfglock);
@@ -1150,7 +1159,7 @@ int
ub_ctx_hosts(struct ub_ctx* ctx, const char* fname)
{
FILE* in;
- char buf[1024], ldata[1024];
+ char buf[1024], ldata[2048];
char* parse, *addr, *name, *ins;
lock_basic_lock(&ctx->cfglock);
if(ctx->finalized) {