From cf9537f6b724ede0227e0e26a62491700c9cfa4c Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 22 Oct 2021 15:03:28 +0000 Subject: [PATCH] config_new_empty() should give us a completely empty config, let parse_config() handle the case of defaults. This prevents the resolver process from spinning up resolver strategies before the config has been parsed and tearing them down immediately after if they are not listed in the config files preferences section. OK kn --- sbin/unwind/parse.y | 19 +++++++++++++++++-- sbin/unwind/unwind.c | 16 +--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/sbin/unwind/parse.y b/sbin/unwind/parse.y index 3bb5c98af18..79231e3d5be 100644 --- a/sbin/unwind/parse.y +++ b/sbin/unwind/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.28 2021/10/15 15:01:27 naddy Exp $ */ +/* $OpenBSD: parse.y,v 1.29 2021/10/22 15:03:28 florian Exp $ */ /* * Copyright (c) 2018 Florian Obser @@ -788,10 +788,25 @@ popfile(void) struct uw_conf * parse_config(char *filename) { - struct sym *sym, *next; + static enum uw_resolver_type default_res_pref[] = { + UW_RES_DOT, + UW_RES_ODOT_FORWARDER, + UW_RES_FORWARDER, + UW_RES_RECURSOR, + UW_RES_ODOT_AUTOCONF, + UW_RES_AUTOCONF, + UW_RES_ASR}; + struct sym *sym, *next; + int i; conf = config_new_empty(); + memcpy(&conf->res_pref.types, &default_res_pref, + sizeof(default_res_pref)); + conf->res_pref.len = nitems(default_res_pref); + for (i = 0; i < conf->res_pref.len; i++) + conf->enabled_resolvers[conf->res_pref.types[i]] = 1; + file = pushfile(filename != NULL ? filename : _PATH_CONF_FILE, 0); if (file == NULL) { /* no default config file is fine */ diff --git a/sbin/unwind/unwind.c b/sbin/unwind/unwind.c index 49201e46d0f..67676f3107d 100644 --- a/sbin/unwind/unwind.c +++ b/sbin/unwind/unwind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unwind.c,v 1.64 2021/10/22 13:38:07 kn Exp $ */ +/* $OpenBSD: unwind.c,v 1.65 2021/10/22 15:03:28 florian Exp $ */ /* * Copyright (c) 2018 Florian Obser @@ -688,14 +688,6 @@ merge_config(struct uw_conf *conf, struct uw_conf *xconf) struct uw_conf * config_new_empty(void) { - static enum uw_resolver_type default_res_pref[] = { - UW_RES_DOT, - UW_RES_ODOT_FORWARDER, - UW_RES_FORWARDER, - UW_RES_RECURSOR, - UW_RES_ODOT_AUTOCONF, - UW_RES_AUTOCONF, - UW_RES_ASR}; struct uw_conf *xconf; int i; @@ -703,12 +695,6 @@ config_new_empty(void) if (xconf == NULL) fatal(NULL); - memcpy(&xconf->res_pref.types, &default_res_pref, - sizeof(default_res_pref)); - xconf->res_pref.len = nitems(default_res_pref); - for (i = 0; i < xconf->res_pref.len; i++) - xconf->enabled_resolvers[xconf->res_pref.types[i]] = 1; - TAILQ_INIT(&xconf->uw_forwarder_list); TAILQ_INIT(&xconf->uw_dot_forwarder_list); -- 2.20.1