From: Mark Andrews Date: Tue, 15 Aug 2017 23:29:20 +0000 (+1000) Subject: 4681. [bug] Log messages from the validator now include the X-Git-Tag: v9.12.0a1~109 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=52fd57c989de0c8b4b9f0559248e713b7fdee6a7;p=thirdparty%2Fbind9.git 4681. [bug] Log messages from the validator now include the associated view unless the view is "_default/IN" or "_dnsclient/IN". [RT #45770] --- diff --git a/CHANGES b/CHANGES index 1c64c552d52..eff693c5b42 100644 --- 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] diff --git a/bin/tests/system/dnssec/tests.sh b/bin/tests/system/dnssec/tests.sh index bccf666b48e..fb4df207155 100644 --- a/bin/tests/system/dnssec/tests.sh +++ b/bin/tests/system/dnssec/tests.sh @@ -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 diff --git a/doc/arm/notes.xml b/doc/arm/notes.xml index 81376bfc1d1..45a3d0c26ec 100644 --- a/doc/arm/notes.xml +++ b/doc/arm/notes.xml @@ -475,6 +475,12 @@ [RT #42793] + + + The view associated with the query is now logged unless it + it is "_default/IN" or "_dnsclient/IN". + + diff --git a/lib/dns/client.c b/lib/dns/client.c index 4efab4cf2f5..1d8269912e0 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -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 */ diff --git a/lib/dns/include/dns/client.h b/lib/dns/include/dns/client.h index 0bd04d068c0..837b206b5ab 100644 --- a/lib/dns/include/dns/client.h +++ b/lib/dns/include/dns/client.h @@ -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 diff --git a/lib/dns/validator.c b/lib/dns/validator.c index 9f0c6801c97..db9d4baf0dc 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -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); } }