From 58c42ee18c186b2151ced62f64aa4ca23cff4a1d Mon Sep 17 00:00:00 2001 From: James Brister Date: Tue, 20 Jun 2000 21:36:49 +0000 Subject: [PATCH] 263. [func] New logging channel type 'stderr' channel some-name { stderr; severity error; } --- CHANGES | 7 +++++++ bin/tests/named.conf | 4 ++++ lib/dns/config/confctx.c | 27 ++++++++++++++++++++++++++- lib/dns/config/conflog.c | 9 ++++++++- lib/dns/config/confparser.y | 21 ++++++++++++++++++++- lib/dns/include/dns/confcommon.h | 3 ++- lib/dns/include/dns/confctx.h | 2 ++ 7 files changed, 69 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 7e0e7c1c13..e7f4773ff2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ + 263. [func] New logging channel type 'stderr' + + channel some-name { + stderr; + severity error; + } + 262. [bug] 'master' was not initalised in zone.c:stub_callback(). 261. [func] Add dns_zone_markdirty(). diff --git a/bin/tests/named.conf b/bin/tests/named.conf index dd6f2a3b0d..3740cd9db2 100644 --- a/bin/tests/named.conf +++ b/bin/tests/named.conf @@ -393,6 +393,10 @@ logging { severity error; }; + channel stderr_errors { + stderr; + }; + /* * Channels have a severity level. Messages at severity levels * greater than or equal to the channel's level will be logged on diff --git a/lib/dns/config/confctx.c b/lib/dns/config/confctx.c index c21c03f4bb..a2fcce2ba6 100644 --- a/lib/dns/config/confctx.c +++ b/lib/dns/config/confctx.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: confctx.c,v 1.69 2000/06/15 23:38:12 brister Exp $ */ +/* $Id: confctx.c,v 1.70 2000/06/20 21:36:43 brister Exp $ */ #include @@ -1302,6 +1302,31 @@ dns_c_ctx_addnullchannel(dns_c_ctx_t *cfg, const char *name, } +isc_result_t +dns_c_ctx_addstderrchannel(dns_c_ctx_t *cfg, const char *name, + dns_c_logchan_t **chan) +{ + dns_c_logchan_t *newc; + isc_result_t res; + + REQUIRE(DNS_C_CONFCTX_VALID(cfg)); + REQUIRE(name != NULL); + REQUIRE(chan != NULL); + REQUIRE(cfg->logging != NULL); + + res = dns_c_logchan_new(cfg->mem, name, dns_c_logchan_stderr, &newc); + if (res != ISC_R_SUCCESS) { + return (res); + } + + res = dns_c_logginglist_addchannel(cfg->logging, newc, ISC_FALSE); + + *chan = newc; + + return (res); +} + + isc_result_t dns_c_ctx_addcategory(dns_c_ctx_t *cfg, const char *catname, dns_c_logcat_t **newcat) diff --git a/lib/dns/config/conflog.c b/lib/dns/config/conflog.c index ea7f267e2d..67ce5a4159 100644 --- a/lib/dns/config/conflog.c +++ b/lib/dns/config/conflog.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: conflog.c,v 1.15 2000/05/08 18:42:38 brister Exp $ */ +/* $Id: conflog.c,v 1.16 2000/06/20 21:36:44 brister Exp $ */ #include @@ -515,6 +515,7 @@ dns_c_logchan_new(isc_mem_t *mem, const char *name, case dns_c_logchan_syslog: case dns_c_logchan_null: + case dns_c_logchan_stderr: break; } @@ -544,6 +545,7 @@ dns_c_logchan_delete(dns_c_logchan_t **channel) { case dns_c_logchan_syslog: case dns_c_logchan_null: + case dns_c_logchan_stderr: break; } @@ -590,6 +592,7 @@ dns_c_logchan_copy(isc_mem_t *mem, dns_c_logchan_t **dest, break; case dns_c_logchan_null: + case dns_c_logchan_stderr: break; } @@ -643,6 +646,10 @@ dns_c_logchan_print(FILE *fp, int indent, dns_c_logchan_t *logchan, case dns_c_logchan_null: fputs("null", fp); break; + + case dns_c_logchan_stderr: + fputs("stderr", fp); + break; } fprintf(fp, ";\n"); diff --git a/lib/dns/config/confparser.y b/lib/dns/config/confparser.y index b44be2e1cb..b0bb982dad 100644 --- a/lib/dns/config/confparser.y +++ b/lib/dns/config/confparser.y @@ -16,7 +16,7 @@ * SOFTWARE. */ -/* $Id: confparser.y,v 1.97 2000/06/15 23:38:14 brister Exp $ */ +/* $Id: confparser.y,v 1.98 2000/06/20 21:36:45 brister Exp $ */ #include @@ -354,6 +354,7 @@ static isc_boolean_t int_too_big(isc_uint32_t base, isc_uint32_t mult); %token L_STACKSIZE %token L_STATS_FILE %token L_STATS_INTERVAL +%token L_STDERR %token L_STUB %token L_SUBDOMAIN %token L_SUPPORT_IXFR @@ -2178,6 +2179,23 @@ channel_stmt: isc_mem_free(memctx, $2); } L_EOS optional_channel_opt_list L_RBRACE + | L_CHANNEL channel_name L_LBRACE L_STDERR { + dns_c_logchan_t *newc; + + tmpres = dns_c_ctx_addstderrchannel(currcfg, + $2, &newc); + if (tmpres == ISC_R_EXISTS) { + parser_error(ISC_FALSE, + "cannot redefine channel %s", $2); + YYABORT; + } else if (tmpres != ISC_R_SUCCESS) { + parser_error(ISC_FALSE, + "failed to add new channel '%s'", $2); + YYABORT; + } + + isc_mem_free(memctx, $2); + } L_EOS optional_channel_opt_list L_RBRACE | L_CHANNEL channel_name L_LBRACE logging_non_type_keywords { parser_error(ISC_FALSE, "first statment inside a channel definition " @@ -5181,6 +5199,7 @@ static struct token keyword_tokens [] = { { "stacksize", L_STACKSIZE }, { "statistics-file", L_STATS_FILE }, { "statistics-interval", L_STATS_INTERVAL }, + { "stderr", L_STDERR }, { "stub", L_STUB }, { "support-ixfr", L_SUPPORT_IXFR }, { "syslog", L_SYSLOG }, diff --git a/lib/dns/include/dns/confcommon.h b/lib/dns/include/dns/confcommon.h index 092a4a4ac2..5ff7515c7b 100644 --- a/lib/dns/include/dns/confcommon.h +++ b/lib/dns/include/dns/confcommon.h @@ -160,7 +160,8 @@ typedef enum { typedef enum { dns_c_logchan_file, dns_c_logchan_syslog, - dns_c_logchan_null + dns_c_logchan_null, + dns_c_logchan_stderr } dns_c_logchantype_t; diff --git a/lib/dns/include/dns/confctx.h b/lib/dns/include/dns/confctx.h index 255ec9cc5d..04d848be3c 100644 --- a/lib/dns/include/dns/confctx.h +++ b/lib/dns/include/dns/confctx.h @@ -251,6 +251,8 @@ isc_result_t dns_c_ctx_addsyslogchannel(dns_c_ctx_t *cfg, const char *name, dns_c_logchan_t **chan); isc_result_t dns_c_ctx_addnullchannel(dns_c_ctx_t *cfg, const char *name, dns_c_logchan_t **chan); +isc_result_t dns_c_ctx_addstderrchannel(dns_c_ctx_t *cfg, const char *name, + dns_c_logchan_t **chan); isc_result_t dns_c_ctx_addcategory(dns_c_ctx_t *cfg, const char *catname, dns_c_logcat_t **newcat);