From a0f6cda5fd9f2fcc4154bb63628f849b639a40ca Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Fri, 28 Apr 2000 18:53:45 +0000 Subject: [PATCH] the 'default_debug' log channel was not set up when 'category default' was present in the config file --- CHANGES | 3 +++ bin/named/include/named/log.h | 13 ++++++++++++- bin/named/log.c | 29 +++++++++++++++++++++-------- bin/named/logconf.c | 4 +++- bin/named/server.c | 11 +++++++---- 5 files changed, 46 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 99a2c8a4f7..6c93458e66 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ + 129. [bug] The 'default_debug' log channel was not set up when + 'category default' was present in the config file + 128. [cleanup] had ISC_LANG_BEGINDECLS instead of ISC_LANG_ENDDECLS at end of header. diff --git a/bin/named/include/named/log.h b/bin/named/include/named/log.h index 74aac91d53..c5239a2730 100644 --- a/bin/named/include/named/log.h +++ b/bin/named/include/named/log.h @@ -48,7 +48,18 @@ isc_result_t ns_log_init(void); isc_result_t -ns_log_setdefaults(isc_logconfig_t *lcfg); +ns_log_setdefaultchannels(isc_logconfig_t *lcfg); +/* + * Set up logging channels according to the named defaults, which + * may differ from the logging library defaults. Currently, + * this just means setting up default_debug. + */ + +isc_result_t +ns_log_setdefaultcategory(isc_logconfig_t *lcfg); +/* + * Set up "category default" to go to the right places. + */ void ns_log_shutdown(void); diff --git a/bin/named/log.c b/bin/named/log.c index f9c11bb91d..b8dbd786e8 100644 --- a/bin/named/log.c +++ b/bin/named/log.c @@ -79,7 +79,10 @@ ns_log_init(void) { isc_log_registermodules(ns_g_lctx, ns_g_modules); dns_log_init(ns_g_lctx); - result = ns_log_setdefaults(lcfg); + result = ns_log_setdefaultchannels(lcfg); + if (result != ISC_R_SUCCESS) + goto cleanup; + result = ns_log_setdefaultcategory(lcfg); if (result != ISC_R_SUCCESS) goto cleanup; @@ -92,7 +95,7 @@ ns_log_init(void) { } isc_result_t -ns_log_setdefaults(isc_logconfig_t *lcfg) { +ns_log_setdefaultchannels(isc_logconfig_t *lcfg) { isc_result_t result; isc_logdestination_t destination; @@ -116,6 +119,21 @@ ns_log_setdefaults(isc_logconfig_t *lcfg) { goto cleanup; } + /* + * Set the initial debug level. + */ + isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel); + + result = ISC_R_SUCCESS; + + cleanup: + return (result); +} + +isc_result_t +ns_log_setdefaultcategory(isc_logconfig_t *lcfg) { + isc_result_t result; + result = isc_log_usechannel(lcfg, "default_syslog", ISC_LOGCATEGORY_DEFAULT, NULL); if (result != ISC_R_SUCCESS) @@ -126,12 +144,7 @@ ns_log_setdefaults(isc_logconfig_t *lcfg) { if (result != ISC_R_SUCCESS) goto cleanup; - /* - * Set the initial debug level. - */ - isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel); - - return (ISC_R_SUCCESS); + result = ISC_R_SUCCESS; cleanup: return (result); diff --git a/bin/named/logconf.c b/bin/named/logconf.c index 71d47f3aa2..3951ab2e71 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -150,6 +150,8 @@ ns_log_configure(isc_logconfig_t *lcctx, dns_c_logginglist_t *clog) { dns_c_logcat_t *ccat; isc_boolean_t default_set = ISC_FALSE; + CHECK(ns_log_setdefaultchannels(lcctx)); + for (cchan = ISC_LIST_HEAD(clog->channels); cchan != NULL; cchan = ISC_LIST_NEXT(cchan, next)) { @@ -166,7 +168,7 @@ ns_log_configure(isc_logconfig_t *lcctx, dns_c_logginglist_t *clog) { } if (! default_set) - CHECK(ns_log_setdefaults(lcctx)); + CHECK(ns_log_setdefaultcategory(lcctx)); return (ISC_R_SUCCESS); diff --git a/bin/named/server.c b/bin/named/server.c index 69d6d6130f..3a9422a4ae 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -1314,12 +1314,15 @@ load_configuration(const char *filename, ns_server_t *server, "creating new logging configuration"); (void) dns_c_ctx_getlogging(cctx, &clog); - if (clog != NULL) + if (clog != NULL) { CHECKM(ns_log_configure(logc, clog), "configuring logging"); - else - CHECKM(ns_log_setdefaults(logc), - "setting up default logging defaults"); + } else { + CHECKM(ns_log_setdefaultchannels(logc), + "setting up default logging channels"); + CHECKM(ns_log_setdefaultcategory(logc), + "setting up default 'category default'"); + } result = isc_logconfig_use(ns_g_lctx, logc); if (result != ISC_R_SUCCESS) {