[PATCH] config: Support setting a default suppress() globally.

Gergely Nagy algernon at balabit.hu
Fri Feb 11 20:40:40 CET 2011


While setting suppress() on a per-destination basis is flexible, when
one wants to have the same setting for all destinations by default,
it's more convenient to do that globally in the options block.

That is implemented herein: one can set a global suppress(), and it
will be the default for all destinations that support it, yet, can
still be overridden on a per-destination basis.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 lib/cfg-grammar.y                    |    1 +
 lib/cfg.h                            |    1 +
 modules/affile/affile-grammar.ym     |    2 ++
 modules/afprog/afprog-grammar.ym     |    1 +
 modules/afsocket/afsocket-grammar.ym |    5 +++++
 5 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/lib/cfg-grammar.y b/lib/cfg-grammar.y
index 8d45af3..0a78b68 100644
--- a/lib/cfg-grammar.y
+++ b/lib/cfg-grammar.y
@@ -600,6 +600,7 @@ options_item
 	| KW_TIME_REOPEN '(' LL_NUMBER ')'		{ configuration->time_reopen = $3; }
 	| KW_TIME_REAP '(' LL_NUMBER ')'		{ configuration->time_reap = $3; }
 	| KW_TIME_SLEEP '(' LL_NUMBER ')'	{}
+	| KW_SUPPRESS '(' LL_NUMBER ')'		{ configuration->suppress = $3; }
 	| KW_THREADED '(' yesno ')'		{ configuration->threaded = $3; }
 	| KW_LOG_FIFO_SIZE '(' LL_NUMBER ')'	{ configuration->log_fifo_size = $3; }
 	| KW_LOG_IW_SIZE '(' LL_NUMBER ')'	{ msg_error("Using a global log-iw-size() option was removed, please use a per-source log-iw-size()", NULL); }
diff --git a/lib/cfg.h b/lib/cfg.h
index 455b36d..82a30c5 100644
--- a/lib/cfg.h
+++ b/lib/cfg.h
@@ -76,6 +76,7 @@ struct _GlobalConfig
   gchar *dns_cache_hosts;
   gint time_reopen;
   gint time_reap;
+  gint suppress;
 
   gint log_fifo_size;
   gint log_msg_size;
diff --git a/modules/affile/affile-grammar.ym b/modules/affile/affile-grammar.ym
index 2a7c134..5379b81 100644
--- a/modules/affile/affile-grammar.ym
+++ b/modules/affile/affile-grammar.ym
@@ -132,6 +132,7 @@ dest_affile_params
 	    (*last_driver) = affile_dd_new($1, 0);
 	    free($1);
 	    last_writer_options = &((AFFileDestDriver *) (*last_driver))->writer_options;
+	    last_writer_options->suppress = configuration->suppress;
 	  }
 	  dest_affile_options                           { $$ = (*last_driver); }
 	;
@@ -163,6 +164,7 @@ dest_afpipe_params
 	    free($1);
 	    last_writer_options = &((AFFileDestDriver *) (*last_driver))->writer_options;
 	    last_writer_options->flush_lines = 0;
+	    last_writer_options->suppress = configuration->suppress;
 	  }
 	  dest_afpipe_options                   { $$ = (*last_driver); }
 	;
diff --git a/modules/afprog/afprog-grammar.ym b/modules/afprog/afprog-grammar.ym
index 1e9f05b..388d1fc 100644
--- a/modules/afprog/afprog-grammar.ym
+++ b/modules/afprog/afprog-grammar.ym
@@ -91,6 +91,7 @@ dest_afprogram_params
 	    (*last_driver) = afprogram_dd_new($1);
 	    free($1);
 	    last_writer_options = &((AFProgramDestDriver *) (*last_driver))->writer_options;
+	    last_writer_options->suppress = configuration->suppress;
 	  }
 	  dest_writer_options			{ $$ = (*last_driver); }
 	;
diff --git a/modules/afsocket/afsocket-grammar.ym b/modules/afsocket/afsocket-grammar.ym
index 8081b03..c359911 100644
--- a/modules/afsocket/afsocket-grammar.ym
+++ b/modules/afsocket/afsocket-grammar.ym
@@ -321,6 +321,7 @@ dest_afunix_dgram_params
 	    (*last_driver) = afunix_dd_new($1, AFSOCKET_DGRAM);
 	    free($1);
 	    last_writer_options = &((AFSocketDestDriver *) (*last_driver))->writer_options;
+	    last_writer_options->suppress = configuration->suppress;
 	    last_sock_options = &((AFUnixDestDriver *) (*last_driver))->sock_options;
 	  }
 	  dest_afunix_options			{ $$ = (*last_driver); }
@@ -332,6 +333,7 @@ dest_afunix_stream_params
 	    (*last_driver) = afunix_dd_new($1, AFSOCKET_STREAM);
 	    free($1);
 	    last_writer_options = &((AFSocketDestDriver *) (*last_driver))->writer_options;
+	    last_writer_options->suppress = configuration->suppress;
 	    last_sock_options = &((AFUnixDestDriver *) (*last_driver))->sock_options;
 	  }
 	  dest_afunix_options			{ $$ = (*last_driver); }
@@ -356,6 +358,7 @@ dest_afinet_udp_params
 			AFSOCKET_DGRAM);
 	    free($1);
 	    last_writer_options = &((AFSocketDestDriver *) (*last_driver))->writer_options;
+    	    last_writer_options->suppress = configuration->suppress;
 	    last_sock_options = &((AFInetDestDriver *) (*last_driver))->sock_options.super;
 	  }
 	  dest_afinet_udp_options		{ $$ = (*last_driver); }
@@ -390,6 +393,7 @@ dest_afinet_tcp_params
 			AFSOCKET_STREAM);
 	    free($1);
 	    last_writer_options = &((AFSocketDestDriver *) (*last_driver))->writer_options;
+	    last_writer_options->suppress = configuration->suppress;
 	    last_sock_options = &((AFInetDestDriver *) (*last_driver))->sock_options.super;
 	  }
 	  dest_afinet_tcp_options		{ $$ = (*last_driver); }
@@ -429,6 +433,7 @@ dest_afsyslog_params
           {
             (*last_driver) = afinet_dd_new(last_addr_family, $1, 601, AFSOCKET_STREAM | AFSOCKET_SYSLOG_PROTOCOL);
 	    last_writer_options = &((AFSocketDestDriver *) (*last_driver))->writer_options;
+	    last_writer_options->suppress = configuration->suppress;
 	    last_sock_options = &((AFInetDestDriver *) (*last_driver))->sock_options.super;
 	    free($1);
 	  }
-- 
1.7.2.3


--=-Lkq2Ib+3B70ePgcRExFi--




More information about the syslog-ng mailing list