[syslog-ng] [PATCH] logrewrite: Correctly initialize the conditional rules.
Thomas Wollner
tw at wollner-net.de
Mon Jan 9 23:34:43 CET 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I just want to confirm that the issue is solved now.
Conditional rewrite works in 3.3.3 now.
Thank you,
best regards,
Tom
On 02.12.2011 13:29, Gergely Nagy wrote:
> In case where the condition of a rewrite used a filter reference
> instead of inlining the filter itself, the filter expression was
> never initialized. This resulted in the condition always evaluating
> to not-match, making the following construct completely useless:
>
> rewrite("new-value", value("MESSAGE"),
> condition(filter(f_my_filter)))
>
> The fix is to introduce a new function, log_rewrite_init_method(),
> which will initialize the condition filter if it exists, and has
> an init method. Then we bind this method to LogPipe's init
> callback during log_rewrite_init().
>
> This way, when initializing the rewrite pipe, the condition will
> get initialised too.
>
> Reported-by: Thomas Wollner <tw at wollner-net.de> Signed-off-by:
> Gergely Nagy <algernon at balabit.hu> --- lib/logrewrite.c | 12
> ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
>
> diff --git a/lib/logrewrite.c b/lib/logrewrite.c index
> a578439..3ff245a 100644 --- a/lib/logrewrite.c +++
> b/lib/logrewrite.c @@ -75,6 +75,17 @@
> log_rewrite_free_method(LogPipe *s)
> log_process_pipe_free_method(s); }
>
> +static gboolean +log_rewrite_init_method(LogPipe *s) +{ +
> LogRewrite *self = (LogRewrite *) s; + + if (self->condition &&
> self->condition->init) + self->condition->init(self->condition,
> log_pipe_get_config(s)); + + return TRUE; +} + static void
> log_rewrite_init(LogRewrite *self) { @@ -83,6 +94,7 @@
> log_rewrite_init(LogRewrite *self) self->super.super.flags |=
> PIF_CLONE; self->super.super.free_fn = log_rewrite_free_method;
> self->super.super.queue = log_rewrite_queue; +
> self->super.super.init = log_rewrite_init_method;
> self->value_handle = LM_V_MESSAGE; }
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFPC2uDTCCRT+dccOYRAhcVAJ9xEUoQ+N37LV5cIPXY4BlOybYAvgCgumUQ
eTzzYkvGxNxWm+ZCrrRl8AA=
=I5Ts
-----END PGP SIGNATURE-----
More information about the syslog-ng
mailing list