]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: Warn if resolvers has no nameservers
authorBen Draut <drautb@gmail.com>
Fri, 13 Apr 2018 21:43:04 +0000 (15:43 -0600)
committerWilly Tarreau <w@1wt.eu>
Mon, 16 Apr 2018 13:58:23 +0000 (15:58 +0200)
Today, a `resolvers` section may be configured without any `nameserver`
directives, which is useless. This implements a warning when such
sections are detected.

[List thread][1].

[1]: https://www.mail-archive.com/haproxy@formilux.org/msg29600.html

src/cfgparse.c

index 37bbf45313299ed44f4a53747458040f02b348d1..621af6c814268e127aa9ee36963d12b15a52144c 100644 (file)
@@ -7336,6 +7336,7 @@ int check_config_validity()
        struct bind_conf *bind_conf;
        char *err;
        struct cfg_postparser *postparser;
+       struct dns_resolvers *curr_resolvers = NULL;
 
        bind_conf = NULL;
        /*
@@ -8976,6 +8977,15 @@ out_uri_auth_compat:
                                    global.tune.max_http_hdr * sizeof(struct hdr_idx_elem),
                                    MEM_F_SHARED);
 
+       list_for_each_entry(curr_resolvers, &dns_resolvers, list) {
+               if (LIST_ISEMPTY(&curr_resolvers->nameservers)) {
+                       ha_warning("config : resolvers '%s' [%s:%d] has no nameservers configured!\n",
+                                  curr_resolvers->id, curr_resolvers->conf.file,
+                                  curr_resolvers->conf.line);
+                       err_code |= ERR_WARN;
+               }
+       }
+
        list_for_each_entry(postparser, &postparsers, list) {
                if (postparser->func)
                        cfgerr += postparser->func();