mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +00:00
1756. [func] named-checkconf now checks the logging configuration.
[RT #12352]
This commit is contained in:
parent
4c8df3b2e8
commit
84a5b69f00
3
CHANGES
3
CHANGES
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
1757. [placeholder] rt12919
|
1757. [placeholder] rt12919
|
||||||
|
|
||||||
1756. [placeholder] rt12352
|
1756. [func] named-checkconf now checks the logging configuration.
|
||||||
|
[RT #12352]
|
||||||
|
|
||||||
1755. [placeholder] rt6636
|
1755. [placeholder] rt6636
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: check-tool.c,v 1.11 2004/10/06 05:56:28 marka Exp $ */
|
/* $Id: check-tool.c,v 1.12 2004/11/09 21:24:20 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -52,6 +52,20 @@ unsigned int zone_options = DNS_ZONEOPT_CHECKNS |
|
|||||||
DNS_ZONEOPT_MANYERRORS |
|
DNS_ZONEOPT_MANYERRORS |
|
||||||
DNS_ZONEOPT_CHECKNAMES;
|
DNS_ZONEOPT_CHECKNAMES;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This needs to match the list in bin/named/log.c.
|
||||||
|
*/
|
||||||
|
static isc_logcategory_t categories[] = {
|
||||||
|
{ "", 0 },
|
||||||
|
{ "client", 0 },
|
||||||
|
{ "network", 0 },
|
||||||
|
{ "update", 0 },
|
||||||
|
{ "queries", 0 },
|
||||||
|
{ "unmatched", 0 },
|
||||||
|
{ "update-security", 0 },
|
||||||
|
{ NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
|
setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
|
||||||
isc_logdestination_t destination;
|
isc_logdestination_t destination;
|
||||||
@ -59,7 +73,9 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
|
|||||||
isc_log_t *log = NULL;
|
isc_log_t *log = NULL;
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
|
||||||
|
isc_log_registercategories(log, categories);
|
||||||
isc_log_setcontext(log);
|
isc_log_setcontext(log);
|
||||||
|
dns_log_init(log);
|
||||||
|
|
||||||
destination.file.stream = stdout;
|
destination.file.stream = stdout;
|
||||||
destination.file.name = NULL;
|
destination.file.name = NULL;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: log.c,v 1.37 2004/03/05 04:57:47 marka Exp $ */
|
/* $Id: log.c,v 1.38 2004/11/09 21:24:20 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -31,7 +31,8 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* When adding a new category, be sure to add the appropriate
|
* When adding a new category, be sure to add the appropriate
|
||||||
* #define to <named/log.h>.
|
* #define to <named/log.h> and to update the list in
|
||||||
|
* bin/check/check-tool.c.
|
||||||
*/
|
*/
|
||||||
static isc_logcategory_t categories[] = {
|
static isc_logcategory_t categories[] = {
|
||||||
{ "", 0 },
|
{ "", 0 },
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: check.c,v 1.49 2004/10/07 02:15:13 marka Exp $ */
|
/* $Id: check.c,v 1.50 2004/11/09 21:24:20 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -1191,6 +1191,120 @@ check_viewconf(cfg_obj_t *config, cfg_obj_t *vconfig, dns_rdataclass_t vclass,
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
default_channels[] = {
|
||||||
|
"default_syslog",
|
||||||
|
"default_stderr",
|
||||||
|
"default_debug",
|
||||||
|
"null",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static isc_result_t
|
||||||
|
bind9_check_logging(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
|
||||||
|
cfg_obj_t *categories = NULL;
|
||||||
|
cfg_obj_t *category;
|
||||||
|
cfg_obj_t *channels = NULL;
|
||||||
|
cfg_obj_t *channel;
|
||||||
|
cfg_listelt_t *element;
|
||||||
|
cfg_listelt_t *delement;
|
||||||
|
const char *channelname;
|
||||||
|
const char *catname;
|
||||||
|
cfg_obj_t *fileobj = NULL;
|
||||||
|
cfg_obj_t *syslogobj = NULL;
|
||||||
|
cfg_obj_t *nullobj = NULL;
|
||||||
|
cfg_obj_t *stderrobj = NULL;
|
||||||
|
cfg_obj_t *logobj = NULL;
|
||||||
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
|
isc_result_t tresult;
|
||||||
|
isc_symtab_t *symtab = NULL;
|
||||||
|
isc_symvalue_t symvalue;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
(void)cfg_map_get(config, "logging", &logobj);
|
||||||
|
if (logobj == NULL)
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
result = isc_symtab_create(mctx, 100, NULL, NULL, ISC_FALSE, &symtab);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
|
||||||
|
symvalue.as_pointer = NULL;
|
||||||
|
for (i = 0; default_channels[i] != NULL; i++) {
|
||||||
|
tresult = isc_symtab_define(symtab, default_channels[i], 1,
|
||||||
|
symvalue, isc_symexists_replace);
|
||||||
|
if (tresult != ISC_R_SUCCESS)
|
||||||
|
result = tresult;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg_map_get(logobj, "channel", &channels);
|
||||||
|
|
||||||
|
for (element = cfg_list_first(channels);
|
||||||
|
element != NULL;
|
||||||
|
element = cfg_list_next(element))
|
||||||
|
{
|
||||||
|
channel = cfg_listelt_value(element);
|
||||||
|
channelname = cfg_obj_asstring(cfg_map_getname(channel));
|
||||||
|
fileobj = syslogobj = nullobj = stderrobj = NULL;
|
||||||
|
(void)cfg_map_get(channel, "file", &fileobj);
|
||||||
|
(void)cfg_map_get(channel, "syslog", &syslogobj);
|
||||||
|
(void)cfg_map_get(channel, "null", &nullobj);
|
||||||
|
(void)cfg_map_get(channel, "stderr", &stderrobj);
|
||||||
|
i = 0;
|
||||||
|
if (fileobj != NULL)
|
||||||
|
i++;
|
||||||
|
if (syslogobj != NULL)
|
||||||
|
i++;
|
||||||
|
if (nullobj != NULL)
|
||||||
|
i++;
|
||||||
|
if (stderrobj != NULL)
|
||||||
|
i++;
|
||||||
|
if (i != 1) {
|
||||||
|
cfg_obj_log(channel, logctx, ISC_LOG_ERROR,
|
||||||
|
"channel '%s': exactly one of file, syslog, "
|
||||||
|
"null, and stderr must be present",
|
||||||
|
channelname);
|
||||||
|
result = ISC_R_FAILURE;
|
||||||
|
}
|
||||||
|
tresult = isc_symtab_define(symtab, channelname, 1,
|
||||||
|
symvalue, isc_symexists_replace);
|
||||||
|
if (tresult != ISC_R_SUCCESS)
|
||||||
|
result = tresult;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg_map_get(logobj, "category", &categories);
|
||||||
|
|
||||||
|
for (element = cfg_list_first(categories);
|
||||||
|
element != NULL;
|
||||||
|
element = cfg_list_next(element))
|
||||||
|
{
|
||||||
|
category = cfg_listelt_value(element);
|
||||||
|
catname = cfg_obj_asstring(cfg_tuple_get(category, "name"));
|
||||||
|
if (isc_log_categorybyname(logctx, catname) == NULL) {
|
||||||
|
cfg_obj_log(category, logctx, ISC_LOG_ERROR,
|
||||||
|
"undefined category: '%s'", catname);
|
||||||
|
result = ISC_R_FAILURE;
|
||||||
|
}
|
||||||
|
channels = cfg_tuple_get(category, "destinations");
|
||||||
|
for (delement = cfg_list_first(channels);
|
||||||
|
delement != NULL;
|
||||||
|
delement = cfg_list_next(delement))
|
||||||
|
{
|
||||||
|
channel = cfg_listelt_value(delement);
|
||||||
|
channelname = cfg_obj_asstring(channel);
|
||||||
|
tresult = isc_symtab_lookup(symtab, channelname, 1,
|
||||||
|
&symvalue);
|
||||||
|
if (tresult != ISC_R_SUCCESS) {
|
||||||
|
cfg_obj_log(channel, logctx, ISC_LOG_ERROR,
|
||||||
|
"undefined channel: '%s'",
|
||||||
|
channelname);
|
||||||
|
result = tresult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isc_symtab_destroy(&symtab);
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
|
bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
|
||||||
@ -1219,6 +1333,9 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
|
|||||||
check_servers(servers, logctx) != ISC_R_SUCCESS)
|
check_servers(servers, logctx) != ISC_R_SUCCESS)
|
||||||
result = ISC_R_FAILURE;
|
result = ISC_R_FAILURE;
|
||||||
|
|
||||||
|
if (bind9_check_logging(config, logctx, mctx) != ISC_R_SUCCESS)
|
||||||
|
result = ISC_R_FAILURE;
|
||||||
|
|
||||||
if (options != NULL &&
|
if (options != NULL &&
|
||||||
check_order(options, logctx) != ISC_R_SUCCESS)
|
check_order(options, logctx) != ISC_R_SUCCESS)
|
||||||
result = ISC_R_FAILURE;
|
result = ISC_R_FAILURE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user