]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix server section search in DNS listener
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 18 Feb 2024 17:53:26 +0000 (11:53 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 18 Feb 2024 17:54:26 +0000 (11:54 -0600)
Currently just throws an assert...

src/lib/server/cf_util.c
src/listen/dns/proto_dns_udp.c

index ade648a3e7699335a747acbac82cd3f0a833306a..26ec045267bc923a0888d43689295fb76f397d12 100644 (file)
@@ -996,6 +996,9 @@ CONF_SECTION *cf_section_find_next(CONF_SECTION const *cs, CONF_SECTION const *p
 }
 
 /** Find a CONF_SECTION with name1 and optionally name2 in the specified conf section of one of its parents
+ *
+ * Will walk up the configuration tree, searching in each parent until a matching section is found or
+ * we hit the root.
  *
  * @param[in] cs       The section we're searching in.
  * @param[in] name1    of the section we're searching for. Special value CF_IDENT_ANY
index 88cc73a24cc771a267f6488e355b60e20d1f131c..94a1feb533f100a08d65828c3a2fbe157ce1d4a2 100644 (file)
@@ -24,6 +24,7 @@
 #define LOG_PREFIX "proto_dns_udp"
 
 #include <freeradius-devel/server/protocol.h>
+#include <freeradius-devel/server/cf_util.h>
 #include <freeradius-devel/util/udp.h>
 #include <freeradius-devel/util/trie.h>
 #include <freeradius-devel/io/application.h>
@@ -340,7 +341,6 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        proto_dns_udp_t         *inst = talloc_get_type_abort(mctx->inst->data, proto_dns_udp_t);
        CONF_SECTION            *conf = mctx->inst->conf;
        size_t                  num;
-       CONF_ITEM               *ci;
        CONF_SECTION            *server_cs;
        fr_client_t             *client;
 
@@ -389,12 +389,8 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
                }
        }
 
-       ci = cf_parent(inst->cs); /* listen { ... } */
-       fr_assert(ci != NULL);
-       ci = cf_parent(ci);
-       fr_assert(ci != NULL);
-
-       server_cs = cf_item_to_section(ci);
+       server_cs = cf_section_find_in_parent(inst->cs, "server", NULL);
+       fr_assert(server_cs != NULL);
 
        /*
         *      Look up local clients, if they exist.