[PATCH] confgen: backticks weren't processed in generated configuration part
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@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); -- 1.8.3.2
Sorry, the correct commit message is: 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 it before add the buffer to the lexer Signed-off-by: Juhász Viktor <jviktor@balabit.hu> 2013 December 4, Szerda 17:14 CET dátummal, Juhász Viktor <jviktor@balabit.hu> ezt írta:
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@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); -- 1.8.3.2
______________________________________________________________________________ Member info: https://lists.balabit.hu/mailman/listinfo/syslog-ng Documentation: http://www.balabit.com/support/documentation/?product=syslog-ng FAQ: http://www.balabit.com/wiki/syslog-ng-faq
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@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 cfg_lexer_include_buffer(). 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. Thanks. Bazsi
participants (2)
-
Balazs Scheidler
-
Juhász Viktor