]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- unbound-checkconf checks if modules exist and prints if they are
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 9 Aug 2018 08:33:56 +0000 (08:33 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 9 Aug 2018 08:33:56 +0000 (08:33 +0000)
  not compiled in the name of the wrong module.

git-svn-id: file:///svn/unbound/trunk@4842 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
smallapp/unbound-checkconf.c

index 21a4aee1bb2160c3595884c6a2b804eb052ed671..d79d388a2e5d3ec1ef8f029fc76d057ecf8e51d9 100644 (file)
@@ -1,3 +1,7 @@
+9 August 2018: Wouter
+       - unbound-checkconf checks if modules exist and prints if they are
+         not compiled in the name of the wrong module.
+
 7 August 2018: Ralph
        - Make capsforid fallback QNAME minimisation aware.
 
index 5c2bf90e3acef28989a39ca626f9fbb66d337ded..fc256188803a37a0c0b30884ef71515a5e768b51 100644 (file)
@@ -43,6 +43,7 @@
  */
 
 #include "config.h"
+#include <ctype.h>
 #include "util/log.h"
 #include "util/config_file.h"
 #include "util/module.h"
@@ -390,6 +391,43 @@ ecs_conf_checks(struct config_file* cfg)
 }
 #endif /* CLIENT_SUBNET */
 
+/** check that the modules exist, are compiled in */
+static void
+check_modules_exist(const char* module_conf)
+{
+       const char** names = module_list_avail();
+       const char* s = module_conf;
+       while(*s) {
+               int i = 0;
+               int is_ok = 0;
+               while(*s && isspace((unsigned char)*s))
+                       s++;
+               while(names[i]) {
+                       if(strncmp(names[i], s, strlen(names[i])) == 0) {
+                               is_ok = 1;
+                               break;
+                       }
+                       i++;
+               }
+               if(is_ok == 0) {
+                       char n[64];
+                       size_t j;
+                       n[0]=0;
+                       n[sizeof(n)-1]=0;
+                       for(j=0; j<sizeof(n); j++) {
+                               if(!s[j] || isspace((unsigned char)s[j])) {
+                                       n[j] = 0;
+                                       break;
+                               }
+                               n[j] = s[j];
+                       }
+                       fatal_exit("module_conf lists module '%s' but that "
+                               "module is not available.", n);
+               }
+               s += strlen(names[i]);
+       }
+}
+
 /** check configuration for errors */
 static void
 morechecks(struct config_file* cfg, const char* fname)
@@ -483,6 +521,9 @@ morechecks(struct config_file* cfg, const char* fname)
        free(cfg->chrootdir);
        cfg->chrootdir = NULL;
 
+       /* check that the modules listed in module_conf exist */
+       check_modules_exist(cfg->module_conf);
+
        /* There should be no reason for 'respip' module not to work with
         * dns64, but it's not explicitly confirmed,  so the combination is
         * excluded below.   It's simply unknown yet for the combination of
@@ -529,7 +570,6 @@ morechecks(struct config_file* cfg, const char* fname)
 #if defined(WITH_PYTHONMODULE) && defined(CLIENT_SUBNET)
                && strcmp(cfg->module_conf, "python subnetcache iterator") != 0
                && strcmp(cfg->module_conf, "subnetcache python iterator") != 0
-               && strcmp(cfg->module_conf, "subnetcache validator iterator") != 0
                && strcmp(cfg->module_conf, "python subnetcache validator iterator") != 0
                && strcmp(cfg->module_conf, "subnetcache python validator iterator") != 0
                && strcmp(cfg->module_conf, "subnetcache validator python iterator") != 0