]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
check for relationship between dnstap and dnstap-output seperately
authorMark Andrews <marka@isc.org>
Mon, 21 Oct 2019 00:08:06 +0000 (11:08 +1100)
committerMark Andrews <marka@isc.org>
Mon, 21 Oct 2019 00:08:06 +0000 (11:08 +1100)
lib/bind9/check.c

index a90fa158300d531f9e1cc5996fda45a2f7532c2f..9fc6736a7ac85624efa0cd943596bd08d0ce3a4c 100644 (file)
@@ -1356,16 +1356,6 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx,
                                        result = ISC_R_FAILURE;
                        }
                }
-       } else {
-               (void) cfg_map_get(options, "dnstap", &obj);
-               if (obj != NULL) {
-                       cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
-                                   "'dnstap-output' must be set if 'dnstap' "
-                                   "is set");
-                       if (result == ISC_R_SUCCESS) {
-                               result = ISC_R_FAILURE;
-                       }
-               }
        }
 #endif
 
@@ -3487,6 +3477,44 @@ check_one_plugin(const cfg_obj_t *config, const cfg_obj_t *obj,
 }
 #endif
 
+static isc_result_t
+check_dnstap(const cfg_obj_t *voptions, const cfg_obj_t *config,
+            isc_log_t *logctx)
+{
+#ifdef HAVE_DNSTAP
+       const cfg_obj_t *options = NULL;
+       const cfg_obj_t *obj = NULL;
+
+       if (config != NULL) {
+               (void) cfg_map_get(config, "options", &options);
+       }
+       if (options != NULL) {
+               (void) cfg_map_get(options, "dnstap-output", &obj);
+       }
+       if (obj == NULL) {
+               if (voptions != NULL) {
+                       (void) cfg_map_get(voptions, "dnstap", &obj);
+               }
+               if (options != NULL && obj == NULL) {
+                       (void) cfg_map_get(options, "dnstap", &obj);
+               }
+               if (obj != NULL) {
+                       cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+                                   "'dnstap-output' must be set if 'dnstap' "
+                                   "is set");
+                       return (ISC_R_FAILURE);
+               }
+       }
+       return (ISC_R_SUCCESS);
+#else
+       UNUSED(voptions);
+       UNUSED(config);
+       UNUSED(logctx);
+
+       return (ISC_R_SUCCESS);
+#endif
+}
+
 static isc_result_t
 check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions,
               const char *viewname, dns_rdataclass_t vclass,
@@ -3834,6 +3862,11 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions,
                result = tresult;
        }
 
+       tresult = check_dnstap(voptions, config, logctx);
+       if (tresult != ISC_R_SUCCESS) {
+               result = tresult;
+       }
+
        tresult = check_viewacls(actx, voptions, config, logctx, mctx);
        if (tresult != ISC_R_SUCCESS) {
                result = tresult;