]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4681. [bug] Log messages from the validator now include the
authorMark Andrews <marka@isc.org>
Tue, 15 Aug 2017 23:29:20 +0000 (09:29 +1000)
committerMark Andrews <marka@isc.org>
Tue, 15 Aug 2017 23:29:20 +0000 (09:29 +1000)
                        associated view unless the view is "_default/IN"
                        or "_dnsclient/IN". [RT #45770]

CHANGES
bin/tests/system/dnssec/tests.sh
doc/arm/notes.xml
lib/dns/client.c
lib/dns/include/dns/client.h
lib/dns/validator.c

diff --git a/CHANGES b/CHANGES
index 1c64c552d52f9ed61dbd9109f3c4174bd80dfc8d..eff693c5b423b43cbc99a0a1881785dbafa3c7dd 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+4681.  [bug]           Log messages from the validator now include the
+                       associated view unless the view is "_default/IN"
+                       or "_dnsclient/IN". [RT #45770]
+
 4680.  [bug]           Fix failing over to another master server address when
                        nsupdate is used with GSS-API. [RT #45380]
 
index bccf666b48ecf3ef1fa02f84b39b94f9bde725df..fb4df2071558ce0faaf78efdfc1536205fdfce78 100644 (file)
@@ -3320,5 +3320,12 @@ n=`expr $n + 1`
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
+echo "I:check that the view is logged in messages from the validator when using views ($n)"
+ret=0
+grep "view rec: *validat" ns4/named.run > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I:exit status: $status"
 [ $status -eq 0 ] || exit 1
index 81376bfc1d1cffac3f2914eb83a30e592656fd4c..45a3d0c26ec73d534f1097ccef1d356784b7986c 100644 (file)
          [RT #42793]
        </para>
       </listitem>
+      <listitem>
+       <para>
+         The view associated with the query is now logged unless it
+         it is "_default/IN" or "_dnsclient/IN".
+       </para>
+      </listitem>
     </itemizedlist>
   </section>
 
index 4efab4cf2f5d99c73edd535705795dd3b869e293..1d8269912e00ea6f0b267f9d8df3a8e57cb6bc64 100644 (file)
@@ -110,8 +110,6 @@ struct dns_client {
 
 #define DNS_CLIENTATTR_OWNCTX                  0x01
 
-#define DNS_CLIENTVIEW_NAME                    "dnsclient"
-
 /*%
  * Internal state for a single name resolution procedure
  */
index 0bd04d068c033217f056b39be4d5d3fa04db817c..837b206b5ab92abe4570da57685135c80a494133 100644 (file)
@@ -96,6 +96,11 @@ ISC_LANG_BEGINDECLS
 /*%< Use TCP transport. */
 #define DNS_CLIENTUPDOPT_TCP           0x02
 
+/*%
+ * View name used in dns_client.
+ */
+#define DNS_CLIENTVIEW_NAME                    "_dnsclient"
+
 /*%
  * A dns_clientresevent_t is sent when name resolution performed by a client
  * completes.  'result' stores the result code of the entire resolution
index 9f0c6801c979810e753f5f46d780f2a13a05ddc2..db9d4baf0dcefe6a7b672be17d150ee25e2169f2 100644 (file)
@@ -16,6 +16,7 @@
 #include <isc/task.h>
 #include <isc/util.h>
 
+#include <dns/client.h>
 #include <dns/db.h>
 #include <dns/dnssec.h>
 #include <dns/ds.h>
@@ -3939,12 +3940,31 @@ validator_logv(dns_validator_t *val, isc_logcategory_t *category,
        char msgbuf[2048];
        static const char spaces[] = "        *";
        int depth = val->depth * 2;
+       const char *viewname, *sep1, *sep2;
 
        vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
 
        if ((unsigned int) depth >= sizeof spaces)
                depth = sizeof spaces - 1;
 
+       /*
+        * Log the view name unless it's:
+        * * "_default/IN" (which means there's only one view
+        *   configured in the server), or
+        * * "_dnsclient/IN" (which means this is being called
+        *   from an application using dns/client.c).
+        */
+       if (val->view->rdclass == dns_rdataclass_in &&
+           (strcmp(val->view->name, "_default") == 0 ||
+            strcmp(val->view->name, DNS_CLIENTVIEW_NAME) == 0))
+       {
+               sep1 = viewname = sep2 = "";
+       } else {
+               sep1 = "view ";
+               viewname = val->view->name;
+               sep2 = ": ";
+       }
+
        if (val->event != NULL && val->event->name != NULL) {
                char namebuf[DNS_NAME_FORMATSIZE];
                char typebuf[DNS_RDATATYPE_FORMATSIZE];
@@ -3953,12 +3973,14 @@ validator_logv(dns_validator_t *val, isc_logcategory_t *category,
                dns_rdatatype_format(val->event->type, typebuf,
                                     sizeof(typebuf));
                isc_log_write(dns_lctx, category, module, level,
-                             "%.*svalidating %s/%s: %s", depth, spaces,
+                             "%s%s%s%.*svalidating %s/%s: %s",
+                             sep1, viewname, sep2, depth, spaces,
                              namebuf, typebuf, msgbuf);
        } else {
                isc_log_write(dns_lctx, category, module, level,
-                             "%.*svalidator @%p: %s", depth, spaces,
-                              val, msgbuf);
+                             "%s%s%s%.*svalidator @%p: %s",
+                             sep1, viewname, sep2, depth, spaces,
+                             val, msgbuf);
        }
 }