[syslog-ng] [PATCH] confgen: backticks weren't processed in generated configuration part

Balazs Scheidler bazsi77 at gmail.com
Sat Dec 28 20:24:10 CET 2013

On Wed, 2013-12-04 at 17:14 +0100, Juhász Viktor wrote:
> confgen: backticks weren't processed in generated configuration part
> produced by confgen module. The reason of this problem was,
> that the cfg_lexer_subst_args was called only for read lines
> from configuration files (YY_INPUT) and for the processed blocks.
> If process the backticks for a cfg input buffer is a must,
> the cfg_lexer_subst_args has to be called explicit. 
> Now the confgen module call the it before set the include buffer to the lexer
> Signed-off-by: Juhász Viktor <jviktor at balabit.hu>
> ---
>  modules/confgen/confgen-plugin.c | 5 +++++
>  1 file changed, 5 insertions(+)
> diff --git a/modules/confgen/confgen-plugin.c b/modules/confgen/confgen-plugin.c
> index 519a660..9831962 100644
> --- a/modules/confgen/confgen-plugin.c
> +++ b/modules/confgen/confgen-plugin.c
> @@ -40,6 +40,7 @@ confgen_generate(CfgLexer *lexer, gint type, const gchar *name, CfgArgs *args, g
>    gchar *exec = (gchar *) user_data;
>    gsize res;
>    gchar buf[256];
> +  gchar *old_value;
>    g_snprintf(buf, sizeof(buf), "%s confgen %s", cfg_lexer_lookup_context_name_by_type(type), name);
>    if (!cfg_args_validate(args, NULL, buf))
> @@ -79,6 +80,10 @@ confgen_generate(CfgLexer *lexer, gint type, const gchar *name, CfgArgs *args, g
>        g_free(value);
>        return FALSE;
>      }
> +
> +  old_value=value;
> +  value = cfg_lexer_subst_args(lexer->globals, NULL, NULL, value, &value_len);
> +  g_free(old_value);
>    if (!cfg_lexer_include_buffer(lexer, buf, value, value_len))
>      {
>        g_free(value);

Sorry for the long delay it took me to review this patch. And thanks for
submitting this contribution.

Am I right that the issue is that cfg_lexer_include_file() does args
substitution whereas cfg_lexer_include_buffer() doesn't do such a thing?

I figure it'd be much better if cfg_lexer_include_buffer() would behave
just like cfg_lexer_include_file() does in this respect, wouldn't it?
e.g. the subst call should be pushed downwards into

As I see there are other call-sites for the same, and that means that
those other call-sites also lack backtick expansion.

Since you are probably on a vacation right now, I'm trying to cook up an
alternative patch and post it here, but if I don't get back to this
topic in the coming days, feel free to ping me and/or offer an
alternative patch.


More information about the syslog-ng mailing list