[PATCH] syslog-ng: Add a -q/--silent-module-load option
With the -q/--silent-module-load option set (defaults to off), no warnings will be printed when a module cannot be found. If it's found, but cannot be loaded, a message is still printed. If it is used later in the config, that's still handled correctly. The flag only suppresses the warning, and nothing else. Signed-off-by: Gergely Nagy <algernon@balabit.hu> --- lib/globals.c | 1 + lib/plugin.c | 9 +++++---- lib/syslog-ng.h | 1 + syslog-ng/main.c | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/globals.c b/lib/globals.c index b2afec7..b3b2121 100644 --- a/lib/globals.c +++ b/lib/globals.c @@ -28,3 +28,4 @@ GlobalConfig *configuration; int cfg_parser_debug; gchar *module_path = MODULE_PATH; gchar *default_modules = DEFAULT_MODULES; +gboolean silent_module_load = FALSE; diff --git a/lib/plugin.c b/lib/plugin.c index 5239974..cce549a 100644 --- a/lib/plugin.c +++ b/lib/plugin.c @@ -179,10 +179,11 @@ plugin_dlopen_module(const gchar *module_name, const gchar *module_path) g_strfreev(module_path_dirs); if (!plugin_module_name) { - msg_error("Plugin module not found in 'module-path'", - evt_tag_str("module-path", module_path), - evt_tag_str("module", module_name), - NULL); + if (!silent_module_load) + msg_error("Plugin module not found in 'module-path'", + evt_tag_str("module-path", module_path), + evt_tag_str("module", module_name), + NULL); return NULL; } msg_debug("Trying to open module", diff --git a/lib/syslog-ng.h b/lib/syslog-ng.h index 4bd79c2..edb8a4d 100644 --- a/lib/syslog-ng.h +++ b/lib/syslog-ng.h @@ -66,5 +66,6 @@ typedef struct _GlobalConfig GlobalConfig; extern GlobalConfig *configuration; extern gchar *module_path; extern gchar *default_modules; +extern gboolean silent_module_load; #endif diff --git a/syslog-ng/main.c b/syslog-ng/main.c index c682e44..e414321 100644 --- a/syslog-ng/main.c +++ b/syslog-ng/main.c @@ -75,6 +75,7 @@ static GOptionEntry syslogng_options[] = { "module-registry", 0, 0, G_OPTION_ARG_NONE, &display_module_registry, "Display module information", NULL }, { "default-modules", 0, 0, G_OPTION_ARG_STRING, &default_modules, "Set the set of auto-loaded modules, default=" DEFAULT_MODULES, "<module-list>" }, { "seed", 'S', 0, G_OPTION_ARG_NONE, &dummy, "Does nothing, the need to seed the random generator is autodetected", NULL}, + { "silent-module-load", 'q', 0, G_OPTION_ARG_NONE, &silent_module_load, "Load modules silently, not printing a warning when one's not found", NULL}, #ifdef YYDEBUG { "yydebug", 'y', 0, G_OPTION_ARG_NONE, &cfg_parser_debug, "Enable configuration parser debugging", NULL }, #endif -- 1.7.7
On Sat, 2011-10-15 at 10:59 +0200, Gergely Nagy wrote:
With the -q/--silent-module-load option set (defaults to off), no warnings will be printed when a module cannot be found.
If it's found, but cannot be loaded, a message is still printed. If it is used later in the config, that's still handled correctly.
The flag only suppresses the warning, and nothing else.
I'm not sure why you'd want to do this, could you elaborate? Thanks. -- Bazsi
Balazs Scheidler <bazsi@balabit.hu> writes:
On Sat, 2011-10-15 at 10:59 +0200, Gergely Nagy wrote:
With the -q/--silent-module-load option set (defaults to off), no warnings will be printed when a module cannot be found.
If it's found, but cannot be loaded, a message is still printed. If it is used later in the config, that's still handled correctly.
The flag only suppresses the warning, and nothing else.
I'm not sure why you'd want to do this, could you elaborate? Thanks.
The main reason is that syslog-ng 3.2 in Debian has all modules in a single package, but with 3.3, they're going to be split out into separate packages (with the syslog-ng package depending on -core and the -modules). And the default modules to load was therefore set to only those modules that remained in the -core package, so that configs that do not use, say, SQL, won't try to load afsql module, and emit a warning each time syslog-ng is started up. Instead, the module packages provide a file under /etc/syslog-ng/conf.d/, which is sourced by the updated syslog-ng.conf. However, there was one case I did not consider: when the user modified syslog-ng.conf already, the include did not get added, and thus, when upgrading, the afsql module wasn't loaded. If they used SQL destinations, then the upgrade broke, because syslog-ng wouldn't start up. To work around this issue, the best idea I could come up with, is to re-enable the afsql module by default. But that would result in a module not found warning when the appropriate package is not installed. So, I figured it'd be a reasonable middleground to add a flag that stops the warning from being printed: if a module is not found, and is not used, so be it. If it would be used, syslog-ng will error out later anyway. All in all, my reason for the flag is to silence a warning in case we know that we'll try to load modules that may or may not be installed, and we don't really care about it, if they're not there, and aren't used anyway. -- |8]
participants (2)
-
Balazs Scheidler
-
Gergely Nagy